src: Apply clang-format and extend use to Java code (#973)
This commit is contained in:
+7
-3
@@ -1,5 +1,3 @@
|
||||
Language: Cpp
|
||||
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlignConsecutiveAssignments: false
|
||||
@@ -37,7 +35,7 @@ ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
FixNamespaceComments: true
|
||||
IncludeBlocks: Preserve
|
||||
IncludeBlocks: Preserve
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentWidth: 4
|
||||
@@ -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),
|
||||
@@ -11,26 +10,37 @@ public enum AccessKind
|
||||
DEFAULT(4),
|
||||
TEMPLATE_PARAMETER(5),
|
||||
TYPE_PARAMETER(6);
|
||||
|
||||
|
||||
private final int m_value;
|
||||
|
||||
private AccessKind(int value)
|
||||
|
||||
private AccessKind(int value)
|
||||
{
|
||||
this.m_value = value;
|
||||
this.m_value = value;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return m_value;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,55 +2,57 @@ package com.sourcetrail;
|
||||
|
||||
import com.sourcetrail.name.NameHierarchy;
|
||||
|
||||
public abstract class AstVisitorClient
|
||||
public abstract class AstVisitorClient
|
||||
{
|
||||
public abstract boolean getInterrupted();
|
||||
|
||||
|
||||
public abstract void logInfo(String info);
|
||||
|
||||
|
||||
public abstract void logWarning(String warning);
|
||||
|
||||
|
||||
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,
|
||||
Range range,
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
NameHierarchy symbolName,
|
||||
SymbolKind symbolKind,
|
||||
Range range,
|
||||
AccessKind access,
|
||||
DefinitionKind definitionKind);
|
||||
|
||||
public abstract 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);
|
||||
|
||||
public abstract 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);
|
||||
|
||||
public abstract void recordReference(
|
||||
ReferenceKind referenceKind, NameHierarchy referencedName, NameHierarchy contextName,
|
||||
Range range);
|
||||
ReferenceKind referenceKind,
|
||||
NameHierarchy referencedName,
|
||||
NameHierarchy contextName,
|
||||
Range range);
|
||||
|
||||
public abstract void recordQualifierLocation(
|
||||
NameHierarchy qualifierName,
|
||||
Range range);
|
||||
|
||||
public abstract void recordLocalSymbol(
|
||||
NameHierarchy symbolName,
|
||||
Range range);
|
||||
|
||||
public abstract void recordComment(
|
||||
Range range);
|
||||
|
||||
public abstract void recordError(
|
||||
String message, boolean fatal, boolean indexed,
|
||||
Range range);
|
||||
public abstract void recordQualifierLocation(NameHierarchy qualifierName, Range range);
|
||||
|
||||
public abstract void recordLocalSymbol(NameHierarchy symbolName, Range range);
|
||||
|
||||
public abstract void recordComment(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;
|
||||
@@ -29,17 +28,17 @@ import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
|
||||
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);
|
||||
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
@@ -56,12 +55,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChildren(node.bodyDeclarations());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(EnumDeclaration node)
|
||||
|
||||
@Override public boolean visit(EnumDeclaration node)
|
||||
{
|
||||
boolean visitChildren = super.visit(node);
|
||||
|
||||
@@ -80,18 +78,17 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChildren(node.bodyDeclarations());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(EnumConstantDeclaration node)
|
||||
|
||||
@Override public boolean visit(EnumConstantDeclaration node)
|
||||
{
|
||||
boolean visitChildren = super.visit(node);
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
// we don't visit and record the name of enum constant declarations because
|
||||
// we don't visit and record the name of enum constant declarations because
|
||||
// this would create an unwanted self-reference.
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
acceptChild(node.getJavadoc());
|
||||
@@ -100,18 +97,17 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChild(node.getAnonymousClassDeclaration());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(VariableDeclarationFragment node)
|
||||
|
||||
@Override public boolean visit(VariableDeclarationFragment node)
|
||||
{
|
||||
boolean visitChildren = super.visit(node);
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
// we don't visit and record the name of field declarations because
|
||||
// we don't visit and record the name of field declarations because
|
||||
// this would create an unwanted self-reference.
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
if (!(node.getParent() instanceof FieldDeclaration))
|
||||
@@ -122,20 +118,19 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChild(node.getInitializer());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
@@ -147,12 +142,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@@ -164,12 +158,11 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChild(node.getName());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@@ -181,15 +174,14 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChild(node.getName());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MethodInvocation node)
|
||||
|
||||
@Override public boolean visit(MethodInvocation node)
|
||||
{
|
||||
boolean visitChildren = super.visit(node);
|
||||
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
@@ -199,16 +191,15 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChildren(node.arguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
@@ -217,15 +208,14 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChildren(node.arguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(ConstructorInvocation node)
|
||||
@Override public boolean visit(ConstructorInvocation node)
|
||||
{
|
||||
boolean visitChildren = super.visit(node);
|
||||
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
@@ -233,15 +223,14 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChildren(node.arguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SuperConstructorInvocation node)
|
||||
@Override public boolean visit(SuperConstructorInvocation node)
|
||||
{
|
||||
boolean visitChildren = super.visit(node);
|
||||
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
@@ -250,32 +239,30 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChildren(node.arguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
acceptChildren(node.typeArguments());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
@@ -284,16 +271,15 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChild(node.getName());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
@@ -301,38 +287,36 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
acceptChild(node.getName());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
if (visitChildren)
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
acceptChildren(node.typeArguments());
|
||||
acceptChild(node.getName());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(ClassInstanceCreation node)
|
||||
|
||||
@Override public boolean visit(ClassInstanceCreation node)
|
||||
{
|
||||
boolean visitChildren = super.visit(node);
|
||||
|
||||
|
||||
if (visitChildren)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
|
||||
acceptChild(node.getExpression());
|
||||
acceptChildren(node.typeArguments());
|
||||
|
||||
|
||||
if (node.getAnonymousClassDeclaration() != null)
|
||||
{
|
||||
m_typeRefKind.push(ReferenceKind.INHERITANCE);
|
||||
@@ -343,25 +327,23 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
{
|
||||
acceptChild(node.getType());
|
||||
}
|
||||
|
||||
|
||||
acceptChildren(node.arguments());
|
||||
acceptChild(node.getAnonymousClassDeclaration());
|
||||
m_typeRefKind.pop();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@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 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()
|
||||
{
|
||||
if (!m_typeRefKind.isEmpty())
|
||||
{
|
||||
@@ -369,7 +351,7 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
}
|
||||
return ReferenceKind.TYPE_USAGE;
|
||||
}
|
||||
|
||||
|
||||
private void acceptChild(ASTNode node)
|
||||
{
|
||||
if (node != null)
|
||||
@@ -377,7 +359,7 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
node.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void acceptChildren(List<?> nodes)
|
||||
{
|
||||
if (nodes != null)
|
||||
@@ -386,10 +368,9 @@ public class ContextAwareAstVisitor extends AstVisitor
|
||||
{
|
||||
if (node instanceof ASTNode)
|
||||
{
|
||||
acceptChild((ASTNode) node);
|
||||
acceptChild((ASTNode)node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,30 +2,29 @@ package com.sourcetrail;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.core.dom.IBinding;
|
||||
|
||||
public class ContextList
|
||||
{
|
||||
private Set<String> m_bindingKeys = new HashSet<>();
|
||||
|
||||
|
||||
public ContextList copy()
|
||||
{
|
||||
ContextList contextList = new ContextList();
|
||||
|
||||
contextList.m_bindingKeys = new HashSet<>(m_bindingKeys);
|
||||
|
||||
|
||||
return contextList;
|
||||
}
|
||||
|
||||
public void add(IBinding v)
|
||||
|
||||
public void add(IBinding v)
|
||||
{
|
||||
if (v != null)
|
||||
{
|
||||
m_bindingKeys.add(v.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean contains(IBinding v)
|
||||
{
|
||||
return v != null && m_bindingKeys.contains(v.getKey());
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
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);
|
||||
|
||||
private final int m_value;
|
||||
|
||||
private DefinitionKind(int value)
|
||||
{
|
||||
this.m_value = value;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
private final int m_value;
|
||||
|
||||
private DefinitionKind(int value)
|
||||
{
|
||||
this.m_value = value;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,20 +3,20 @@ package com.sourcetrail;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class FileContent
|
||||
public class FileContent
|
||||
{
|
||||
private List<String> m_lines;
|
||||
|
||||
|
||||
public FileContent(String text)
|
||||
{
|
||||
m_lines = Arrays.asList(text.split("\\r?\\n"));
|
||||
}
|
||||
|
||||
|
||||
public Position findStartPosition(String s)
|
||||
{
|
||||
return findStartPosition(s, new Position(1, 1));
|
||||
}
|
||||
|
||||
|
||||
public Position findStartPosition(String s, Position from)
|
||||
{
|
||||
int lineIndex = from.line - 1;
|
||||
@@ -43,9 +43,8 @@ public class FileContent
|
||||
public Range findRange(String s, Position from)
|
||||
{
|
||||
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;
|
||||
@@ -26,55 +25,77 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
|
||||
import org.eclipse.jdt.core.dom.LineComment;
|
||||
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 class JavaIndexer
|
||||
{
|
||||
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
|
||||
{
|
||||
astVisitorClient.logInfo("indexing source file: " + filePath);
|
||||
|
||||
|
||||
Path path = Paths.get(filePath);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
{
|
||||
String convertedLanguageStandard = convertLanguageStandard(languageStandard);
|
||||
astVisitorClient.logInfo("using language standard " + convertedLanguageStandard);
|
||||
|
||||
|
||||
Hashtable<String, String> options = JavaCore.getOptions();
|
||||
options.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
|
||||
options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
|
||||
options.put(JavaCore.COMPILER_SOURCE, convertedLanguageStandard);
|
||||
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, convertedLanguageStandard);
|
||||
options.put(JavaCore.COMPILER_COMPLIANCE, convertedLanguageStandard);
|
||||
options.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
|
||||
options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
|
||||
options.put(JavaCore.COMPILER_SOURCE, convertedLanguageStandard);
|
||||
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, convertedLanguageStandard);
|
||||
options.put(JavaCore.COMPILER_COMPLIANCE, convertedLanguageStandard);
|
||||
parser.setCompilerOptions(options);
|
||||
}
|
||||
|
||||
|
||||
parser.setUnitName(path.getFileName().toString());
|
||||
|
||||
|
||||
List<String> classpath = new ArrayList<>();
|
||||
List<String> sources = new ArrayList<>();
|
||||
|
||||
|
||||
for (String classPathEntry: classPath.split("\\;"))
|
||||
{
|
||||
{
|
||||
if (classPathEntry.endsWith(".jar"))
|
||||
{
|
||||
classpath.add(classPathEntry);
|
||||
}
|
||||
else if(classPathEntry.endsWith(".aar"))
|
||||
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());
|
||||
@@ -83,47 +104,50 @@ public class JavaIndexer
|
||||
else if (!classPathEntry.isEmpty())
|
||||
{
|
||||
sources.add(classPathEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
CompilationUnit cu = (CompilationUnit)parser.createAST(null);
|
||||
|
||||
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");
|
||||
|
||||
|
||||
cu.accept(visitor);
|
||||
|
||||
|
||||
for (IProblem problem: cu.getProblems())
|
||||
{
|
||||
if (problem.isError())
|
||||
{
|
||||
Range range = new Range(
|
||||
cu.getLineNumber(problem.getSourceStart()),
|
||||
cu.getColumnNumber(problem.getSourceStart() + 1),
|
||||
cu.getLineNumber(problem.getSourceEnd()),
|
||||
cu.getColumnNumber(problem.getSourceEnd()) + 1);
|
||||
|
||||
cu.getLineNumber(problem.getSourceStart()),
|
||||
cu.getColumnNumber(problem.getSourceStart() + 1),
|
||||
cu.getLineNumber(problem.getSourceEnd()),
|
||||
cu.getColumnNumber(problem.getSourceEnd()) + 1);
|
||||
|
||||
astVisitorClient.recordError(problem.getMessage(), false, true, range);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (Object commentObject: cu.getCommentList())
|
||||
{
|
||||
if ((commentObject instanceof LineComment) || (commentObject instanceof BlockComment))
|
||||
{
|
||||
((Comment) commentObject).accept(visitor);
|
||||
((Comment)commentObject).accept(visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,15 +159,16 @@ public class JavaIndexer
|
||||
astVisitorClient.logError(sw.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getPackageName(String fileContent)
|
||||
{
|
||||
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);
|
||||
CompilationUnit cu = (CompilationUnit)parser.createAST(null);
|
||||
PackageDeclaration packageDeclaration = cu.getPackage();
|
||||
if (packageDeclaration != null)
|
||||
{
|
||||
@@ -151,138 +176,181 @@ public class JavaIndexer
|
||||
}
|
||||
return packageName;
|
||||
}
|
||||
|
||||
|
||||
public static void clearCaches()
|
||||
{
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
|
||||
|
||||
private static String convertLanguageStandard(String s)
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case "1":
|
||||
return JavaCore.VERSION_1_1;
|
||||
case "2":
|
||||
return JavaCore.VERSION_1_2;
|
||||
case "3":
|
||||
return JavaCore.VERSION_1_3;
|
||||
case "4":
|
||||
return JavaCore.VERSION_1_4;
|
||||
case "5":
|
||||
return JavaCore.VERSION_1_5;
|
||||
case "6":
|
||||
return JavaCore.VERSION_1_6;
|
||||
case "7":
|
||||
return JavaCore.VERSION_1_7;
|
||||
case "8":
|
||||
return JavaCore.VERSION_1_8;
|
||||
case "9":
|
||||
return JavaCore.VERSION_9;
|
||||
case "10":
|
||||
return JavaCore.VERSION_10;
|
||||
case "11":
|
||||
return JavaCore.VERSION_11;
|
||||
case "12":
|
||||
default:
|
||||
return JavaCore.VERSION_12;
|
||||
}
|
||||
{
|
||||
case "1":
|
||||
return JavaCore.VERSION_1_1;
|
||||
case "2":
|
||||
return JavaCore.VERSION_1_2;
|
||||
case "3":
|
||||
return JavaCore.VERSION_1_3;
|
||||
case "4":
|
||||
return JavaCore.VERSION_1_4;
|
||||
case "5":
|
||||
return JavaCore.VERSION_1_5;
|
||||
case "6":
|
||||
return JavaCore.VERSION_1_6;
|
||||
case "7":
|
||||
return JavaCore.VERSION_1_7;
|
||||
case "8":
|
||||
return JavaCore.VERSION_1_8;
|
||||
case "9":
|
||||
return JavaCore.VERSION_9;
|
||||
case "10":
|
||||
return JavaCore.VERSION_10;
|
||||
case "11":
|
||||
return JavaCore.VERSION_11;
|
||||
case "12":
|
||||
default:
|
||||
return JavaCore.VERSION_12;
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
try
|
||||
|
||||
try
|
||||
{
|
||||
OutputStream output = new FileOutputStream(tempFile);
|
||||
try
|
||||
try
|
||||
{
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1)
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1)
|
||||
{
|
||||
output.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
finally
|
||||
}
|
||||
finally
|
||||
{
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
}
|
||||
finally
|
||||
{
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// the following methods are defined in the native c++ code
|
||||
|
||||
static public native boolean getInterrupted(int address);
|
||||
|
||||
|
||||
static public native void logInfo(int address, String info);
|
||||
|
||||
|
||||
static public native void logWarning(int address, String warning);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
int address, String qualifierName, int beginLine, int beginColumn, int endLine, int endColumn);
|
||||
|
||||
static public native void recordLocalSymbol(
|
||||
int address, String symbolName, int beginLine, int beginColumn, int endLine, int endColumn);
|
||||
|
||||
int address, String symbolName, int beginLine, int beginColumn, int endLine, int endColumn);
|
||||
|
||||
static public native void recordComment(
|
||||
int address, int beginLine, int beginColumn, int endLine, int endColumn);
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.sourcetrail;
|
||||
import com.sourcetrail.name.NameElement;
|
||||
import com.sourcetrail.name.NameHierarchy;
|
||||
|
||||
public class JavaIndexerAstVisitorClient extends AstVisitorClient
|
||||
public class JavaIndexerAstVisitorClient extends AstVisitorClient
|
||||
{
|
||||
private int m_address;
|
||||
private String m_javaLangPackageName;
|
||||
@@ -12,135 +12,187 @@ public class JavaIndexerAstVisitorClient extends AstVisitorClient
|
||||
public JavaIndexerAstVisitorClient(int address)
|
||||
{
|
||||
m_address = address;
|
||||
|
||||
|
||||
NameHierarchy javaLangPackageNameHierarchy = new NameHierarchy();
|
||||
javaLangPackageNameHierarchy.push(new NameElement("java"));
|
||||
javaLangPackageNameHierarchy.push(new NameElement("lang"));
|
||||
m_javaLangPackageName = javaLangPackageNameHierarchy.serialize();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package com.sourcetrail;
|
||||
|
||||
public class Position
|
||||
public class Position
|
||||
{
|
||||
public int line = 0;
|
||||
public int column = 0;
|
||||
|
||||
public Position()
|
||||
{
|
||||
}
|
||||
|
||||
public Position() {}
|
||||
|
||||
public Position(int line, int column)
|
||||
{
|
||||
this.line = line;
|
||||
|
||||
@@ -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,45 +30,41 @@ 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
|
||||
public class QualifierVisitor
|
||||
{
|
||||
protected AstVisitorClient m_client = null;
|
||||
private File m_filePath;
|
||||
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;
|
||||
m_compilationUnit = compilationUnit;
|
||||
m_recordSymbolKinds = recordSymbolKinds;
|
||||
}
|
||||
|
||||
public void recordQualifierOfNode(ImportDeclaration node)
|
||||
public void recordQualifierOfNode(ImportDeclaration node)
|
||||
{
|
||||
if (node != null && node.getName() instanceof QualifiedName)
|
||||
{
|
||||
recordNodeAsQualifier(((QualifiedName) node.getName()).getQualifier());
|
||||
recordNodeAsQualifier(((QualifiedName)node.getName()).getQualifier());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void recordQualifierOfNode(SimpleType node)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
if (node.getName() instanceof QualifiedName)
|
||||
{
|
||||
recordNodeAsQualifier(((QualifiedName) node.getName()).getQualifier());
|
||||
recordNodeAsQualifier(((QualifiedName)node.getName()).getQualifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void recordQualifierOfNode(QualifiedType node)
|
||||
{
|
||||
if (node != null)
|
||||
@@ -73,7 +72,7 @@ public class QualifierVisitor
|
||||
recordNodeAsQualifier(node.getQualifier());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void recordQualifierOfNode(NameQualifiedType node)
|
||||
{
|
||||
if (node != null)
|
||||
@@ -121,11 +120,11 @@ public class QualifierVisitor
|
||||
recordNodeAsQualifier(node.getExpression(), fileContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void recordQualifierOfNode(SuperMethodInvocation node, FileContent fileContent)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveMethodBinding();
|
||||
if (methodBinding != null)
|
||||
{
|
||||
@@ -133,23 +132,23 @@ public class QualifierVisitor
|
||||
if (typeBinding != null)
|
||||
{
|
||||
m_client.recordQualifierLocation(
|
||||
BindingNameResolver
|
||||
.getQualifiedName(typeBinding, m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
fileContent.findRange("super", getRange(node).begin));
|
||||
BindingNameResolver
|
||||
.getQualifiedName(typeBinding, m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
fileContent.findRange("super", getRange(node).begin));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
recordNodeAsQualifier(node.getQualifier());
|
||||
}
|
||||
}
|
||||
|
||||
public void recordQualifierOfNode(CreationReference node)
|
||||
public void recordQualifierOfNode(CreationReference node)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
{
|
||||
recordNodeAsQualifier(node.getType());
|
||||
}
|
||||
}
|
||||
@@ -165,7 +164,7 @@ public class QualifierVisitor
|
||||
public void recordQualifierOfNode(SuperMethodReference node, FileContent fileContent)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
{
|
||||
IMethodBinding methodBinding = node.resolveMethodBinding();
|
||||
if (methodBinding != null)
|
||||
{
|
||||
@@ -173,15 +172,15 @@ public class QualifierVisitor
|
||||
if (typeBinding != null)
|
||||
{
|
||||
m_client.recordQualifierLocation(
|
||||
BindingNameResolver
|
||||
.getQualifiedName(typeBinding, m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
fileContent.findRange("super", getRange(node).begin));
|
||||
BindingNameResolver
|
||||
.getQualifiedName(typeBinding, m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
fileContent.findRange("super", getRange(node).begin));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
recordNodeAsQualifier(node.getQualifier());
|
||||
}
|
||||
}
|
||||
@@ -193,79 +192,80 @@ public class QualifierVisitor
|
||||
recordNodeAsQualifier(node.getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void recordNodeAsQualifier(Expression node, FileContent fileContent) {
|
||||
|
||||
|
||||
private void recordNodeAsQualifier(Expression node, FileContent fileContent)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
if (node instanceof Name)
|
||||
{
|
||||
recordNodeAsQualifier((Name) node);
|
||||
recordNodeAsQualifier((Name)node);
|
||||
}
|
||||
else if (node instanceof SuperFieldAccess)
|
||||
{
|
||||
SuperFieldAccess expression = (SuperFieldAccess) node;
|
||||
SuperFieldAccess expression = (SuperFieldAccess)node;
|
||||
IVariableBinding fieldBinding = expression.resolveFieldBinding();
|
||||
|
||||
|
||||
if (fieldBinding != null)
|
||||
{
|
||||
m_client.recordQualifierLocation(
|
||||
BindingNameResolver
|
||||
.getQualifiedName(fieldBinding.getDeclaringClass(), m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
fileContent.findRange(
|
||||
"super",
|
||||
expression.getQualifier() != null
|
||||
? getRange(expression.getQualifier()).end
|
||||
: getRange(expression).begin));
|
||||
BindingNameResolver
|
||||
.getQualifiedName(
|
||||
fieldBinding.getDeclaringClass(), m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
fileContent.findRange(
|
||||
"super",
|
||||
expression.getQualifier() != null ? getRange(expression.getQualifier()).end
|
||||
: getRange(expression).begin));
|
||||
}
|
||||
|
||||
|
||||
recordNodeAsQualifier(expression.getQualifier());
|
||||
}
|
||||
else if (node instanceof ThisExpression)
|
||||
{
|
||||
ThisExpression expression = (ThisExpression) node;
|
||||
|
||||
ThisExpression expression = (ThisExpression)node;
|
||||
|
||||
m_client.recordQualifierLocation(
|
||||
BindingNameResolver
|
||||
.getQualifiedName(expression.resolveTypeBinding(), m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
fileContent.findRange(
|
||||
"this",
|
||||
expression.getQualifier() != null
|
||||
? getRange(expression.getQualifier()).end
|
||||
: getRange(expression).begin));
|
||||
|
||||
BindingNameResolver
|
||||
.getQualifiedName(
|
||||
expression.resolveTypeBinding(), m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
fileContent.findRange(
|
||||
"this",
|
||||
expression.getQualifier() != null ? getRange(expression.getQualifier()).end
|
||||
: getRange(expression).begin));
|
||||
|
||||
recordNodeAsQualifier(expression.getQualifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void recordNodeAsQualifier(Type node)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
{
|
||||
if (node instanceof SimpleType)
|
||||
{
|
||||
recordNodeAsQualifier(((SimpleType) node).getName());
|
||||
recordNodeAsQualifier(((SimpleType)node).getName());
|
||||
}
|
||||
else if (node instanceof QualifiedType)
|
||||
{
|
||||
recordNodeAsQualifier(((QualifiedType) node).getName());
|
||||
recordNodeAsQualifier(((QualifiedType) node).getQualifier());
|
||||
recordNodeAsQualifier(((QualifiedType)node).getName());
|
||||
recordNodeAsQualifier(((QualifiedType)node).getQualifier());
|
||||
}
|
||||
else if (node instanceof NameQualifiedType)
|
||||
{
|
||||
recordNodeAsQualifier(((NameQualifiedType) node).getName());
|
||||
recordNodeAsQualifier(((NameQualifiedType) node).getQualifier());
|
||||
recordNodeAsQualifier(((NameQualifiedType)node).getName());
|
||||
recordNodeAsQualifier(((NameQualifiedType)node).getQualifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void recordNodeAsQualifier(Name node)
|
||||
{
|
||||
if (node != null)
|
||||
@@ -276,47 +276,47 @@ public class QualifierVisitor
|
||||
Range range = getRange(node);
|
||||
if (node instanceof QualifiedName)
|
||||
{
|
||||
range = getRange(((QualifiedName) node).getName());
|
||||
range = getRange(((QualifiedName)node).getName());
|
||||
}
|
||||
|
||||
|
||||
m_client.recordQualifierLocation(
|
||||
BindingNameResolver
|
||||
.getQualifiedName((ITypeBinding) binding, m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
range);
|
||||
BindingNameResolver
|
||||
.getQualifiedName((ITypeBinding)binding, m_filePath, m_compilationUnit)
|
||||
.orElse(TypeName.unsolved())
|
||||
.toDeclName()
|
||||
.toNameHierarchy(),
|
||||
range);
|
||||
}
|
||||
else if (binding instanceof IPackageBinding)
|
||||
{
|
||||
Range range = getRange(node);
|
||||
if (node instanceof QualifiedName)
|
||||
{
|
||||
range = getRange(((QualifiedName) node).getName());
|
||||
range = getRange(((QualifiedName)node).getName());
|
||||
}
|
||||
|
||||
NameHierarchy symbolName = BindingNameResolver
|
||||
.getQualifiedName((IPackageBinding) binding, m_filePath, m_compilationUnit)
|
||||
|
||||
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)
|
||||
{
|
||||
recordNodeAsQualifier(((QualifiedName) node).getQualifier());
|
||||
recordNodeAsQualifier(((QualifiedName)node).getQualifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Range getRange(ASTNode node)
|
||||
{
|
||||
return Utility.getRange(node, m_compilationUnit);
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
package com.sourcetrail;
|
||||
|
||||
public class Range
|
||||
public class Range
|
||||
{
|
||||
public Position begin = new Position();
|
||||
public Position end = new Position();
|
||||
|
||||
public Range()
|
||||
{
|
||||
}
|
||||
|
||||
public Range(int beginLine, int beginColumn, int endLine, int endColumn)
|
||||
|
||||
public Range() {}
|
||||
|
||||
public Range(int beginLine, int beginColumn, int endLine, int endColumn)
|
||||
{
|
||||
this.begin.line = beginLine;
|
||||
this.begin.column = beginColumn;
|
||||
this.end.line = endLine;
|
||||
this.end.column = endColumn;
|
||||
}
|
||||
|
||||
public Range(Position begin, Position end)
|
||||
|
||||
public Range(Position begin, Position end)
|
||||
{
|
||||
this.begin.line = begin.line;
|
||||
this.begin.column = begin.column;
|
||||
|
||||
@@ -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),
|
||||
@@ -14,16 +13,16 @@ public enum ReferenceKind
|
||||
IMPORT(9),
|
||||
MACRO_USAGE(10),
|
||||
ANNOTATION_USAGE(11);
|
||||
|
||||
private final int m_value;
|
||||
|
||||
private ReferenceKind(int value)
|
||||
{
|
||||
this.m_value = value;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
private final int m_value;
|
||||
|
||||
private ReferenceKind(int value)
|
||||
{
|
||||
this.m_value = value;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
@@ -21,16 +20,16 @@ public enum SymbolKind
|
||||
TYPE_PARAMETER(17),
|
||||
UNION(18),
|
||||
TYPE_MAX(19);
|
||||
|
||||
private final int m_value;
|
||||
|
||||
private SymbolKind(int value)
|
||||
{
|
||||
this.m_value = value;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
private final int m_value;
|
||||
|
||||
private SymbolKind(int value)
|
||||
{
|
||||
this.m_value = value;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
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;
|
||||
import org.eclipse.jdt.core.dom.Javadoc;
|
||||
|
||||
public class Utility
|
||||
public class Utility
|
||||
{
|
||||
public static Range getRange(ASTNode node, CompilationUnit compilationUnit)
|
||||
{
|
||||
int startPosition = node.getStartPosition() + 1;
|
||||
int endPosition = node.getStartPosition() + node.getLength() - 1;
|
||||
|
||||
if (node instanceof BodyDeclaration && ((BodyDeclaration) node).getJavadoc() != null)
|
||||
|
||||
if (node instanceof BodyDeclaration && ((BodyDeclaration)node).getJavadoc() != null)
|
||||
{
|
||||
Javadoc javadoc = ((BodyDeclaration) node).getJavadoc();
|
||||
Javadoc javadoc = ((BodyDeclaration)node).getJavadoc();
|
||||
startPosition = javadoc.getStartPosition() + javadoc.getLength() + 2;
|
||||
}
|
||||
|
||||
|
||||
return new Range(
|
||||
compilationUnit.getLineNumber(startPosition),
|
||||
compilationUnit.getColumnNumber(startPosition),
|
||||
compilationUnit.getLineNumber(endPosition),
|
||||
compilationUnit.getColumnNumber(endPosition) + 1);
|
||||
compilationUnit.getLineNumber(startPosition),
|
||||
compilationUnit.getColumnNumber(startPosition),
|
||||
compilationUnit.getLineNumber(endPosition),
|
||||
compilationUnit.getColumnNumber(endPosition) + 1);
|
||||
}
|
||||
|
||||
|
||||
public static String getFilenameWithoutExtension(Path filePath)
|
||||
{
|
||||
return filePath.getFileName().toString().replaceFirst("[.][^.]+$", "");
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.sourcetrail;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.jdt.core.dom.ASTNode;
|
||||
import org.eclipse.jdt.core.dom.CompilationUnit;
|
||||
|
||||
public class VerboseContextAwareAstVisitor extends ContextAwareAstVisitor
|
||||
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,10 +17,12 @@ 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 += "| ";
|
||||
}
|
||||
|
||||
|
||||
public void postVisit(ASTNode node)
|
||||
{
|
||||
indentation = indentation.substring(0, indentation.length() - 2);
|
||||
|
||||
@@ -9,20 +9,19 @@ 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;
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
|
||||
public class InfoRetriever
|
||||
public class InfoRetriever
|
||||
{
|
||||
public static String getMainSrcDirs(String projectRootPath, String initScriptPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
String ret = "";
|
||||
|
||||
|
||||
List<String> srcDirs = getSrcDirs("printMainSrcDirs", projectRootPath, initScriptPath);
|
||||
for (int i = 0; i < srcDirs.size(); i++)
|
||||
{
|
||||
@@ -32,7 +31,7 @@ public class InfoRetriever
|
||||
}
|
||||
ret += srcDirs.get(i);
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch (GradleException e)
|
||||
@@ -40,7 +39,7 @@ public class InfoRetriever
|
||||
return "[ERROR] " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getTestSrcDirs(String projectRootPath, String initScriptPath)
|
||||
{
|
||||
try
|
||||
@@ -56,7 +55,7 @@ public class InfoRetriever
|
||||
}
|
||||
ret += srcDirs.get(i);
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch (GradleException e)
|
||||
@@ -64,50 +63,58 @@ public class InfoRetriever
|
||||
return "[ERROR] " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
{
|
||||
String output = executeTask(taskName, projectRootPath, initScriptPath, null);
|
||||
|
||||
|
||||
List<String> paths = new ArrayList<>();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new StringReader(output)))
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new StringReader(output)))
|
||||
{
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
paths.add(line);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
paths.add(line);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO: LOGERROR
|
||||
}
|
||||
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
private static String executeTask(String taskName, String projectRootPath, String initScriptPath, List<String> additionalArguments) throws GradleException
|
||||
{
|
||||
ProjectConnection connection = GradleConnector
|
||||
.newConnector()
|
||||
.forProjectDirectory(new File(projectRootPath))
|
||||
.connect();
|
||||
|
||||
|
||||
private static String executeTask(
|
||||
String taskName, String projectRootPath, String initScriptPath, List<String> additionalArguments)
|
||||
throws GradleException
|
||||
{
|
||||
ProjectConnection connection =
|
||||
GradleConnector.newConnector().forProjectDirectory(new File(projectRootPath)).connect();
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
|
||||
|
||||
try
|
||||
|
||||
try
|
||||
{
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.add("--init-script");
|
||||
@@ -118,28 +125,29 @@ public class InfoRetriever
|
||||
{
|
||||
arguments.addAll(additionalArguments);
|
||||
}
|
||||
|
||||
BuildLauncher Launcher = connection.newBuild().forTasks(taskName)
|
||||
.withArguments(arguments)
|
||||
.setStandardOutput(new PrintStream(outputStream))
|
||||
.setStandardError(new PrintStream(errorStream));
|
||||
|
||||
|
||||
BuildLauncher Launcher = connection.newBuild()
|
||||
.forTasks(taskName)
|
||||
.withArguments(arguments)
|
||||
.setStandardOutput(new PrintStream(outputStream))
|
||||
.setStandardError(new PrintStream(errorStream));
|
||||
|
||||
Launcher.run();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// TODO: LOGERROR
|
||||
}
|
||||
finally
|
||||
finally
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
|
||||
|
||||
if (!errorStream.toString().isEmpty())
|
||||
{
|
||||
throw new GradleException(errorStream.toString());
|
||||
}
|
||||
|
||||
|
||||
return outputStream.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -21,34 +20,36 @@ public class DeclName implements SymbolName
|
||||
declName.m_isUnsolved = true;
|
||||
return declName;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public static DeclName localSymbol(DeclName methodContextName, int id)
|
||||
{
|
||||
DeclName declName = new DeclName(methodContextName + "<" + id + ">");
|
||||
declName.m_isLocal = true;
|
||||
return declName;
|
||||
}
|
||||
|
||||
|
||||
public static DeclName globalSymbol(File fileContext, int id)
|
||||
{
|
||||
DeclName declName = new DeclName(fileContext.getName() + "<" + id + ">");
|
||||
declName.m_isGlobal = true;
|
||||
return declName;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public static DeclName fromDotSeparatedString(String s)
|
||||
{
|
||||
DeclName declName = null;
|
||||
@@ -63,60 +64,60 @@ public class DeclName implements SymbolName
|
||||
{
|
||||
declName = new DeclName(s, null);
|
||||
}
|
||||
|
||||
|
||||
return declName;
|
||||
}
|
||||
|
||||
|
||||
public DeclName(String name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
|
||||
public DeclName(String name, List<String> typeParameterNames)
|
||||
{
|
||||
m_name = name;
|
||||
m_typeParameterNames = typeParameterNames;
|
||||
}
|
||||
|
||||
|
||||
public void setParent(DeclName parent)
|
||||
{
|
||||
m_parent = parent;
|
||||
}
|
||||
|
||||
|
||||
public DeclName getParent()
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
public boolean getIsUnsolved()
|
||||
{
|
||||
return m_isUnsolved;
|
||||
}
|
||||
|
||||
|
||||
public boolean getIsAnonymous()
|
||||
{
|
||||
return m_isAnonymous;
|
||||
}
|
||||
|
||||
|
||||
public boolean getIsLocal()
|
||||
{
|
||||
return m_isLocal;
|
||||
}
|
||||
|
||||
|
||||
public boolean getIsGlobal()
|
||||
{
|
||||
return m_isGlobal;
|
||||
}
|
||||
|
||||
|
||||
public NameHierarchy toNameHierarchy()
|
||||
{
|
||||
NameHierarchy nameHierarchy;
|
||||
|
||||
|
||||
if (m_parent != null)
|
||||
{
|
||||
nameHierarchy = m_parent.toNameHierarchy();
|
||||
@@ -125,12 +126,12 @@ public class DeclName implements SymbolName
|
||||
{
|
||||
nameHierarchy = new NameHierarchy();
|
||||
}
|
||||
|
||||
|
||||
nameHierarchy.push(new NameElement(m_name + getTypeParameterString()));
|
||||
|
||||
|
||||
return nameHierarchy;
|
||||
}
|
||||
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String string = "";
|
||||
@@ -139,13 +140,13 @@ public class DeclName implements SymbolName
|
||||
string = m_parent.toString();
|
||||
string += ".";
|
||||
}
|
||||
|
||||
|
||||
string += m_name;
|
||||
string += getTypeParameterString();
|
||||
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
public String getTypeParameterString()
|
||||
{
|
||||
String string = "";
|
||||
@@ -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)
|
||||
|
||||
@@ -9,27 +9,34 @@ public class FunctionDeclName extends DeclName
|
||||
private TypeName m_returnTypeName = null;
|
||||
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)
|
||||
@@ -40,23 +47,23 @@ public class FunctionDeclName extends DeclName
|
||||
{
|
||||
prefix += m_returnTypeName.toString();
|
||||
}
|
||||
|
||||
|
||||
String postfix = getParameterString();
|
||||
|
||||
|
||||
NameHierarchy nameHierarchy = super.toNameHierarchy();
|
||||
|
||||
|
||||
Optional<NameElement> nameElement = nameHierarchy.peek();
|
||||
if (nameElement.isPresent())
|
||||
{
|
||||
String name = nameElement.get().getName();
|
||||
|
||||
|
||||
nameHierarchy.pop();
|
||||
nameHierarchy.push(new NameElement(name, prefix, postfix));
|
||||
}
|
||||
|
||||
|
||||
return nameHierarchy;
|
||||
}
|
||||
|
||||
|
||||
private String getParameterString()
|
||||
{
|
||||
String string = "(";
|
||||
|
||||
@@ -1,33 +1,37 @@
|
||||
package com.sourcetrail.name;
|
||||
|
||||
public class NameElement
|
||||
public class NameElement
|
||||
{
|
||||
private String m_name = "";
|
||||
private String m_prefix = "";
|
||||
private String m_postfix = "";
|
||||
|
||||
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
String getNameWithSignature()
|
||||
{
|
||||
String nameWithSignature = m_name;
|
||||
|
||||
|
||||
if (m_prefix.length() > 0 || m_postfix.length() > 0)
|
||||
{
|
||||
nameWithSignature = m_prefix;
|
||||
@@ -41,10 +45,10 @@ public class NameElement
|
||||
}
|
||||
nameWithSignature += m_postfix;
|
||||
}
|
||||
|
||||
|
||||
return nameWithSignature;
|
||||
}
|
||||
|
||||
|
||||
String serialize()
|
||||
{
|
||||
return m_name + "\ts" + m_prefix + "\tp" + m_postfix;
|
||||
|
||||
@@ -4,40 +4,38 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class NameHierarchy
|
||||
public class NameHierarchy
|
||||
{
|
||||
private List<NameElement> m_elements = new ArrayList<>();
|
||||
private char m_separatpr = '.';
|
||||
|
||||
public NameHierarchy()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public NameHierarchy() {}
|
||||
|
||||
public NameHierarchy(String name)
|
||||
{
|
||||
m_elements.add(new NameElement(name));
|
||||
}
|
||||
|
||||
|
||||
public NameHierarchy(NameElement name)
|
||||
{
|
||||
m_elements.add(name);
|
||||
}
|
||||
|
||||
|
||||
public NameHierarchy(List<NameElement> names)
|
||||
{
|
||||
m_elements.addAll(names);
|
||||
}
|
||||
|
||||
|
||||
public void setSeparator(char separator)
|
||||
{
|
||||
m_separatpr = separator;
|
||||
}
|
||||
|
||||
|
||||
public void push(NameElement element)
|
||||
{
|
||||
m_elements.add(element);
|
||||
}
|
||||
|
||||
|
||||
public void pop()
|
||||
{
|
||||
if (!m_elements.isEmpty())
|
||||
@@ -45,7 +43,7 @@ public class NameHierarchy
|
||||
m_elements.remove(m_elements.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Optional<NameElement> peek()
|
||||
{
|
||||
if (!m_elements.isEmpty())
|
||||
@@ -54,22 +52,21 @@ public class NameHierarchy
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
public String serialize()
|
||||
{
|
||||
String serialized = m_separatpr + "\tm";
|
||||
|
||||
|
||||
for (int i = 0; i < m_elements.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
serialized += "\tn";
|
||||
}
|
||||
|
||||
|
||||
serialized += m_elements.get(i).serialize();
|
||||
}
|
||||
|
||||
return serialized;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.sourcetrail.name;
|
||||
|
||||
public interface SymbolName
|
||||
{
|
||||
public interface SymbolName {
|
||||
public NameHierarchy toNameHierarchy();
|
||||
}
|
||||
|
||||
@@ -16,64 +16,67 @@ public class TypeName implements SymbolName
|
||||
typeName.m_isUnsolved = true;
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public static TypeName fromDotSeparatedString(String s)
|
||||
|
||||
public static TypeName fromDotSeparatedString(String s)
|
||||
{
|
||||
TypeName typeName = null;
|
||||
|
||||
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
|
||||
{
|
||||
typeName = new TypeName(s, null);
|
||||
}
|
||||
|
||||
|
||||
return typeName;
|
||||
}
|
||||
|
||||
|
||||
public TypeName(String name, DeclName parent)
|
||||
{
|
||||
m_parent = parent;
|
||||
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;
|
||||
m_typeParameterNames = typeParameterNames;
|
||||
m_typeArguments = typeArguments;
|
||||
}
|
||||
|
||||
|
||||
public DeclName getParent()
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
public boolean getIsUnsolved()
|
||||
{
|
||||
return m_isUnsolved;
|
||||
}
|
||||
|
||||
|
||||
public DeclName toDeclName()
|
||||
{
|
||||
DeclName declName = new DeclName(m_name, m_typeParameterNames);
|
||||
declName.setParent(m_parent);
|
||||
return declName;
|
||||
}
|
||||
|
||||
|
||||
public NameHierarchy toNameHierarchy()
|
||||
{
|
||||
NameHierarchy nameHierarchy;
|
||||
|
||||
|
||||
if (m_parent != null)
|
||||
{
|
||||
nameHierarchy = m_parent.toNameHierarchy();
|
||||
@@ -82,12 +85,12 @@ public class TypeName implements SymbolName
|
||||
{
|
||||
nameHierarchy = new NameHierarchy();
|
||||
}
|
||||
|
||||
|
||||
nameHierarchy.push(new NameElement(m_name + getTypeArgumentString()));
|
||||
|
||||
|
||||
return nameHierarchy;
|
||||
}
|
||||
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String string = "";
|
||||
@@ -96,13 +99,13 @@ public class TypeName implements SymbolName
|
||||
string = m_parent.toString();
|
||||
string += ".";
|
||||
}
|
||||
|
||||
|
||||
string += m_name;
|
||||
string += getTypeArgumentString();
|
||||
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
private String getTypeArgumentString()
|
||||
{
|
||||
String string = "";
|
||||
|
||||
@@ -6,17 +6,16 @@ public class VariableDeclName extends DeclName
|
||||
{
|
||||
private TypeName m_typeName = null;
|
||||
private boolean m_isStatic = false;
|
||||
|
||||
|
||||
public VariableDeclName(String name, TypeName typeName, boolean isStatic)
|
||||
{
|
||||
super(name);
|
||||
|
||||
|
||||
m_typeName = typeName;
|
||||
m_isStatic = isStatic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NameHierarchy toNameHierarchy()
|
||||
|
||||
@Override public NameHierarchy toNameHierarchy()
|
||||
{
|
||||
String prefix = "";
|
||||
if (m_isStatic)
|
||||
@@ -27,13 +26,13 @@ public class VariableDeclName extends DeclName
|
||||
{
|
||||
prefix += m_typeName.toString();
|
||||
}
|
||||
|
||||
|
||||
NameHierarchy nameHierarchy = super.toNameHierarchy();
|
||||
Optional<NameElement> nameElement = nameHierarchy.peek();
|
||||
if (nameElement.isPresent())
|
||||
{
|
||||
String name = nameElement.get().getName();
|
||||
|
||||
|
||||
nameHierarchy.pop();
|
||||
nameHierarchy.push(new NameElement(name, prefix, ""));
|
||||
}
|
||||
|
||||
+122
-77
@@ -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,38 +19,32 @@ 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)
|
||||
{
|
||||
if (binding instanceof ITypeBinding)
|
||||
{
|
||||
return getParentBinding((ITypeBinding) binding);
|
||||
return getParentBinding((ITypeBinding)binding);
|
||||
}
|
||||
if (binding instanceof IMethodBinding)
|
||||
{
|
||||
return ((IMethodBinding) binding).getDeclaringClass();
|
||||
return ((IMethodBinding)binding).getDeclaringClass();
|
||||
}
|
||||
if (binding instanceof IVariableBinding)
|
||||
{
|
||||
return ((IVariableBinding) binding).getDeclaringClass();
|
||||
return ((IVariableBinding)binding).getDeclaringClass();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static IBinding getParentBinding(ITypeBinding binding)
|
||||
{
|
||||
if (binding.isLocal() || binding.isAnonymous())
|
||||
{
|
||||
if (binding.getDeclaringMember() instanceof IVariableBinding)
|
||||
{
|
||||
IVariableBinding variableBinding = (IVariableBinding) binding.getDeclaringMember();
|
||||
IVariableBinding variableBinding = (IVariableBinding)binding.getDeclaringMember();
|
||||
if (variableBinding.getDeclaringClass() != null)
|
||||
{
|
||||
return variableBinding.getDeclaringClass();
|
||||
@@ -60,7 +58,7 @@ public class BindingNameResolver extends NameResolver
|
||||
{
|
||||
return binding.getDeclaringMethod();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (binding.isMember())
|
||||
{
|
||||
return binding.getDeclaringClass();
|
||||
@@ -80,33 +78,40 @@ public class BindingNameResolver extends NameResolver
|
||||
{
|
||||
return binding.getPackage();
|
||||
}
|
||||
|
||||
return null; // we don't have a parent (like void doesn't have a parent)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public Optional<TypeName> getQualifiedName(ITypeBinding binding)
|
||||
{
|
||||
if (binding == null)
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
if (binding.isArray())
|
||||
{
|
||||
return getQualifiedName(binding.getElementType());
|
||||
@@ -116,15 +121,20 @@ 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
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (binding.isParameterizedType())
|
||||
{
|
||||
List<TypeName> typeArguments = new ArrayList<>();
|
||||
@@ -136,19 +146,23 @@ public class BindingNameResolver extends NameResolver
|
||||
typeArguments.add(typeArgument.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Optional<TypeName> typeName = getQualifiedName(binding.getTypeDeclaration());
|
||||
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
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String name = binding.getName();
|
||||
List<String> typeParameterNames = null;
|
||||
if (binding.isGenericType())
|
||||
@@ -158,38 +172,44 @@ public class BindingNameResolver extends NameResolver
|
||||
{
|
||||
typeParameterNames.add(typeParameter.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DeclName parentDeclName = getQualifiedContextName(binding);
|
||||
if (parentDeclName != null && parentDeclName.getIsUnsolved())
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
// type arguments will be set in caller (which is this same method)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public Optional<DeclName> getQualifiedName(IMethodBinding binding)
|
||||
{
|
||||
if (binding == null)
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
String name = binding.getName();
|
||||
|
||||
|
||||
List<String> typeParameterNames = null;
|
||||
if (binding.isGenericMethod())
|
||||
{
|
||||
@@ -199,32 +219,40 @@ public class BindingNameResolver extends NameResolver
|
||||
typeParameterNames.add(typeParameter.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DeclName declName = null;
|
||||
{
|
||||
boolean isStatic = Modifier.isStatic(binding.getModifiers());
|
||||
|
||||
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())
|
||||
{
|
||||
declName = new VariableDeclName(name, returnTypeName, isStatic);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<TypeName> parameterTypeNames = new ArrayList<>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DeclName parentDeclName = getQualifiedContextName(binding);
|
||||
if (parentDeclName != null)
|
||||
{
|
||||
@@ -238,47 +266,59 @@ public class BindingNameResolver extends NameResolver
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.of(declName);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public Optional<DeclName> getQualifiedName(IPackageBinding binding)
|
||||
{
|
||||
if (!binding.isUnnamed())
|
||||
{
|
||||
return Optional.of(DeclName.fromDotSeparatedString(binding.getName()));
|
||||
}
|
||||
return Optional.empty();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public DeclName getQualifiedName(IVariableBinding binding)
|
||||
{
|
||||
if (binding == null)
|
||||
{
|
||||
return DeclName.unsolved();
|
||||
}
|
||||
|
||||
|
||||
if (binding.isField() || binding.isEnumConstant())
|
||||
{
|
||||
DeclName declName;
|
||||
@@ -289,9 +329,10 @@ 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);
|
||||
if (parentDeclName != null)
|
||||
{
|
||||
@@ -304,14 +345,16 @@ public class BindingNameResolver extends NameResolver
|
||||
declName = DeclName.unsolved();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return declName;
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
{
|
||||
@@ -319,33 +362,35 @@ public class BindingNameResolver extends NameResolver
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private DeclName getQualifiedContextName(IBinding binding)
|
||||
{
|
||||
IBinding parentBinding = getParentBinding(binding);
|
||||
|
||||
|
||||
if (parentBinding == null || m_ignoredContexts.contains(parentBinding))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
return getQualifiedName((IMethodBinding) parentBinding).orElse(DeclName.unsolved());
|
||||
return getQualifiedName((IMethodBinding)parentBinding).orElse(DeclName.unsolved());
|
||||
}
|
||||
else if (parentBinding instanceof IVariableBinding)
|
||||
{
|
||||
return getQualifiedName((IVariableBinding) parentBinding);
|
||||
return getQualifiedName((IVariableBinding)parentBinding);
|
||||
}
|
||||
else if (parentBinding instanceof IPackageBinding)
|
||||
{
|
||||
return getQualifiedName((IPackageBinding) parentBinding).orElse(null);
|
||||
return getQualifiedName((IPackageBinding)parentBinding).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,32 +33,30 @@ 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)
|
||||
{
|
||||
public DeclNameResolver(File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public DeclName getQualifiedDeclName(VariableDeclarationFragment decl)
|
||||
{
|
||||
DeclName declName = DeclName.unsolved();
|
||||
@@ -78,11 +82,11 @@ public class DeclNameResolver extends NameResolver
|
||||
}
|
||||
return declName;
|
||||
}
|
||||
|
||||
|
||||
public DeclName getDeclName(VariableDeclarationFragment decl)
|
||||
{
|
||||
TypeName typeName = TypeName.unsolved();
|
||||
|
||||
|
||||
boolean isStatic = false;
|
||||
Optional<FieldDeclaration> fieldDeclaration = getAncestorOfType(decl, FieldDeclaration.class);
|
||||
if (fieldDeclaration.isPresent())
|
||||
@@ -95,31 +99,39 @@ public class DeclNameResolver extends NameResolver
|
||||
{
|
||||
isStatic = Modifier.isStatic(fieldDeclaration.get().getModifiers());
|
||||
}
|
||||
typeName = BindingNameResolver.getQualifiedName(
|
||||
fieldDeclaration.get().getType().resolveBinding(),
|
||||
m_currentFile,
|
||||
m_compilationUnit,
|
||||
m_ignoredContexts.copy()).orElse(TypeName.unsolved());
|
||||
typeName = BindingNameResolver
|
||||
.getQualifiedName(
|
||||
fieldDeclaration.get().getType().resolveBinding(),
|
||||
m_currentFile,
|
||||
m_compilationUnit,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public DeclName getQualifiedDeclName(BodyDeclaration decl)
|
||||
{
|
||||
DeclName declName = DeclName.unsolved();
|
||||
|
||||
|
||||
if (decl != null)
|
||||
{
|
||||
declName = getDeclName(decl);
|
||||
@@ -139,46 +151,49 @@ public class DeclNameResolver extends NameResolver
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return declName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DeclName getDeclName(BodyDeclaration decl)
|
||||
{
|
||||
DeclName declName = DeclName.unsolved();
|
||||
|
||||
|
||||
if (decl != null)
|
||||
{
|
||||
if (decl instanceof AnnotationTypeDeclaration)
|
||||
{
|
||||
declName = new DeclName(((AnnotationTypeDeclaration) decl).getName().getIdentifier());
|
||||
declName = new DeclName(((AnnotationTypeDeclaration)decl).getName().getIdentifier());
|
||||
}
|
||||
else if (decl instanceof EnumDeclaration)
|
||||
{
|
||||
declName = new DeclName(((EnumDeclaration) decl).getName().getIdentifier());
|
||||
declName = new DeclName(((EnumDeclaration)decl).getName().getIdentifier());
|
||||
}
|
||||
else if (decl instanceof TypeDeclaration)
|
||||
{
|
||||
TypeDeclaration typeDeclaration = (TypeDeclaration) decl;
|
||||
TypeDeclaration typeDeclaration = (TypeDeclaration)decl;
|
||||
|
||||
List<String> typeParameterNames = new ArrayList<>();
|
||||
for (Object typeParameter: typeDeclaration.typeParameters())
|
||||
{
|
||||
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)
|
||||
{
|
||||
declName = new DeclName(((EnumConstantDeclaration) decl).getName().getIdentifier());
|
||||
declName = new DeclName(((EnumConstantDeclaration)decl).getName().getIdentifier());
|
||||
}
|
||||
else if (decl instanceof FieldDeclaration)
|
||||
{
|
||||
@@ -190,56 +205,76 @@ public class DeclNameResolver extends NameResolver
|
||||
}
|
||||
else if (decl instanceof MethodDeclaration)
|
||||
{
|
||||
MethodDeclaration methodDeclaration = (MethodDeclaration) decl;
|
||||
|
||||
MethodDeclaration methodDeclaration = (MethodDeclaration)decl;
|
||||
|
||||
List<String> typeParameterNames = new ArrayList<>();
|
||||
for (Object typeParameter: methodDeclaration.typeParameters())
|
||||
{
|
||||
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());
|
||||
|
||||
List<TypeName> parameterTypeNames = new ArrayList<>();
|
||||
ignoredContexts.add(((MethodDeclaration)decl).resolveBinding());
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
declName = new FunctionDeclName(
|
||||
methodDeclaration.getName().getIdentifier(),
|
||||
typeParameterNames,
|
||||
returnTypeName,
|
||||
parameterTypeNames,
|
||||
Modifier.isStatic(methodDeclaration.getModifiers()));
|
||||
methodDeclaration.getName().getIdentifier(),
|
||||
typeParameterNames,
|
||||
returnTypeName,
|
||||
parameterTypeNames,
|
||||
Modifier.isStatic(methodDeclaration.getModifiers()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public DeclName getQualifiedDeclName(AnonymousClassDeclaration decl)
|
||||
{
|
||||
DeclName declName = DeclName.unsolved();
|
||||
@@ -265,28 +300,28 @@ public class DeclNameResolver extends NameResolver
|
||||
}
|
||||
return declName;
|
||||
}
|
||||
|
||||
|
||||
public DeclName getDeclName(AnonymousClassDeclaration decl)
|
||||
{
|
||||
Position pos = Utility.getRange(decl, m_compilationUnit).begin;
|
||||
return DeclName.anonymousClass(m_currentFile, pos.line, pos.column);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static DeclName getQualifiedName(Name name)
|
||||
{
|
||||
if (name.isSimpleName())
|
||||
{
|
||||
return new DeclName(((SimpleName) name).getIdentifier());
|
||||
return new DeclName(((SimpleName)name).getIdentifier());
|
||||
}
|
||||
else
|
||||
{
|
||||
DeclName declName = new DeclName(((QualifiedName) name).getName().getIdentifier());
|
||||
declName.setParent(getQualifiedName(((QualifiedName) name).getQualifier()));
|
||||
DeclName declName = new DeclName(((QualifiedName)name).getName().getIdentifier());
|
||||
declName.setParent(getQualifiedName(((QualifiedName)name).getQualifier()));
|
||||
return declName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private DeclName getQualifiedContextName(ASTNode decl)
|
||||
{
|
||||
ASTNode parentNode = decl.getParent();
|
||||
@@ -294,25 +329,25 @@ public class DeclNameResolver extends NameResolver
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (parentNode instanceof BodyDeclaration && !(parentNode instanceof FieldDeclaration))
|
||||
{
|
||||
return getQualifiedDeclName((BodyDeclaration) parentNode);
|
||||
return getQualifiedDeclName((BodyDeclaration)parentNode);
|
||||
}
|
||||
else if (parentNode instanceof AnonymousClassDeclaration)
|
||||
{
|
||||
return getQualifiedDeclName((AnonymousClassDeclaration) parentNode);
|
||||
return getQualifiedDeclName((AnonymousClassDeclaration)parentNode);
|
||||
}
|
||||
else if (parentNode instanceof CompilationUnit)
|
||||
{
|
||||
PackageDeclaration packageDecl = ((CompilationUnit) parentNode).getPackage();
|
||||
PackageDeclaration packageDecl = ((CompilationUnit)parentNode).getPackage();
|
||||
if (packageDecl != null)
|
||||
{
|
||||
return getQualifiedName(packageDecl.getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return getQualifiedContextName(parentNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
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
|
||||
public abstract class NameResolver
|
||||
{
|
||||
protected File m_currentFile = null;
|
||||
protected ContextList m_ignoredContexts = null;
|
||||
protected CompilationUnit m_compilationUnit = null;
|
||||
|
||||
static protected <N> Optional<N> getAncestorOfType(ASTNode node, Class<N> classType)
|
||||
|
||||
static protected <N> Optional<N> getAncestorOfType(ASTNode node, Class<N> classType)
|
||||
{
|
||||
ASTNode parent = node.getParent();
|
||||
while (parent != null)
|
||||
while (parent != null)
|
||||
{
|
||||
if (classType.isAssignableFrom(parent.getClass()))
|
||||
{
|
||||
@@ -27,12 +25,12 @@ public abstract class NameResolver
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
public NameResolver(File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
|
||||
{
|
||||
m_currentFile = currentFile;
|
||||
m_compilationUnit = compilationUnit;
|
||||
|
||||
|
||||
if (ignoredContexts != null)
|
||||
{
|
||||
m_ignoredContexts = ignoredContexts;
|
||||
@@ -41,5 +39,5 @@ public abstract class NameResolver
|
||||
{
|
||||
m_ignoredContexts = new ContextList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+27
-40
@@ -12,39 +12,39 @@
|
||||
#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"
|
||||
#include "SourceGroupFactoryModuleCxx.h"
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
# include "LanguagePackageCxx.h"
|
||||
# include "SourceGroupFactoryModuleCxx.h"
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
|
||||
#if BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
#include "LanguagePackageJava.h"
|
||||
#include "SourceGroupFactoryModuleJava.h"
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
# include "LanguagePackageJava.h"
|
||||
# include "SourceGroupFactoryModuleJava.h"
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
|
||||
#if BUILD_PYTHON_LANGUAGE_PACKAGE
|
||||
#include "SourceGroupFactoryModulePython.h"
|
||||
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
|
||||
# include "SourceGroupFactoryModulePython.h"
|
||||
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
|
||||
|
||||
void signalHandler(int signum)
|
||||
{
|
||||
@@ -72,26 +72,26 @@ void addLanguagePackages()
|
||||
|
||||
#if BUILD_CXX_LANGUAGE_PACKAGE
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleCxx>());
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
|
||||
#if BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleJava>());
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
|
||||
#if BUILD_PYTHON_LANGUAGE_PACKAGE
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModulePython>());
|
||||
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
|
||||
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
|
||||
|
||||
#if BUILD_CXX_LANGUAGE_PACKAGE
|
||||
LanguagePackageManager::getInstance()->addPackage(std::make_shared<LanguagePackageCxx>());
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
|
||||
#if BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
LanguagePackageManager::getInstance()->addPackage(std::make_shared<LanguagePackageJava>());
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QCoreApplication::addLibraryPath(QStringLiteral("."));
|
||||
|
||||
@@ -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();
|
||||
|
||||
+12
-12
@@ -2,22 +2,22 @@
|
||||
|
||||
#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"
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
# include "LanguagePackageCxx.h"
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
|
||||
#if BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
#include "LanguagePackageJava.h"
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
# include "LanguagePackageJava.h"
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
|
||||
void setupLogging(const FilePath& logFilePath)
|
||||
{
|
||||
@@ -38,10 +38,10 @@ void suppressCrashMessage()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
||||
#endif // _WIN32
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int processId = -1;
|
||||
std::string instanceUuid;
|
||||
@@ -94,11 +94,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
#if BUILD_CXX_LANGUAGE_PACKAGE
|
||||
LanguagePackageManager::getInstance()->addPackage(std::make_shared<LanguagePackageCxx>());
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
#endif // BUILD_CXX_LANGUAGE_PACKAGE
|
||||
|
||||
#if BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
LanguagePackageManager::getInstance()->addPackage(std::make_shared<LanguagePackageJava>());
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
|
||||
InterprocessIndexer indexer(instanceUuid, processId);
|
||||
indexer.work();
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -21,9 +21,9 @@ bool AppPath::setSharedDataPath(const FilePath& path)
|
||||
FilePath AppPath::getCxxIndexerPath()
|
||||
{
|
||||
#if _WIN32
|
||||
const std::wstring cxxIndexerName(L"sourcetrail_indexer.exe");
|
||||
const std::wstring cxxIndexerName(L"sourcetrail_indexer.exe");
|
||||
#else
|
||||
const std::wstring cxxIndexerName(L"sourcetrail_indexer");
|
||||
const std::wstring cxxIndexerName(L"sourcetrail_indexer");
|
||||
#endif
|
||||
|
||||
if (!m_cxxIndexerPath.empty())
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
namespace
|
||||
{
|
||||
template <class Container>
|
||||
void reverseErase(Container & container)
|
||||
void reverseErase(Container& container)
|
||||
{
|
||||
while(!container.empty())
|
||||
while (!container.empty())
|
||||
container.pop_back();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -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,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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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_MACRO), NodeType(NODE_UNION)};
|
||||
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,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())
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -340,10 +340,10 @@ void ApplicationSettings::setVerboseIndexerLoggingEnabled(bool value)
|
||||
FilePath ApplicationSettings::getLogDirectoryPath() const
|
||||
{
|
||||
return FilePath(getValue<std::wstring>(
|
||||
"application/log_directory_path", UserPaths::getLogPath().getAbsolute().wstr()));
|
||||
"application/log_directory_path", UserPaths::getLogPath().getAbsolute().wstr()));
|
||||
}
|
||||
|
||||
void ApplicationSettings::setLogDirectoryPath(const FilePath &path)
|
||||
void ApplicationSettings::setLogDirectoryPath(const FilePath& path)
|
||||
{
|
||||
setValue<std::wstring>("application/log_directory_path", path.wstr());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -30,7 +29,7 @@ CommandLineParser::CommandLineParser(const std::string& version): m_version(vers
|
||||
m_commands.push_back(std::make_unique<commandline::CommandlineCommandConfig>(this));
|
||||
m_commands.push_back(std::make_unique<commandline::CommandlineCommandIndex>(this));
|
||||
|
||||
for (auto& command : m_commands)
|
||||
for (auto& command: m_commands)
|
||||
{
|
||||
command->setup();
|
||||
}
|
||||
|
||||
@@ -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,16 +14,17 @@ 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;
|
||||
// throw e;
|
||||
|
||||
boost::interprocess::permissions permissions;
|
||||
permissions.set_unrestricted();
|
||||
@@ -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)
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
return "MessageRefreshUIState";
|
||||
}
|
||||
|
||||
MessageRefreshUIState(bool isAfterIndexing) : isAfterIndexing(isAfterIndexing) {}
|
||||
MessageRefreshUIState(bool isAfterIndexing): isAfterIndexing(isAfterIndexing) {}
|
||||
|
||||
bool isAfterIndexing = false;
|
||||
};
|
||||
|
||||
@@ -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,9 +130,8 @@ FilePath CanonicalFilePathCache::getDeclarationFilePath(const clang::Decl* decla
|
||||
{
|
||||
return getCanonicalFilePath(fileId, sourceManager);
|
||||
}
|
||||
return getCanonicalFilePath(
|
||||
utility::decodeFromUtf8(
|
||||
sourceManager.getPresumedLoc(declaration->getBeginLoc()).getFilename()));
|
||||
return getCanonicalFilePath(utility::decodeFromUtf8(
|
||||
sourceManager.getPresumedLoc(declaration->getBeginLoc()).getFilename()));
|
||||
}
|
||||
|
||||
std::wstring CanonicalFilePathCache::getDeclarationFileName(const clang::Decl* declaration)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -44,7 +44,7 @@ std::unique_ptr<clang::ASTConsumer> GeneratePCHAction::CreateASTConsumer(
|
||||
Sysroot,
|
||||
Buffer,
|
||||
FrontendOpts.ModuleFileExtensions,
|
||||
true, // always allow errors in the PCH
|
||||
true, // always allow errors in the PCH
|
||||
FrontendOpts.IncludeTimestamps,
|
||||
+CI.getLangOpts().CacheGeneratedPCH));
|
||||
Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -1066,7 +1066,7 @@ void QtCodeArea::activateAnnotationsOrErrors(
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_showLineNumbers) // for links in project description
|
||||
if (!m_showLineNumbers) // for links in project description
|
||||
{
|
||||
std::set<Id> tokenIds;
|
||||
for (const Annotation* annotation: annotations)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -33,7 +33,7 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeNavigator* navigator, boo
|
||||
connect(m_titleBar, &QtCodeFileTitleBar::minimize, this, &QtCodeFile::clickedMinimizeButton);
|
||||
connect(m_titleBar, &QtCodeFileTitleBar::snippet, this, &QtCodeFile::clickedSnippetButton);
|
||||
connect(m_titleBar, &QtCodeFileTitleBar::maximize, this, &QtCodeFile::clickedMaximizeButton);
|
||||
connect(m_titleBar, &QtHoverButton::hoveredIn, [this](){
|
||||
connect(m_titleBar, &QtHoverButton::hoveredIn, [this]() {
|
||||
m_navigator->setFocusedFile(this);
|
||||
m_navigator->setFocus();
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +533,7 @@ void QtCodeFileList::updateFirstSnippetTitleBar(QtCodeFile* file, int fileTitleB
|
||||
&QtCodeFileTitleBar::maximize,
|
||||
file,
|
||||
&QtCodeFile::clickedMaximizeButton);
|
||||
connect(m_firstSnippetTitleBar, &QtHoverButton::hoveredIn, [this, file](){
|
||||
connect(m_firstSnippetTitleBar, &QtHoverButton::hoveredIn, [this, file]() {
|
||||
m_navigator->setFocusedFile(file);
|
||||
m_navigator->setFocus();
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,27 +128,27 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated(
|
||||
switch (target)
|
||||
{
|
||||
case CodeScrollParams::Target::VISIBLE:
|
||||
{
|
||||
int visibleTop = visibleY + 50;
|
||||
int visibleBottom = visibleY + visibleHeight - 50;
|
||||
|
||||
int scrollTop = scrollY;
|
||||
int scrollBottom = scrollY + rectHeight;
|
||||
|
||||
if (scrollTop < visibleTop)
|
||||
{
|
||||
int visibleTop = visibleY + 50;
|
||||
int visibleBottom = visibleY + visibleHeight - 50;
|
||||
|
||||
int scrollTop = scrollY;
|
||||
int scrollBottom = scrollY + rectHeight;
|
||||
|
||||
if (scrollTop < visibleTop)
|
||||
{
|
||||
scrollY = scrollTop - 50;
|
||||
}
|
||||
else if (scrollBottom > visibleBottom)
|
||||
{
|
||||
scrollY = visibleTop + scrollBottom - visibleBottom;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
scrollY = scrollTop - 50;
|
||||
}
|
||||
break;
|
||||
else if (scrollBottom > visibleBottom)
|
||||
{
|
||||
scrollY = visibleTop + scrollBottom - visibleBottom;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CodeScrollParams::Target::CENTER:
|
||||
if (rectHeight < visibleHeight / 2)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+2
-1
@@ -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")
|
||||
|
||||
+8
-5
@@ -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);
|
||||
|
||||
+12
-6
@@ -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 "
|
||||
"that should be indexed."));
|
||||
QPushButton* yesButton = msgBox.addButton(QStringLiteral("Continue"), QMessageBox::ButtonRole::YesRole);
|
||||
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);
|
||||
msgBox.addButton(QStringLiteral("Cancel"), QMessageBox::ButtonRole::NoRole);
|
||||
msgBox.setDefaultButton(yesButton);
|
||||
|
||||
|
||||
@@ -44,14 +44,15 @@ std::string QtHighlighter::highlightTypeToString(QtHighlighter::HighlightType ty
|
||||
|
||||
QtHighlighter::HighlightType QtHighlighter::highlightTypeFromString(const std::string& typeStr)
|
||||
{
|
||||
const std::array<HighlightType, 8> types = {HighlightType::COMMENT,
|
||||
HighlightType::DIRECTIVE,
|
||||
HighlightType::FUNCTION,
|
||||
HighlightType::KEYWORD,
|
||||
HighlightType::NUMBER,
|
||||
HighlightType::QUOTATION,
|
||||
HighlightType::TEXT,
|
||||
HighlightType::TYPE};
|
||||
const std::array<HighlightType, 8> types = {
|
||||
HighlightType::COMMENT,
|
||||
HighlightType::DIRECTIVE,
|
||||
HighlightType::FUNCTION,
|
||||
HighlightType::KEYWORD,
|
||||
HighlightType::NUMBER,
|
||||
HighlightType::QUOTATION,
|
||||
HighlightType::TEXT,
|
||||
HighlightType::TYPE};
|
||||
|
||||
for (HighlightType type: types)
|
||||
{
|
||||
@@ -68,14 +69,15 @@ void QtHighlighter::loadHighlightingRules()
|
||||
{
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
|
||||
const std::array<HighlightType, 8> types = {HighlightType::COMMENT,
|
||||
HighlightType::DIRECTIVE,
|
||||
HighlightType::FUNCTION,
|
||||
HighlightType::KEYWORD,
|
||||
HighlightType::NUMBER,
|
||||
HighlightType::QUOTATION,
|
||||
HighlightType::TEXT,
|
||||
HighlightType::TYPE};
|
||||
const std::array<HighlightType, 8> types = {
|
||||
HighlightType::COMMENT,
|
||||
HighlightType::DIRECTIVE,
|
||||
HighlightType::FUNCTION,
|
||||
HighlightType::KEYWORD,
|
||||
HighlightType::NUMBER,
|
||||
HighlightType::QUOTATION,
|
||||
HighlightType::TEXT,
|
||||
HighlightType::TYPE};
|
||||
|
||||
s_charFormats.clear();
|
||||
for (HighlightType type: types)
|
||||
|
||||
@@ -15,8 +15,8 @@ QtCodeView::QtCodeView(ViewLayout* viewLayout): CodeView(viewLayout)
|
||||
{
|
||||
m_widget = new QtCodeNavigator();
|
||||
|
||||
m_widget->connect(m_widget, &QtCodeNavigator::focusIn, [this](){ setNavigationFocus(true); });
|
||||
m_widget->connect(m_widget, &QtCodeNavigator::focusOut, [this](){ setNavigationFocus(false); });
|
||||
m_widget->connect(m_widget, &QtCodeNavigator::focusIn, [this]() { setNavigationFocus(true); });
|
||||
m_widget->connect(m_widget, &QtCodeNavigator::focusOut, [this]() { setNavigationFocus(false); });
|
||||
}
|
||||
|
||||
void QtCodeView::createWidgetWrapper()
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -67,8 +67,8 @@ QtGraphView::QtGraphView(ViewLayout* viewLayout)
|
||||
|
||||
connect(view, &QtGraphicsView::emptySpaceClicked, this, &QtGraphView::clickedInEmptySpace);
|
||||
connect(view, &QtGraphicsView::resized, this, &QtGraphView::resized);
|
||||
connect(view, &QtGraphicsView::focusIn, [this](){ setNavigationFocus(true); });
|
||||
connect(view, &QtGraphicsView::focusOut, [this](){ setNavigationFocus(false); });
|
||||
connect(view, &QtGraphicsView::focusIn, [this]() { setNavigationFocus(true); });
|
||||
connect(view, &QtGraphicsView::focusOut, [this]() { setNavigationFocus(false); });
|
||||
|
||||
m_scrollSpeedChangeListenerHorizontal.setScrollBar(view->horizontalScrollBar());
|
||||
m_scrollSpeedChangeListenerVertical.setScrollBar(view->verticalScrollBar());
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
@@ -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());
|
||||
|
||||
@@ -311,8 +311,9 @@ 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"
|
||||
"different cases but after lower casing are equal")
|
||||
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!"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user