2
2
3
3
import java .io .File ;
4
4
import java .io .IOException ;
5
- import java .io .InputStream ;
6
5
import java .nio .charset .Charset ;
7
- import java .nio .file .Files ;
8
- import java .nio .file .Path ;
9
- import java .nio .file .Paths ;
10
6
import java .util .List ;
11
7
import java .util .Set ;
12
8
import java .util .function .BiConsumer ;
20
16
import javax .tools .ToolProvider ;
21
17
22
18
import org .jboss .logging .Logger ;
23
- import org .objectweb .asm .ClassReader ;
24
- import org .objectweb .asm .ClassVisitor ;
25
19
26
20
import io .quarkus .deployment .dev .filesystem .QuarkusFileManager ;
27
21
import io .quarkus .deployment .dev .filesystem .ReloadableFileManager ;
28
22
import io .quarkus .deployment .dev .filesystem .StaticFileManager ;
29
- import io .quarkus .gizmo .Gizmo ;
30
- import io .quarkus .paths .PathCollection ;
31
23
32
24
public class JavaCompilationProvider implements CompilationProvider {
33
25
@@ -115,20 +107,6 @@ public void compile(Set<File> filesToCompile, CompilationProvider.Context contex
115
107
}
116
108
}
117
109
118
- @ Override
119
- public Path getSourcePath (Path classFilePath , PathCollection sourcePaths , String classesPath ) {
120
- Path sourceFilePath ;
121
- final RuntimeUpdatesClassVisitor visitor = new RuntimeUpdatesClassVisitor (sourcePaths , classesPath );
122
- try (final InputStream inputStream = Files .newInputStream (classFilePath )) {
123
- final ClassReader reader = new ClassReader (inputStream );
124
- reader .accept (visitor , 0 );
125
- sourceFilePath = visitor .getSourceFileForClass (classFilePath );
126
- } catch (IOException e ) {
127
- throw new RuntimeException (e );
128
- }
129
- return sourceFilePath ;
130
- }
131
-
132
110
@ Override
133
111
public void close () throws IOException {
134
112
if (this .fileManager != null ) {
@@ -154,36 +132,4 @@ private String extractCompilationErrorMessage(final DiagnosticCollector<JavaFile
154
132
diagnosticsCollector .getDiagnostics ().forEach (diagnostic -> builder .append ("\n " ).append (diagnostic ));
155
133
return String .format ("\u001B [91mCompilation Failed:%s\u001b [0m" , builder );
156
134
}
157
-
158
- private static class RuntimeUpdatesClassVisitor extends ClassVisitor {
159
- private final PathCollection sourcePaths ;
160
- private final String classesPath ;
161
- private String sourceFile ;
162
-
163
- public RuntimeUpdatesClassVisitor (PathCollection sourcePaths , String classesPath ) {
164
- super (Gizmo .ASM_API_VERSION );
165
- this .sourcePaths = sourcePaths ;
166
- this .classesPath = classesPath ;
167
- }
168
-
169
- @ Override
170
- public void visitSource (String source , String debug ) {
171
- this .sourceFile = source ;
172
- }
173
-
174
- public Path getSourceFileForClass (final Path classFilePath ) {
175
- for (Path sourcesDir : sourcePaths ) {
176
- final Path classesDir = Paths .get (classesPath );
177
- final StringBuilder sourceRelativeDir = new StringBuilder ();
178
- sourceRelativeDir .append (classesDir .relativize (classFilePath .getParent ()));
179
- sourceRelativeDir .append (File .separator );
180
- sourceRelativeDir .append (sourceFile );
181
- final Path sourceFilePath = sourcesDir .resolve (Path .of (sourceRelativeDir .toString ()));
182
- if (Files .exists (sourceFilePath )) {
183
- return sourceFilePath ;
184
- }
185
- }
186
- return null ;
187
- }
188
- }
189
135
}
0 commit comments