Package scala.tools.nsc.interpreter

Examples of scala.tools.nsc.interpreter.IMain


  @Override public void runPlugin(String pathToPluginFolder, final String pluginId,
                                  Map<String, ?> binding, Function<Runnable, Void> runOnEDTCallback) {
    final File scriptFile = MyFileUtil.findSingleFileIn(pathToPluginFolder, ScalaPluginRunner.MAIN_SCRIPT);
    assert scriptFile != null;

    final IMain interpreter;
    synchronized (interpreterLock) {
      try {
        environment.put("PLUGIN_PATH", pathToPluginFolder);

        List<String> additionalPaths = findClasspathAdditions(readLines(asUrl(scriptFile)), SCALA_ADD_TO_CLASSPATH_KEYWORD, environment, new Function<String, Void>() {
          @Override public Void fun(String path) {
            errorReporter.addLoadingError(pluginId, "Couldn't find dependency '" + path + "'");
            return null;
          }
        });
        String classpath = createInterpreterClasspath(additionalPaths);
        interpreter = initInterpreter(classpath);

      } catch (Exception e) {
        errorReporter.addLoadingError("Failed to init scala interpreter", e);
        return;
      } catch (LinkageError e) {
        errorReporter.addLoadingError("Failed to init scala interpreter", e);
        return;
      }

      interpreterOutput.getBuffer().delete(0, interpreterOutput.getBuffer().length());
      for (Map.Entry<String, ?> entry : binding.entrySet()) {
        interpreter.bindValue(entry.getKey(), entry.getValue());
      }
    }

    runOnEDTCallback.fun(new Runnable() {
      @Override public void run() {
        synchronized (interpreterLock) {
          Results.Result result;
          try {
            result = interpreter.interpret(FileUtil.loadFile(scriptFile));
          } catch (LinkageError e) {
            errorReporter.addLoadingError(pluginId, "Error linking script file: " + scriptFile);
            return;
          } catch (Exception e) {
            errorReporter.addLoadingError(pluginId, "Error reading script file: " + scriptFile);
View Full Code Here


    MutableSettings.PathSetting bootClasspath = (MutableSettings.PathSetting) settings.bootclasspath();
    bootClasspath.append(interpreterClasspath);

    ((MutableSettings.BooleanSetting) settings.usejavacp()).tryToSetFromPropertyValue("true");

    return new IMain(settings, new PrintWriter(interpreterOutput));
  }
View Full Code Here

TOP

Related Classes of scala.tools.nsc.interpreter.IMain

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.