-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into issue9inference
- Loading branch information
Showing
184 changed files
with
2,567 additions
and
5,616 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/JavaSymbolSolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.github.javaparser.symbolsolver; | ||
|
||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.Node; | ||
import com.github.javaparser.ast.body.MethodDeclaration; | ||
import com.github.javaparser.resolution.SymbolResolver; | ||
import com.github.javaparser.resolution.types.ResolvedArrayType; | ||
import com.github.javaparser.resolution.types.ResolvedType; | ||
import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade; | ||
import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFactory; | ||
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserMethodDeclaration; | ||
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver; | ||
|
||
import com.github.javaparser.ast.type.ArrayType; | ||
|
||
|
||
public class JavaSymbolSolver implements SymbolResolver { | ||
|
||
private TypeSolver typeSolver; | ||
|
||
public JavaSymbolSolver(TypeSolver typeSolver) { | ||
this.typeSolver = typeSolver; | ||
} | ||
|
||
@Override | ||
public <T> T resolve(Node node, Class<T> resultClass) { | ||
if (node instanceof MethodDeclaration) { | ||
return resultClass.cast(new JavaParserMethodDeclaration((MethodDeclaration)node, typeSolver)); | ||
} | ||
if (node instanceof ArrayType) { | ||
return resultClass.cast(JavaParserFacade.get(typeSolver).convert((ArrayType)node, node)); | ||
} | ||
throw new UnsupportedOperationException("Unable to resolve to " + resultClass.getSimpleName() + " from " + node.getClass().getSimpleName()); | ||
} | ||
|
||
public void inject(CompilationUnit destination) { | ||
destination.setData(Node.SYMBOL_RESOLVER_KEY, this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.