|
3 | 3 | import java.io.IOException; |
4 | 4 | import java.io.StringWriter; |
5 | 5 | import java.io.UncheckedIOException; |
6 | | -import java.nio.charset.StandardCharsets; |
7 | 6 | import java.nio.file.Files; |
8 | 7 | import java.nio.file.Path; |
9 | 8 | import java.util.ArrayList; |
10 | | -import java.util.Collections; |
11 | 9 | import java.util.List; |
12 | 10 | import java.util.stream.Collectors; |
13 | | -import java.util.stream.Stream; |
14 | 11 | import javax.tools.JavaCompiler; |
15 | 12 | import javax.tools.JavaFileObject; |
16 | 13 | import javax.tools.ToolProvider; |
@@ -39,31 +36,6 @@ public TestCompiler( |
39 | 36 | new SimpleFileManager(compiler.getStandardFileManager(null, null, null), targetroot); |
40 | 37 | } |
41 | 38 |
|
42 | | - public TestCompiler(String classpath, List<String> javacOptions, Path targetroot) { |
43 | | - this(classpath, javacOptions, targetroot, createTempDir()); |
44 | | - } |
45 | | - |
46 | | - public TestCompiler(Path targetroot) { |
47 | | - this(PROCESSOR_PATH, Collections.emptyList(), targetroot); |
48 | | - } |
49 | | - |
50 | | - public CompileResult compileScipDirectory(Path dir) { |
51 | | - return compileScip(inputsFromDirectory(dir)); |
52 | | - } |
53 | | - |
54 | | - public CompileResult compileScip(List<VirtualFile> inputs) { |
55 | | - return compile( |
56 | | - inputs, |
57 | | - Collections.singletonList( |
58 | | - String.format( |
59 | | - "-Xplugin:scip -verbose -text:on -sourceroot:%s -targetroot:%s", |
60 | | - sourceroot, targetroot))); |
61 | | - } |
62 | | - |
63 | | - public CompileResult compile(List<VirtualFile> inputs) { |
64 | | - return compile(inputs, Collections.emptyList()); |
65 | | - } |
66 | | - |
67 | 39 | public CompileResult compile(List<VirtualFile> inputs, List<String> extraJavacOptions) { |
68 | 40 | List<VirtualFile> javacInputs = |
69 | 41 | inputs.stream().filter(i -> i.path.endsWith(".java")).collect(Collectors.toList()); |
@@ -108,33 +80,4 @@ private CompileResult compileJavac(List<VirtualFile> inputs, List<String> extraJ |
108 | 80 | } |
109 | 81 | return new CompileResult(bytecode, output.toString(), docs, isSuccess); |
110 | 82 | } |
111 | | - |
112 | | - private List<VirtualFile> inputsFromDirectory(Path dir) { |
113 | | - try (Stream<Path> paths = Files.walk(dir)) { |
114 | | - return paths |
115 | | - .filter(Files::isRegularFile) |
116 | | - .filter(p -> p.getFileName().toString().endsWith(".java")) |
117 | | - .map( |
118 | | - p -> { |
119 | | - try { |
120 | | - return new VirtualFile( |
121 | | - dir.relativize(p).toString(), |
122 | | - new String(Files.readAllBytes(p), StandardCharsets.UTF_8)); |
123 | | - } catch (IOException e) { |
124 | | - throw new UncheckedIOException(e); |
125 | | - } |
126 | | - }) |
127 | | - .collect(Collectors.toList()); |
128 | | - } catch (IOException e) { |
129 | | - throw new UncheckedIOException(e); |
130 | | - } |
131 | | - } |
132 | | - |
133 | | - private static Path createTempDir() { |
134 | | - try { |
135 | | - return Files.createTempDirectory("scip-javac"); |
136 | | - } catch (IOException e) { |
137 | | - throw new UncheckedIOException(e); |
138 | | - } |
139 | | - } |
140 | 83 | } |
0 commit comments