From 6dd5a945b4985abb6b2b822804ab5f5e462f0072 Mon Sep 17 00:00:00 2001 From: Noah Santschi-Cooney Date: Wed, 26 Aug 2020 00:37:33 +0100 Subject: [PATCH] Fallback to resolving compilation unit from filename as previously --- .gitignore | 6 ++++++ .../spoon/support/compiler/jdt/JDTBatchCompiler.java | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 56aa7bb2a9b..2a80c44bfeb 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ maven-eclipse.xml !.idea/codeStyleSettings.xml *.iml +# VSCode +.vscode + # Spoon spooned-classes/ spooned/ @@ -31,3 +34,6 @@ doc/_jekyll/_site/ # Nodejs node_modules/ + +# Gradle +.gradle \ No newline at end of file diff --git a/src/main/java/spoon/support/compiler/jdt/JDTBatchCompiler.java b/src/main/java/spoon/support/compiler/jdt/JDTBatchCompiler.java index d80bff647cf..a00df752722 100644 --- a/src/main/java/spoon/support/compiler/jdt/JDTBatchCompiler.java +++ b/src/main/java/spoon/support/compiler/jdt/JDTBatchCompiler.java @@ -91,7 +91,14 @@ public CompilationUnit[] getCompilationUnits() { } else { lastSlash += 1; } - compilationUnit.module = this.module.name(); + + if (this.module == null) { + compilationUnit.module = CharOperation.subarray(modulePath, lastSlash, modulePath.length); + } else { + //TODO the module name parsed by JDK compiler is in `this.modNames`, consider using that instead? + compilationUnit.module = this.module.name(); + } + pathToModName.put(String.valueOf(modulePath), compilationUnit.module); } } else {