BowlerKernel
KotlinHelper.java
Go to the documentation of this file.
1 package com.neuronrobotics.bowlerstudio.scripting;
2 //
3 //import de.swirtz.ktsrunner.objectloader.KtsObjectLoader;
4 //
5 //import java.io.File;
6 //import java.nio.file.Files;
7 //import java.util.ArrayList;
8 //import java.util.Arrays;
9 //import java.util.stream.Collectors;
10 //import java.util.stream.Stream;
11 //
13 // * Provides kotlin support. If you want to pass arguments to the script. return a class which
14 // * implements KotlinScriptSkeleton (it will be instantiated and runScript will be called).
15 // */
16 //
17 //public class KotlinHelper implements IScriptingLanguage {
18 // static {
19 // System.setProperty("idea.io.use.fallback", "true");
20 // }
21 // private Object inline(String content, ArrayList<Object> args) throws Exception {
22 // KtsObjectLoader loader = new KtsObjectLoader();
23 // Object result = loader.getEngine().eval(content);
24 //
25 // if (result instanceof Class<?>) {
26 // // Try to parse the class into a KotlinScriptSkeleton
27 // Object instance = ((Class<?>) result).getDeclaredConstructor().newInstance();
28 // if (instance instanceof KotlinScriptSkeleton) {
29 // // This is the skeleton interface for kotlin scripts, so we can pass args in
30 // return ((KotlinScriptSkeleton) instance).runScript(args);
31 // } else {
32 // return instance;
33 // }
34 // } else {
35 // // Didn't get a class so we don't know what to do
36 // return result;
37 // }
38 // }
39 //
40 // @Override
41 // public Object inlineScriptRun(File code, ArrayList<Object> args) throws Exception {
42 // try (Stream<String> lines = Files.lines(code.toPath())) {
43 // return inline(lines.collect(Collectors.joining("\n")), args);
44 // }
45 // }
46 //
47 // @Override
48 // public Object inlineScriptRun(String code, ArrayList<Object> args) throws Exception {
49 // return inline(code, args);
50 // }
51 //
52 // @Override
53 // public String getShellType() {
54 // return "Kotlin";
55 // }
56 //
57 // @Override
58 // public ArrayList<String> getFileExtenetion() {
59 // return new ArrayList<>(Arrays.asList("kt", "kts"));
60 // }
61 //
62 // @Override
63 // public boolean getIsTextFile() {
64 // return true;
65 // }
66 //}