Skip to content

Conversation

@chrismwendt
Copy link
Contributor

(no intention to merge)

This is my attempt to see if cross-file j2d/refs would work by using SymbolSolverCollectionStrategy as shown in https://javaparser.org/setting-up-for-analysing-a-whole-project/

It currently doesn't work, and I seem to have hit a roadblock. Take for example this call to postIndex:

https://github.com/sourcegraph/lsif-java/blob/4cf52ba51fb1439afbb61e393c4e4cfafc3cd378/src/main/java/ProjectIndexer.java#L57

When I print out the value of System.out.println(n.resolve());, where n is a MethodCallExpr for postIndex, I get:

ReflectionMethodDeclaration{method=public void DocumentIndexer.postIndex()}

instead of a JavaParserMethodDeclaration. This is problematic because:

getWrappedNode is present only on the subclasses of the Resolved* declarations that derive from JP AST nodes (such as JavaParserClassDeclaration).

From https://static.javadoc.io/com.github.javaparser/javaparser-core/3.13.2/com/github/javaparser/resolution/declarations/AssociableToAST.html#toAst--

ReflectionMethodDeclaration cannot be cast to JavaParserMethodDeclaration. That means I can't call getWrappedNode on it.

I did a bunch of GitHub code searches for other uses of SymbolSolverCollectionStrategy, getWrappedNode, etc. and haven't found any workaround. It seems that Reflection* classes come from jars:

https://github.com/opensathishrtskumar/StaticAnalyzer/blob/cd889d4b9fd631ba13dccce1fce340005ea76e86/src/com/analyzer/visitor/GeneralVisitor.java#L75-L82

@chrismwendt
Copy link
Contributor Author

Subsumed by #2

Strum355 added a commit that referenced this pull request Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants