src: Apply clang-format and extend use to Java code (#973)

This commit is contained in:
Louis St-Amour
2020-04-19 14:11:48 +02:00
committed by GitHub
parent a6e02cc249
commit 224c89182a
94 changed files with 1998 additions and 1773 deletions
+6 -2
View File
@@ -1,5 +1,3 @@
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
@@ -76,3 +74,9 @@ SpacesInSquareBrackets: false
Standard: c++17
TabWidth: 4
UseTab: Always
---
Language: Cpp
---
Language: Java
#BasedOnStyle: Google
#BreakAfterJavaFieldAnnotations: true
@@ -2,8 +2,7 @@ package com.sourcetrail;
import org.eclipse.jdt.core.dom.Modifier;
public enum AccessKind
{ // these values need to be the same as AccesKind in C++ code
public enum AccessKind { // these values need to be the same as AccesKind in C++ code
NONE(0),
PUBLIC(1),
PROTECTED(2),
@@ -26,11 +25,22 @@ public enum AccessKind
public static AccessKind fromModifiers(int modifiers)
{
if ((modifiers & Modifier.PUBLIC) != 0) { return AccessKind.PUBLIC; }
if ((modifiers & Modifier.PROTECTED) != 0) { return AccessKind.PROTECTED; }
if ((modifiers & Modifier.PRIVATE) != 0) { return AccessKind.PRIVATE; }
if ((modifiers & Modifier.DEFAULT) != 0) { return AccessKind.DEFAULT; }
if ((modifiers & Modifier.PUBLIC) != 0)
{
return AccessKind.PUBLIC;
}
if ((modifiers & Modifier.PROTECTED) != 0)
{
return AccessKind.PROTECTED;
}
if ((modifiers & Modifier.PRIVATE) != 0)
{
return AccessKind.PRIVATE;
}
if ((modifiers & Modifier.DEFAULT) != 0)
{
return AccessKind.DEFAULT;
}
return AccessKind.DEFAULT;
}
}
@@ -1,11 +1,19 @@
package com.sourcetrail;
import com.sourcetrail.name.DeclName;
import com.sourcetrail.name.FileName;
import com.sourcetrail.name.NameHierarchy;
import com.sourcetrail.name.SymbolName;
import com.sourcetrail.name.TypeName;
import com.sourcetrail.name.resolver.BindingNameResolver;
import com.sourcetrail.name.resolver.DeclNameResolver;
import java.io.File;
import java.lang.String;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Stack;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.Annotation;
@@ -60,17 +68,6 @@ import org.eclipse.jdt.core.dom.TypeMethodReference;
import org.eclipse.jdt.core.dom.TypeParameter;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import com.sourcetrail.name.DeclName;
import com.sourcetrail.name.FileName;
import com.sourcetrail.name.SymbolName;
import com.sourcetrail.name.TypeName;
import com.sourcetrail.name.NameHierarchy;
import com.sourcetrail.name.resolver.BindingNameResolver;
import com.sourcetrail.name.resolver.DeclNameResolver;
import java.util.ArrayList;
import java.util.Arrays;
public abstract class AstVisitor extends ASTVisitor
{
protected AstVisitorClient m_client = null;
@@ -79,7 +76,8 @@ public abstract class AstVisitor extends ASTVisitor
private CompilationUnit m_compilationUnit;
private Stack<List<SymbolName>> m_contextStack = new Stack<>();
public AstVisitor(AstVisitorClient client, File filePath, String fileContent, CompilationUnit compilationUnit)
public AstVisitor(
AstVisitorClient client, File filePath, String fileContent, CompilationUnit compilationUnit)
{
m_client = client;
m_filePath = filePath;
@@ -94,8 +92,7 @@ public abstract class AstVisitor extends ASTVisitor
// --- record declarations ---
@Override
public boolean visit(PackageDeclaration node)
@Override public boolean visit(PackageDeclaration node)
{
Name name = node.getName();
@@ -112,7 +109,8 @@ public abstract class AstVisitor extends ASTVisitor
AccessKind.NONE,
DefinitionKind.EXPLICIT);
// Here we just record the symbol types of qualifiers. The nodes and their location are visited and recorded because the "name" is a QualifiedName
// Here we just record the symbol types of qualifiers. The nodes and their location are
// visited and recorded because the "name" is a QualifiedName
while (name instanceof QualifiedName)
{
name = ((QualifiedName)name).getQualifier();
@@ -127,10 +125,10 @@ public abstract class AstVisitor extends ASTVisitor
}
@Override
public boolean visit(AnnotationTypeDeclaration node)
@Override public boolean visit(AnnotationTypeDeclaration node)
{
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(node, m_filePath, m_compilationUnit);
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(
node, m_filePath, m_compilationUnit);
Range scopeRange = getRange(node);
m_client.recordSymbolWithLocationAndScope(
@@ -149,17 +147,18 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public void endVisit(AnnotationTypeDeclaration node)
@Override public void endVisit(AnnotationTypeDeclaration node)
{
m_contextStack.pop();
}
@Override
public boolean visit(AnnotationTypeMemberDeclaration node)
@Override public boolean visit(AnnotationTypeMemberDeclaration node)
{
DeclName symbolName = BindingNameResolver.getQualifiedName(node.resolveBinding(), m_filePath, m_compilationUnit).orElse(DeclName.unsolved());
DeclName symbolName = BindingNameResolver
.getQualifiedName(
node.resolveBinding(), m_filePath, m_compilationUnit)
.orElse(DeclName.unsolved());
m_client.recordSymbolWithLocation(
symbolName.toNameHierarchy(),
@@ -173,17 +172,16 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public void endVisit(AnnotationTypeMemberDeclaration node)
@Override public void endVisit(AnnotationTypeMemberDeclaration node)
{
m_contextStack.pop();
}
@Override
public boolean visit(TypeDeclaration node)
@Override public boolean visit(TypeDeclaration node)
{
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(node, m_filePath, m_compilationUnit);
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(
node, m_filePath, m_compilationUnit);
Range scopeRange = getRange(node);
m_client.recordSymbolWithLocationAndScope(
@@ -202,17 +200,19 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public void endVisit(TypeDeclaration node)
@Override public void endVisit(TypeDeclaration node)
{
m_contextStack.pop();
}
@Override
public boolean visit(TypeParameter node)
@Override public boolean visit(TypeParameter node)
{
DeclName symbolName = BindingNameResolver.getQualifiedName(node.resolveBinding(), m_filePath, m_compilationUnit).map(tn -> tn.toDeclName()).orElse(DeclName.unsolved());
DeclName symbolName = BindingNameResolver
.getQualifiedName(
node.resolveBinding(), m_filePath, m_compilationUnit)
.map(tn -> tn.toDeclName())
.orElse(DeclName.unsolved());
m_client.recordSymbolWithLocation(
symbolName.toNameHierarchy(),
@@ -226,18 +226,16 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public void endVisit(TypeParameter node)
@Override public void endVisit(TypeParameter node)
{
m_contextStack.pop();
}
@Override
public boolean visit(EnumDeclaration node)
@Override public boolean visit(EnumDeclaration node)
{
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(node, m_filePath, m_compilationUnit);
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(
node, m_filePath, m_compilationUnit);
Range scopeRange = getRange(node);
m_client.recordSymbolWithLocationAndScope(
@@ -256,8 +254,7 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public void endVisit(EnumDeclaration node)
@Override public void endVisit(EnumDeclaration node)
{
m_contextStack.pop();
}
@@ -265,7 +262,8 @@ public abstract class AstVisitor extends ASTVisitor
public boolean visit(EnumConstantDeclaration node)
{
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(node, m_filePath, m_compilationUnit);
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(
node, m_filePath, m_compilationUnit);
m_client.recordSymbolWithLocation(
symbolName.toNameHierarchy(),
@@ -279,15 +277,13 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public void endVisit(EnumConstantDeclaration node)
@Override public void endVisit(EnumConstantDeclaration node)
{
m_contextStack.pop();
}
@Override
public boolean visit(MethodDeclaration node)
@Override public boolean visit(MethodDeclaration node)
{
if (m_client.getInterrupted())
{
@@ -295,12 +291,14 @@ public abstract class AstVisitor extends ASTVisitor
return false;
}
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(node, m_filePath, m_compilationUnit);
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(
node, m_filePath, m_compilationUnit);
Range signatureRange = getRange(node);
if (!node.thrownExceptionTypes().isEmpty())
{
Object lastExceptionType = node.thrownExceptionTypes().get(node.thrownExceptionTypes().size() - 1);
Object lastExceptionType = node.thrownExceptionTypes().get(
node.thrownExceptionTypes().size() - 1);
if (lastExceptionType instanceof ASTNode)
{
signatureRange.end = getRange((ASTNode)lastExceptionType).end;
@@ -336,13 +334,21 @@ public abstract class AstVisitor extends ASTVisitor
Optional<IMethodBinding> overriddenMethod = getOverriddenMethod(node.resolveBinding());
if (overriddenMethod.isPresent())
{
// We use the declaration to replace type arguments with the respective type parameters inside the signature.
// We use the declaration to replace type arguments with the respective type parameters
// inside the signature.
IMethodBinding overriddenMethodDeclaration = overriddenMethod.get().getMethodDeclaration();
DeclName overriddenMethodName = BindingNameResolver.getQualifiedName(overriddenMethodDeclaration, m_filePath, m_compilationUnit).orElse(DeclName.unsolved());
DeclName overriddenMethodName =
BindingNameResolver
.getQualifiedName(overriddenMethodDeclaration, m_filePath, m_compilationUnit)
.orElse(DeclName.unsolved());
if (!overriddenMethodName.getIsUnsolved())
{
m_client.recordSymbol(overriddenMethodName.toNameHierarchy(), SymbolKind.METHOD, AccessKind.NONE, DefinitionKind.NONE);
m_client.recordSymbol(
overriddenMethodName.toNameHierarchy(),
SymbolKind.METHOD,
AccessKind.NONE,
DefinitionKind.NONE);
}
m_client.recordReference(
@@ -357,15 +363,13 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public void endVisit(MethodDeclaration node)
@Override public void endVisit(MethodDeclaration node)
{
m_contextStack.pop();
}
@Override
public boolean visit(FieldDeclaration node)
@Override public boolean visit(FieldDeclaration node)
{
ArrayList<SymbolName> childContext = new ArrayList<>();
@@ -375,7 +379,8 @@ public abstract class AstVisitor extends ASTVisitor
{
VariableDeclarationFragment fragment = (VariableDeclarationFragment)declarator;
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(fragment, m_filePath, m_compilationUnit);
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(
fragment, m_filePath, m_compilationUnit);
m_client.recordSymbolWithLocation(
symbolName.toNameHierarchy(),
@@ -393,8 +398,7 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public void endVisit(FieldDeclaration node)
@Override public void endVisit(FieldDeclaration node)
{
m_contextStack.pop();
}
@@ -402,8 +406,7 @@ public abstract class AstVisitor extends ASTVisitor
// --- record references ---
@Override
public boolean visit(final ImportDeclaration node)
@Override public boolean visit(final ImportDeclaration node)
{
DeclName symbolName = DeclName.unsolved();
IBinding binding = node.resolveBinding();
@@ -411,19 +414,30 @@ public abstract class AstVisitor extends ASTVisitor
{
if (binding instanceof IPackageBinding)
{
symbolName = BindingNameResolver.getQualifiedName((IPackageBinding) binding, m_filePath, m_compilationUnit).orElse(DeclName.unsolved());
symbolName = BindingNameResolver
.getQualifiedName(
(IPackageBinding)binding, m_filePath, m_compilationUnit)
.orElse(DeclName.unsolved());
}
else if (binding instanceof ITypeBinding)
{
symbolName = BindingNameResolver.getQualifiedName((ITypeBinding) binding, m_filePath, m_compilationUnit).map(tn -> tn.toDeclName()).orElse(DeclName.unsolved());
symbolName = BindingNameResolver
.getQualifiedName(
(ITypeBinding)binding, m_filePath, m_compilationUnit)
.map(tn -> tn.toDeclName())
.orElse(DeclName.unsolved());
}
else if (binding instanceof IMethodBinding)
{
symbolName = BindingNameResolver.getQualifiedName((IMethodBinding) binding, m_filePath, m_compilationUnit).orElse(DeclName.unsolved());
symbolName = BindingNameResolver
.getQualifiedName(
(IMethodBinding)binding, m_filePath, m_compilationUnit)
.orElse(DeclName.unsolved());
}
else if (binding instanceof IVariableBinding)
{
symbolName = BindingNameResolver.getQualifiedName((IVariableBinding) binding, m_filePath, m_compilationUnit);
symbolName = BindingNameResolver.getQualifiedName(
(IVariableBinding)binding, m_filePath, m_compilationUnit);
}
}
@@ -436,19 +450,21 @@ public abstract class AstVisitor extends ASTVisitor
}
m_client.recordReference(
ReferenceKind.IMPORT,
symbolName.toNameHierarchy(), context.toNameHierarchy(),
range);
ReferenceKind.IMPORT, symbolName.toNameHierarchy(), context.toNameHierarchy(), range);
}
// record package symbol kind of current node if appliccable
if (binding instanceof IPackageBinding)
{
Optional<DeclName> packageName = BindingNameResolver.getQualifiedName((IPackageBinding)binding, m_filePath, m_compilationUnit);
Optional<DeclName> packageName = BindingNameResolver.getQualifiedName(
(IPackageBinding)binding, m_filePath, m_compilationUnit);
if (packageName.isPresent())
{
m_client.recordSymbol(packageName.get().toNameHierarchy(),
SymbolKind.PACKAGE, AccessKind.NONE, DefinitionKind.NONE);
m_client.recordSymbol(
packageName.get().toNameHierarchy(),
SymbolKind.PACKAGE,
AccessKind.NONE,
DefinitionKind.NONE);
}
}
@@ -457,14 +473,12 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(SingleMemberAnnotation node)
@Override public boolean visit(SingleMemberAnnotation node)
{
return recordAnnotation(node);
}
@Override
public boolean visit(NormalAnnotation node)
@Override public boolean visit(NormalAnnotation node)
{
for (Object value: node.values())
{
@@ -474,11 +488,18 @@ public abstract class AstVisitor extends ASTVisitor
IBinding binding = name.resolveBinding();
if (binding instanceof IMethodBinding)
{
DeclName symbolName = BindingNameResolver.getQualifiedName((IMethodBinding) binding, m_filePath, m_compilationUnit).orElse(DeclName.unsolved());
DeclName symbolName =
BindingNameResolver
.getQualifiedName((IMethodBinding)binding, m_filePath, m_compilationUnit)
.orElse(DeclName.unsolved());
for (SymbolName context: m_contextStack.peek())
{
m_client.recordReference(ReferenceKind.USAGE, symbolName.toNameHierarchy(), context.toNameHierarchy(), getRange(name));
m_client.recordReference(
ReferenceKind.USAGE,
symbolName.toNameHierarchy(),
context.toNameHierarchy(),
getRange(name));
}
}
}
@@ -487,8 +508,7 @@ public abstract class AstVisitor extends ASTVisitor
return recordAnnotation(node);
}
@Override
public boolean visit(MarkerAnnotation node)
@Override public boolean visit(MarkerAnnotation node)
{
return recordAnnotation(node);
}
@@ -512,7 +532,10 @@ public abstract class AstVisitor extends ASTVisitor
m_client.recordReference(
ReferenceKind.ANNOTATION_USAGE,
BindingNameResolver.getQualifiedName(typeBinding, m_filePath, m_compilationUnit).orElse(TypeName.unsolved()).toDeclName().toNameHierarchy(),
BindingNameResolver.getQualifiedName(typeBinding, m_filePath, m_compilationUnit)
.orElse(TypeName.unsolved())
.toDeclName()
.toNameHierarchy(),
context.toNameHierarchy(),
range);
}
@@ -521,8 +544,7 @@ public abstract class AstVisitor extends ASTVisitor
}
@Override
public boolean visit(SimpleType node)
@Override public boolean visit(SimpleType node)
{
for (SymbolName context: m_contextStack.peek())
{
@@ -540,7 +562,10 @@ public abstract class AstVisitor extends ASTVisitor
m_client.recordReference(
getTypeReferenceKind(),
BindingNameResolver.getQualifiedName(binding, m_filePath, m_compilationUnit).orElse(TypeName.unsolved()).toDeclName().toNameHierarchy(),
BindingNameResolver.getQualifiedName(binding, m_filePath, m_compilationUnit)
.orElse(TypeName.unsolved())
.toDeclName()
.toNameHierarchy(),
context.toNameHierarchy(),
range);
}
@@ -550,8 +575,7 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(QualifiedType node)
@Override public boolean visit(QualifiedType node)
{
for (SymbolName context: m_contextStack.peek())
{
@@ -563,7 +587,10 @@ public abstract class AstVisitor extends ASTVisitor
m_client.recordReference(
getTypeReferenceKind(),
BindingNameResolver.getQualifiedName(binding, m_filePath, m_compilationUnit).orElse(TypeName.unsolved()).toDeclName().toNameHierarchy(),
BindingNameResolver.getQualifiedName(binding, m_filePath, m_compilationUnit)
.orElse(TypeName.unsolved())
.toDeclName()
.toNameHierarchy(),
context.toNameHierarchy(),
getRange(node.getName()));
}
@@ -573,8 +600,7 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(NameQualifiedType node)
@Override public boolean visit(NameQualifiedType node)
{
for (SymbolName context: m_contextStack.peek())
{
@@ -586,7 +612,10 @@ public abstract class AstVisitor extends ASTVisitor
m_client.recordReference(
getTypeReferenceKind(),
BindingNameResolver.getQualifiedName(binding, m_filePath, m_compilationUnit).orElse(TypeName.unsolved()).toDeclName().toNameHierarchy(),
BindingNameResolver.getQualifiedName(binding, m_filePath, m_compilationUnit)
.orElse(TypeName.unsolved())
.toDeclName()
.toNameHierarchy(),
context.toNameHierarchy(),
getRange(node.getName()));
}
@@ -596,29 +625,25 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(final PrimitiveType node)
@Override public boolean visit(final PrimitiveType node)
{
NameHierarchy referencedName = TypeName.fromDotSeparatedString(node.getPrimitiveTypeCode().toString()).toDeclName().toNameHierarchy();
NameHierarchy referencedName =
TypeName.fromDotSeparatedString(node.getPrimitiveTypeCode().toString())
.toDeclName()
.toNameHierarchy();
m_client.recordSymbol(
referencedName, SymbolKind.BUILTIN_TYPE,
AccessKind.NONE,
DefinitionKind.EXPLICIT);
referencedName, SymbolKind.BUILTIN_TYPE, AccessKind.NONE, DefinitionKind.EXPLICIT);
for (SymbolName context: m_contextStack.peek())
{
m_client.recordReference(
getTypeReferenceKind(),
referencedName,
context.toNameHierarchy(),
getRange(node));
getTypeReferenceKind(), referencedName, context.toNameHierarchy(), getRange(node));
}
return true;
}
@Override
public boolean visit(SimpleName node)
@Override public boolean visit(SimpleName node)
{
IBinding binding = node.resolveBinding();
if (binding instanceof IVariableBinding)
@@ -627,18 +652,19 @@ public abstract class AstVisitor extends ASTVisitor
DeclName declName = BindingNameResolver.getQualifiedName(
variableBinding, m_filePath, m_compilationUnit);
if (declName.getIsUnsolved() && variableBinding.getDeclaringClass() == null && variableBinding.getName().equals("length"))
if (declName.getIsUnsolved() && variableBinding.getDeclaringClass() == null &&
variableBinding.getName().equals("length"))
{
// Do nothing. We ignore the case of unsolved symbols on array type
}
else if (declName.getIsLocal() || declName.getIsGlobal())
{
m_client.recordLocalSymbol(
declName.toNameHierarchy(), getRange(node));
m_client.recordLocalSymbol(declName.toNameHierarchy(), getRange(node));
}
else
{
m_client.recordSymbol(declName.toNameHierarchy(), SymbolKind.FIELD, AccessKind.NONE, DefinitionKind.NONE);
m_client.recordSymbol(
declName.toNameHierarchy(), SymbolKind.FIELD, AccessKind.NONE, DefinitionKind.NONE);
for (SymbolName context: m_contextStack.peek())
{
@@ -653,8 +679,7 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(ParameterizedType node)
@Override public boolean visit(ParameterizedType node)
{
ITypeBinding binding = node.resolveBinding();
if (binding != null)
@@ -670,8 +695,14 @@ public abstract class AstVisitor extends ASTVisitor
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(),
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));
}
}
@@ -679,76 +710,68 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(QualifiedName node)
@Override public boolean visit(QualifiedName node)
{
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node);
return true;
}
@Override
public boolean visit(FieldAccess node)
@Override public boolean visit(FieldAccess node)
{
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node, m_fileContent);
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false)
.recordQualifierOfNode(node, m_fileContent);
return true;
}
@Override
public boolean visit(SuperFieldAccess node)
@Override public boolean visit(SuperFieldAccess node)
{
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node, m_fileContent);
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false)
.recordQualifierOfNode(node, m_fileContent);
return true;
}
@Override
public boolean visit(ThisExpression node)
@Override public boolean visit(ThisExpression node)
{
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node, m_fileContent);
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false)
.recordQualifierOfNode(node, m_fileContent);
return true;
}
@Override
public boolean visit(MethodInvocation node)
@Override public boolean visit(MethodInvocation node)
{
IMethodBinding methodBinding = node.resolveMethodBinding();
recordReferenceToMethodDeclaration(
methodBinding,
getRange(node.getName()),
ReferenceKind.CALL,
m_contextStack.peek());
methodBinding, getRange(node.getName()), ReferenceKind.CALL, m_contextStack.peek());
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node, m_fileContent);
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false)
.recordQualifierOfNode(node, m_fileContent);
return true;
}
@Override
public boolean visit(SuperMethodInvocation node)
@Override public boolean visit(SuperMethodInvocation node)
{
IMethodBinding methodBinding = node.resolveMethodBinding();
recordReferenceToMethodDeclaration(
methodBinding,
getRange(node.getName()),
ReferenceKind.CALL,
m_contextStack.peek());
methodBinding, getRange(node.getName()), ReferenceKind.CALL, m_contextStack.peek());
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node, m_fileContent);
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false)
.recordQualifierOfNode(node, m_fileContent);
return true;
}
@Override
public boolean visit(ConstructorInvocation node)
@Override public boolean visit(ConstructorInvocation node)
{
IMethodBinding methodBinding = node.resolveConstructorBinding();
@@ -763,8 +786,7 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(SuperConstructorInvocation node)
@Override public boolean visit(SuperConstructorInvocation node)
{
IMethodBinding methodBinding = node.resolveConstructorBinding();
@@ -779,8 +801,7 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(CreationReference node)
@Override public boolean visit(CreationReference node)
{
IMethodBinding methodBinding = node.resolveMethodBinding();
@@ -797,44 +818,37 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(ExpressionMethodReference node)
@Override public boolean visit(ExpressionMethodReference node)
{
IMethodBinding methodBinding = node.resolveMethodBinding();
recordReferenceToMethodDeclaration(
methodBinding,
getRange(node.getName()),
ReferenceKind.USAGE,
m_contextStack.peek());
methodBinding, 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);
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false)
.recordQualifierOfNode(node, m_fileContent);
return true;
}
@Override
public boolean visit(SuperMethodReference node)
@Override public boolean visit(SuperMethodReference node)
{
IMethodBinding methodBinding = node.resolveMethodBinding();
recordReferenceToMethodDeclaration(
methodBinding,
getRange(node.getName()),
ReferenceKind.USAGE,
m_contextStack.peek());
methodBinding, 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);
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false)
.recordQualifierOfNode(node, m_fileContent);
return true;
}
@Override
public boolean visit(TypeMethodReference node)
@Override public boolean visit(TypeMethodReference node)
{
IMethodBinding methodBinding = node.resolveMethodBinding();
if (methodBinding == null && node.getType() != null && node.getType().isArrayType())
@@ -844,29 +858,27 @@ public abstract class AstVisitor extends ASTVisitor
else
{
recordReferenceToMethodDeclaration(
methodBinding,
getRange(node.getName()),
ReferenceKind.USAGE,
m_contextStack.peek());
methodBinding, getRange(node.getName()), ReferenceKind.USAGE, m_contextStack.peek());
recordReferenceToTypeArguments(methodBinding, node.typeArguments());
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false).recordQualifierOfNode(node);
new QualifierVisitor(m_client, m_filePath, m_compilationUnit, false)
.recordQualifierOfNode(node);
}
return true;
}
@Override
public boolean visit(ClassInstanceCreation node)
@Override public boolean visit(ClassInstanceCreation node)
{
if (node.getAnonymousClassDeclaration() != null)
{
// record anonymous class here instead of overriding visit(AnonymousClassDeclaration node) because
// the ClassInstanceCreation still contains the Type node.
// record anonymous class here instead of overriding visit(AnonymousClassDeclaration
// node) because the ClassInstanceCreation still contains the Type node.
AnonymousClassDeclaration anonymousClassDeclaration = node.getAnonymousClassDeclaration();
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(anonymousClassDeclaration, m_filePath, m_compilationUnit);
DeclName symbolName = DeclNameResolver.getQualifiedDeclName(
anonymousClassDeclaration, m_filePath, m_compilationUnit);
Range anonymousClassScope = getRange(anonymousClassDeclaration);
@@ -890,10 +902,17 @@ public abstract class AstVisitor extends ASTVisitor
constructorBinding = constructorBinding.getMethodDeclaration();
}
DeclName referencedDeclName = BindingNameResolver.getQualifiedName(constructorBinding, m_filePath, m_compilationUnit).orElse(DeclName.unsolved());
DeclName referencedDeclName = BindingNameResolver
.getQualifiedName(
constructorBinding, m_filePath, m_compilationUnit)
.orElse(DeclName.unsolved());
if (!referencedDeclName.getIsUnsolved())
{
m_client.recordSymbol(referencedDeclName.toNameHierarchy(), SymbolKind.METHOD, AccessKind.NONE, DefinitionKind.NONE);
m_client.recordSymbol(
referencedDeclName.toNameHierarchy(),
SymbolKind.METHOD,
AccessKind.NONE,
DefinitionKind.NONE);
}
for (SymbolName context: m_contextStack.peek())
@@ -911,8 +930,7 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public void endVisit(ClassInstanceCreation node)
@Override public void endVisit(ClassInstanceCreation node)
{
if (node.getAnonymousClassDeclaration() != null)
{
@@ -920,22 +938,19 @@ public abstract class AstVisitor extends ASTVisitor
}
}
@Override
public boolean visit(Block node)
@Override public boolean visit(Block node)
{
recordScope(getRange(node));
return true;
}
@Override
public boolean visit(ArrayInitializer node)
@Override public boolean visit(ArrayInitializer node)
{
recordScope(getRange(node));
return true;
}
@Override
public boolean visit(SwitchStatement node)
@Override public boolean visit(SwitchStatement node)
{
Range scopeRange = getRange(node);
scopeRange.begin = m_fileContent.findStartPosition("{", scopeRange.begin);
@@ -944,22 +959,19 @@ public abstract class AstVisitor extends ASTVisitor
return true;
}
@Override
public boolean visit(LineComment node)
@Override public boolean visit(LineComment node)
{
m_client.recordComment(getRange(node));
return true;
}
@Override
public boolean visit(BlockComment node)
@Override public boolean visit(BlockComment node)
{
m_client.recordComment(getRange(node));
return true;
}
@Override
public boolean visit(Javadoc node)
@Override public boolean visit(Javadoc node)
{
m_client.recordComment(getRange(node));
return true;
@@ -968,7 +980,8 @@ public abstract class AstVisitor extends ASTVisitor
// --- utility methods ---
private void recordReferenceToMethodDeclaration(IMethodBinding methodBinding, Range range, ReferenceKind referenceKind, List<SymbolName> contexts)
private void recordReferenceToMethodDeclaration(
IMethodBinding methodBinding, Range range, ReferenceKind referenceKind, List<SymbolName> contexts)
{
if (methodBinding != null)
{
@@ -976,19 +989,22 @@ public abstract class AstVisitor extends ASTVisitor
methodBinding = methodBinding.getMethodDeclaration();
}
DeclName referencedDeclName = BindingNameResolver.getQualifiedName(methodBinding, m_filePath, m_compilationUnit).orElse(DeclName.unsolved());
DeclName referencedDeclName =
BindingNameResolver.getQualifiedName(methodBinding, m_filePath, m_compilationUnit)
.orElse(DeclName.unsolved());
if (!referencedDeclName.getIsUnsolved())
{
m_client.recordSymbol(referencedDeclName.toNameHierarchy(), SymbolKind.METHOD, AccessKind.NONE, DefinitionKind.NONE);
m_client.recordSymbol(
referencedDeclName.toNameHierarchy(),
SymbolKind.METHOD,
AccessKind.NONE,
DefinitionKind.NONE);
}
for (SymbolName context: m_contextStack.peek())
{
m_client.recordReference(
referenceKind,
referencedDeclName.toNameHierarchy(),
context.toNameHierarchy(),
range);
referenceKind, referencedDeclName.toNameHierarchy(), context.toNameHierarchy(), range);
}
}
@@ -1010,8 +1026,15 @@ public abstract class AstVisitor extends ASTVisitor
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(),
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));
}
}
@@ -1050,7 +1073,8 @@ public abstract class AstVisitor extends ASTVisitor
{
for (ITypeBinding declaringClassAncestor: getAllAncestorTypes(method.getDeclaringClass()))
{
for (IMethodBinding potentiallyOverridden: declaringClassAncestor.getDeclaredMethods())
for (IMethodBinding potentiallyOverridden:
declaringClassAncestor.getDeclaredMethods())
{
if (method.overrides(potentiallyOverridden))
{
@@ -13,44 +13,46 @@ public abstract class AstVisitorClient
public abstract void logError(String error);
public abstract void recordSymbol(
NameHierarchy symbolName, SymbolKind symbolKind,
AccessKind access, DefinitionKind definitionKind);
NameHierarchy symbolName,
SymbolKind symbolKind,
AccessKind access,
DefinitionKind definitionKind);
public abstract void recordSymbolWithLocation(
NameHierarchy symbolName, SymbolKind symbolKind,
NameHierarchy symbolName,
SymbolKind symbolKind,
Range range,
AccessKind access, DefinitionKind definitionKind);
AccessKind access,
DefinitionKind definitionKind);
public abstract void recordSymbolWithLocationAndScope(
NameHierarchy symbolName, SymbolKind symbolKind,
NameHierarchy symbolName,
SymbolKind symbolKind,
Range range,
Range scopeRange,
AccessKind access, DefinitionKind definitionKind);
AccessKind access,
DefinitionKind definitionKind);
public abstract void recordSymbolWithLocationAndScopeAndSignature(
NameHierarchy symbolName, SymbolKind symbolKind,
NameHierarchy symbolName,
SymbolKind symbolKind,
Range range,
Range scopeRange,
Range signatureRange,
AccessKind access, DefinitionKind definitionKind);
AccessKind access,
DefinitionKind definitionKind);
public abstract void recordReference(
ReferenceKind referenceKind, NameHierarchy referencedName, NameHierarchy contextName,
ReferenceKind referenceKind,
NameHierarchy referencedName,
NameHierarchy contextName,
Range range);
public abstract void recordQualifierLocation(
NameHierarchy qualifierName,
Range range);
public abstract void recordQualifierLocation(NameHierarchy qualifierName, Range range);
public abstract void recordLocalSymbol(
NameHierarchy symbolName,
Range range);
public abstract void recordLocalSymbol(NameHierarchy symbolName, Range range);
public abstract void recordComment(
Range range);
public abstract void recordComment(Range range);
public abstract void recordError(
String message, boolean fatal, boolean indexed,
Range range);
public abstract void recordError(String message, boolean fatal, boolean indexed, Range range);
}
@@ -3,7 +3,6 @@ package com.sourcetrail;
import java.io.File;
import java.util.List;
import java.util.Stack;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -30,13 +29,13 @@ public class ContextAwareAstVisitor extends AstVisitor
{
private Stack<ReferenceKind> m_typeRefKind = new Stack<>();
public ContextAwareAstVisitor(AstVisitorClient client, File filePath, String fileContent, CompilationUnit compilationUnit)
public ContextAwareAstVisitor(
AstVisitorClient client, File filePath, String fileContent, CompilationUnit compilationUnit)
{
super(client, filePath, fileContent, compilationUnit);
}
@Override
public boolean visit(TypeDeclaration node)
@Override public boolean visit(TypeDeclaration node)
{
boolean visitChildren = super.visit(node);
@@ -60,8 +59,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(EnumDeclaration node)
@Override public boolean visit(EnumDeclaration node)
{
boolean visitChildren = super.visit(node);
@@ -84,8 +82,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(EnumConstantDeclaration node)
@Override public boolean visit(EnumConstantDeclaration node)
{
boolean visitChildren = super.visit(node);
@@ -104,8 +101,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(VariableDeclarationFragment node)
@Override public boolean visit(VariableDeclarationFragment node)
{
boolean visitChildren = super.visit(node);
@@ -126,16 +122,15 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(final ImportDeclaration node)
@Override public boolean visit(final ImportDeclaration node)
{
// We don't want to visit the name of the ImportDeclaration because this could cause a self reference.
// We don't want to visit the name of the ImportDeclaration because this could cause a self
// reference.
super.visit(node);
return false;
}
@Override
public boolean visit(ParameterizedType node)
@Override public boolean visit(ParameterizedType node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
@@ -151,8 +146,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(QualifiedType node)
@Override public boolean visit(QualifiedType node)
{
// We don't want to visit the qualifier right now.
boolean visitChildren = super.visit(node);
@@ -168,8 +162,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(NameQualifiedType node)
@Override public boolean visit(NameQualifiedType node)
{
// We don't want to visit the qualifier right now.
boolean visitChildren = super.visit(node);
@@ -185,8 +178,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(MethodInvocation node)
@Override public boolean visit(MethodInvocation node)
{
boolean visitChildren = super.visit(node);
@@ -203,8 +195,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(SuperMethodInvocation node)
@Override public boolean visit(SuperMethodInvocation node)
{
// We don't want to visit the qualifier right now.
boolean visitChildren = super.visit(node);
@@ -221,8 +212,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(ConstructorInvocation node)
@Override public boolean visit(ConstructorInvocation node)
{
boolean visitChildren = super.visit(node);
@@ -237,8 +227,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(SuperConstructorInvocation node)
@Override public boolean visit(SuperConstructorInvocation node)
{
boolean visitChildren = super.visit(node);
@@ -254,8 +243,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(CreationReference node)
@Override public boolean visit(CreationReference node)
{
// We don't want to visit the qualifying type right now.
boolean visitChildren = super.visit(node);
@@ -270,8 +258,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(ExpressionMethodReference node)
@Override public boolean visit(ExpressionMethodReference node)
{
// We don't want to visit qualifiers right now.
boolean visitChildren = super.visit(node);
@@ -288,8 +275,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(SuperMethodReference node)
@Override public boolean visit(SuperMethodReference node)
{
// We don't want to visit qualifiers right now.
boolean visitChildren = super.visit(node);
@@ -305,8 +291,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(TypeMethodReference node)
@Override public boolean visit(TypeMethodReference node)
{
// We don't want to visit the qualifying type right now.
boolean visitChildren = super.visit(node);
@@ -322,8 +307,7 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(ClassInstanceCreation node)
@Override public boolean visit(ClassInstanceCreation node)
{
boolean visitChildren = super.visit(node);
@@ -352,16 +336,14 @@ public class ContextAwareAstVisitor extends AstVisitor
return false;
}
@Override
public boolean visit(Javadoc node)
@Override public boolean visit(Javadoc node)
{
// We don't want to visit symbol references inside Javadoc right now.
super.visit(node);
return false;
}
@Override
protected ReferenceKind getTypeReferenceKind()
@Override protected ReferenceKind getTypeReferenceKind()
{
if (!m_typeRefKind.isEmpty())
{
@@ -392,4 +374,3 @@ public class ContextAwareAstVisitor extends AstVisitor
}
}
}
@@ -2,7 +2,6 @@ package com.sourcetrail;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.jdt.core.dom.IBinding;
public class ContextList
@@ -1,7 +1,6 @@
package com.sourcetrail;
public enum DefinitionKind
{ // these values need to be the same as DefinitionKind in C++ code
public enum DefinitionKind { // these values need to be the same as DefinitionKind in C++ code
NONE(0),
IMPLICIT(1),
EXPLICIT(2);
@@ -45,7 +45,6 @@ public class FileContent
Position startPosition = findStartPosition(s, from);
return new Range(
startPosition,
new Position(startPosition.line, startPosition.column + s.length() - 1));
startPosition, new Position(startPosition.line, startPosition.column + s.length() - 1));
}
}
@@ -14,7 +14,6 @@ import java.util.Hashtable;
import java.util.List;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
@@ -28,12 +27,30 @@ import org.eclipse.jdt.core.dom.PackageDeclaration;
public class JavaIndexer
{
public static void processFile(int address, String filePath, String fileContent, String languageStandard, String classPath, int verbose)
public static void processFile(
int address,
String filePath,
String fileContent,
String languageStandard,
String classPath,
int verbose)
{
processFile(new JavaIndexerAstVisitorClient(address), filePath, fileContent, languageStandard, classPath, verbose);
processFile(
new JavaIndexerAstVisitorClient(address),
filePath,
fileContent,
languageStandard,
classPath,
verbose);
}
public static void processFile(AstVisitorClient astVisitorClient, String filePath, String fileContent, String languageStandard, String classPath, int verbose)
public static void processFile(
AstVisitorClient astVisitorClient,
String filePath,
String fileContent,
String languageStandard,
String classPath,
int verbose)
{
try
{
@@ -43,9 +60,12 @@ public class JavaIndexer
ASTParser parser = ASTParser.newParser(AST.JLS12);
parser.setResolveBindings(true); // solve "bindings" like the declaration of the type used in a var decl
parser.setKind(ASTParser.K_COMPILATION_UNIT); // specify to parse the entire compilation unit
parser.setBindingsRecovery(true); // also return bindings that are not resolved completely
parser.setResolveBindings(
true); // solve "bindings" like the declaration of the type used in a var decl
parser.setKind(
ASTParser.K_COMPILATION_UNIT); // specify to parse the entire compilation unit
parser.setBindingsRecovery(
true); // also return bindings that are not resolved completely
parser.setStatementsRecovery(true);
{
@@ -74,7 +94,8 @@ public class JavaIndexer
}
else if (classPathEntry.endsWith(".aar"))
{
File extractedJarFile = extractClassesJarFileFromAarFile(Paths.get(classPathEntry), astVisitorClient);
File extractedJarFile = extractClassesJarFileFromAarFile(
Paths.get(classPathEntry), astVisitorClient);
if (extractedJarFile != null)
{
classpath.add(extractedJarFile.getAbsolutePath());
@@ -86,7 +107,8 @@ public class JavaIndexer
}
}
parser.setEnvironment(classpath.toArray(new String[0]), sources.toArray(new String[0]), null, true);
parser.setEnvironment(
classpath.toArray(new String[0]), sources.toArray(new String[0]), null, true);
parser.setSource(fileContent.toCharArray());
CompilationUnit cu = (CompilationUnit)parser.createAST(null);
@@ -94,11 +116,13 @@ public class JavaIndexer
ASTVisitor visitor;
if (verbose != 0)
{
visitor = new VerboseContextAwareAstVisitor(astVisitorClient, path.toFile(), fileContent, cu);
visitor = new VerboseContextAwareAstVisitor(
astVisitorClient, path.toFile(), fileContent, cu);
}
else
{
visitor = new ContextAwareAstVisitor(astVisitorClient, path.toFile(), fileContent, cu);
visitor = new ContextAwareAstVisitor(
astVisitorClient, path.toFile(), fileContent, cu);
}
astVisitorClient.logInfo("starting AST traversal");
@@ -141,7 +165,8 @@ public class JavaIndexer
String packageName = "";
ASTParser parser = ASTParser.newParser(AST.JLS12);
parser.setKind(ASTParser.K_COMPILATION_UNIT); // specify to parse the entire compilation unit
parser.setKind(
ASTParser.K_COMPILATION_UNIT); // specify to parse the entire compilation unit
parser.setSource(fileContent.toCharArray());
CompilationUnit cu = (CompilationUnit)parser.createAST(null);
PackageDeclaration packageDeclaration = cu.getPackage();
@@ -189,14 +214,16 @@ public class JavaIndexer
}
}
private static File extractClassesJarFileFromAarFile(Path aarFilePath, AstVisitorClient astVisitorClient) throws IOException
private static File extractClassesJarFileFromAarFile(
Path aarFilePath, AstVisitorClient astVisitorClient) throws IOException
{
JarFile jarFile = new JarFile(aarFilePath.toString());
ZipEntry classesJarEntry = jarFile.getEntry("classes.jar");
if (classesJarEntry != null)
{
InputStream inputStream = jarFile.getInputStream(classesJarEntry);
File tempFile = File.createTempFile("jar_file_from_" + Utility.getFilenameWithoutExtension(aarFilePath) + "_", ".jar");
File tempFile = File.createTempFile(
"jar_file_from_" + Utility.getFilenameWithoutExtension(aarFilePath) + "_", ".jar");
tempFile.deleteOnExit();
byte[] buffer = new byte[8 * 1024];
@@ -223,14 +250,17 @@ public class JavaIndexer
}
astVisitorClient.logInfo(
"Extracted classes.jar file from \"" + aarFilePath.toString() + "\" to \"" + tempFile.getAbsolutePath() + "\". " +
"This file will be automatically deleted when the session ends.");
"Extracted classes.jar file from \"" + aarFilePath.toString() + "\" to \"" +
tempFile.getAbsolutePath() + "\". "
+ "This file will be automatically deleted when the session ends.");
return tempFile;
}
else
{
astVisitorClient.logError("Classpath entry \"" + aarFilePath + "\" is malformed. No internal \"classes.jar\" entry could be found.");
astVisitorClient.logError(
"Classpath entry \"" + aarFilePath +
"\" is malformed. No internal \"classes.jar\" entry could be found.");
}
jarFile.close();
@@ -248,31 +278,62 @@ public class JavaIndexer
static public native void logError(int address, String error);
static public native void recordSymbol(
int address, String symbolName, int symbolType,
int access, int definitionKind);
int address, String symbolName, int symbolType, int access, int definitionKind);
static public native void recordSymbolWithLocation(
int address, String symbolName, int symbolType,
int beginLine, int beginColumn, int endLine, int endColumn,
int access, int definitionKind);
int address,
String symbolName,
int symbolType,
int beginLine,
int beginColumn,
int endLine,
int endColumn,
int access,
int definitionKind);
static public native void recordSymbolWithLocationAndScope(
int address, String symbolName, int symbolType,
int beginLine, int beginColumn, int endLine, int endColumn,
int scopeBeginLine, int scopeBeginColumn, int scopeEndLine, int scopeEndColumn,
int access, int definitionKind
);
int address,
String symbolName,
int symbolType,
int beginLine,
int beginColumn,
int endLine,
int endColumn,
int scopeBeginLine,
int scopeBeginColumn,
int scopeEndLine,
int scopeEndColumn,
int access,
int definitionKind);
static public native void recordSymbolWithLocationAndScopeAndSignature(
int address, String symbolName, int symbolType,
int beginLine, int beginColumn, int endLine, int endColumn,
int scopeBeginLine, int scopeBeginColumn, int scopeEndLine, int scopeEndColumn,
int signatureBeginLine, int signatureBeginColumn, int signatureEndLine, int signatureEndColumn,
int access, int definitionKind
);
int address,
String symbolName,
int symbolType,
int beginLine,
int beginColumn,
int endLine,
int endColumn,
int scopeBeginLine,
int scopeBeginColumn,
int scopeEndLine,
int scopeEndColumn,
int signatureBeginLine,
int signatureBeginColumn,
int signatureEndLine,
int signatureEndColumn,
int access,
int definitionKind);
static public native void recordReference(
int address, int referenceKind, String referencedName, String contextName, int beginLine, int beginColumn, int endLine, int endColumn);
int address,
int referenceKind,
String referencedName,
String contextName,
int beginLine,
int beginColumn,
int endLine,
int endColumn);
static public native void recordQualifierLocation(
int address, String qualifierName, int beginLine, int beginColumn, int endLine, int endColumn);
@@ -284,5 +345,12 @@ public class JavaIndexer
int address, int beginLine, int beginColumn, int endLine, int endColumn);
static public native void recordError(
int address, String message, int fatal, int indexed, int beginLine, int beginColumn, int endLine, int endColumn);
int address,
String message,
int fatal,
int indexed,
int beginLine,
int beginColumn,
int endLine,
int endColumn);
}
@@ -20,127 +20,179 @@ public class JavaIndexerAstVisitorClient extends AstVisitorClient
m_javaLangPackageRecorded = false;
}
@Override
public boolean getInterrupted()
@Override public boolean getInterrupted()
{
return JavaIndexer.getInterrupted(m_address);
}
@Override
public void logInfo(String info)
@Override public void logInfo(String info)
{
JavaIndexer.logInfo(m_address, info);
}
@Override
public void logWarning(String warning)
@Override public void logWarning(String warning)
{
JavaIndexer.logWarning(m_address, warning);
}
@Override
public void logError(String error)
@Override public void logError(String error)
{
JavaIndexer.logError(m_address, error);
}
@Override
public void recordSymbol(
NameHierarchy symbolName, SymbolKind symbolKind,
AccessKind access, DefinitionKind definitionKind)
NameHierarchy symbolName, SymbolKind symbolKind, AccessKind access, DefinitionKind definitionKind)
{
JavaIndexer.recordSymbol(
m_address, symbolName.serialize(), symbolKind.getValue(),
access.getValue(), definitionKind.getValue());
m_address,
symbolName.serialize(),
symbolKind.getValue(),
access.getValue(),
definitionKind.getValue());
}
@Override
public void recordSymbolWithLocation(
NameHierarchy symbolName, SymbolKind symbolKind, Range range,
AccessKind access, DefinitionKind definitionKind)
NameHierarchy symbolName,
SymbolKind symbolKind,
Range range,
AccessKind access,
DefinitionKind definitionKind)
{
JavaIndexer.recordSymbolWithLocation(
m_address, symbolName.serialize(), symbolKind.getValue(),
range.begin.line, range.begin.column, range.end.line, range.end.column,
access.getValue(), definitionKind.getValue());
m_address,
symbolName.serialize(),
symbolKind.getValue(),
range.begin.line,
range.begin.column,
range.end.line,
range.end.column,
access.getValue(),
definitionKind.getValue());
}
@Override
public void recordSymbolWithLocationAndScope(
NameHierarchy symbolName, SymbolKind symbolKind, Range range,
Range scopeRange, AccessKind access, DefinitionKind definitionKind)
NameHierarchy symbolName,
SymbolKind symbolKind,
Range range,
Range scopeRange,
AccessKind access,
DefinitionKind definitionKind)
{
JavaIndexer.recordSymbolWithLocationAndScope(
m_address, symbolName.serialize(), symbolKind.getValue(),
range.begin.line, range.begin.column, range.end.line, range.end.column,
scopeRange.begin.line, scopeRange.begin.column, scopeRange.end.line, scopeRange.end.column,
access.getValue(), definitionKind.getValue());
m_address,
symbolName.serialize(),
symbolKind.getValue(),
range.begin.line,
range.begin.column,
range.end.line,
range.end.column,
scopeRange.begin.line,
scopeRange.begin.column,
scopeRange.end.line,
scopeRange.end.column,
access.getValue(),
definitionKind.getValue());
}
@Override
public void recordSymbolWithLocationAndScopeAndSignature(
NameHierarchy symbolName, SymbolKind symbolKind, Range range,
Range scopeRange, Range signatureRange, AccessKind access, DefinitionKind definitionKind)
NameHierarchy symbolName,
SymbolKind symbolKind,
Range range,
Range scopeRange,
Range signatureRange,
AccessKind access,
DefinitionKind definitionKind)
{
JavaIndexer.recordSymbolWithLocationAndScopeAndSignature(
m_address, symbolName.serialize(), symbolKind.getValue(),
range.begin.line, range.begin.column, range.end.line, range.end.column,
scopeRange.begin.line, scopeRange.begin.column, scopeRange.end.line, scopeRange.end.column,
signatureRange.begin.line, signatureRange.begin.column, signatureRange.end.line, signatureRange.end.column,
access.getValue(), definitionKind.getValue());
m_address,
symbolName.serialize(),
symbolKind.getValue(),
range.begin.line,
range.begin.column,
range.end.line,
range.end.column,
scopeRange.begin.line,
scopeRange.begin.column,
scopeRange.end.line,
scopeRange.end.column,
signatureRange.begin.line,
signatureRange.begin.column,
signatureRange.end.line,
signatureRange.end.column,
access.getValue(),
definitionKind.getValue());
}
@Override
public void recordReference(
ReferenceKind referenceKind, NameHierarchy referencedName,
NameHierarchy contextName, Range range)
ReferenceKind referenceKind, NameHierarchy referencedName, NameHierarchy contextName, Range range)
{
String serializedReferencedName = referencedName.serialize();
if (!m_javaLangPackageRecorded && serializedReferencedName.startsWith(m_javaLangPackageName))
{
JavaIndexer.recordSymbol(
m_address, m_javaLangPackageName, SymbolKind.PACKAGE.getValue(),
AccessKind.NONE.getValue(), DefinitionKind.NONE.getValue());
m_address,
m_javaLangPackageName,
SymbolKind.PACKAGE.getValue(),
AccessKind.NONE.getValue(),
DefinitionKind.NONE.getValue());
m_javaLangPackageRecorded = true;
}
JavaIndexer.recordReference(
m_address, referenceKind.getValue(), serializedReferencedName, contextName.serialize(),
range.begin.line, range.begin.column, range.end.line, range.end.column);
m_address,
referenceKind.getValue(),
serializedReferencedName,
contextName.serialize(),
range.begin.line,
range.begin.column,
range.end.line,
range.end.column);
}
@Override
public void recordQualifierLocation(
NameHierarchy qualifierName,
Range range)
@Override public void recordQualifierLocation(NameHierarchy qualifierName, Range range)
{
JavaIndexer.recordQualifierLocation(
m_address, qualifierName.serialize(),
range.begin.line, range.begin.column, range.end.line, range.end.column);
m_address,
qualifierName.serialize(),
range.begin.line,
range.begin.column,
range.end.line,
range.end.column);
}
@Override
public void recordLocalSymbol(NameHierarchy symbolName, Range range)
@Override public void recordLocalSymbol(NameHierarchy symbolName, Range range)
{
JavaIndexer.recordLocalSymbol(
m_address, symbolName.serialize(),
range.begin.line, range.begin.column, range.end.line, range.end.column);
m_address,
symbolName.serialize(),
range.begin.line,
range.begin.column,
range.end.line,
range.end.column);
}
@Override
public void recordComment(Range range)
@Override public void recordComment(Range range)
{
JavaIndexer.recordComment(
m_address,
range.begin.line, range.begin.column, range.end.line, range.end.column);
m_address, range.begin.line, range.begin.column, range.end.line, range.end.column);
}
@Override
public void recordError(String message, boolean fatal, boolean indexed, Range range)
@Override public void recordError(String message, boolean fatal, boolean indexed, Range range)
{
JavaIndexer.recordError(
m_address, message, (fatal ? 1 : 0), (indexed ? 1 : 0),
range.begin.line, range.begin.column, range.end.line, range.end.column);
m_address,
message,
(fatal ? 1 : 0),
(indexed ? 1 : 0),
range.begin.line,
range.begin.column,
range.end.line,
range.end.column);
}
}
@@ -5,9 +5,7 @@ public class Position
public int line = 0;
public int column = 0;
public Position()
{
}
public Position() {}
public Position(int line, int column)
{
@@ -1,7 +1,10 @@
package com.sourcetrail;
import com.sourcetrail.name.DeclName;
import com.sourcetrail.name.NameHierarchy;
import com.sourcetrail.name.TypeName;
import com.sourcetrail.name.resolver.BindingNameResolver;
import java.io.File;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.CreationReference;
@@ -27,11 +30,6 @@ import org.eclipse.jdt.core.dom.ThisExpression;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeMethodReference;
import com.sourcetrail.name.DeclName;
import com.sourcetrail.name.NameHierarchy;
import com.sourcetrail.name.TypeName;
import com.sourcetrail.name.resolver.BindingNameResolver;
public class QualifierVisitor
{
protected AstVisitorClient m_client = null;
@@ -39,7 +37,8 @@ public class QualifierVisitor
private CompilationUnit m_compilationUnit;
private boolean m_recordSymbolKinds = false;
public QualifierVisitor(AstVisitorClient client, File filePath, CompilationUnit compilationUnit, boolean recordSymbolKinds)
public QualifierVisitor(
AstVisitorClient client, File filePath, CompilationUnit compilationUnit, boolean recordSymbolKinds)
{
m_client = client;
m_filePath = filePath;
@@ -195,7 +194,8 @@ public class QualifierVisitor
}
private void recordNodeAsQualifier(Expression node, FileContent fileContent) {
private void recordNodeAsQualifier(Expression node, FileContent fileContent)
{
if (node != null)
{
if (node instanceof Name)
@@ -211,14 +211,14 @@ public class QualifierVisitor
{
m_client.recordQualifierLocation(
BindingNameResolver
.getQualifiedName(fieldBinding.getDeclaringClass(), m_filePath, m_compilationUnit)
.getQualifiedName(
fieldBinding.getDeclaringClass(), m_filePath, m_compilationUnit)
.orElse(TypeName.unsolved())
.toDeclName()
.toNameHierarchy(),
fileContent.findRange(
"super",
expression.getQualifier() != null
? getRange(expression.getQualifier()).end
expression.getQualifier() != null ? getRange(expression.getQualifier()).end
: getRange(expression).begin));
}
@@ -230,14 +230,14 @@ public class QualifierVisitor
m_client.recordQualifierLocation(
BindingNameResolver
.getQualifiedName(expression.resolveTypeBinding(), m_filePath, m_compilationUnit)
.getQualifiedName(
expression.resolveTypeBinding(), m_filePath, m_compilationUnit)
.orElse(TypeName.unsolved())
.toDeclName()
.toNameHierarchy(),
fileContent.findRange(
"this",
expression.getQualifier() != null
? getRange(expression.getQualifier()).end
expression.getQualifier() != null ? getRange(expression.getQualifier()).end
: getRange(expression).begin));
recordNodeAsQualifier(expression.getQualifier());
@@ -295,19 +295,19 @@ public class QualifierVisitor
range = getRange(((QualifiedName)node).getName());
}
NameHierarchy symbolName = BindingNameResolver
NameHierarchy symbolName =
BindingNameResolver
.getQualifiedName((IPackageBinding)binding, m_filePath, m_compilationUnit)
.orElse(DeclName.unsolved())
.toNameHierarchy();
if (m_recordSymbolKinds)
{
m_client.recordSymbol(symbolName, SymbolKind.PACKAGE, AccessKind.NONE, DefinitionKind.NONE);
m_client.recordSymbol(
symbolName, SymbolKind.PACKAGE, AccessKind.NONE, DefinitionKind.NONE);
}
m_client.recordQualifierLocation(
symbolName,
range);
m_client.recordQualifierLocation(symbolName, range);
}
if (node instanceof QualifiedName)
@@ -5,9 +5,7 @@ public class Range
public Position begin = new Position();
public Position end = new Position();
public Range()
{
}
public Range() {}
public Range(int beginLine, int beginColumn, int endLine, int endColumn)
{
@@ -1,7 +1,6 @@
package com.sourcetrail;
public enum ReferenceKind
{ // these values need to be the same as ReferenceKind in C++ code
public enum ReferenceKind { // these values need to be the same as ReferenceKind in C++ code
UNDEFINED(0),
TYPE_USAGE(1),
USAGE(2),
@@ -1,7 +1,6 @@
package com.sourcetrail;
public enum SymbolKind
{ // these values need to be the same as SymbolKind in C++ code
public enum SymbolKind { // these values need to be the same as SymbolKind in C++ code
ANNOTATION(1),
BUILTIN_TYPE(2),
CLASS(3),
@@ -1,7 +1,6 @@
package com.sourcetrail;
import java.nio.file.Path;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -1,7 +1,6 @@
package com.sourcetrail;
import java.io.File;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -9,7 +8,8 @@ public class VerboseContextAwareAstVisitor extends ContextAwareAstVisitor
{
private String indentation = "";
public VerboseContextAwareAstVisitor(AstVisitorClient client, File filePath, String fileContent, CompilationUnit compilationUnit)
public VerboseContextAwareAstVisitor(
AstVisitorClient client, File filePath, String fileContent, CompilationUnit compilationUnit)
{
super(client, filePath, fileContent, compilationUnit);
}
@@ -17,7 +17,9 @@ public class VerboseContextAwareAstVisitor extends ContextAwareAstVisitor
public void preVisit(ASTNode node)
{
Range range = getRange(node);
m_client.logInfo(indentation + node.getClass().toString() + "[" + range.begin.line + ":" + range.begin.column + "|" + range.end.line + ":" + range.end.column + "]");
m_client.logInfo(
indentation + node.getClass().toString() + "[" + range.begin.line + ":" +
range.begin.column + "|" + range.end.line + ":" + range.end.column + "]");
indentation += "| ";
}
@@ -9,7 +9,6 @@ import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gradle.api.GradleException;
import org.gradle.tooling.BuildLauncher;
import org.gradle.tooling.GradleConnector;
@@ -67,12 +66,20 @@ public class InfoRetriever
public static void copyCompileLibs(String projectRootPath, String initScriptPath, String targetPath)
{
executeTask("copyCompileLibs", projectRootPath, initScriptPath, Arrays.asList("-Psourcetrail_lib_path=" + targetPath));
executeTask(
"copyCompileLibs",
projectRootPath,
initScriptPath,
Arrays.asList("-Psourcetrail_lib_path=" + targetPath));
}
public static void copyTestCompileLibs(String projectRootPath, String initScriptPath, String targetPath)
{
executeTask("copyTestCompileLibs", projectRootPath, initScriptPath, Arrays.asList("-Psourcetrail_lib_path=" + targetPath));
executeTask(
"copyTestCompileLibs",
projectRootPath,
initScriptPath,
Arrays.asList("-Psourcetrail_lib_path=" + targetPath));
}
private static List<String> getSrcDirs(String taskName, String projectRootPath, String initScriptPath)
@@ -97,12 +104,12 @@ public class InfoRetriever
return paths;
}
private static String executeTask(String taskName, String projectRootPath, String initScriptPath, List<String> additionalArguments) throws GradleException
private static String executeTask(
String taskName, String projectRootPath, String initScriptPath, List<String> additionalArguments)
throws GradleException
{
ProjectConnection connection = GradleConnector
.newConnector()
.forProjectDirectory(new File(projectRootPath))
.connect();
ProjectConnection connection =
GradleConnector.newConnector().forProjectDirectory(new File(projectRootPath)).connect();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
@@ -119,7 +126,8 @@ public class InfoRetriever
arguments.addAll(additionalArguments);
}
BuildLauncher Launcher = connection.newBuild().forTasks(taskName)
BuildLauncher Launcher = connection.newBuild()
.forTasks(taskName)
.withArguments(arguments)
.setStandardOutput(new PrintStream(outputStream))
.setStandardError(new PrintStream(errorStream));
@@ -1,10 +1,9 @@
package com.sourcetrail.name;
import com.sourcetrail.Position;
import java.io.File;
import java.util.List;
import com.sourcetrail.Position;
public class DeclName implements SymbolName
{
private DeclName m_parent = null;
@@ -24,7 +23,8 @@ public class DeclName implements SymbolName
public static DeclName anonymousClass(File filePath, int line, int col)
{
DeclName declName = new DeclName("anonymous class (" + filePath.getName() + "<" + line + ":" + col + ">)");
DeclName declName = new DeclName(
"anonymous class (" + filePath.getName() + "<" + line + ":" + col + ">)");
declName.m_isAnonymous = true;
return declName;
}
@@ -45,7 +45,8 @@ public class DeclName implements SymbolName
public static DeclName scope(File fileContext, Position begin)
{
DeclName declName = new DeclName(fileContext.getName() + "<" + begin.line + ":" + begin.column + ">");
DeclName declName = new DeclName(
fileContext.getName() + "<" + begin.line + ":" + begin.column + ">");
return declName;
}
@@ -165,7 +166,8 @@ public class DeclName implements SymbolName
return string;
}
public List<String> getTypeParameterNames() {
public List<String> getTypeParameterNames()
{
return m_typeParameterNames;
}
}
@@ -11,8 +11,7 @@ public class FileName implements SymbolName
m_filePath = filePath;
}
@Override
public NameHierarchy toNameHierarchy()
@Override public NameHierarchy toNameHierarchy()
{
NameHierarchy nameHierarchy;
if (m_filePath != null)
@@ -10,26 +10,33 @@ public class FunctionDeclName extends DeclName
private List<TypeName> m_parameterTypeNames = new ArrayList<>();
private boolean m_isStatic = false;
public FunctionDeclName(String name, TypeName returnTypeName, List<TypeName> parameterTypeNames, boolean isStatic)
public FunctionDeclName(
String name, TypeName returnTypeName, List<TypeName> parameterTypeNames, boolean isStatic)
{
super(name);
m_returnTypeName = returnTypeName;
if (parameterTypeNames != null) m_parameterTypeNames = parameterTypeNames;
if (parameterTypeNames != null)
m_parameterTypeNames = parameterTypeNames;
m_isStatic = isStatic;
}
public FunctionDeclName(String name, List<String> typeParameterNames, TypeName returnTypeName, List<TypeName> parameterTypeNames, boolean isStatic)
public FunctionDeclName(
String name,
List<String> typeParameterNames,
TypeName returnTypeName,
List<TypeName> parameterTypeNames,
boolean isStatic)
{
super(name, typeParameterNames);
m_returnTypeName = returnTypeName;
if (parameterTypeNames != null) m_parameterTypeNames = parameterTypeNames;
if (parameterTypeNames != null)
m_parameterTypeNames = parameterTypeNames;
m_isStatic = isStatic;
}
@Override
public NameHierarchy toNameHierarchy()
@Override public NameHierarchy toNameHierarchy()
{
String prefix = "";
if (m_isStatic)
@@ -9,14 +9,18 @@ public class NameElement
public NameElement(String name)
{
if (name != null) m_name = name;
if (name != null)
m_name = name;
}
public NameElement(String name, String prefix, String postfix)
{
if (name != null) m_name = name;
if (prefix != null) m_prefix = prefix;
if (postfix != null) m_postfix = postfix;
if (name != null)
m_name = name;
if (prefix != null)
m_prefix = prefix;
if (postfix != null)
m_postfix = postfix;
}
String getName()
@@ -9,9 +9,7 @@ public class NameHierarchy
private List<NameElement> m_elements = new ArrayList<>();
private char m_separatpr = '.';
public NameHierarchy()
{
}
public NameHierarchy() {}
public NameHierarchy(String name)
{
@@ -71,5 +69,4 @@ public class NameHierarchy
return serialized;
}
}
@@ -1,6 +1,5 @@
package com.sourcetrail.name;
public interface SymbolName
{
public interface SymbolName {
public NameHierarchy toNameHierarchy();
}
@@ -24,7 +24,9 @@ public class TypeName implements SymbolName
int separatorIndex = s.lastIndexOf('.');
if (separatorIndex != -1)
{
typeName = new TypeName(s.substring(separatorIndex + 1), DeclName.fromDotSeparatedString(s.substring(0, separatorIndex)));
typeName = new TypeName(
s.substring(separatorIndex + 1),
DeclName.fromDotSeparatedString(s.substring(0, separatorIndex)));
}
else
{
@@ -40,7 +42,8 @@ public class TypeName implements SymbolName
m_name = name;
}
public TypeName(String name, List<String> typeParameterNames, List<TypeName> typeArguments, DeclName parent)
public TypeName(
String name, List<String> typeParameterNames, List<TypeName> typeArguments, DeclName parent)
{
m_parent = parent;
m_name = name;
@@ -15,8 +15,7 @@ public class VariableDeclName extends DeclName
m_isStatic = isStatic;
}
@Override
public NameHierarchy toNameHierarchy()
@Override public NameHierarchy toNameHierarchy()
{
String prefix = "";
if (m_isStatic)
@@ -1,10 +1,14 @@
package com.sourcetrail.name.resolver;
import com.sourcetrail.ContextList;
import com.sourcetrail.name.DeclName;
import com.sourcetrail.name.FunctionDeclName;
import com.sourcetrail.name.TypeName;
import com.sourcetrail.name.VariableDeclName;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -15,12 +19,6 @@ import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.Modifier;
import com.sourcetrail.ContextList;
import com.sourcetrail.name.DeclName;
import com.sourcetrail.name.FunctionDeclName;
import com.sourcetrail.name.TypeName;
import com.sourcetrail.name.VariableDeclName;
public class BindingNameResolver extends NameResolver
{
public static IBinding getParentBinding(IBinding binding)
@@ -84,19 +82,26 @@ public class BindingNameResolver extends NameResolver
return null; // we don't have a parent (like void doesn't have a parent)
}
public BindingNameResolver(File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
public BindingNameResolver(
File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
super(currentFile, compilationUnit, ignoredContexts);
}
public static Optional<TypeName> getQualifiedName(ITypeBinding binding, File currentFile, CompilationUnit compilationUnit)
public static Optional<TypeName> getQualifiedName(
ITypeBinding binding, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedName(binding, currentFile, compilationUnit, null);
}
public static Optional<TypeName> getQualifiedName(ITypeBinding binding, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
public static Optional<TypeName> getQualifiedName(
ITypeBinding binding,
File currentFile,
CompilationUnit compilationUnit,
ContextList ignoredContexts)
{
BindingNameResolver resolver = new BindingNameResolver(currentFile, compilationUnit, ignoredContexts);
BindingNameResolver resolver = new BindingNameResolver(
currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedName(binding);
}
@@ -116,8 +121,13 @@ public class BindingNameResolver extends NameResolver
ASTNode node = m_compilationUnit.findDeclaringNode(binding);
if (node instanceof AnonymousClassDeclaration)
{
DeclName decl = DeclNameResolver.getQualifiedDeclName((AnonymousClassDeclaration) node, m_currentFile, m_compilationUnit, m_ignoredContexts);
return Optional.of(new TypeName(decl.getName(), decl.getTypeParameterNames(), null, decl.getParent()));
DeclName decl = DeclNameResolver.getQualifiedDeclName(
(AnonymousClassDeclaration)node,
m_currentFile,
m_compilationUnit,
m_ignoredContexts);
return Optional.of(new TypeName(
decl.getName(), decl.getTypeParameterNames(), null, decl.getParent()));
}
else
{
@@ -141,7 +151,11 @@ public class BindingNameResolver extends NameResolver
if (typeName.isPresent())
{
DeclName declName = typeName.get().toDeclName();
return Optional.of(new TypeName(declName.getName(), declName.getTypeParameterNames(), typeArguments, declName.getParent()));
return Optional.of(new TypeName(
declName.getName(),
declName.getTypeParameterNames(),
typeArguments,
declName.getParent()));
}
else
{
@@ -170,14 +184,20 @@ public class BindingNameResolver extends NameResolver
return Optional.of(new TypeName(name, typeParameterNames, null, parentDeclName));
}
public static Optional<DeclName> getQualifiedName(IMethodBinding binding, File currentFile, CompilationUnit compilationUnit)
public static Optional<DeclName> getQualifiedName(
IMethodBinding binding, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedName(binding, currentFile, compilationUnit, null);
}
public static Optional<DeclName> getQualifiedName(IMethodBinding binding, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
public static Optional<DeclName> getQualifiedName(
IMethodBinding binding,
File currentFile,
CompilationUnit compilationUnit,
ContextList ignoredContexts)
{
BindingNameResolver resolver = new BindingNameResolver(currentFile, compilationUnit, ignoredContexts);
BindingNameResolver resolver = new BindingNameResolver(
currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedName(binding);
}
@@ -207,7 +227,11 @@ public class BindingNameResolver extends NameResolver
ContextList ignoredContexts = m_ignoredContexts.copy();
ignoredContexts.add(binding);
TypeName returnTypeName = binding.isConstructor() ? null : getQualifiedName(binding.getReturnType(), m_currentFile, m_compilationUnit, ignoredContexts).orElse(TypeName.unsolved());
TypeName returnTypeName = binding.isConstructor()
? null
: getQualifiedName(
binding.getReturnType(), m_currentFile, m_compilationUnit, ignoredContexts)
.orElse(TypeName.unsolved());
if (binding.isAnnotationMember())
{
@@ -218,10 +242,14 @@ public class BindingNameResolver extends NameResolver
List<TypeName> parameterTypeNames = new ArrayList<>();
for (ITypeBinding parameterType: binding.getParameterTypes())
{
parameterTypeNames.add(getQualifiedName(parameterType, m_currentFile, m_compilationUnit, ignoredContexts).orElse(TypeName.unsolved()));
parameterTypeNames.add(
getQualifiedName(
parameterType, m_currentFile, m_compilationUnit, ignoredContexts)
.orElse(TypeName.unsolved()));
}
declName = new FunctionDeclName(name, typeParameterNames, returnTypeName, parameterTypeNames, isStatic);
declName = new FunctionDeclName(
name, typeParameterNames, returnTypeName, parameterTypeNames, isStatic);
}
}
@@ -241,14 +269,20 @@ public class BindingNameResolver extends NameResolver
return Optional.of(declName);
}
public static Optional<DeclName> getQualifiedName(IPackageBinding binding, File currentFile, CompilationUnit compilationUnit)
public static Optional<DeclName> getQualifiedName(
IPackageBinding binding, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedName(binding, currentFile, compilationUnit, null);
}
public static Optional<DeclName> getQualifiedName(IPackageBinding binding, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
public static Optional<DeclName> getQualifiedName(
IPackageBinding binding,
File currentFile,
CompilationUnit compilationUnit,
ContextList ignoredContexts)
{
BindingNameResolver resolver = new BindingNameResolver(currentFile, compilationUnit, ignoredContexts);
BindingNameResolver resolver = new BindingNameResolver(
currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedName(binding);
}
@@ -261,14 +295,20 @@ public class BindingNameResolver extends NameResolver
return Optional.empty();
}
public static DeclName getQualifiedName(IVariableBinding binding, File currentFile, CompilationUnit compilationUnit)
public static DeclName getQualifiedName(
IVariableBinding binding, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedName(binding, currentFile, compilationUnit, null);
}
public static DeclName getQualifiedName(IVariableBinding binding, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
public static DeclName getQualifiedName(
IVariableBinding binding,
File currentFile,
CompilationUnit compilationUnit,
ContextList ignoredContexts)
{
BindingNameResolver resolver = new BindingNameResolver(currentFile, compilationUnit, ignoredContexts);
BindingNameResolver resolver = new BindingNameResolver(
currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedName(binding);
}
@@ -289,7 +329,8 @@ public class BindingNameResolver extends NameResolver
else
{
TypeName typeName = getQualifiedName(binding.getType()).orElse(TypeName.unsolved());
declName = new VariableDeclName(binding.getName(), typeName, Modifier.isStatic(binding.getModifiers()));
declName = new VariableDeclName(
binding.getName(), typeName, Modifier.isStatic(binding.getModifiers()));
}
DeclName parentDeclName = getQualifiedContextName(binding);
@@ -311,7 +352,9 @@ public class BindingNameResolver extends NameResolver
{
if (binding.getDeclaringMethod() != null)
{
return DeclName.localSymbol(getQualifiedName(binding.getDeclaringMethod()).orElse(DeclName.unsolved()), binding.getVariableId());
return DeclName.localSymbol(
getQualifiedName(binding.getDeclaringMethod()).orElse(DeclName.unsolved()),
binding.getVariableId());
}
else
{
@@ -331,7 +374,9 @@ public class BindingNameResolver extends NameResolver
if (parentBinding instanceof ITypeBinding)
{
return getQualifiedName((ITypeBinding) parentBinding).map(tn ->tn.toDeclName()).orElse(DeclName.unsolved());
return getQualifiedName((ITypeBinding)parentBinding)
.map(tn -> tn.toDeclName())
.orElse(DeclName.unsolved());
}
else if (parentBinding instanceof IMethodBinding)
{
@@ -1,10 +1,16 @@
package com.sourcetrail.name.resolver;
import com.sourcetrail.ContextList;
import com.sourcetrail.Position;
import com.sourcetrail.Utility;
import com.sourcetrail.name.DeclName;
import com.sourcetrail.name.FunctionDeclName;
import com.sourcetrail.name.TypeName;
import com.sourcetrail.name.VariableDeclName;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
@@ -27,14 +33,6 @@ import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.TypeParameter;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import com.sourcetrail.ContextList;
import com.sourcetrail.Position;
import com.sourcetrail.Utility;
import com.sourcetrail.name.DeclName;
import com.sourcetrail.name.FunctionDeclName;
import com.sourcetrail.name.TypeName;
import com.sourcetrail.name.VariableDeclName;
public class DeclNameResolver extends NameResolver
{
public DeclNameResolver(File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
@@ -42,14 +40,20 @@ public class DeclNameResolver extends NameResolver
super(currentFile, compilationUnit, ignoredContexts);
}
public static DeclName getQualifiedDeclName(VariableDeclarationFragment decl, File currentFile, CompilationUnit compilationUnit)
public static DeclName getQualifiedDeclName(
VariableDeclarationFragment decl, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedDeclName(decl, currentFile, compilationUnit, null);
}
public static DeclName getQualifiedDeclName(VariableDeclarationFragment decl, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
public static DeclName getQualifiedDeclName(
VariableDeclarationFragment decl,
File currentFile,
CompilationUnit compilationUnit,
ContextList ignoredContexts)
{
DeclNameResolver resolver = new DeclNameResolver(currentFile, compilationUnit, ignoredContexts);
DeclNameResolver resolver = new DeclNameResolver(
currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
@@ -95,24 +99,32 @@ public class DeclNameResolver extends NameResolver
{
isStatic = Modifier.isStatic(fieldDeclaration.get().getModifiers());
}
typeName = BindingNameResolver.getQualifiedName(
typeName = BindingNameResolver
.getQualifiedName(
fieldDeclaration.get().getType().resolveBinding(),
m_currentFile,
m_compilationUnit,
m_ignoredContexts.copy()).orElse(TypeName.unsolved());
m_ignoredContexts.copy())
.orElse(TypeName.unsolved());
}
return new VariableDeclName(decl.getName().getIdentifier(), typeName, isStatic);
}
public static DeclName getQualifiedDeclName(BodyDeclaration decl, File currentFile, CompilationUnit compilationUnit)
public static DeclName getQualifiedDeclName(
BodyDeclaration decl, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedDeclName(decl, currentFile, compilationUnit, null);
}
public static DeclName getQualifiedDeclName(BodyDeclaration decl, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
public static DeclName getQualifiedDeclName(
BodyDeclaration decl,
File currentFile,
CompilationUnit compilationUnit,
ContextList ignoredContexts)
{
DeclNameResolver resolver = new DeclNameResolver(currentFile, compilationUnit, ignoredContexts);
DeclNameResolver resolver = new DeclNameResolver(
currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
@@ -166,15 +178,18 @@ public class DeclNameResolver extends NameResolver
{
if (typeParameter instanceof TypeParameter)
{
typeParameterNames.add(((TypeParameter) typeParameter).getName().getIdentifier());
typeParameterNames.add(
((TypeParameter)typeParameter).getName().getIdentifier());
}
}
declName = new DeclName(typeDeclaration.getName().getIdentifier(), typeParameterNames);
declName = new DeclName(
typeDeclaration.getName().getIdentifier(), typeParameterNames);
}
else if (decl instanceof AnnotationTypeMemberDeclaration)
{
declName = new DeclName(((AnnotationTypeMemberDeclaration) decl).getName().getIdentifier());
declName = new DeclName(
((AnnotationTypeMemberDeclaration)decl).getName().getIdentifier());
}
else if (decl instanceof EnumConstantDeclaration)
{
@@ -197,23 +212,37 @@ public class DeclNameResolver extends NameResolver
{
if (typeParameter instanceof TypeParameter)
{
typeParameterNames.add(((TypeParameter) typeParameter).getName().getIdentifier());
typeParameterNames.add(
((TypeParameter)typeParameter).getName().getIdentifier());
}
}
ContextList ignoredContexts = m_ignoredContexts.copy();
ignoredContexts.add(((MethodDeclaration)decl).resolveBinding());
TypeName returnTypeName = methodDeclaration.isConstructor() ? null : BindingNameResolver.getQualifiedName(
methodDeclaration.getReturnType2().resolveBinding(), m_currentFile, m_compilationUnit, ignoredContexts).orElse(TypeName.unsolved());
TypeName returnTypeName = methodDeclaration.isConstructor()
? null
: BindingNameResolver
.getQualifiedName(
methodDeclaration.getReturnType2().resolveBinding(),
m_currentFile,
m_compilationUnit,
ignoredContexts)
.orElse(TypeName.unsolved());
List<TypeName> parameterTypeNames = new ArrayList<>();
for (Object parameter: methodDeclaration.parameters())
{
if (parameter instanceof SingleVariableDeclaration)
{
parameterTypeNames.add(BindingNameResolver.getQualifiedName(
((SingleVariableDeclaration) parameter).getType().resolveBinding(), m_currentFile, m_compilationUnit, ignoredContexts).orElse(TypeName.unsolved()));
parameterTypeNames.add(
BindingNameResolver
.getQualifiedName(
((SingleVariableDeclaration)parameter).getType().resolveBinding(),
m_currentFile,
m_compilationUnit,
ignoredContexts)
.orElse(TypeName.unsolved()));
}
}
@@ -229,14 +258,20 @@ public class DeclNameResolver extends NameResolver
return declName;
}
public static DeclName getQualifiedDeclName(AnonymousClassDeclaration decl, File currentFile, CompilationUnit compilationUnit)
public static DeclName getQualifiedDeclName(
AnonymousClassDeclaration decl, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedDeclName(decl, currentFile, compilationUnit, null);
}
public static DeclName getQualifiedDeclName(AnonymousClassDeclaration decl, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
public static DeclName getQualifiedDeclName(
AnonymousClassDeclaration decl,
File currentFile,
CompilationUnit compilationUnit,
ContextList ignoredContexts)
{
DeclNameResolver resolver = new DeclNameResolver(currentFile, compilationUnit, ignoredContexts);
DeclNameResolver resolver = new DeclNameResolver(
currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
@@ -1,13 +1,11 @@
package com.sourcetrail.name.resolver;
import com.sourcetrail.ContextList;
import java.io.File;
import java.util.Optional;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
import com.sourcetrail.ContextList;
public abstract class NameResolver
{
protected File m_currentFile = null;
+13 -26
View File
@@ -12,25 +12,25 @@
#include "ConsoleLogger.h"
#include "FileLogger.h"
#include "LanguagePackageManager.h"
#include "logging.h"
#include "LogManager.h"
#include "MessageIndexingInterrupted.h"
#include "MessageLoadProject.h"
#include "MessageStatus.h"
#include "productVersion.h"
#include "QtNetworkFactory.h"
#include "QtApplication.h"
#include "QtCoreApplication.h"
#include "QtNetworkFactory.h"
#include "QtViewFactory.h"
#include "ResourcePaths.h"
#include "ScopedFunctor.h"
#include "SourceGroupFactory.h"
#include "SourceGroupFactoryModuleCustom.h"
#include "UserPaths.h"
#include "Version.h"
#include "logging.h"
#include "productVersion.h"
#include "utility.h"
#include "utilityApp.h"
#include "utilityQt.h"
#include "Version.h"
#if BUILD_CXX_LANGUAGE_PACKAGE
# include "LanguagePackageCxx.h"
@@ -111,19 +111,14 @@ int main(int argc, char *argv[])
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
}
Version version(
VERSION_YEAR,
VERSION_MINOR,
VERSION_COMMIT,
GIT_COMMIT_HASH
);
Version version(VERSION_YEAR, VERSION_MINOR, VERSION_COMMIT, GIT_COMMIT_HASH);
QApplication::setApplicationVersion(version.toDisplayString().c_str());
MessageStatus(
std::wstring(L"Starting Sourcetrail ") +
(utility::getApplicationArchitectureType() == APPLICATION_ARCHITECTURE_X86_32 ? L"32" : L"64") + L" bit, " +
L"version " + version.toDisplayWString()
).dispatch();
(utility::getApplicationArchitectureType() == APPLICATION_ARCHITECTURE_X86_32 ? L"32" : L"64") +
L" bit, " + L"version " + version.toDisplayWString())
.dispatch();
commandline::CommandLineParser commandLineParser(version.toDisplayString());
commandLineParser.preparse(argc, argv);
@@ -144,9 +139,7 @@ int main(int argc, char *argv[])
setupLogging();
Application::createInstance(version, nullptr, nullptr);
ScopedFunctor f([](){
Application::destroyInstance();
});
ScopedFunctor f([]() { Application::destroyInstance(); });
ApplicationSettingsPrefiller::prefillPaths(ApplicationSettings::getInstance().get());
addLanguagePackages();
@@ -172,8 +165,8 @@ int main(int argc, char *argv[])
commandLineParser.getProjectFilePath(),
false,
commandLineParser.getRefreshMode(),
commandLineParser.getShallowIndexingRequested()
).dispatch();
commandLineParser.getShallowIndexingRequested())
.dispatch();
}
return qtApp.exec();
@@ -204,9 +197,7 @@ int main(int argc, char *argv[])
QtNetworkFactory networkFactory;
Application::createInstance(version, &viewFactory, &networkFactory);
ScopedFunctor f([](){
Application::destroyInstance();
});
ScopedFunctor f([]() { Application::destroyInstance(); });
ApplicationSettingsPrefiller::prefillPaths(ApplicationSettings::getInstance().get());
addLanguagePackages();
@@ -220,11 +211,7 @@ int main(int argc, char *argv[])
}
else
{
MessageLoadProject(
commandLineParser.getProjectFilePath(),
false,
REFRESH_NONE
).dispatch();
MessageLoadProject(commandLineParser.getProjectFilePath(), false, REFRESH_NONE).dispatch();
}
return qtApp.exec();
+4 -4
View File
@@ -2,14 +2,14 @@
#include "language_packages.h"
#include "LanguagePackageManager.h"
#include "InterprocessIndexer.h"
#include "ApplicationSettings.h"
#include "AppPath.h"
#include "ApplicationSettings.h"
#include "ConsoleLogger.h"
#include "FileLogger.h"
#include "logging.h"
#include "InterprocessIndexer.h"
#include "LanguagePackageManager.h"
#include "LogManager.h"
#include "logging.h"
#if BUILD_CXX_LANGUAGE_PACKAGE
# include "LanguagePackageCxx.h"
+4 -4
View File
@@ -4,6 +4,7 @@
#include "ApplicationSettings.h"
#include "ColorScheme.h"
#include "DialogView.h"
#include "FileLogger.h"
#include "FileSystem.h"
#include "GraphViewStyle.h"
#include "IDECommunicationController.h"
@@ -30,7 +31,6 @@
#include "tracing.h"
#include "utilityString.h"
#include "utilityUuid.h"
#include "FileLogger.h"
std::shared_ptr<Application> Application::s_instance;
std::string Application::s_uuid;
@@ -333,8 +333,7 @@ void Application::handleMessage(MessageRefresh* message)
{
TRACE("app refresh");
refreshProject(
message->all ? REFRESH_ALL_FILES : REFRESH_UPDATED_FILES, false);
refreshProject(message->all ? REFRESH_ALL_FILES : REFRESH_UPDATED_FILES, false);
}
void Application::handleMessage(MessageRefreshUI* message)
@@ -424,7 +423,8 @@ void Application::refreshProject(RefreshMode refreshMode, bool shallowIndexingRe
{
if (m_project && checkSharedMemory())
{
m_project->refresh(getDialogView(DialogView::UseCase::INDEXING), refreshMode, shallowIndexingRequested);
m_project->refresh(
getDialogView(DialogView::UseCase::INDEXING), refreshMode, shallowIndexingRequested);
if (!m_hasGUI && !m_project->isIndexing())
{
@@ -577,10 +577,15 @@ void CodeController::handleMessage(MessageToNextCodeReference* message)
}
else if (referenceFileIndex == 0)
{
if (m_references[referenceIndex].lineNumber == m_localReferences[localReferenceIndex].lineNumber)
if (m_references[referenceIndex].lineNumber ==
m_localReferences[localReferenceIndex].lineNumber)
{
if ((next && m_references[referenceIndex].columnNumber < m_localReferences[localReferenceIndex].columnNumber) ||
(!next && m_references[referenceIndex].columnNumber > m_localReferences[localReferenceIndex].columnNumber))
if ((next &&
m_references[referenceIndex].columnNumber <
m_localReferences[localReferenceIndex].columnNumber) ||
(!next &&
m_references[referenceIndex].columnNumber >
m_localReferences[localReferenceIndex].columnNumber))
{
localReferenceIndex = -1;
}
@@ -591,8 +596,12 @@ void CodeController::handleMessage(MessageToNextCodeReference* message)
}
else
{
if ((next && m_references[referenceIndex].lineNumber < m_localReferences[localReferenceIndex].lineNumber) ||
(!next && m_references[referenceIndex].lineNumber > m_localReferences[localReferenceIndex].lineNumber))
if ((next &&
m_references[referenceIndex].lineNumber <
m_localReferences[localReferenceIndex].lineNumber) ||
(!next &&
m_references[referenceIndex].lineNumber >
m_localReferences[localReferenceIndex].lineNumber))
{
localReferenceIndex = -1;
}
@@ -1200,7 +1209,8 @@ std::pair<int, int> CodeController::findClosestReferenceIndex(
if (!next)
{
if (references[i].lineNumber < currentLineNumber ||
(references[i].lineNumber == currentLineNumber && references[i].columnNumber < currentColumnNumber))
(references[i].lineNumber == currentLineNumber &&
references[i].columnNumber < currentColumnNumber))
{
referenceIndex = static_cast<int>(i);
}
@@ -1209,8 +1219,10 @@ std::pair<int, int> CodeController::findClosestReferenceIndex(
return {referenceIndex, beforeCurrentFile ? -1 : 0};
}
}
else if (references[i].lineNumber > currentLineNumber ||
(references[i].lineNumber == currentLineNumber && references[i].columnNumber > currentColumnNumber))
else if (
references[i].lineNumber > currentLineNumber ||
(references[i].lineNumber == currentLineNumber &&
references[i].columnNumber > currentColumnNumber))
{
return {static_cast<int>(i), 0};
}
@@ -19,8 +19,8 @@
#include "MessageCodeShowDefinition.h"
#include "MessageDeactivateEdge.h"
#include "MessageErrorCountClear.h"
#include "MessageFocusChanged.h"
#include "MessageFlushUpdates.h"
#include "MessageFocusChanged.h"
#include "MessageFocusIn.h"
#include "MessageFocusOut.h"
#include "MessageListener.h"
@@ -12,8 +12,8 @@
#include "MessageActivateTrail.h"
#include "MessageActivateTrailEdge.h"
#include "MessageDeactivateEdge.h"
#include "MessageFocusChanged.h"
#include "MessageFlushUpdates.h"
#include "MessageFocusChanged.h"
#include "MessageFocusIn.h"
#include "MessageFocusOut.h"
#include "MessageGraphNodeBundleSplit.h"
+2 -1
View File
@@ -2,7 +2,8 @@
#include <algorithm>
CompositeView::CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId)
CompositeView::CompositeView(
ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId)
: View(viewLayout), m_direction(direction), m_name(name), m_tabId(tabId)
{
}
+2 -1
View File
@@ -20,7 +20,8 @@ public:
DIRECTION_VERTICAL
};
CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId);
CompositeView(
ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId);
virtual ~CompositeView();
Id getSchedulerId() const override;
+9 -2
View File
@@ -371,7 +371,13 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfGroupNode(GroupType type
}
GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
NodeType type, bool defined, bool isActive, bool isFocused, bool isCoFocused, bool hasChildren, bool hasQualifier)
NodeType type,
bool defined,
bool isActive,
bool isFocused,
bool isCoFocused,
bool hasChildren,
bool hasQualifier)
{
return getStyleForNodeType(
type.getNodeStyle(),
@@ -685,7 +691,8 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
if (isTrailEdge && isActive)
{
style.width = 3;
style.color = ColorScheme::getInstance()->getColor("graph/edge/call_trail_focus", style.color);
style.color = ColorScheme::getInstance()->getColor(
"graph/edge/call_trail_focus", style.color);
}
break;
@@ -22,9 +22,11 @@ struct CodeScrollParams
TOP
};
static CodeScrollParams toReference(const FilePath& filePath, Id locationId, Id scopeLocationId, Target target)
static CodeScrollParams toReference(
const FilePath& filePath, Id locationId, Id scopeLocationId, Target target)
{
return CodeScrollParams(Type::TO_REFERENCE, target, filePath, locationId, scopeLocationId, 0, 0, false);
return CodeScrollParams(
Type::TO_REFERENCE, target, filePath, locationId, scopeLocationId, 0, 0, false);
}
static CodeScrollParams toFile(const FilePath& filePath, Target target)
@@ -39,7 +41,8 @@ struct CodeScrollParams
static CodeScrollParams toValue(size_t value, bool inListMode)
{
return CodeScrollParams(Type::TO_VALUE, Target::VISIBLE, FilePath(), 0, 0, 0, value, inListMode);
return CodeScrollParams(
Type::TO_VALUE, Target::VISIBLE, FilePath(), 0, 0, 0, value, inListMode);
}
CodeScrollParams(
@@ -50,8 +53,7 @@ struct CodeScrollParams
Id scopeLocationId,
size_t line,
size_t value,
bool inListMode
)
bool inListMode)
: type(type)
, target(target)
, filePath(filePath)
+6 -9
View File
@@ -166,13 +166,10 @@ NodeTypeSet::MaskType NodeTypeSet::nodeTypeToMask(const NodeType& nodeType)
}
const std::vector<NodeType> NodeTypeSet::s_allNodeTypes = {
NodeType(NODE_SYMBOL), NodeType(NODE_TYPE),
NodeType(NODE_BUILTIN_TYPE), NodeType(NODE_MODULE),
NodeType(NODE_NAMESPACE), NodeType(NODE_PACKAGE),
NodeType(NODE_STRUCT), NodeType(NODE_CLASS),
NodeType(NODE_INTERFACE), NodeType(NODE_GLOBAL_VARIABLE),
NodeType(NODE_FIELD), NodeType(NODE_FUNCTION),
NodeType(NODE_METHOD), NodeType(NODE_ENUM),
NodeType(NODE_ENUM_CONSTANT), NodeType(NODE_TYPEDEF),
NodeType(NODE_TYPE_PARAMETER), NodeType(NODE_FILE),
NodeType(NODE_SYMBOL), NodeType(NODE_TYPE), NodeType(NODE_BUILTIN_TYPE),
NodeType(NODE_MODULE), NodeType(NODE_NAMESPACE), NodeType(NODE_PACKAGE),
NodeType(NODE_STRUCT), NodeType(NODE_CLASS), NodeType(NODE_INTERFACE),
NodeType(NODE_GLOBAL_VARIABLE), NodeType(NODE_FIELD), NodeType(NODE_FUNCTION),
NodeType(NODE_METHOD), NodeType(NODE_ENUM), NodeType(NODE_ENUM_CONSTANT),
NodeType(NODE_TYPEDEF), NodeType(NODE_TYPE_PARAMETER), NodeType(NODE_FILE),
NodeType(NODE_MACRO), NodeType(NODE_UNION)};
+1 -1
View File
@@ -1,9 +1,9 @@
#ifndef TOKEN_H
#define TOKEN_H
#include <string>
#include <typeinfo>
#include <vector>
#include <string>
#include "TokenComponent.h"
#include "types.h"
@@ -361,7 +361,8 @@ std::vector<Id> SqliteIndexStorage::addSourceLocations(const std::vector<Storage
static_cast<uint16_t>(data.endCol),
data.type);
std::map<TempSourceLocation, uint32_t>& index = m_tempSourceLocationIndices[static_cast<uint32_t>(data.fileNodeId)];
std::map<TempSourceLocation, uint32_t>& index =
m_tempSourceLocationIndices[static_cast<uint32_t>(data.fileNodeId)];
std::map<TempSourceLocation, uint32_t>::const_iterator it = index.find(tempLoc);
if (it != index.end())
{
+2 -1
View File
@@ -272,7 +272,8 @@ void Project::load(std::shared_ptr<DialogView> dialogView)
}
}
void Project::refresh(std::shared_ptr<DialogView> dialogView, RefreshMode refreshMode, bool shallowIndexingRequested)
void Project::refresh(
std::shared_ptr<DialogView> dialogView, RefreshMode refreshMode, bool shallowIndexingRequested)
{
if (m_refreshStage != RefreshStageType::NONE)
{
+2 -1
View File
@@ -37,7 +37,8 @@ public:
void load(std::shared_ptr<DialogView> dialogView);
void refresh(std::shared_ptr<DialogView> dialogView, RefreshMode refreshMode, bool shallowIndexingRequested);
void refresh(
std::shared_ptr<DialogView> dialogView, RefreshMode refreshMode, bool shallowIndexingRequested);
RefreshInfo getRefreshInfo(RefreshMode mode) const;
+2 -2
View File
@@ -82,8 +82,8 @@ RefreshInfo RefreshInfoGenerator::getRefreshInfoForUpdatedFiles(
// 2.3) Handle files that are referenced by the files that will be cleared. These will be
// re-indexed on the fly. However, we do not
// need to clear files that are also referenced by unchanged source files, because otherwise
//we will lose these connections.
// need to clear files that are also referenced by unchanged source files, because
//otherwise we will lose these connections.
// 2.3.1) Get all source file paths that will not be cleared.
// - Initially this list contains all source file paths the project would index right now.
// - Then we remove all source files that will be cleared
@@ -19,10 +19,9 @@ namespace commandline
CommandLineParser::CommandLineParser(const std::string& version): m_version(version)
{
po::options_description options("Options");
options.add_options()
("help,h", "Print this help message")
("version,v", "Version of Sourcetrail")
("project-file", po::value<std::string>(), "Open Sourcetrail with this project (.srctrlprj)");
options.add_options()("help,h", "Print this help message")(
"version,v", "Version of Sourcetrail")(
"project-file", po::value<std::string>(), "Open Sourcetrail with this project (.srctrlprj)");
m_options.add(options);
m_positional.add("project-file", 1);
@@ -19,12 +19,11 @@ CommandlineCommandIndex::~CommandlineCommandIndex() {}
void CommandlineCommandIndex::setup()
{
po::options_description options("Config Options");
options.add_options()
("help,h", "Print this help message")
("incomplete,i", "Also reindex incomplete files (files with errors)")
("full,f", "Index full project (omit to only index new/changed files)")
("shallow,s", "Build a shallow index is supported by the project")
("project-file", po::value<std::string>(), "Project file to index (.srctrlprj)");
options.add_options()("help,h", "Print this help message")(
"incomplete,i", "Also reindex incomplete files (files with errors)")(
"full,f", "Index full project (omit to only index new/changed files)")(
"shallow,s", "Build a shallow index is supported by the project")(
"project-file", po::value<std::string>(), "Project file to index (.srctrlprj)");
m_options.add(options);
m_positional.add("project-file", 1);
@@ -14,13 +14,14 @@ SharedMemory::ScopedAccess::ScopedAccess(SharedMemory* memory)
{
try
{
m_memory = boost::interprocess::managed_shared_memory(boost::interprocess::open_only, memory->getMemoryName().c_str());
m_memory = boost::interprocess::managed_shared_memory(
boost::interprocess::open_only, memory->getMemoryName().c_str());
}
catch (boost::interprocess::interprocess_exception& e)
{
LOG_ERROR_STREAM(
<< "boost exception thrown at ScopedAccess constructor - " << memory->getMemoryName() << ": "
<< e.what());
<< "boost exception thrown at ScopedAccess constructor - " << memory->getMemoryName()
<< ": " << e.what());
// Behaves the same as the initializer construction, with the error printed out
// throw e;
@@ -32,10 +33,8 @@ SharedMemory::ScopedAccess::ScopedAccess(SharedMemory* memory)
memory->getMemoryName().c_str(),
memory->getInitialMemorySize(),
0,
permissions
);
permissions);
}
}
SharedMemory::ScopedAccess::~ScopedAccess() {}
@@ -10,7 +10,10 @@ class MessageLoadProject: public Message<MessageLoadProject>
{
public:
MessageLoadProject(
const FilePath& filePath, bool settingsChanged = false, RefreshMode refreshMode = REFRESH_NONE, bool shallowIndexingRequested = false)
const FilePath& filePath,
bool settingsChanged = false,
RefreshMode refreshMode = REFRESH_NONE,
bool shallowIndexingRequested = false)
: projectSettingsFilePath(filePath)
, settingsChanged(settingsChanged)
, refreshMode(refreshMode)
@@ -14,8 +14,7 @@ public:
};
MessageFocusChanged(ViewType type, Id tokenOrLocationId)
: type(type)
, tokenOrLocationId(tokenOrLocationId)
: type(type), tokenOrLocationId(tokenOrLocationId)
{
setIsLogged(false);
setSchedulerId(TabId::currentTab());
@@ -7,8 +7,7 @@
class MessageFocusedSearchView: public Message<MessageFocusedSearchView>
{
public:
MessageFocusedSearchView(bool focusIn)
: focusIn(focusIn)
MessageFocusedSearchView(bool focusIn): focusIn(focusIn)
{
setIsLogged(false);
setSchedulerId(TabId::currentTab());
@@ -130,8 +130,7 @@ FilePath CanonicalFilePathCache::getDeclarationFilePath(const clang::Decl* decla
{
return getCanonicalFilePath(fileId, sourceManager);
}
return getCanonicalFilePath(
utility::decodeFromUtf8(
return getCanonicalFilePath(utility::decodeFromUtf8(
sourceManager.getPresumedLoc(declaration->getBeginLoc()).getFilename()));
}
@@ -2,8 +2,8 @@
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/MultiplexConsumer.h>
#include <clang/Serialization/ASTWriter.h>
#include <clang/Lex/PreprocessorOptions.h>
#include <clang/Serialization/ASTWriter.h>
#include "PreprocessorCallbacks.h"
@@ -2,8 +2,8 @@
#define CODEBLOCKS_COMPILER_H
#include <memory>
#include <vector>
#include <string>
#include <vector>
class TiXmlElement;
@@ -44,7 +44,8 @@ void setupPlatform(int argc, char* argv[])
void setupApp(int argc, char* argv[])
{
FilePath appPath = FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/").getAbsolute();
FilePath appPath =
FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/").getAbsolute();
AppPath::setSharedDataPath(appPath);
AppPath::setCxxIndexerPath(appPath);
@@ -67,7 +68,8 @@ void setupApp(int argc, char* argv[])
utility::copyNewFilesFromDirectory(
QString::fromStdWString(ResourcePaths::getFallbackPath().wstr()), userDataPath);
utility::copyNewFilesFromDirectory(
QString::fromStdWString(AppPath::getSharedDataPath().concatenate(L"user/").wstr()), userDataPath);
QString::fromStdWString(AppPath::getSharedDataPath().concatenate(L"user/").wstr()),
userDataPath);
}
#endif // INCLUDES_DEFAULT_H
@@ -81,7 +81,13 @@ bool CodeFocusHandler::hasCurrentFocus() const
}
void CodeFocusHandler::setFocusedLocationId(
QtCodeArea* area, size_t lineNumber, size_t columnNumber, Id locationId, const std::vector<Id>& tokenIds, bool updateTargetColumn, bool fromMouse)
QtCodeArea* area,
size_t lineNumber,
size_t columnNumber,
Id locationId,
const std::vector<Id>& tokenIds,
bool updateTargetColumn,
bool fromMouse)
{
if (updateTargetColumn)
{
+2 -1
View File
@@ -94,7 +94,8 @@ protected:
Id focusedLocationId);
void createAnnotations(std::shared_ptr<SourceLocationFile> locationFile);
void activateAnnotations(const std::vector<const Annotation*>& annotations, bool fromMouse, int mouseOffsetX);
void activateAnnotations(
const std::vector<const Annotation*>& annotations, bool fromMouse, int mouseOffsetX);
int toTextEditPosition(int lineNumber, int columnNumber) const;
std::pair<int, int> toLineColumn(int textEditPosition) const;
+12 -4
View File
@@ -177,7 +177,8 @@ void QtCodeFileList::addFile(const CodeFileParams& params)
{
Id focusedLocationId = 0;
const CodeFocusHandler::Focus& currentFocus = m_navigator->getCurrentFocus();
if (currentFocus.area && file->getFilePath() == currentFocus.area->getSourceLocationFile()->getFilePath())
if (currentFocus.area &&
file->getFilePath() == currentFocus.area->getSourceLocationFile()->getFilePath())
{
focusedLocationId = currentFocus.locationId;
}
@@ -299,8 +300,14 @@ void QtCodeFileList::scrollTo(
if (focusTarget)
{
m_navigator->setFocusedLocationId(snippet->getArea(), lineNumber,
snippet->getArea()->getColumnNumberForLocationId(locationId), locationId, {}, false, false);
m_navigator->setFocusedLocationId(
snippet->getArea(),
lineNumber,
snippet->getArea()->getColumnNumberForLocationId(locationId),
locationId,
{},
false,
false);
}
}
@@ -429,7 +436,8 @@ void QtCodeFileList::updateSnippetTitleAndScrollBarSlot()
if (m_firstSnippetTitleBar && m_firstSnippetFile)
{
m_firstSnippetTitleBar->setIsFocused(m_navigator->getCurrentFocus().file == m_firstSnippetFile);
m_firstSnippetTitleBar->setIsFocused(
m_navigator->getCurrentFocus().file == m_firstSnippetFile);
}
}
@@ -217,8 +217,14 @@ void QtCodeFileSingle::scrollTo(
if (focusTarget && locationId)
{
m_navigator->setFocusedLocationId(m_area, lineNumber, m_area->getColumnNumberForLocationId(locationId),
locationId, {}, false, false);
m_navigator->setFocusedLocationId(
m_area,
lineNumber,
m_area->getColumnNumberForLocationId(locationId),
locationId,
{},
false,
false);
}
}
+35 -14
View File
@@ -562,10 +562,7 @@ void QtCodeNavigator::activateScreenMatch(size_t matchIndex)
scrollTo(
CodeScrollParams::toReference(
p.first->getFilePath(),
m_activeScreenMatchId,
0,
CodeScrollParams::Target::CENTER),
p.first->getFilePath(), m_activeScreenMatchId, 0, CodeScrollParams::Target::CENTER),
true,
true);
}
@@ -619,15 +616,24 @@ void QtCodeNavigator::scrollTo(const CodeScrollParams& params, bool animated, bo
case CodeScrollParams::Type::TO_REFERENCE:
func = [=]() {
m_current->scrollTo(
params.filePath, 0, params.locationId, params.scopeLocationId, animated, params.target, focusTarget);
params.filePath,
0,
params.locationId,
params.scopeLocationId,
animated,
params.target,
focusTarget);
};
break;
case CodeScrollParams::Type::TO_FILE:
func = [=]() { m_current->scrollTo(params.filePath, 0, 0, 0, animated, params.target, focusTarget); };
func = [=]() {
m_current->scrollTo(params.filePath, 0, 0, 0, animated, params.target, focusTarget);
};
break;
case CodeScrollParams::Type::TO_LINE:
func = [=]() {
m_current->scrollTo(params.filePath, params.line, 0, 0, animated, params.target, focusTarget);
m_current->scrollTo(
params.filePath, params.line, 0, 0, animated, params.target, focusTarget);
};
break;
case CodeScrollParams::Type::TO_VALUE:
@@ -664,15 +670,26 @@ void QtCodeNavigator::scrollToFocus()
if (focus.file)
{
scrollTo(CodeScrollParams::toFile(focus.file->getFilePath(), CodeScrollParams::Target::VISIBLE), true, false);
scrollTo(
CodeScrollParams::toFile(focus.file->getFilePath(), CodeScrollParams::Target::VISIBLE),
true,
false);
}
else if (focus.scopeLine)
{
scrollTo(CodeScrollParams::toLine(focus.area->getFilePath(), focus.lineNumber, CodeScrollParams::Target::VISIBLE), true, false);
scrollTo(
CodeScrollParams::toLine(
focus.area->getFilePath(), focus.lineNumber, CodeScrollParams::Target::VISIBLE),
true,
false);
}
else if (focus.locationId)
{
scrollTo(CodeScrollParams::toReference(focus.area->getFilePath(), focus.locationId, 0, CodeScrollParams::Target::VISIBLE), true, false);
scrollTo(
CodeScrollParams::toReference(
focus.area->getFilePath(), focus.locationId, 0, CodeScrollParams::Target::VISIBLE),
true,
false);
}
}
@@ -709,9 +726,12 @@ void QtCodeNavigator::keyPressEvent(QKeyEvent* event)
if (shift)
{
MessageToNextCodeReference(
currentFilePath, currentFocus.lineNumber, currentFocus.columnNumber,
direction == CodeFocusHandler::Direction::DOWN || direction == CodeFocusHandler::Direction::RIGHT
).dispatch();
currentFilePath,
currentFocus.lineNumber,
currentFocus.columnNumber,
direction == CodeFocusHandler::Direction::DOWN ||
direction == CodeFocusHandler::Direction::RIGHT)
.dispatch();
}
else
{
@@ -726,7 +746,8 @@ void QtCodeNavigator::keyPressEvent(QKeyEvent* event)
{
QAbstractScrollArea* scrollArea = currentFocus.area;
int step = currentFocus.area ? currentFocus.area->lineHeight() * 3 : 50;
if (direction == CodeFocusHandler::Direction::DOWN || direction == CodeFocusHandler::Direction::UP)
if (direction == CodeFocusHandler::Direction::DOWN ||
direction == CodeFocusHandler::Direction::UP)
{
if (m_mode == MODE_LIST)
{
+1 -2
View File
@@ -22,8 +22,7 @@ void QtListWidget::wheelEvent(QWheelEvent* event)
QScrollBar* bar = verticalScrollBar();
bool down = event->angleDelta().y() < 0;
if (bar->minimum() == bar->maximum() ||
(down && bar->value() == bar->maximum()) ||
if (bar->minimum() == bar->maximum() || (down && bar->value() == bar->maximum()) ||
(!down && bar->value() == bar->minimum()))
{
event->ignore();
+2 -1
View File
@@ -42,7 +42,8 @@ public:
void defocus();
void focusInitialNode();
void focusTokenId(const std::list<QtGraphNode*>& nodes, const std::list<QtGraphEdge*>& edges, Id tokenId);
void focusTokenId(
const std::list<QtGraphNode*>& nodes, const std::list<QtGraphEdge*>& edges, Id tokenId);
void refocusNode(const std::list<QtGraphNode*>& newNodes, Id oldActiveTokenId, Id newActiveTokenId);
void focusNext(Direction direction, bool navigateEdges);
+2 -1
View File
@@ -57,7 +57,8 @@ QtGraphicsView::QtGraphicsView(GraphFocusHandler* focusHandler, QWidget* parent)
m_zoomLabelTimer = std::make_shared<QTimer>(this);
connect(m_zoomLabelTimer.get(), &QTimer::timeout, this, &QtGraphicsView::hideZoomLabel);
m_openInTabAction = new QAction(QStringLiteral("Open in New Tab (Ctrl + Shift + Left Click)"), this);
m_openInTabAction = new QAction(
QStringLiteral("Open in New Tab (Ctrl + Shift + Left Click)"), this);
#if defined(Q_OS_MAC)
m_openInTabAction->setText(QStringLiteral("Open in New Tab (Cmd + Shift + Left Click)"));
#endif
@@ -48,8 +48,7 @@ void QtGraphNodeComponentClickable::nodeMouseReleaseEvent(QGraphicsSceneMouseEve
if (!m_mouseMoved)
{
if (
event->modifiers() & Qt::ControlModifier && event->modifiers() & Qt::ShiftModifier &&
if (event->modifiers() & Qt::ControlModifier && event->modifiers() & Qt::ShiftModifier &&
event->button() == Qt::LeftButton)
{
m_graphNode->onMiddleClick();
@@ -147,7 +147,9 @@ void QtProjectWizardContent::showFilesDialog(const std::vector<FilePath>& filePa
if (!m_filesDialog)
{
m_filesDialog = new QtTextEditDialog(
getFileNamesTitle(), QString::number(filePaths.size()) + " " + getFileNamesDescription(), m_window);
getFileNamesTitle(),
QString::number(filePaths.size()) + " " + getFileNamesDescription(),
m_window);
m_filesDialog->setup();
m_filesDialog->setText(utility::join(utility::toWStrings(filePaths), L"\n"));
@@ -80,7 +80,8 @@ bool QtProjectWizardContentCustomCommand::check()
if (m_customCommand->text().toStdWString().find(L"%{SOURCE_FILE_PATH}") == std::wstring::npos)
{
QMessageBox msgBox(m_window);
msgBox.setText(QStringLiteral("The variable %{SOURCE_FILE_PATH} is missing in the custom command."));
msgBox.setText(
QStringLiteral("The variable %{SOURCE_FILE_PATH} is missing in the custom command."));
msgBox.exec();
return false;
}
@@ -91,7 +91,8 @@ bool QtProjectWizardContentProjectData::check()
if (m_projectFileLocation->getText().isEmpty())
{
QMessageBox msgBox(m_window);
msgBox.setText(QStringLiteral("Please define the location for the Sourcetrail project file."));
msgBox.setText(
QStringLiteral("Please define the location for the Sourcetrail project file."));
msgBox.exec();
return false;
}
@@ -128,10 +129,11 @@ bool QtProjectWizardContentProjectData::check()
else if (!paths[0].exists())
{
QMessageBox msgBox(m_window);
msgBox.setText(
QStringLiteral("The specified location does not exist. Do you want to create the directory?"));
msgBox.setText(QStringLiteral(
"The specified location does not exist. Do you want to create the directory?"));
msgBox.addButton(QStringLiteral("Abort"), QMessageBox::ButtonRole::NoRole);
QPushButton* createButton = msgBox.addButton(QStringLiteral("Create"), QMessageBox::ButtonRole::YesRole);
QPushButton* createButton = msgBox.addButton(
QStringLiteral("Create"), QMessageBox::ButtonRole::YesRole);
msgBox.setDefaultButton(createButton);
msgBox.setIcon(QMessageBox::Icon::Question);
int ret = msgBox.exec();
@@ -8,7 +8,8 @@ class QtProjectWizardContentRequiredLabel: public QtProjectWizardContent
public:
QtProjectWizardContentRequiredLabel(QtProjectWizardWindow* window)
: QtProjectWizardContent(window)
{}
{
}
// QtProjectWizardContent implementation
void populate(QGridLayout* layout, int& row) override
@@ -32,7 +32,10 @@ void QtProjectWizardContentSourceGroupData::populate(QGridLayout* layout, int& r
connect(
m_status, &QCheckBox::toggled, this, &QtProjectWizardContentSourceGroupData::changedStatus);
layout->addWidget(
createFormSubLabel(QStringLiteral("Status")), row, QtProjectWizardWindow::FRONT_COL, Qt::AlignRight);
createFormSubLabel(QStringLiteral("Status")),
row,
QtProjectWizardWindow::FRONT_COL,
Qt::AlignRight);
layout->addWidget(m_status, row, QtProjectWizardWindow::BACK_COL);
addHelpButton(
@@ -15,16 +15,22 @@ void QtProjectWizardContentVS::populate(QGridLayout* layout, int& row)
addHelpButton(
QStringLiteral("Create Compilation Database"),
QStringLiteral("To create a new Compilation Database from a Visual Studio Solution, a Solution has to be open in Visual "
"Studio.\n Sourcetrail will call Visual Studio to open the 'Create Compilation Database' dialog. Please follow "
"the instructions in Visual Studio to complete the process.\n Note: Sourcetrail's Visual Studio plugin has to "
"be installed. Visual Studio has to be running with an eligible Solution, containing C/C++ projects, loaded."),
QStringLiteral("To create a new Compilation Database from a Visual Studio Solution, a "
"Solution has to be open in Visual "
"Studio.\n Sourcetrail will call Visual Studio to open the 'Create "
"Compilation Database' dialog. Please follow "
"the instructions in Visual Studio to complete the process.\n Note: "
"Sourcetrail's Visual Studio plugin has to "
"be installed. Visual Studio has to be running with an eligible Solution, "
"containing C/C++ projects, loaded."),
layout,
row);
QLabel* descriptionLabel = createFormSubLabel(
QStringLiteral("Call Visual Studio to create a Compilation Database from the loaded Solution (requires installed "
"<a href=\"https://sourcetrail.com/documentation/index.html#VisualStudio\">Sourcetrail Visual Studio "
QLabel* descriptionLabel = createFormSubLabel(QStringLiteral(
"Call Visual Studio to create a Compilation Database from the loaded Solution (requires "
"installed "
"<a href=\"https://sourcetrail.com/documentation/index.html#VisualStudio\">Sourcetrail "
"Visual Studio "
"Extension</a>)."));
descriptionLabel->setObjectName(QStringLiteral("description"));
descriptionLabel->setOpenExternalLinks(true);
@@ -57,7 +57,8 @@ bool QtProjectWizardContentPathCxxPch::check()
if (!cdb)
{
QMessageBox msgBox(m_window);
msgBox.setText(QStringLiteral("Unable to open and read the provided compilation database file."));
msgBox.setText(
QStringLiteral("Unable to open and read the provided compilation database file."));
msgBox.exec();
return false;
}
@@ -7,7 +7,8 @@ QtProjectWizardContentPathsFrameworkSearch::QtProjectWizardContentPathsFramework
std::shared_ptr<SourceGroupSettings> settings,
QtProjectWizardWindow* window,
bool indicateAsAdditional)
: QtProjectWizardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY, true)
: QtProjectWizardContentPaths(
settings, window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY, true)
{
setTitleString(
indicateAsAdditional ? QStringLiteral("Additional Framework Search Paths")
@@ -25,7 +25,8 @@ QtProjectWizardContentPathsHeaderSearch::QtProjectWizardContentPathsHeaderSearch
std::shared_ptr<SourceGroupSettings> settings,
QtProjectWizardWindow* window,
bool indicateAsAdditional)
: QtProjectWizardContentPaths(settings, window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY, true)
: QtProjectWizardContentPaths(
settings, window, QtPathListBox::SELECTION_POLICY_DIRECTORIES_ONLY, true)
, m_showDetectedIncludesResultFunctor(std::bind(
&QtProjectWizardContentPathsHeaderSearch::showDetectedIncludesResult,
this,
@@ -363,7 +364,8 @@ void QtProjectWizardContentPathsHeaderSearch::showDetectedIncludesResult(
("<p>The following <b>" + std::to_string(additionalHeaderSearchPaths.size()) +
"</b> include paths have been "
"detected and will be added to the include paths of this Source Group.<b>")
.c_str(), m_window);
.c_str(),
m_window);
m_filesDialog->setup();
m_filesDialog->setReadOnly(true);
@@ -392,8 +394,8 @@ void QtProjectWizardContentPathsHeaderSearch::showValidationResult(
if (unresolvedIncludes.empty())
{
QMessageBox msgBox(m_window);
msgBox.setText(
QStringLiteral("<p>All include directives throughout the indexed files have been resolved.</p>"));
msgBox.setText(QStringLiteral(
"<p>All include directives throughout the indexed files have been resolved.</p>"));
msgBox.exec();
}
else
@@ -428,7 +430,8 @@ void QtProjectWizardContentPathsHeaderSearch::showValidationResult(
"conditional preprocessor "
"directives. This means that some of the unresolved includes may actually not be "
"required by the indexer.</p>")
.c_str(), m_window);
.c_str(),
m_window);
m_filesDialog->setup();
m_filesDialog->setCloseVisible(false);
@@ -166,11 +166,13 @@ bool QtProjectWizardContentPathsIndexedHeaders::check()
if (m_list->getPathsAsDisplayed().empty())
{
QMessageBox msgBox(m_window);
msgBox.setText(QStringLiteral("You didn't specify any Header Files & Directories to Index."));
msgBox.setText(
QStringLiteral("You didn't specify any Header Files & Directories to Index."));
msgBox.setInformativeText(QString::fromStdString(
"Sourcetrail will only index the source files listed in the " + m_projectKindName +
" file and none of the included header files."));
QPushButton* yesButton = msgBox.addButton(QStringLiteral("Continue"), QMessageBox::ButtonRole::YesRole);
QPushButton* yesButton = msgBox.addButton(
QStringLiteral("Continue"), QMessageBox::ButtonRole::YesRole);
msgBox.addButton(QStringLiteral("Cancel"), QMessageBox::ButtonRole::NoRole);
msgBox.setDefaultButton(yesButton);
@@ -197,7 +199,8 @@ void QtProjectWizardContentPathsIndexedHeaders::buttonClicked()
if (!codeblocksProjectPath.exists())
{
QMessageBox msgBox(m_window);
msgBox.setText(QStringLiteral("The provided Code::Blocks project path does not exist."));
msgBox.setText(
QStringLiteral("The provided Code::Blocks project path does not exist."));
msgBox.setDetailedText(QString::fromStdWString(codeblocksProjectPath.wstr()));
msgBox.exec();
return;
@@ -207,7 +210,8 @@ void QtProjectWizardContentPathsIndexedHeaders::buttonClicked()
"Select from Include Paths",
"The list contains all Include Paths found in the Code::Blocks project. Red paths "
"do not exist. Select the "
"paths containing the header files you want to index with Sourcetrail.", m_window);
"paths containing the header files you want to index with Sourcetrail.",
m_window);
m_filesDialog->setup();
connect(
@@ -241,7 +245,8 @@ void QtProjectWizardContentPathsIndexedHeaders::buttonClicked()
if (!cdbPath.exists())
{
QMessageBox msgBox(m_window);
msgBox.setText(QStringLiteral("The provided Compilation Database path does not exist."));
msgBox.setText(
QStringLiteral("The provided Compilation Database path does not exist."));
msgBox.setDetailedText(QString::fromStdWString(cdbPath.wstr()));
msgBox.exec();
return;
@@ -251,7 +256,8 @@ void QtProjectWizardContentPathsIndexedHeaders::buttonClicked()
"Select from Include Paths",
"The list contains all Include Paths found in the Compilation Database. Red paths "
"do not exist. Select the "
"paths containing the header files you want to index with Sourcetrail.", m_window);
"paths containing the header files you want to index with Sourcetrail.",
m_window);
m_filesDialog->setup();
connect(
@@ -72,10 +72,12 @@ bool QtProjectWizardContentPathsSource::check()
{
QMessageBox msgBox(m_window);
msgBox.setText(QStringLiteral("You didn't specify any 'Files & Directories to Index'."));
msgBox.setInformativeText(QStringLiteral(
"Sourcetrail will not index any files for this Source Group. Please add paths to files or directories "
msgBox.setInformativeText(
QStringLiteral("Sourcetrail will not index any files for this Source Group. Please add "
"paths to files or directories "
"that should be indexed."));
QPushButton* yesButton = msgBox.addButton(QStringLiteral("Continue"), QMessageBox::ButtonRole::YesRole);
QPushButton* yesButton = msgBox.addButton(
QStringLiteral("Continue"), QMessageBox::ButtonRole::YesRole);
msgBox.addButton(QStringLiteral("Cancel"), QMessageBox::ButtonRole::NoRole);
msgBox.setDefaultButton(yesButton);
+4 -2
View File
@@ -44,7 +44,8 @@ std::string QtHighlighter::highlightTypeToString(QtHighlighter::HighlightType ty
QtHighlighter::HighlightType QtHighlighter::highlightTypeFromString(const std::string& typeStr)
{
const std::array<HighlightType, 8> types = {HighlightType::COMMENT,
const std::array<HighlightType, 8> types = {
HighlightType::COMMENT,
HighlightType::DIRECTIVE,
HighlightType::FUNCTION,
HighlightType::KEYWORD,
@@ -68,7 +69,8 @@ void QtHighlighter::loadHighlightingRules()
{
ColorScheme* scheme = ColorScheme::getInstance().get();
const std::array<HighlightType, 8> types = {HighlightType::COMMENT,
const std::array<HighlightType, 8> types = {
HighlightType::COMMENT,
HighlightType::DIRECTIVE,
HighlightType::FUNCTION,
HighlightType::KEYWORD,
+2 -1
View File
@@ -69,6 +69,7 @@ void QtCompositeView::showFocusIndicator(bool focus)
{
m_onQtThread([=]() {
const std::string& colorName = focus ? "window/focus" : "search/background";
utility::setWidgetBackgroundColor(m_focusIndicator, ColorScheme::getInstance()->getColor(colorName));
utility::setWidgetBackgroundColor(
m_focusIndicator, ColorScheme::getInstance()->getColor(colorName));
});
}
+2 -1
View File
@@ -10,7 +10,8 @@ class QWidget;
class QtCompositeView: public CompositeView
{
public:
QtCompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId);
QtCompositeView(
ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId);
~QtCompositeView() = default;
// View implementation
+2 -1
View File
@@ -1056,7 +1056,8 @@ QtGraphNode* QtGraphView::createNodeRecursive(
}
else if (node->isExpandToggleNode())
{
newNode = new QtGraphNodeExpandToggle(node->isExpanded(), static_cast<int>(node->invisibleSubNodeCount));
newNode = new QtGraphNodeExpandToggle(
node->isExpanded(), static_cast<int>(node->invisibleSubNodeCount));
}
else if (node->isBundleNode())
{
+4 -1
View File
@@ -28,7 +28,10 @@ std::shared_ptr<MainView> QtViewFactory::createMainView(StorageAccess* storageAc
}
std::shared_ptr<CompositeView> QtViewFactory::createCompositeView(
ViewLayout* viewLayout, CompositeView::CompositeDirection direction, const std::string& name, const Id tabId) const
ViewLayout* viewLayout,
CompositeView::CompositeDirection direction,
const std::string& name,
const Id tabId) const
{
return View::createAndAddToLayout<QtCompositeView>(viewLayout, direction, name, tabId);
}
+6 -2
View File
@@ -36,9 +36,13 @@ private:
const QString shortcut;
Shortcut(const QString& name, const QString& shortcut);
static Shortcut defaultOrMac(const QString& name, const QString& defaultShortcut, const QString& macShortcut);
static Shortcut defaultOrMac(
const QString& name, const QString& defaultShortcut, const QString& macShortcut);
static Shortcut winMacOrLinux(
const QString& name, const QString& winShortcut, const QString& macShortcut, const QString& linuxShortcut);
const QString& name,
const QString& winShortcut,
const QString& macShortcut,
const QString& linuxShortcut);
};
QtShortcutTable* createTableWidget(const std::string& objectName);
+2 -1
View File
@@ -758,7 +758,8 @@ void QtMainWindow::updateRecentProjectsMenu()
{
m_recentProjectsMenu->clear();
const std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
const std::vector<FilePath> recentProjects =
ApplicationSettings::getInstance()->getRecentProjects();
const size_t recentProjectsCount = ApplicationSettings::getInstance()->getMaxRecentProjectsCount();
for (size_t i = 0; i < recentProjects.size() && i < recentProjectsCount; ++i)
@@ -63,8 +63,8 @@ void JavaEnvironmentFactory::createInstance(std::string classPath, std::string&
// options[3].optionString = const_cast<char*>("-Dcom.sun.management.jmxremote.port=9010");
// options[4].optionString =
// const_cast<char*>("-Dcom.sun.management.jmxremote.local.only=false"); options[5].optionString
// = const_cast<char*>("-Dcom.sun.management.jmxremote.authenticate=false"); options[6].optionString
// = const_cast<char*>("-Dcom.sun.management.jmxremote.ssl=false");
// = const_cast<char*>("-Dcom.sun.management.jmxremote.authenticate=false");
// options[6].optionString = const_cast<char*>("-Dcom.sun.management.jmxremote.ssl=false");
vm_args.version = JNI_VERSION_1_8;
vm_args.nOptions = optionCount;
@@ -56,7 +56,8 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupPythonEmpty::getIndexerC
if (!m_settings->getEnvironmentPath().empty())
{
args += L" --environment-path=\"" + m_settings->getEnvironmentPathExpandedAndAbsolute().wstr() + L"\"";
args += L" --environment-path=\"" +
m_settings->getEnvironmentPathExpandedAndAbsolute().wstr() + L"\"";
}
if (ApplicationSettings::getInstance()->getVerboseIndexerLoggingEnabled())
+29 -139
View File
@@ -142,11 +142,7 @@ TEST_CASE("token copies components when token is copied")
TEST_CASE("nodes are nodes")
{
Node a(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node a(1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
REQUIRE(a.isNode());
REQUIRE(!a.isEdge());
@@ -154,16 +150,8 @@ TEST_CASE("nodes are nodes")
TEST_CASE("edges are edges")
{
Node a(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node b(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node a(1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node b(2, NodeType(NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Edge e(3, Edge::EDGE_USAGE, &a, &b);
REQUIRE(!e.isNode());
@@ -172,43 +160,27 @@ TEST_CASE("edges are edges")
TEST_CASE("set type of node from constructor")
{
Node n(
1,
NodeType(NODE_FUNCTION),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node n(1, NodeType(NODE_FUNCTION), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
REQUIRE(NodeType(NODE_FUNCTION) == n.getType());
}
TEST_CASE("set type of node from non indexed")
{
Node n(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node n(2, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
n.setType(NodeType(NODE_CLASS));
REQUIRE(NodeType(NODE_CLASS) == n.getType());
}
TEST_CASE("can not change type of node after it was set")
{
Node n(
3,
NodeType(NODE_NAMESPACE),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node n(3, NodeType(NODE_NAMESPACE), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
n.setType(NodeType(NODE_CLASS));
REQUIRE(NodeType(NODE_CLASS) != n.getType());
}
TEST_CASE("node can be copied and keeps same id")
{
Node n(
4,
NodeType(NODE_NAMESPACE),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node n(4, NodeType(NODE_NAMESPACE), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node n2(n);
REQUIRE(&n != &n2);
@@ -219,27 +191,15 @@ TEST_CASE("node can be copied and keeps same id")
TEST_CASE("node type bit masking")
{
Node n(
1,
NodeType(NODE_NAMESPACE),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node n(1, NodeType(NODE_NAMESPACE), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
REQUIRE(n.isType(NODE_FUNCTION | NODE_NAMESPACE | NODE_CLASS));
REQUIRE(!n.isType(NODE_FUNCTION | NODE_METHOD | NODE_CLASS));
}
TEST_CASE("get type of edges")
{
Node a(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node b(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node a(1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node b(2, NodeType(NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Edge e(3, Edge::EDGE_USAGE, &a, &b);
REQUIRE(Edge::EDGE_USAGE == e.getType());
@@ -247,16 +207,8 @@ TEST_CASE("get type of edges")
TEST_CASE("edge can be copied and keeps same id")
{
Node a(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node b(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node a(1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node b(2, NodeType(NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Edge e(3, Edge::EDGE_USAGE, &a, &b);
Edge e2(e, &a, &b);
@@ -267,16 +219,8 @@ TEST_CASE("edge can be copied and keeps same id")
TEST_CASE("edge type bit masking")
{
Node a(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node b(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node a(1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node b(2, NodeType(NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Edge e(3, Edge::EDGE_USAGE, &a, &b);
REQUIRE(e.isType(Edge::EDGE_MEMBER | Edge::EDGE_CALL | Edge::EDGE_USAGE));
@@ -285,21 +229,9 @@ TEST_CASE("edge type bit masking")
TEST_CASE("node finds child node")
{
Node a(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node b(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node c(
3,
NodeType(NODE_SYMBOL),
NameHierarchy(L"C", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node a(1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node b(2, NodeType(NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node c(3, NodeType(NODE_SYMBOL), NameHierarchy(L"C", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Edge e(4, Edge::EDGE_MEMBER, &a, &b);
Edge e2(5, Edge::EDGE_MEMBER, &a, &c);
@@ -311,21 +243,9 @@ TEST_CASE("node finds child node")
TEST_CASE("node can not find child node")
{
Node a(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node b(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node c(
3,
NodeType(NODE_SYMBOL),
NameHierarchy(L"C", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node a(1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node b(2, NodeType(NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node c(3, NodeType(NODE_SYMBOL), NameHierarchy(L"C", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Edge e(4, Edge::EDGE_MEMBER, &a, &b);
Edge e2(5, Edge::EDGE_MEMBER, &a, &c);
@@ -336,21 +256,9 @@ TEST_CASE("node can not find child node")
TEST_CASE("node visits child nodes")
{
Node a(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node b(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node c(
3,
NodeType(NODE_SYMBOL),
NameHierarchy(L"C", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
Node a(1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node b(2, NodeType(NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node c(3, NodeType(NODE_SYMBOL), NameHierarchy(L"C", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Edge e(4, Edge::EDGE_MEMBER, &a, &b);
Edge e2(5, Edge::EDGE_MEMBER, &a, &c);
@@ -366,15 +274,9 @@ TEST_CASE("graph saves nodes")
{
Graph graph;
Node* a = graph.createNode(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node* b = graph.createNode(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
2, NodeType(NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
REQUIRE(2 == graph.getNodeCount());
REQUIRE(0 == graph.getEdgeCount());
@@ -393,15 +295,9 @@ TEST_CASE("graph saves edges")
Graph graph;
Node* a = graph.createNode(
1,
NodeType(NODE_FUNCTION),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
1, NodeType(NODE_FUNCTION), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Node* b = graph.createNode(
2,
NodeType(NODE_FUNCTION),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
2, NodeType(NODE_FUNCTION), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
Edge* e = graph.createEdge(3, Edge::EDGE_CALL, a, b);
@@ -417,15 +313,9 @@ TEST_CASE("graph removes nodes")
Graph graph;
Node* a = graph.createNode(
1,
NodeType(NODE_SYMBOL),
NameHierarchy(L"A", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
1, NodeType(NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
graph.createNode(
2,
NodeType(NODE_SYMBOL),
NameHierarchy(L"B", NAME_DELIMITER_CXX),
DEFINITION_EXPLICIT);
2, NodeType(NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
REQUIRE(2 == graph.getNodeCount());
REQUIRE(0 == graph.getEdgeCount());
+20 -7
View File
@@ -311,7 +311,8 @@ TEST_CASE("caseInsensitiveLess should return false when both wstrings are equal"
REQUIRE_FALSE(utility::caseInsensitiveLess(L"ab_cd!", L"ab_cd!"));
}
TEST_CASE("caseInsensitiveLess should return false when both wstrings have"
TEST_CASE(
"caseInsensitiveLess should return false when both wstrings have"
"different cases but after lower casing are equal")
{
REQUIRE_FALSE(utility::caseInsensitiveLess(L"ab_CD!", L"aB_cD!"));
@@ -337,32 +338,44 @@ TEST_CASE("caseInsensitiveLess should return false when second wstring is prefix
REQUIRE_FALSE(utility::caseInsensitiveLess(L"ab_cd!e", L"ab_cd!"));
}
TEST_CASE("caseInsensitiveLess should return true when after lower casing first wstring, first is prefix of second")
TEST_CASE(
"caseInsensitiveLess should return true when after lower casing first wstring, first is prefix "
"of second")
{
REQUIRE(utility::caseInsensitiveLess(L"aB_cd!", L"ab_cd!e"));
}
TEST_CASE("caseInsensitiveLess should return true when after lower casing second wstring, first is prefix of second")
TEST_CASE(
"caseInsensitiveLess should return true when after lower casing second wstring, first is "
"prefix of second")
{
REQUIRE(utility::caseInsensitiveLess(L"ab_cd!", L"ab_cD!e"));
}
TEST_CASE("caseInsensitiveLess should return true when after lower casing both wstrings, first is prefix of second")
TEST_CASE(
"caseInsensitiveLess should return true when after lower casing both wstrings, first is prefix "
"of second")
{
REQUIRE(utility::caseInsensitiveLess(L"aB_cd!", L"ab_cD!E"));
}
TEST_CASE("caseInsensitiveLess should return false when after lower casing first wstring, second is prefix of first")
TEST_CASE(
"caseInsensitiveLess should return false when after lower casing first wstring, second is "
"prefix of first")
{
REQUIRE_FALSE(utility::caseInsensitiveLess(L"ab_Cd!e", L"ab_cd!"));
}
TEST_CASE("caseInsensitiveLess should return false when after lower casing second wstring, second is prefix of first")
TEST_CASE(
"caseInsensitiveLess should return false when after lower casing second wstring, second is "
"prefix of first")
{
REQUIRE_FALSE(utility::caseInsensitiveLess(L"ab_cd!e", L"Ab_cd!"));
}
TEST_CASE("caseInsensitiveLess should return false when after lower casing both wstrings, second is prefix of first")
TEST_CASE(
"caseInsensitiveLess should return false when after lower casing both wstrings, second is "
"prefix of first")
{
REQUIRE_FALSE(utility::caseInsensitiveLess(L"ab_cD!E", L"aB_cd!"));
}