Package org.rascalmpl.uri

Examples of org.rascalmpl.uri.URIResolverRegistry


        String moduleText = module.getType().isString() ? ((IString) module).getValue() : TreeAdapter.yield((IConstructor) module);
       
        moduleText = "@generated\n" + moduleText;
       
        try {
          URIResolverRegistry reg = eval.getResolverRegistry();
          String moduleEnvName = eval.getCurrentModuleEnvironment().getName();
          URI ur = null;
          if (moduleEnvName.equals(ModuleEnvironment.SHELL_MODULE)) {
            ur = URIUtil.rootScheme("rascal");
          } else {
            ur = eval.getRascalResolver().getRootForModule((URIUtil.createRascalModule(moduleEnvName)));
          }
          Result<?> loc = new SourceLocationResult(TF.sourceLocationType(), VF.sourceLocation(ur), eval);
          String modulePath = moduleName.replaceAll("::", "/");
          loc = loc.add(ResultFactory.makeResult(TF.stringType(), VF.string(modulePath), eval));
          loc = loc.fieldUpdate("extension", ResultFactory.makeResult(TF.stringType(), VF.string(".rsc"), eval), eval.getCurrentEnvt().getStore());
         
          OutputStream outputStream;
          try {
            outputStream = reg.getOutputStream(((ISourceLocation) loc.getValue()).getURI(), false);
          }
          catch (IOException e) {
            outputStream = reg.getOutputStream(URIUtil.rootScheme("cwd"), false);
          }
         
          if (outputStream == null) {
            outputStream = reg.getOutputStream(URIUtil.rootScheme("cwd"), false);
          }
         
          BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream));
          writer.write(moduleText);
          writer.close();
View Full Code Here


    return ownEvaluator.parseModule(ownEvaluator.getMonitor(), str.getValue().toCharArray(), loc.getURI());
  }
 
  public IValue parseModule(ISourceLocation loc, final IList searchPath, IEvaluatorContext ctx) {
    final Evaluator ownEvaluator = getPrivateEvaluator(ctx);
    final URIResolverRegistry otherReg = ctx.getResolverRegistry();
    URIResolverRegistry ownRegistry = ownEvaluator.getResolverRegistry();
   
    // bridge the resolvers that are not defined in the new Evaluator, but needed here
    for (IValue l : searchPath) {
      String scheme = ((ISourceLocation) l).getURI().getScheme();
      if (!ownRegistry.supportsInputScheme(scheme)) {
        ownRegistry.registerInput(new ResolverBridge(scheme, otherReg));
      }
    }
   
    // add the given locations to the search path
    SourceLocationListContributor contrib = new SourceLocationListContributor("reflective", searchPath);
View Full Code Here

  private final Map<IConstructorDeclared,Object> constructorDeclaredListeners; // TODO: can this be shared?
  private static final Object dummy = new Object()
 
  public Evaluator(IValueFactory f, PrintWriter stderr, PrintWriter stdout, ModuleEnvironment scope, GlobalEnvironment heap) {
    this(f, stderr, stdout, scope, heap, new ArrayList<ClassLoader>(Collections.singleton(Evaluator.class.getClassLoader())), new RascalURIResolver(new URIResolverRegistry()));
  }
View Full Code Here

    ModuleEnvironment root = heap.addModule(new ModuleEnvironment("___TUTOR___", heap));
    PrintWriter stderr = new PrintWriter(System.err);
    PrintWriter stdout = new PrintWriter(System.out);
    eval = new Evaluator(ValueFactoryFactory.getValueFactory(), stderr, stdout, root, heap);
   
    URIResolverRegistry reg = eval.getResolverRegistry();
   
    if (isEditMode()) {
       FileURIResolver fileURIResolver = new FileURIResolver() {
        @Override
        public String scheme() {
          return "courses";
        }
       
        @Override
        protected String getPath(URI uri) {
          String path = uri.getPath();
          return getCoursesLocation() + (path.startsWith("/") ? path : ("/" + path));
        }
      };
     
      reg.registerInputOutput(fileURIResolver);
    }
    else {
      eval.addRascalSearchPathContributor(StandardLibraryContributor.getInstance());
      reg.registerInput(new ClassResourceInput(reg, "courses", getClass(), "/org/rascalmpl/courses"));
    }
   
    eval.addRascalSearchPath(URIUtil.rootScheme("tutor"));
    eval.addRascalSearchPath(URIUtil.rootScheme("courses"));

    for (final String lib : new String[] { "rascal", "rascal-eclipse" }) {
      final String libSrc = System.getProperty("rascal.courses.lib." + lib);

      if (libSrc != null) {
        FileURIResolver fileURIResolver = new FileURIResolver() {
          @Override
          public String scheme() {
            return "clib-" + lib;
          }

          @Override
          protected String getPath(URI uri) {
            String path = uri.getPath();
            return libSrc + (path.startsWith("/") ? path : ("/" + path));
          }
        };

        reg.registerInputOutput(fileURIResolver);
        eval.addRascalSearchPath(URIUtil.rootScheme("clib-" + lib));
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.rascalmpl.uri.URIResolverRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.