logic: improved reliability of Java indexer
* moved to JavaParser 3.0 * Fixed many unsolved types and symbols
This commit is contained in:
@@ -36,7 +36,11 @@ public class ASTDumper extends JavaAstVisitor{
|
||||
{
|
||||
line += " [" + ((ClassOrInterfaceType)n).getName() + "]";
|
||||
}
|
||||
|
||||
else if (n instanceof MethodCallExpr)
|
||||
{
|
||||
line += " [" + ((MethodCallExpr)n).getName() + "]";
|
||||
}
|
||||
line += " line: " + n.getBegin().line;
|
||||
|
||||
System.out.println(line);
|
||||
}
|
||||
@@ -80,8 +84,6 @@ public class ASTDumper extends JavaAstVisitor{
|
||||
public void visit(MethodDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
|
||||
|
||||
public void visit(Parameter n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
|
||||
|
||||
public void visit(MultiTypeParameter n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
|
||||
|
||||
public void visit(EmptyMemberDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.github.javaparser.ast.body.EnumConstantDeclaration;
|
||||
import com.github.javaparser.ast.body.EnumDeclaration;
|
||||
import com.github.javaparser.ast.body.FieldDeclaration;
|
||||
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||
import com.github.javaparser.ast.body.ModifierSet;
|
||||
import com.github.javaparser.ast.body.Parameter;
|
||||
import com.github.javaparser.ast.body.VariableDeclarator;
|
||||
import com.github.javaparser.ast.body.VariableDeclaratorId;
|
||||
@@ -28,6 +27,7 @@ import com.github.javaparser.ast.type.PrimitiveType;
|
||||
import com.github.javaparser.ast.type.Type;
|
||||
import com.github.javaparser.ast.type.VoidType;
|
||||
import com.github.javaparser.ast.ImportDeclaration;
|
||||
import com.github.javaparser.ast.Modifier;
|
||||
import com.github.javaparser.ast.Node;
|
||||
import com.github.javaparser.ast.PackageDeclaration;
|
||||
import com.github.javaparser.ast.TypeParameter;
|
||||
@@ -51,10 +51,16 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
private FileContent m_fileContent;
|
||||
private TypeSolver m_typeSolver;
|
||||
private List<DeclContext> m_context = new ArrayList<DeclContext>();
|
||||
private boolean m_verbose = false;
|
||||
private boolean m_verbose = true;
|
||||
static int errorCount = 0;
|
||||
|
||||
public JavaAstVisitor(int callbackId, String filePath, FileContent fileContent, TypeSolver typeSolver)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println("indexing file: " + filePath);
|
||||
}
|
||||
|
||||
m_callbackId = callbackId;
|
||||
m_filePath = filePath;
|
||||
m_fileContent = fileContent;
|
||||
@@ -76,8 +82,8 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.recordSymbolWithScope(
|
||||
m_callbackId, packageName, SymbolType.PACKAGE,
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column,
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column,
|
||||
AccessKind.NONE, false
|
||||
);
|
||||
|
||||
@@ -92,13 +98,13 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.recordSymbolWithScope(
|
||||
m_callbackId, qualifiedName, (n.isInterface() ? SymbolType.INTERFACE : SymbolType.CLASS),
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
|
||||
AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column,
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column,
|
||||
AccessKind.fromAccessSpecifier(Modifier.getAccessSpecifier(n.getModifiers())), false
|
||||
);
|
||||
|
||||
FileContent.Location scopeStartLocation = m_fileContent.find("{", n.getBeginLine(), n.getBeginColumn());
|
||||
recordScope(scopeStartLocation.line, scopeStartLocation.column, n.getEndLine(), n.getEndColumn());
|
||||
FileContent.Location scopeStartLocation = m_fileContent.find("{", n.getBegin().line, n.getBegin().column);
|
||||
recordScope(scopeStartLocation.line, scopeStartLocation.column, n.getEnd().line, n.getEnd().column);
|
||||
|
||||
List<DeclContext> parentContext = m_context;
|
||||
m_context = new ArrayList<DeclContext>();
|
||||
@@ -124,7 +130,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.recordSymbol(
|
||||
m_callbackId, qualifiedName, SymbolType.TYPE_PARAMETER,
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getBeginLine(), n.getBeginColumn() + n.getName().length() - 1,
|
||||
n.getBegin().line, n.getBegin().column, n.getBegin().line, n.getBegin().column + n.getName().length() - 1,
|
||||
AccessKind.TYPE_PARAMETER, false
|
||||
);
|
||||
|
||||
@@ -143,13 +149,13 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.recordSymbolWithScope(
|
||||
m_callbackId, qualifiedName, SymbolType.ENUM,
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
|
||||
AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column,
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column,
|
||||
AccessKind.fromAccessSpecifier(Modifier.getAccessSpecifier(n.getModifiers())), false
|
||||
);
|
||||
|
||||
FileContent.Location scopeStartLocation = m_fileContent.find("{", n.getBeginLine(), n.getBeginColumn());
|
||||
recordScope(scopeStartLocation.line, scopeStartLocation.column, n.getEndLine(), n.getEndColumn());
|
||||
FileContent.Location scopeStartLocation = m_fileContent.find("{", n.getBegin().line, n.getBegin().column);
|
||||
recordScope(scopeStartLocation.line, scopeStartLocation.column, n.getEnd().line, n.getEnd().column);
|
||||
|
||||
List<DeclContext> parentContext = m_context;
|
||||
m_context = new ArrayList<DeclContext>();
|
||||
@@ -164,7 +170,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.recordSymbol(
|
||||
m_callbackId, qualifiedName, SymbolType.ENUM_CONSTANT,
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column,
|
||||
AccessKind.NONE, false
|
||||
);
|
||||
|
||||
@@ -183,9 +189,9 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.recordSymbolWithScope(
|
||||
m_callbackId, qualifiedName, SymbolType.METHOD,
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
|
||||
AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column,
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column,
|
||||
AccessKind.fromAccessSpecifier(Modifier.getAccessSpecifier(n.getModifiers())), false
|
||||
);
|
||||
|
||||
List<DeclContext> parentContext = m_context;
|
||||
@@ -203,9 +209,9 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.recordSymbolWithScope(
|
||||
m_callbackId, qualifiedName, SymbolType.METHOD,
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
|
||||
AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column,
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column,
|
||||
AccessKind.fromAccessSpecifier(Modifier.getAccessSpecifier(n.getModifiers())), false
|
||||
);
|
||||
|
||||
|
||||
@@ -219,7 +225,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.recordReference(
|
||||
m_callbackId, ReferenceKind.OVERRIDE, overriddenName, qualifiedName,
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn()
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column
|
||||
);
|
||||
}
|
||||
|
||||
@@ -312,8 +318,8 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.recordSymbol(
|
||||
m_callbackId, qualifiedName, SymbolType.FIELD,
|
||||
varDeclId.getBeginLine(), varDeclId.getBeginColumn(), varDeclId.getEndLine(), varDeclId.getEndColumn(),
|
||||
AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
|
||||
varDeclId.getBegin().line, varDeclId.getBegin().column, varDeclId.getEnd().line, varDeclId.getEnd().column,
|
||||
AccessKind.fromAccessSpecifier(Modifier.getAccessSpecifier(n.getModifiers())), false
|
||||
);
|
||||
|
||||
m_context.add(new DeclContext(qualifiedName));
|
||||
@@ -328,11 +334,11 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
for (VariableDeclarator declarator: n.getVars())
|
||||
{
|
||||
VariableDeclaratorId identifier = declarator.getId();
|
||||
String qualifiedName = m_filePath + "<" + identifier.getBeginLine() + ":" + identifier.getBeginColumn() + ">";
|
||||
String qualifiedName = m_filePath + "<" + identifier.getBegin().line + ":" + identifier.getBegin().column + ">";
|
||||
|
||||
JavaIndexer.recordLocalSymbol(
|
||||
m_callbackId, qualifiedName,
|
||||
identifier.getBeginLine(), identifier.getBeginColumn(), identifier.getEndLine(), identifier.getEndColumn()
|
||||
identifier.getBegin().line, identifier.getBegin().column, identifier.getEnd().line, identifier.getEnd().column
|
||||
);
|
||||
|
||||
}
|
||||
@@ -344,11 +350,11 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
@Override public void visit(final Parameter n, final Void v)
|
||||
{
|
||||
VariableDeclaratorId identifier = n.getId();
|
||||
String qualifiedName = m_filePath + "<" + identifier.getBeginLine() + ":" + identifier.getBeginColumn() + ">";
|
||||
String qualifiedName = m_filePath + "<" + identifier.getBegin().line + ":" + identifier.getBegin().column + ">";
|
||||
|
||||
JavaIndexer.recordLocalSymbol(
|
||||
m_callbackId, qualifiedName,
|
||||
identifier.getBeginLine(), identifier.getBeginColumn(), identifier.getEndLine(), identifier.getEndColumn()
|
||||
identifier.getBegin().line, identifier.getBegin().column, identifier.getEnd().line, identifier.getEnd().column
|
||||
);
|
||||
|
||||
// don't change the context here.
|
||||
@@ -370,7 +376,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
JavaIndexer.recordReference(
|
||||
m_callbackId, ReferenceKind.IMPORT,
|
||||
importedName, context.getName(),
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn()
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -431,7 +437,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
JavaIndexer.recordReference(
|
||||
m_callbackId, ReferenceKind.IMPORT,
|
||||
nameHierarchy, context.getName(),
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn()
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -440,16 +446,13 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
JavaIndexer.recordError(
|
||||
m_callbackId, "Import not found.", true, true,
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn()
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
}
|
||||
recordException(e, n);
|
||||
}
|
||||
}
|
||||
super.visit(n, v);
|
||||
@@ -463,15 +466,15 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
String referencedName = JavaparserTypeNameResolver.getQualifiedTypeName(n, m_typeSolver).toSerializedNameHierarchy();
|
||||
|
||||
int beginLine = n.getBeginLine();
|
||||
int beginColumn = n.getBeginColumn();
|
||||
int endLine = n.getBeginLine();
|
||||
int endColumn = n.getBeginColumn() + n.getName().length() - 1;
|
||||
int beginLine = n.getBegin().line;
|
||||
int beginColumn = n.getBegin().column;
|
||||
int endLine = n.getBegin().line;
|
||||
int endColumn = n.getBegin().column + n.getName().length() - 1;
|
||||
|
||||
if (n.getScope() != null)
|
||||
{
|
||||
endLine = n.getScope().getEndLine();
|
||||
endColumn = n.getScope().getEndColumn() + n.getName().length() + 1; // +1 for separator
|
||||
endLine = n.getScope().getEnd().line;
|
||||
endColumn = n.getScope().getEnd().column + n.getName().length() + 1; // +1 for separator
|
||||
}
|
||||
|
||||
JavaIndexer.recordReference(
|
||||
@@ -482,10 +485,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
}
|
||||
recordException(e, n);
|
||||
}
|
||||
super.visit(n, v);
|
||||
}
|
||||
@@ -505,16 +505,13 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
JavaIndexer.recordReference(
|
||||
m_callbackId, getTypeReferenceKind(), referencedName, context.getName(),
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn()
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
}
|
||||
recordException(e, n);
|
||||
}
|
||||
|
||||
super.visit(n, v);
|
||||
@@ -535,16 +532,13 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
JavaIndexer.recordReference(
|
||||
m_callbackId, getTypeReferenceKind(), referencedName, context.getName(),
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn()
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
}
|
||||
recordException(e, n);
|
||||
}
|
||||
|
||||
super.visit(n, v);
|
||||
@@ -558,10 +552,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
}
|
||||
recordException(e, n);
|
||||
}
|
||||
|
||||
super.visit(n, v);
|
||||
@@ -585,11 +576,11 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
if (wrappedNode instanceof Parameter)
|
||||
{
|
||||
VariableDeclaratorId identifier = ((Parameter)wrappedNode).getId();
|
||||
String qualifiedName = m_filePath + "<" + identifier.getBeginLine() + ":" + identifier.getBeginColumn() + ">";
|
||||
String qualifiedName = m_filePath + "<" + identifier.getBegin().line + ":" + identifier.getBegin().column + ">";
|
||||
|
||||
JavaIndexer.recordLocalSymbol(
|
||||
m_callbackId, qualifiedName,
|
||||
e.getBeginLine(), e.getBeginColumn(), e.getEndLine(), e.getEndColumn()
|
||||
e.getBegin().line, e.getBegin().column, e.getEnd().line, e.getEnd().column
|
||||
);
|
||||
}
|
||||
else if (wrappedNode instanceof VariableDeclarator)
|
||||
@@ -602,18 +593,18 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
JavaIndexer.recordReference(
|
||||
m_callbackId, ReferenceKind.USAGE, qualifiedName, context.getName(),
|
||||
e.getBeginLine(), e.getBeginColumn(), e.getEndLine(), e.getEndColumn()
|
||||
e.getBegin().line, e.getBegin().column, e.getEnd().line, e.getEnd().column
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
VariableDeclaratorId identifier = ((VariableDeclarator)wrappedNode).getId();
|
||||
String qualifiedName = m_filePath + "<" + identifier.getBeginLine() + ":" + identifier.getBeginColumn() + ">";
|
||||
String qualifiedName = m_filePath + "<" + identifier.getBegin().line + ":" + identifier.getBegin().column + ">";
|
||||
|
||||
JavaIndexer.recordLocalSymbol(
|
||||
m_callbackId, qualifiedName,
|
||||
e.getBeginLine(), e.getBeginColumn(), e.getEndLine(), e.getEndColumn()
|
||||
e.getBegin().line, e.getBegin().column, e.getEnd().line, e.getEnd().column
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -650,34 +641,24 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
MethodUsage solvedMethod = JavaParserFacade.get(m_typeSolver).solveMethodAsUsage(n);
|
||||
qualifiedName = getQualifiedName(solvedMethod);
|
||||
}
|
||||
|
||||
catch (UnsupportedOperationException e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
}
|
||||
recordException(e, n);
|
||||
}
|
||||
catch (MethodAmbiguityException e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
}
|
||||
recordException(e, n);
|
||||
}
|
||||
catch(StackOverflowError e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
}
|
||||
recordError(e, n);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
}
|
||||
recordException(e, n);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!qualifiedName.isEmpty())
|
||||
@@ -687,13 +668,45 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
JavaIndexer.recordReference(
|
||||
m_callbackId, ReferenceKind.CALL, qualifiedName, context.getName(),
|
||||
nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn()
|
||||
nameExpr.getBegin().line, nameExpr.getBegin().column, nameExpr.getEnd().line, nameExpr.getEnd().column
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
super.visit(n, v);
|
||||
}
|
||||
|
||||
|
||||
private void recordException(Exception e, Node n)
|
||||
{
|
||||
JavaIndexer.recordSymbol(
|
||||
m_callbackId, "unsolved-symbol\ts\tp", SymbolType.TYPE_MAX,
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column,
|
||||
AccessKind.DEFAULT, false
|
||||
);
|
||||
errorCount++;
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBegin().line + ", " + n.getBegin().column + " [errors: " + errorCount + "]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void recordError(Error e, Node n)
|
||||
{
|
||||
JavaIndexer.recordSymbol(
|
||||
m_callbackId, "unsolved-symbol\ts\tp", SymbolType.TYPE_MAX,
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column,
|
||||
AccessKind.DEFAULT, false
|
||||
);
|
||||
errorCount++;
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBegin().line + ", " + n.getBegin().column + " [errors: " + errorCount + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Override public void visit(final ObjectCreationExpr n, final Void v)
|
||||
{
|
||||
@@ -730,28 +743,28 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
System.out.println(e + " at location " + n.getBegin().line + ", " + n.getBegin().column);
|
||||
}
|
||||
}
|
||||
catch (MethodAmbiguityException e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
System.out.println(e + " at location " + n.getBegin().line + ", " + n.getBegin().column);
|
||||
}
|
||||
}
|
||||
catch(StackOverflowError e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
System.out.println(e + " at location " + n.getBegin().line + ", " + n.getBegin().column);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
|
||||
System.out.println(e + " at location " + n.getBegin().line + ", " + n.getBegin().column);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -763,7 +776,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
JavaIndexer.recordRef(
|
||||
m_callbackId, ReferenceType.CALL.getValue(), qualifiedName, context.getName(),
|
||||
type.getBeginLine(), type.getBeginColumn(), type.getEndLine(), type.getEndColumn()
|
||||
type.getBegin().line, type.getBegin().column, type.getEnd().line, type.getEnd().column
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -809,20 +822,20 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
@Override public void visit(final BlockStmt n, final Void v)
|
||||
{
|
||||
recordScope(n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn());
|
||||
recordScope(n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column);
|
||||
super.visit(n, v);
|
||||
}
|
||||
|
||||
@Override public void visit(final ArrayInitializerExpr n, final Void v)
|
||||
{
|
||||
recordScope(n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn());
|
||||
recordScope(n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column);
|
||||
super.visit(n, v);
|
||||
}
|
||||
|
||||
@Override public void visit(final SwitchStmt n, final Void v)
|
||||
{
|
||||
FileContent.Location scopeStartLocation = m_fileContent.find("{", n.getBeginLine(), n.getBeginColumn());
|
||||
recordScope(scopeStartLocation.line, scopeStartLocation.column, n.getEndLine(), n.getEndColumn());
|
||||
FileContent.Location scopeStartLocation = m_fileContent.find("{", n.getBegin().line, n.getBegin().column);
|
||||
recordScope(scopeStartLocation.line, scopeStartLocation.column, n.getEnd().line, n.getEnd().column);
|
||||
super.visit(n, v);
|
||||
}
|
||||
|
||||
@@ -837,7 +850,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
JavaIndexer.recordComment(
|
||||
m_callbackId,
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn()
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column
|
||||
);
|
||||
super.visit(n, v);
|
||||
}
|
||||
@@ -846,7 +859,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
{
|
||||
JavaIndexer.recordComment(
|
||||
m_callbackId,
|
||||
n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn()
|
||||
n.getBegin().line, n.getBegin().column, n.getEnd().line, n.getEnd().column
|
||||
);
|
||||
super.visit(n, v);
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@ import com.github.javaparser.ast.body.FieldDeclaration;
|
||||
import com.github.javaparser.ast.body.InitializerDeclaration;
|
||||
import com.github.javaparser.ast.comments.JavadocComment;
|
||||
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||
import com.github.javaparser.ast.body.MultiTypeParameter;
|
||||
import com.github.javaparser.ast.body.Parameter;
|
||||
import com.github.javaparser.ast.body.TypeDeclaration;
|
||||
import com.github.javaparser.ast.body.VariableDeclarator;
|
||||
import com.github.javaparser.ast.body.VariableDeclaratorId;
|
||||
import com.github.javaparser.ast.expr.*;
|
||||
import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations;
|
||||
import com.github.javaparser.ast.nodeTypes.NodeWithArrays;
|
||||
import com.github.javaparser.ast.stmt.AssertStmt;
|
||||
import com.github.javaparser.ast.stmt.BlockStmt;
|
||||
import com.github.javaparser.ast.stmt.BreakStmt;
|
||||
@@ -51,8 +52,9 @@ import com.github.javaparser.ast.stmt.WhileStmt;
|
||||
import com.github.javaparser.ast.type.*;
|
||||
import com.github.javaparser.ast.visitor.VoidVisitor;
|
||||
|
||||
import static com.github.javaparser.ast.internal.Utils.isNullOrEmpty;
|
||||
import static com.github.javaparser.utils.Utils.isNullOrEmpty;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@@ -87,8 +89,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
}
|
||||
if (n.getTypes() != null)
|
||||
{
|
||||
for (final TypeDeclaration typeDeclaration : n.getTypes())
|
||||
{
|
||||
for (final TypeDeclaration<?> typeDeclaration : n.getTypes())
|
||||
{
|
||||
typeDeclaration.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -98,13 +100,7 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(PackageDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
// n.getName().accept(this, arg);
|
||||
}
|
||||
|
||||
@@ -141,14 +137,7 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(ClassOrInterfaceDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
// n.getNameExpr().accept(this, arg);
|
||||
for (final TypeParameter t : n.getTypeParameters())
|
||||
{
|
||||
@@ -166,7 +155,7 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
}
|
||||
m_typeRefKind.pop();
|
||||
|
||||
for (final BodyDeclaration member : n.getMembers())
|
||||
for (final BodyDeclaration<?> member : n.getMembers())
|
||||
{
|
||||
member.accept(this, arg);
|
||||
}
|
||||
@@ -175,16 +164,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(EnumDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations()) {
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
|
||||
// n.getNameExpr().accept(this, arg);
|
||||
|
||||
m_typeRefKind.push(ReferenceKind.INHERITANCE);
|
||||
@@ -206,7 +187,7 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
}
|
||||
if (n.getMembers() != null)
|
||||
{
|
||||
for (final BodyDeclaration member : n.getMembers())
|
||||
for (final BodyDeclaration<?> member : n.getMembers())
|
||||
{
|
||||
member.accept(this, arg);
|
||||
}
|
||||
@@ -216,27 +197,13 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(EmptyTypeDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
// n.getNameExpr().accept(this, arg);
|
||||
}
|
||||
|
||||
@Override public void visit(EnumConstantDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
if (n.getArgs() != null)
|
||||
{
|
||||
for (final Expression e : n.getArgs())
|
||||
@@ -246,7 +213,7 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
}
|
||||
if (n.getClassBody() != null)
|
||||
{
|
||||
for (final BodyDeclaration member : n.getClassBody())
|
||||
for (final BodyDeclaration<?> member : n.getClassBody())
|
||||
{
|
||||
member.accept(this, arg);
|
||||
}
|
||||
@@ -256,21 +223,11 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(AnnotationDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
// n.getNameExpr().accept(this, arg);
|
||||
if (n.getMembers() != null)
|
||||
{
|
||||
for (final BodyDeclaration member : n.getMembers())
|
||||
for (final BodyDeclaration<?> member : n.getMembers())
|
||||
{
|
||||
member.accept(this, arg);
|
||||
}
|
||||
@@ -280,17 +237,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(AnnotationMemberDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
|
||||
n.getType().accept(this, arg);
|
||||
if (n.getDefaultValue() != null)
|
||||
{
|
||||
@@ -301,17 +249,7 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(FieldDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
n.getType().accept(this, arg);
|
||||
for (final VariableDeclarator var : n.getVariables())
|
||||
{
|
||||
@@ -337,17 +275,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(ConstructorDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
|
||||
if (n.getTypeParameters() != null)
|
||||
{
|
||||
for (final TypeParameter t : n.getTypeParameters())
|
||||
@@ -365,28 +294,19 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
}
|
||||
if (n.getThrows() != null)
|
||||
{
|
||||
for (final NameExpr name : n.getThrows())
|
||||
for (final ReferenceType name : n.getThrows())
|
||||
{
|
||||
name.accept(this, arg);
|
||||
}
|
||||
}
|
||||
n.getBlock().accept(this, arg);
|
||||
n.getBody().accept(this, arg);
|
||||
}
|
||||
|
||||
@Override public void visit(MethodDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
|
||||
if (n.getTypeParameters() != null)
|
||||
{
|
||||
for (final TypeParameter t : n.getTypeParameters())
|
||||
@@ -419,56 +339,26 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(Parameter n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
|
||||
n.getType().accept(this, arg);
|
||||
n.getId().accept(this, arg);
|
||||
}
|
||||
|
||||
@Override public void visit(MultiTypeParameter n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getAnnotations() != null)
|
||||
{
|
||||
for (final AnnotationExpr a : n.getAnnotations())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
if (n.getType() != null)
|
||||
{
|
||||
n.getType().accept(this, arg);
|
||||
}
|
||||
n.getId().accept(this, arg);
|
||||
}
|
||||
|
||||
@Override public void visit(EmptyMemberDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visit(InitializerDeclaration n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getJavaDoc() != null)
|
||||
{
|
||||
n.getJavaDoc().accept(this, arg);
|
||||
}
|
||||
|
||||
n.getBlock().accept(this, arg);
|
||||
}
|
||||
|
||||
@Override public void visit(JavadocComment n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
}
|
||||
|
||||
//- Type ----------------------------------------------
|
||||
@@ -476,6 +366,7 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(ClassOrInterfaceType n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
visitAnnotations(n, arg);
|
||||
// if (n.getScope() != null) // don't visit the qualifier here.
|
||||
// {
|
||||
// n.getScope().accept(this, arg);
|
||||
@@ -494,17 +385,21 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(PrimitiveType n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
visitAnnotations(n, arg);
|
||||
}
|
||||
|
||||
@Override public void visit(ReferenceType n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
visitAnnotations(n, arg);
|
||||
visitArraysAnnotations(n, arg);
|
||||
n.getType().accept(this, arg);
|
||||
}
|
||||
|
||||
@Override public void visit(IntersectionType n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
visitAnnotations(n, arg);
|
||||
for (ReferenceType element : n.getElements())
|
||||
{
|
||||
element.accept(this, arg);
|
||||
@@ -514,6 +409,7 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(UnionType n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
visitAnnotations(n, arg);
|
||||
for (ReferenceType element : n.getElements())
|
||||
{
|
||||
element.accept(this, arg);
|
||||
@@ -523,11 +419,13 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(VoidType n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
visitAnnotations(n, arg);
|
||||
}
|
||||
|
||||
@Override public void visit(WildcardType n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
visitAnnotations(n, arg);
|
||||
if (n.getExtends() != null)
|
||||
{
|
||||
n.getExtends().accept(this, arg);
|
||||
@@ -555,6 +453,7 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(ArrayCreationExpr n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
visitArraysAnnotations(n, arg);
|
||||
n.getType().accept(this, arg);
|
||||
if (!isNullOrEmpty(n.getDimensions()))
|
||||
{
|
||||
@@ -562,7 +461,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
{
|
||||
dim.accept(this, arg);
|
||||
}
|
||||
} else
|
||||
}
|
||||
if (n.getInitializer() != null)
|
||||
{
|
||||
n.getInitializer().accept(this, arg);
|
||||
}
|
||||
@@ -683,21 +583,26 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(MethodCallExpr n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getScope() != null) {
|
||||
if (n.getScope() != null)
|
||||
{
|
||||
n.getScope().accept(this, arg);
|
||||
}
|
||||
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
if (n.getTypeArgs() != null) {
|
||||
for (final Type t : n.getTypeArgs()) {
|
||||
if (n.getTypeArgs() != null)
|
||||
{
|
||||
for (final Type t : n.getTypeArgs())
|
||||
{
|
||||
t.accept(this, arg);
|
||||
}
|
||||
}
|
||||
m_typeRefKind.pop();
|
||||
|
||||
// n.getNameExpr().accept(this, arg);
|
||||
if (n.getArgs() != null) {
|
||||
for (final Expression e : n.getArgs()) {
|
||||
if (n.getArgs() != null)
|
||||
{
|
||||
for (final Expression e : n.getArgs())
|
||||
{
|
||||
e.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -711,26 +616,33 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(ObjectCreationExpr n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getScope() != null) {
|
||||
if (n.getScope() != null)
|
||||
{
|
||||
n.getScope().accept(this, arg);
|
||||
}
|
||||
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
if (n.getTypeArgs() != null) {
|
||||
for (final Type t : n.getTypeArgs()) {
|
||||
if (n.getTypeArgs() != null)
|
||||
{
|
||||
for (final Type t : n.getTypeArgs())
|
||||
{
|
||||
t.accept(this, arg);
|
||||
}
|
||||
}
|
||||
m_typeRefKind.pop();
|
||||
|
||||
n.getType().accept(this, arg);
|
||||
if (n.getArgs() != null) {
|
||||
for (final Expression e : n.getArgs()) {
|
||||
if (n.getArgs() != null)
|
||||
{
|
||||
for (final Expression e : n.getArgs())
|
||||
{
|
||||
e.accept(this, arg);
|
||||
}
|
||||
}
|
||||
if (n.getAnonymousClassBody() != null) {
|
||||
for (final BodyDeclaration member : n.getAnonymousClassBody()) {
|
||||
if (n.getAnonymousClassBody() != null)
|
||||
{
|
||||
for (final BodyDeclaration<?> member : n.getAnonymousClassBody())
|
||||
{
|
||||
member.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -745,7 +657,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(ThisExpr n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getClassExpr() != null) {
|
||||
if (n.getClassExpr() != null)
|
||||
{
|
||||
n.getClassExpr().accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -753,7 +666,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(SuperExpr n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getClassExpr() != null) {
|
||||
if (n.getClassExpr() != null)
|
||||
{
|
||||
n.getClassExpr().accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -767,13 +681,10 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(VariableDeclarationExpr n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getAnnotations() != null) {
|
||||
for (final AnnotationExpr a : n.getAnnotations()) {
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
visitAnnotations(n, arg);
|
||||
n.getType().accept(this, arg);
|
||||
for (final VariableDeclarator v : n.getVars()) {
|
||||
for (final VariableDeclarator v : n.getVars())
|
||||
{
|
||||
v.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -795,8 +706,10 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
n.getName().accept(this, arg);
|
||||
if (n.getPairs() != null) {
|
||||
for (final MemberValuePair m : n.getPairs()) {
|
||||
if (n.getPairs() != null)
|
||||
{
|
||||
for (final MemberValuePair m : n.getPairs())
|
||||
{
|
||||
m.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -813,20 +726,23 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(ExplicitConstructorInvocationStmt n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (!n.isThis() && n.getExpr() != null) {
|
||||
if (!n.isThis() && n.getExpr() != null)
|
||||
{
|
||||
n.getExpr().accept(this, arg);
|
||||
}
|
||||
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
if (n.getTypeArgs() != null) {
|
||||
for (final Type t : n.getTypeArgs()) {
|
||||
for (final Type t : n.getTypeArgs())
|
||||
{
|
||||
t.accept(this, arg);
|
||||
}
|
||||
}
|
||||
m_typeRefKind.pop();
|
||||
|
||||
if (n.getArgs() != null) {
|
||||
for (final Expression e : n.getArgs()) {
|
||||
for (final Expression e : n.getArgs())
|
||||
{
|
||||
e.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -842,7 +758,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
n.getCheck().accept(this, arg);
|
||||
if (n.getMessage() != null) {
|
||||
if (n.getMessage() != null)
|
||||
{
|
||||
n.getMessage().accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -850,8 +767,10 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(BlockStmt n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getStmts() != null) {
|
||||
for (final Statement s : n.getStmts()) {
|
||||
if (n.getStmts() != null)
|
||||
{
|
||||
for (final Statement s : n.getStmts())
|
||||
{
|
||||
s.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -878,8 +797,10 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
n.getSelector().accept(this, arg);
|
||||
if (n.getEntries() != null) {
|
||||
for (final SwitchEntryStmt e : n.getEntries()) {
|
||||
if (n.getEntries() != null)
|
||||
{
|
||||
for (final SwitchEntryStmt e : n.getEntries())
|
||||
{
|
||||
e.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -888,11 +809,14 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(SwitchEntryStmt n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getLabel() != null) {
|
||||
if (n.getLabel() != null)
|
||||
{
|
||||
n.getLabel().accept(this, arg);
|
||||
}
|
||||
if (n.getStmts() != null) {
|
||||
for (final Statement s : n.getStmts()) {
|
||||
if (n.getStmts() != null)
|
||||
{
|
||||
for (final Statement s : n.getStmts())
|
||||
{
|
||||
s.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -906,7 +830,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(ReturnStmt n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getExpr() != null) {
|
||||
if (n.getExpr() != null)
|
||||
{
|
||||
n.getExpr().accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -916,7 +841,8 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
visitComment(n.getComment(), arg);
|
||||
n.getCondition().accept(this, arg);
|
||||
n.getThenStmt().accept(this, arg);
|
||||
if (n.getElseStmt() != null) {
|
||||
if (n.getElseStmt() != null)
|
||||
{
|
||||
n.getElseStmt().accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -951,16 +877,21 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(ForStmt n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getInit() != null) {
|
||||
for (final Expression e : n.getInit()) {
|
||||
if (n.getInit() != null)
|
||||
{
|
||||
for (final Expression e : n.getInit())
|
||||
{
|
||||
e.accept(this, arg);
|
||||
}
|
||||
}
|
||||
if (n.getCompare() != null) {
|
||||
if (n.getCompare() != null)
|
||||
{
|
||||
n.getCompare().accept(this, arg);
|
||||
}
|
||||
if (n.getUpdate() != null) {
|
||||
for (final Expression e : n.getUpdate()) {
|
||||
if (n.getUpdate() != null)
|
||||
{
|
||||
for (final Expression e : n.getUpdate())
|
||||
{
|
||||
e.accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -983,18 +914,23 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
@Override public void visit(TryStmt n, Void arg)
|
||||
{
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getResources() != null) {
|
||||
for (final VariableDeclarationExpr v : n.getResources()) {
|
||||
if (n.getResources() != null)
|
||||
{
|
||||
for (final VariableDeclarationExpr v : n.getResources())
|
||||
{
|
||||
v.accept(this, arg);
|
||||
}
|
||||
}
|
||||
n.getTryBlock().accept(this, arg);
|
||||
if (n.getCatchs() != null) {
|
||||
for (final CatchClause c : n.getCatchs()) {
|
||||
if (n.getCatchs() != null)
|
||||
{
|
||||
for (final CatchClause c : n.getCatchs())
|
||||
{
|
||||
c.accept(this, arg);
|
||||
}
|
||||
}
|
||||
if (n.getFinallyBlock() != null) {
|
||||
if (n.getFinallyBlock() != null)
|
||||
{
|
||||
n.getFinallyBlock().accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -1008,31 +944,41 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
|
||||
@Override public void visit(LambdaExpr n, Void arg)
|
||||
{
|
||||
if (n.getParameters() != null) {
|
||||
for (final Parameter a : n.getParameters()) {
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getParameters() != null)
|
||||
{
|
||||
for (final Parameter a : n.getParameters())
|
||||
{
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
if (n.getBody() != null) {
|
||||
if (n.getBody() != null)
|
||||
{
|
||||
n.getBody().accept(this, arg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visit(MethodReferenceExpr n, Void arg)
|
||||
{
|
||||
if (n.getTypeParameters() != null) {
|
||||
for (final TypeParameter a : n.getTypeParameters()) {
|
||||
a.accept(this, arg);
|
||||
}
|
||||
}
|
||||
if (n.getScope() != null) {
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getTypeArguments().getTypeArguments() != null)
|
||||
{
|
||||
for (final Type t : n.getTypeArguments().getTypeArguments())
|
||||
{
|
||||
t.accept(this, arg);
|
||||
}
|
||||
}
|
||||
if (n.getScope() != null)
|
||||
{
|
||||
n.getScope().accept(this, arg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visit(TypeExpr n, Void arg)
|
||||
{
|
||||
if (n.getType() != null) {
|
||||
visitComment(n.getComment(), arg);
|
||||
if (n.getType() != null)
|
||||
{
|
||||
n.getType().accept(this, arg);
|
||||
}
|
||||
}
|
||||
@@ -1044,4 +990,26 @@ public abstract class JavaAstVisitorAdapter implements VoidVisitor<Void>
|
||||
n.accept(this, arg);
|
||||
}
|
||||
}
|
||||
|
||||
private void visitAnnotations(NodeWithAnnotations<?> n, final Void arg)
|
||||
{
|
||||
for (AnnotationExpr annotation : n.getAnnotations())
|
||||
{
|
||||
annotation.accept(this, arg);
|
||||
}
|
||||
}
|
||||
|
||||
private void visitArraysAnnotations(NodeWithArrays<?> n, final Void arg)
|
||||
{
|
||||
for (List<AnnotationExpr> aux : n.getArraysAnnotations())
|
||||
{
|
||||
if (aux != null)
|
||||
{
|
||||
for (AnnotationExpr annotation : aux)
|
||||
{
|
||||
annotation.accept(this, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.lang.String;
|
||||
import com.github.javaparser.ast.CompilationUnit;
|
||||
import com.github.javaparser.JavaParser;
|
||||
import com.github.javaparser.ParseException;
|
||||
import com.github.javaparser.ParseProblemException;
|
||||
import com.github.javaparser.Problem;
|
||||
import com.github.javaparser.Token;
|
||||
|
||||
import me.tomassetti.symbolsolver.javaparsermodel.JavaParserFacade;
|
||||
@@ -53,23 +55,38 @@ public class JavaIndexer
|
||||
// JavaAstVisitor astVisitor = new ASTDumper(address, filePath, new FileContent(fileContent), typeSolver);
|
||||
cu.accept(astVisitor, null);
|
||||
}
|
||||
catch (ParseException e)
|
||||
catch (ParseProblemException e)
|
||||
{
|
||||
if (e.expectedTokenSequences == null || e.expectedTokenSequences.length == 0)
|
||||
for (Problem problem: e.problems)
|
||||
{
|
||||
Token token = e.currentToken;
|
||||
recordError(
|
||||
address, e.getMessage(), true, true,
|
||||
token.beginLine, token.beginColumn, token.endLine, token.endColumn
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Token token = e.currentToken.next;
|
||||
recordError(
|
||||
address, "Encountered unexpected token.", true, true,
|
||||
token.beginLine, token.beginColumn, token.endLine, token.endColumn
|
||||
);
|
||||
if (problem.message.startsWith("Encountered unexpected token"))
|
||||
{
|
||||
|
||||
|
||||
int startLine = Integer.parseInt(problem.message.substring(
|
||||
problem.message.indexOf("line ") + ("line ").length(),
|
||||
problem.message.indexOf(",")
|
||||
));
|
||||
|
||||
int startColumn = Integer.parseInt(problem.message.substring(
|
||||
problem.message.indexOf("column ") + ("column ").length(),
|
||||
problem.message.indexOf(".")
|
||||
));
|
||||
|
||||
recordError(
|
||||
address, "Encountered unexpected token.", true, true,
|
||||
startLine, startColumn,
|
||||
startLine, startColumn
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
recordError(
|
||||
address, problem.toString(), true, true,
|
||||
problem.range.begin.line, problem.range.begin.column,
|
||||
problem.range.end.line, problem.range.end.column
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ public class JavaSymbolSolverTypeNameResolver extends JavaNameResolver
|
||||
}
|
||||
else if (typeUsage instanceof WildcardUsage)
|
||||
{
|
||||
// TODO: implement this one
|
||||
return new JavaTypeName("?", null);
|
||||
}
|
||||
|
||||
System.out.println("Unable to resolve qualified name of " + typeUsage.getClass().toString() + ": " + typeUsage.toString());
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -43,7 +43,7 @@ bool JavaProject::prepareIndexing()
|
||||
ResourcePaths::getJavaPath() + "guava-18.0.jar" + separator +
|
||||
ResourcePaths::getJavaPath() + "java-indexer.jar" + separator +
|
||||
ResourcePaths::getJavaPath() + "javaparser-core.jar" + separator +
|
||||
ResourcePaths::getJavaPath() + "javaslang-2.0.0-beta.jar" + separator +
|
||||
ResourcePaths::getJavaPath() + "javaslang-2.0.3.jar" + separator +
|
||||
ResourcePaths::getJavaPath() + "javassist-3.19.0-GA.jar" + separator +
|
||||
ResourcePaths::getJavaPath() + "java-symbol-solver-core.jar" + separator +
|
||||
ResourcePaths::getJavaPath() + "java-symbol-solver-logic.jar" + separator +
|
||||
|
||||
@@ -319,7 +319,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->errors.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->errors[0], "Encountered unexpected token. <1:1 1:7>");
|
||||
TS_ASSERT_EQUALS(client->errors[0], "Encountered unexpected token. <1:1 1:1>");
|
||||
}
|
||||
|
||||
//void _test_java_parser_finds_missing_import_as_error()
|
||||
@@ -1199,7 +1199,7 @@ private:
|
||||
"../app/data/java/guava-18.0.jar" + separator +
|
||||
"../app/data/java/java-indexer.jar" + separator +
|
||||
"../app/data/java/javaparser-core.jar" + separator +
|
||||
"../app/data/java/javaslang-2.0.0-beta.jar" + separator +
|
||||
"../app/data/java/javaslang-2.0.3.jar" + separator +
|
||||
"../app/data/java/javassist-3.19.0-GA.jar" + separator +
|
||||
"../app/data/java/java-symbol-solver-core.jar" + separator +
|
||||
"../app/data/java/java-symbol-solver-logic.jar" + separator +
|
||||
|
||||
Reference in New Issue
Block a user