Skip to content

Commit

Permalink
fix: fetchin module from the JDT compiler (INRIA#3549)
Browse files Browse the repository at this point in the history
  • Loading branch information
Strum355 committed Sep 7, 2020
1 parent bfc1d4b commit 7c5eb53
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public CompilationUnit[] getCompilationUnits() {
} else {
lastSlash += 1;
}

if (this.module == null) {
compilationUnit.module = CharOperation.subarray(modulePath, lastSlash, modulePath.length);
} else {
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/spoon/test/compilation/CompilationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,21 @@ public CompilationUnit[] getCompilationUnits() {

}

@Test
public void testModuleResolution() throws InterruptedException {
// contract: module name is set from the info extract from the module-info.java file
// when such file exists
Launcher launcher = new Launcher();

// contract: ComplianceLevel must be >=9 to build a model from an input resource
// that contains module-info.java file(s)
launcher.getEnvironment().setComplianceLevel(9);
launcher.addInputResource("./src/test/resources/simple-module");
launcher.buildModel();

assertTrue(launcher.getModel().getAllModules().iterator().next().getSimpleName().equals("spoonmod"));
}

@Test
public void testFilterResourcesDir() {
// shows how to filter input java dir
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/simple-module/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module spoonmod {

}
5 changes: 5 additions & 0 deletions src/test/resources/simple-module/spoonmod/TestClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package spoonmod;

public class TestClass {
public TestClass() {}
}

0 comments on commit 7c5eb53

Please sign in to comment.