use of javax.script.ScriptEngineManager in project intellij-community by JetBrains.
the class JavaFxInjectPageLanguageIntention method getAvailableLanguages.
public static Set<String> getAvailableLanguages(Project project) {
final List<ScriptEngineFactory> engineFactories = new ScriptEngineManager(composeUserClassLoader(project)).getEngineFactories();
if (engineFactories != null) {
final Set<String> availableNames = new TreeSet<>();
for (ScriptEngineFactory factory : engineFactories) {
final String engineName = (String) factory.getParameter(ScriptEngine.NAME);
availableNames.add(engineName);
}
return availableNames;
}
return null;
}
use of javax.script.ScriptEngineManager in project bytecode-viewer by Konloch.
the class GroovyPluginLaunchStrategy method run.
@Override
public Plugin run(File file) throws Throwable {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("groovy");
if (engine == null)
throw new Exception("Cannot find Groovy script engine! Please contact Konloch.");
Reader reader = new FileReader(file);
engine.eval(reader);
return (Plugin) engine.eval("new " + file.getName().replace(".gy", "").replace(".groovy", "") + "();");
}
use of javax.script.ScriptEngineManager in project bytecode-viewer by Konloch.
the class PythonPluginLaunchStrategy method run.
@Override
public Plugin run(File file) throws Throwable {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("python");
if (engine == null)
throw new Exception("Cannot find Jython script engine! Please contact Konloch.");
Reader reader = new FileReader(file);
engine.eval(reader);
return (Plugin) engine.eval(file.getName().replace(".py", "").replace(".python", "") + "()");
}
use of javax.script.ScriptEngineManager in project bytecode-viewer by Konloch.
the class RubyPluginLaunchStrategy method run.
@Override
public Plugin run(File file) throws Throwable {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("jruby");
if (engine == null)
throw new Exception("Cannot find jRuby script engine! Please contact Konloch.");
Reader reader = new FileReader(file);
engine.eval(reader);
return (Plugin) engine.eval(file.getName().replace(".rb", "").replace(".ruby", "") + ".new");
}
use of javax.script.ScriptEngineManager in project yyl_example by Relucent.
the class BindingsScript method main.
public static void main(String[] args) {
try {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
String script = "print('hello')";
Bindings bindings = new SimpleBindings();
if (engine instanceof Compilable) {
System.out.println("Compiling....");
Compilable compEngine = (Compilable) engine;
CompiledScript cs = compEngine.compile(script);
cs.eval(bindings);
} else {
engine.eval(script, bindings);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations