Revert "logic: changed Java type_argument edges to originate in the generic type or method"
This commit is contained in:
@@ -41,7 +41,6 @@ import org.eclipse.jdt.core.dom.Name;
|
||||
import org.eclipse.jdt.core.dom.NameQualifiedType;
|
||||
import org.eclipse.jdt.core.dom.NormalAnnotation;
|
||||
import org.eclipse.jdt.core.dom.PackageDeclaration;
|
||||
import org.eclipse.jdt.core.dom.ParameterizedType;
|
||||
import org.eclipse.jdt.core.dom.PrimitiveType;
|
||||
import org.eclipse.jdt.core.dom.QualifiedName;
|
||||
import org.eclipse.jdt.core.dom.QualifiedType;
|
||||
@@ -54,7 +53,6 @@ import org.eclipse.jdt.core.dom.SuperMethodInvocation;
|
||||
import org.eclipse.jdt.core.dom.SuperMethodReference;
|
||||
import org.eclipse.jdt.core.dom.SwitchStatement;
|
||||
import org.eclipse.jdt.core.dom.ThisExpression;
|
||||
import org.eclipse.jdt.core.dom.Type;
|
||||
import org.eclipse.jdt.core.dom.TypeDeclaration;
|
||||
import org.eclipse.jdt.core.dom.TypeMethodReference;
|
||||
import org.eclipse.jdt.core.dom.TypeParameter;
|
||||
@@ -123,6 +121,7 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
DefinitionKind.EXPLICIT);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -297,6 +296,7 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
|
||||
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(node, m_filePath, m_compilationUnit);
|
||||
|
||||
|
||||
Range signatureRange = getRange(node);
|
||||
if (!node.thrownExceptionTypes().isEmpty())
|
||||
{
|
||||
@@ -652,32 +652,6 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(ParameterizedType node)
|
||||
{
|
||||
ITypeBinding binding = node.resolveBinding();
|
||||
if (binding != null)
|
||||
{
|
||||
binding = binding.getTypeDeclaration();
|
||||
}
|
||||
|
||||
for (Object o : node.typeArguments())
|
||||
{
|
||||
if (o instanceof Type)
|
||||
{
|
||||
Type type = (Type)o;
|
||||
ITypeBinding typeBinding = type.resolveBinding();
|
||||
m_client.recordReference(
|
||||
ReferenceKind.TYPE_ARGUMENT,
|
||||
BindingNameResolver.getQualifiedName(typeBinding, m_filePath, m_compilationUnit).orElse(TypeName.unsolved()).toDeclName().toNameHierarchy(),
|
||||
BindingNameResolver.getQualifiedName(binding, m_filePath, m_compilationUnit).orElse(TypeName.unsolved()).toDeclName().toNameHierarchy(),
|
||||
getRange(type));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(QualifiedName node)
|
||||
@@ -714,15 +688,7 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
@Override
|
||||
public boolean visit(MethodInvocation node)
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveMethodBinding();
|
||||
|
||||
recordReferenceToMethodDeclaration(
|
||||
methodBinding,
|
||||
getRange(node.getName()),
|
||||
ReferenceKind.CALL,
|
||||
m_contextStack.peek());
|
||||
|
||||
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
|
||||
recordReferenceToMethodDeclaration(node.resolveMethodBinding(), getRange(node.getName()), ReferenceKind.CALL, m_contextStack.peek());
|
||||
|
||||
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node, m_fileContent);
|
||||
|
||||
@@ -732,15 +698,7 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
@Override
|
||||
public boolean visit(SuperMethodInvocation node)
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveMethodBinding();
|
||||
|
||||
recordReferenceToMethodDeclaration(
|
||||
methodBinding,
|
||||
getRange(node.getName()),
|
||||
ReferenceKind.CALL,
|
||||
m_contextStack.peek());
|
||||
|
||||
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
|
||||
recordReferenceToMethodDeclaration(node.resolveMethodBinding(), getRange(node.getName()), ReferenceKind.CALL, m_contextStack.peek());
|
||||
|
||||
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node, m_fileContent);
|
||||
|
||||
@@ -750,47 +708,35 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
@Override
|
||||
public boolean visit(ConstructorInvocation node)
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveConstructorBinding();
|
||||
|
||||
recordReferenceToMethodDeclaration(
|
||||
methodBinding,
|
||||
node.resolveConstructorBinding(),
|
||||
m_fileContent.findRange("this", getRange(node).begin),
|
||||
ReferenceKind.CALL,
|
||||
m_contextStack.peek());
|
||||
|
||||
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SuperConstructorInvocation node)
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveConstructorBinding();
|
||||
|
||||
recordReferenceToMethodDeclaration(
|
||||
methodBinding,
|
||||
node.resolveConstructorBinding(),
|
||||
m_fileContent.findRange("super", getRange(node).begin),
|
||||
ReferenceKind.CALL,
|
||||
m_contextStack.peek());
|
||||
|
||||
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(CreationReference node)
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveMethodBinding();
|
||||
|
||||
recordReferenceToMethodDeclaration(
|
||||
methodBinding,
|
||||
node.resolveMethodBinding(),
|
||||
m_fileContent.findRange("new", getRange(node).begin),
|
||||
ReferenceKind.USAGE,
|
||||
m_contextStack.peek());
|
||||
|
||||
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
|
||||
|
||||
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node);
|
||||
|
||||
@@ -800,15 +746,11 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
@Override
|
||||
public boolean visit(ExpressionMethodReference node)
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveMethodBinding();
|
||||
|
||||
recordReferenceToMethodDeclaration(
|
||||
methodBinding,
|
||||
node.resolveMethodBinding(),
|
||||
getRange(node.getName()),
|
||||
ReferenceKind.USAGE,
|
||||
m_contextStack.peek());
|
||||
|
||||
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
|
||||
|
||||
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node, m_fileContent);
|
||||
|
||||
@@ -818,15 +760,11 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
@Override
|
||||
public boolean visit(SuperMethodReference node)
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveMethodBinding();
|
||||
|
||||
recordReferenceToMethodDeclaration(
|
||||
methodBinding,
|
||||
node.resolveMethodBinding(),
|
||||
getRange(node.getName()),
|
||||
ReferenceKind.USAGE,
|
||||
m_contextStack.peek());
|
||||
|
||||
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
|
||||
|
||||
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node, m_fileContent);
|
||||
|
||||
@@ -836,20 +774,18 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
@Override
|
||||
public boolean visit(TypeMethodReference node)
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveMethodBinding();
|
||||
if (methodBinding == null && node.getType() != null && node.getType().isArrayType())
|
||||
IMethodBinding binding = node.resolveMethodBinding();
|
||||
if (binding == null && node.getType() != null && node.getType().isArrayType())
|
||||
{
|
||||
// Do nothing. We ignore the case of unsolved symbols on array type
|
||||
}
|
||||
else
|
||||
{
|
||||
recordReferenceToMethodDeclaration(
|
||||
methodBinding,
|
||||
binding,
|
||||
getRange(node.getName()),
|
||||
ReferenceKind.USAGE,
|
||||
m_contextStack.peek());
|
||||
|
||||
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
|
||||
|
||||
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node);
|
||||
}
|
||||
@@ -904,8 +840,6 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
context.toNameHierarchy(),
|
||||
getRange(node.getType()));
|
||||
}
|
||||
|
||||
recordReferenceToTypeArguments(constructorBinding, node.typeArguments());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -992,32 +926,6 @@ public abstract class AstVisitor extends ASTVisitor
|
||||
}
|
||||
}
|
||||
|
||||
private void recordReferenceToTypeArguments(IMethodBinding methodBinding, List typeArguments)
|
||||
{
|
||||
if (!typeArguments.isEmpty())
|
||||
{
|
||||
if (methodBinding != null)
|
||||
{
|
||||
// replacing type arguments of invocation with type variables of declaration
|
||||
methodBinding = methodBinding.getMethodDeclaration();
|
||||
}
|
||||
|
||||
for (Object o : typeArguments)
|
||||
{
|
||||
if (o instanceof Type)
|
||||
{
|
||||
Type type = (Type)o;
|
||||
ITypeBinding typeBinding = type.resolveBinding();
|
||||
m_client.recordReference(
|
||||
ReferenceKind.TYPE_ARGUMENT,
|
||||
BindingNameResolver.getQualifiedName(typeBinding, m_filePath, m_compilationUnit).orElse(TypeName.unsolved()).toDeclName().toNameHierarchy(),
|
||||
BindingNameResolver.getQualifiedName(methodBinding, m_filePath, m_compilationUnit).orElse(DeclName.unsolved()).toNameHierarchy(),
|
||||
getRange(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void recordScope(Range range)
|
||||
{
|
||||
NameHierarchy nameHierarchy = DeclName.scope(m_filePath, range.begin).toNameHierarchy();
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.eclipse.jdt.core.dom.ConstructorInvocation;
|
||||
import org.eclipse.jdt.core.dom.CreationReference;
|
||||
import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
|
||||
import org.eclipse.jdt.core.dom.EnumDeclaration;
|
||||
import org.eclipse.jdt.core.dom.ExpressionMethodReference;
|
||||
import org.eclipse.jdt.core.dom.FieldDeclaration;
|
||||
import org.eclipse.jdt.core.dom.ImportDeclaration;
|
||||
import org.eclipse.jdt.core.dom.Javadoc;
|
||||
@@ -134,7 +133,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChild(node.getType());
|
||||
acceptChildren(node.typeArguments());
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -178,7 +181,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChild(node.getExpression());
|
||||
acceptChildren(node.typeArguments());
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
acceptChild(node.getName());
|
||||
acceptChildren(node.arguments());
|
||||
}
|
||||
@@ -194,7 +201,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChildren(node.typeArguments());
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
acceptChild(node.getName());
|
||||
acceptChildren(node.arguments());
|
||||
}
|
||||
@@ -209,7 +220,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChildren(node.typeArguments());
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
acceptChildren(node.arguments());
|
||||
}
|
||||
|
||||
@@ -224,7 +239,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChild(node.getExpression());
|
||||
acceptChildren(node.typeArguments());
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
acceptChildren(node.arguments());
|
||||
}
|
||||
|
||||
@@ -239,23 +258,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChildren(node.typeArguments());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(ExpressionMethodReference node)
|
||||
{
|
||||
// We don't want to visit qualifiers right now.
|
||||
boolean visitChildren = super.visit(node);
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChild(node.getExpression());
|
||||
acceptChildren(node.typeArguments());
|
||||
acceptChild(node.getName());
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -269,7 +276,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChildren(node.typeArguments());
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
acceptChild(node.getName());
|
||||
}
|
||||
|
||||
@@ -284,7 +295,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChildren(node.typeArguments());
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
acceptChild(node.getName());
|
||||
}
|
||||
|
||||
@@ -299,7 +314,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
if (visitChildren)
|
||||
{
|
||||
acceptChild(node.getExpression());
|
||||
acceptChildren(node.typeArguments());
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
if (node.getAnonymousClassDeclaration() != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user