You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following exception is thrown from a simple sample Java code below:
Exception in thread "main" UnsolvedSymbolException{context='null', name='Method 'key' cannot be resolved in context key(KEYWORD_LBRA, RPAR) (line: 35) MethodCallExprContext{wrapped=key(KEYWORD_LBRA, RPAR)}. Parameter types: [PrimitiveTypeUsage{name='int'}, PrimitiveTypeUsage{name='int'}]', cause='null'}
at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.solveMethodAsUsage(JavaParserFacade.java:651)
at com.github.javaparser.symbolsolver.javaparsermodel.TypeExtractor.visit(TypeExtractor.java:324)
at com.github.javaparser.symbolsolver.javaparsermodel.TypeExtractor.visit(TypeExtractor.java:64)
at com.github.javaparser.ast.expr.MethodCallExpr.accept(MethodCallExpr.java:118)
at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.getTypeConcrete(JavaParserFacade.java:493)
at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.lambda$getType$5(JavaParserFacade.java:380)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.getType(JavaParserFacade.java:379)
at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.solveMethodAsUsage(JavaParserFacade.java:640)
at com.github.javaparser.symbolsolver.javaparsermodel.contexts.LambdaExprContext.solveSymbolAsValue(LambdaExprContext.java:74)
at com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserParameterDeclaration.getType(JavaParserParameterDeclaration.java:63)
at com.github.javaparser.resolution.model.Value.from(Value.java:45)
`public class Sample {
private static final Map<Long, ExpressionMaker> patterns = new HashMap<>();
public static final int KEYWORD_LBRA = 69;
public static final int RPAR = 204;
public Sample() {
}
private static long key(Integer... tokens) {
long key = 0L;
for (int token : tokens) {
key = (key << 8) + token;
}
return key;
}
@FunctionalInterface
private interface ExpressionMaker {
String make(List<String> tokens, String env) ;
}
static {
patterns.put(
key(KEYWORD_LBRA, RPAR),
(values, env) -> {
String kind = values.get(0);
return kind;
});
}
}`
Run it with the following:
`
CompilationUnit cu = StaticJavaParser.parse(filename);
System.err.println("Processing " + filename);
List nes = cu.findAll(NameExpr .class);
nes.forEach(ne -> {
System.out.println(( ne.calculateResolvedType().describe()));
});`
There is some type resolution problem with the argument Integer ... token in the key method
The text was updated successfully, but these errors were encountered:
Hi,
The following exception is thrown from a simple sample Java code below:
`public class Sample {
}`
Run it with the following:
`
CompilationUnit cu = StaticJavaParser.parse(filename);
System.err.println("Processing " + filename);
List nes = cu.findAll(NameExpr .class);
nes.forEach(ne -> {
System.out.println(( ne.calculateResolvedType().describe()));
});`
There is some type resolution problem with the argument
Integer ... token
in thekey
methodThe text was updated successfully, but these errors were encountered: