1

I'm looking for a way to find all types that are used in a fully qualified way in a JDT ICompilationUnit.

My goal is to find a list of all "referenced" packages in a project. For all things that are imported, the code is pretty straight forward:

for (ICompilationUnit unit : units) {
    try {
        for (IImportDeclaration id : unit.getImports()) {
            String en = id.getElementName();

            // strip off class name or .*
            target.add(en.substring(0, en.lastIndexOf('.')));
        }
    } catch (JavaModelException me) {
        // ...
    }

    // TODO: find fully qualified references from source code?
}

The TODO is the thing I'm interested in :) Best would be a way that does NOT involve full compiler roundtrips or other huge performance hits - but I'll accept them if not otherwise possible...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.