There are two predicates for matching CompilationUnit to corresponding Module, Module.getACompilationUnit() and CompilationUnit.getModule() (both using the database predicate cumodule(@file, @module)).
The issue is that the reported compilation units appear to always be the .class files instead of the source .java files, even when the module-info.java file was part of the source.
For example the following query against OpenJDK has no results:
import java
from Module m, RefType t
where
t.fromSource()
and t.getCompilationUnit().getModule() = m
select m, t
Query Console link
However, if you manually try to match .class compilation units with .java compilation units, you will get the desired results:
import java
predicate areProbablySame(CompilationUnit classComp, CompilationUnit sourceComp) {
classComp.getPackage() = sourceComp.getPackage()
and classComp.getName() = sourceComp.getName()
}
from Module m, TopLevelType t, CompilationUnit classComp, CompilationUnit sourceComp
where
t.fromSource()
and sourceComp = t.getCompilationUnit()
and classComp = m.getACompilationUnit()
and areProbablySame(classComp, sourceComp)
select m, t, classComp.getRelativePath(), sourceComp.getRelativePath()
Query Console link
There are two predicates for matching
CompilationUnitto correspondingModule,Module.getACompilationUnit()andCompilationUnit.getModule()(both using the database predicatecumodule(@file, @module)).The issue is that the reported compilation units appear to always be the
.classfiles instead of the source.javafiles, even when themodule-info.javafile was part of the source.For example the following query against OpenJDK has no results:
Query Console link
However, if you manually try to match
.classcompilation units with.javacompilation units, you will get the desired results:Query Console link