diff --git a/.gitignore b/.gitignore
index 1e8378f1..b2852705 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
/bin/app/Debug/
/bin/app/Release/
/bin/app/data/projects/ignored/
+/bin/app/data/java/
/bin/app/user/log/
/bin/app/user/ApplicationSettings.xml
/bin/app/user/window_settings.ini
@@ -23,7 +24,10 @@
/bin/test/data/temp.xml
/bin/test/data/TestSettings.xml
-/setup/Linux/lib/*
+/java_indexer/bin/
+/java_indexer/lib/
+
+/setup/Linux/lib/
.DS_Store
.idea
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ba7d5013..4c67cd31 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,7 +33,7 @@ endif ()
project(${PROJECT_NAME})
-# set Standerd build type to Release
+# set Standard build type to Release
set(CMAKE_BUILD_TYPE_INIT "Release")
#RPATH
@@ -174,6 +174,8 @@ endif()
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib)
+find_package(JNI)
+
add_subdirectory(src/lib)
add_subdirectory(src/external)
@@ -206,10 +208,11 @@ target_include_directories(${LIB_PROJECT_NAME} SYSTEM
${CLANG_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${EIGEN_ROOT}
+ ${JNI_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/src/external"
)
-target_link_libraries(${LIB_PROJECT_NAME} ${Boost_LIBRARIES} ${LIB_LICENSE_PROJECT_NAME})
+target_link_libraries(${LIB_PROJECT_NAME} ${Boost_LIBRARIES} ${LIB_LICENSE_PROJECT_NAME} ${JNI_LIBRARIES})
# Lib Parser -------------------------------------------------------------------
@@ -242,6 +245,7 @@ target_include_directories(${LIB_PARSER_PROJECT_NAME} SYSTEM
PUBLIC ${LLVM_INCLUDE_DIRS}
${CLANG_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
+ ${JNI_INCLUDE_DIRS}
)
link_directories(${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
@@ -389,6 +393,12 @@ create_source_groups(${APP_FILES})
target_link_libraries(${APP_PROJECT_NAME} ${LIB_GUI_PROJECT_NAME} ${LIB_PARSER_PROJECT_NAME} ${LIB_PROJECT_NAME} ${LIB_LICENSE_PROJECT_NAME})
+if (WIN32)
+SET_TARGET_PROPERTIES(
+ ${APP_PROJECT_NAME} PROPERTIES
+ LINK_FLAGS "/DELAYLOAD:jvm.dll")
+endif()
+
set_property(
TARGET ${APP_PROJECT_NAME}
PROPERTY INCLUDE_DIRECTORIES
@@ -589,6 +599,12 @@ create_source_groups(${TEST_FILES})
target_link_libraries(${TEST_PROJECT_NAME} ${LIB_PARSER_PROJECT_NAME} ${LIB_PROJECT_NAME} ${LIB_LICENSE_PROJECT_NAME})
+if (WIN32)
+SET_TARGET_PROPERTIES(
+ ${TEST_PROJECT_NAME} PROPERTIES
+ LINK_FLAGS "/DELAYLOAD:jvm.dll")
+endif()
+
find_package(CxxTest)
if (CXXTEST_FOUND)
set_property(
diff --git a/JavaSmallTest/JavaSmallTest.coatiproject b/JavaSmallTest/JavaSmallTest.coatiproject
new file mode 100644
index 00000000..675eb3da
--- /dev/null
+++ b/JavaSmallTest/JavaSmallTest.coatiproject
@@ -0,0 +1,15 @@
+
+
+
+ Java
+ 1.8
+
+
+
+ .java
+
+
+ ./src
+
+
+
diff --git a/JavaSmallTest/src/foo/JavaTest.java b/JavaSmallTest/src/foo/JavaTest.java
new file mode 100644
index 00000000..df74ff23
--- /dev/null
+++ b/JavaSmallTest/src/foo/JavaTest.java
@@ -0,0 +1,6 @@
+package foo;
+
+public class JavaTest {
+ public void foo() {
+ }
+}
\ No newline at end of file
diff --git a/JavaSmallTest/src/foos/JavaTestBase.java b/JavaSmallTest/src/foos/JavaTestBase.java
new file mode 100644
index 00000000..f3e82e7e
--- /dev/null
+++ b/JavaSmallTest/src/foos/JavaTestBase.java
@@ -0,0 +1,13 @@
+package foos;
+
+public interface JavaTestBaseBase
+{
+ default void bar()
+ {
+ }
+}
+
+public interface JavaTestBase extends JavaTestBaseBase
+{
+
+}
\ No newline at end of file
diff --git a/bin/app/data/color_scheme_template.xml b/bin/app/data/color_scheme_template.xml
index 3ca3629a..544291f8 100644
--- a/bin/app/data/color_scheme_template.xml
+++ b/bin/app/data/color_scheme_template.xml
@@ -173,11 +173,14 @@
+
+
+
@@ -188,6 +191,7 @@
+
diff --git a/bin/app/data/color_schemes/bad_rainbow.xml b/bin/app/data/color_schemes/bad_rainbow.xml
index 01e3d8c3..ceee8eac 100644
--- a/bin/app/data/color_schemes/bad_rainbow.xml
+++ b/bin/app/data/color_schemes/bad_rainbow.xml
@@ -206,9 +206,15 @@
#FFFFFF
+
+ type
+ type
+
+ type
+ type
@@ -221,6 +227,9 @@
type
+
+ type
+
@@ -272,6 +281,9 @@
undefined
+
+ undefined
+
@@ -342,18 +354,21 @@
#2A6484
-
- #C1305D
- #C1305D
+
+ template_argument
+
- #C1305D
+ template_argument
- #C1305D
+ template_argument
+
+ template_argument
+ #4E82F6
diff --git a/bin/app/data/color_schemes/bright.xml b/bin/app/data/color_schemes/bright.xml
index 0cb12721..f29f5add 100644
--- a/bin/app/data/color_schemes/bright.xml
+++ b/bin/app/data/color_schemes/bright.xml
@@ -198,9 +198,15 @@
#3C3C3C
+
+ type
+ type
+
+ type
+ type
@@ -213,6 +219,9 @@
type
+
+ type
+
@@ -257,6 +266,9 @@
undefined
+
+ undefined
+
@@ -315,20 +327,20 @@
#3190BA
-
- #C1305D
-
- template_parameter
+ #C1305D
+
+ template_argument
+
- template_parameter
+ template_argument
- template_parameter
+ template_argument
- template_parameter
+ template_argument
diff --git a/bin/app/data/color_schemes/dark.xml b/bin/app/data/color_schemes/dark.xml
index 2502d3c3..22cbf179 100644
--- a/bin/app/data/color_schemes/dark.xml
+++ b/bin/app/data/color_schemes/dark.xml
@@ -219,36 +219,30 @@
#C3C3C3
+
+ type
+
-
- #20C3C3C3
- #C3C3C3
-
+ type
+
+ type
+
-
- #20C3C3C3
- #C3C3C3
-
+ type
-
- #20C3C3C3
- #C3C3C3
-
+ type
-
- #20C3C3C3
- #C3C3C3
-
+ type
-
- #20C3C3C3
- #C3C3C3
-
+ type
+
+ type
+
@@ -293,6 +287,9 @@
undefined
+
+ undefined
+
@@ -351,20 +348,20 @@
#2A6484
-
- #C1305D
- #C1305D
+
+ template_argument
+
- #C1305D
+ template_argument
- #C1305D
+ template_argument
- #C1305D
+ template_argument
diff --git a/java_indexer/build/build.sh b/java_indexer/build/build.sh
new file mode 100644
index 00000000..24ef7fb9
--- /dev/null
+++ b/java_indexer/build/build.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# prerequirements: java/bin in path
+
+ABORT="\033[31mAbort:\033[00m"
+SUCCESS="\033[32mSuccess:\033[00m"
+INFO="\033[33mInfo:\033[00m"
+
+# Determine current platform
+PLATFORM='unknown'
+if [ "$(uname)" == "Darwin" ]; then
+ PLATFORM='MacOS'
+elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
+ PLATFORM='Linux'
+elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
+ PLATFORM='Windows'
+fi
+
+if [ $PLATFORM == "Windows" ]; then
+ ORIGINAL_PATH_TO_SCRIPT="${0}"
+ CLEANED_PATH_TO_SCRIPT="${ORIGINAL_PATH_TO_SCRIPT//\\//}"
+ ROOT_DIR=`dirname "$CLEANED_PATH_TO_SCRIPT"`
+else
+ ROOT_DIR="$( cd "$( dirname "$0" )" && pwd )"
+fi
+
+ROOT_DIR=$ROOT_DIR/..
+
+cd $ROOT_DIR
+
+mkdir -p classes
+
+LIB_DIR="./lib/"
+CLASSPATH=""
+CLASSPATH+=$LIB_DIR"java-symbol-solver-core-0.2.0-SNAPSHOT.jar;"
+CLASSPATH+=$LIB_DIR"java-symbol-solver-logic-0.2.0-SNAPSHOT.jar;"
+CLASSPATH+=$LIB_DIR"java-symbol-solver-model-0.2.0-SNAPSHOT.jar;"
+CLASSPATH+=$LIB_DIR"javaparser-core-2.4.1-SNAPSHOT.jar;"
+
+javac.exe -d ./classes -classpath $CLASSPATH src/io/coati/*.java
+
+mkdir -p bin
+
+cd classes
+
+jar cvf ../bin/java-indexer.jar io/coati/*.class
+
+cd ..
+
+rm -rf classes
diff --git a/java_indexer/src/io/coati/ASTDumper.java b/java_indexer/src/io/coati/ASTDumper.java
new file mode 100644
index 00000000..bcf7bd3f
--- /dev/null
+++ b/java_indexer/src/io/coati/ASTDumper.java
@@ -0,0 +1,224 @@
+package io.coati;
+
+import com.github.javaparser.ast.*;
+import com.github.javaparser.ast.body.*;
+import com.github.javaparser.ast.comments.*;
+import com.github.javaparser.ast.expr.*;
+import com.github.javaparser.ast.stmt.*;
+import com.github.javaparser.ast.type.*;
+
+import me.tomassetti.symbolsolver.model.resolution.TypeSolver;
+
+public class ASTDumper extends JavaAstVisitor{
+
+ public ASTDumper(int callbackId, String filePath, TypeSolver typeSolver) {
+ super(callbackId, filePath, typeSolver);
+ }
+
+ int indent = 0;
+ String indentSymbol = "| ";
+
+ private void dump(Node n)
+ {
+ String line = "";
+
+ for (int i = 0; i < this.indent; i++)
+ {
+ line += this.indentSymbol;
+ }
+
+ line += n.getClass().getName();
+ if (n instanceof NameExpr)
+ {
+ line += " [" + ((NameExpr)n).getName() + "]";
+ }
+ else if (n instanceof ClassOrInterfaceType)
+ {
+ line += " [" + ((ClassOrInterfaceType)n).getName() + "]";
+ }
+
+ System.out.println(line);
+ }
+
+ //- Compilation Unit ----------------------------------
+
+ public void visit(CompilationUnit n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(PackageDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ImportDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(TypeParameter n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(LineComment n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(BlockComment n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ //- Body ----------------------------------------------
+
+ public void visit(ClassOrInterfaceDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(EnumDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(EmptyTypeDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(EnumConstantDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(AnnotationDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(AnnotationMemberDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(FieldDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(VariableDeclarator n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(VariableDeclaratorId n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ConstructorDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(MethodDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(Parameter n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(MultiTypeParameter n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(EmptyMemberDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(InitializerDeclaration n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(JavadocComment n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ //- Type ----------------------------------------------
+
+ public void visit(ClassOrInterfaceType n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(PrimitiveType n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ReferenceType n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(IntersectionType n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(UnionType n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(VoidType n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(WildcardType n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(UnknownType n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ //- Expression ----------------------------------------
+
+ public void visit(ArrayAccessExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ArrayCreationExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ArrayInitializerExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(AssignExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(BinaryExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(CastExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ClassExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ConditionalExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(EnclosedExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(FieldAccessExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(InstanceOfExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(StringLiteralExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(IntegerLiteralExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(LongLiteralExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(IntegerLiteralMinValueExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(LongLiteralMinValueExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(CharLiteralExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(DoubleLiteralExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(BooleanLiteralExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(NullLiteralExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(MethodCallExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(NameExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ObjectCreationExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(QualifiedNameExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ThisExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(SuperExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(UnaryExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(VariableDeclarationExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(MarkerAnnotationExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(SingleMemberAnnotationExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(NormalAnnotationExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(MemberValuePair n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ //- Statements ----------------------------------------
+
+ public void visit(ExplicitConstructorInvocationStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(TypeDeclarationStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(AssertStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(BlockStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(LabeledStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(EmptyStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ExpressionStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(SwitchStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(SwitchEntryStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(BreakStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ReturnStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(IfStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(WhileStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ContinueStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(DoStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ForeachStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ForStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(ThrowStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(SynchronizedStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(TryStmt n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(CatchClause n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(LambdaExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(MethodReferenceExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+
+ public void visit(TypeExpr n, Void v) { dump(n); indent++; super.visit(n, v); indent--; }
+}
diff --git a/java_indexer/src/io/coati/AccessKind.java b/java_indexer/src/io/coati/AccessKind.java
new file mode 100644
index 00000000..5195fca5
--- /dev/null
+++ b/java_indexer/src/io/coati/AccessKind.java
@@ -0,0 +1,44 @@
+package io.coati;
+
+import com.github.javaparser.ast.AccessSpecifier;
+
+public enum AccessKind
+{ // these values need to be the same as AccesType in C++ code
+ NONE(0),
+ PUBLIC(1),
+ PROTECTED(2),
+ PRIVATE(3),
+ DEFAULT(4),
+ TEMPLATE_PARAMETER(5),
+ TYPE_PARAMETER(6);
+
+ private final int m_value;
+
+ private AccessKind(int value)
+ {
+ this.m_value = value;
+ }
+
+ public int getValue()
+ {
+ return m_value;
+ }
+
+ public static AccessKind fromAccessSpecifier(AccessSpecifier specifier)
+ {
+ switch (specifier)
+ {
+ case PUBLIC:
+ return AccessKind.PUBLIC;
+ case PROTECTED:
+ return AccessKind.PROTECTED;
+ case PRIVATE:
+ return AccessKind.PRIVATE;
+ case DEFAULT:
+ return AccessKind.DEFAULT;
+ default:
+ return AccessKind.NONE;
+ }
+ }
+}
+
diff --git a/java_indexer/src/io/coati/CallableConstructorDecl.java b/java_indexer/src/io/coati/CallableConstructorDecl.java
new file mode 100644
index 00000000..eef02857
--- /dev/null
+++ b/java_indexer/src/io/coati/CallableConstructorDecl.java
@@ -0,0 +1,45 @@
+package io.coati;
+
+import java.util.List;
+
+import com.github.javaparser.ast.TypeParameter;
+import com.github.javaparser.ast.body.BodyDeclaration;
+import com.github.javaparser.ast.body.ConstructorDeclaration;
+import com.github.javaparser.ast.body.Parameter;
+import com.github.javaparser.ast.type.Type;
+import com.github.javaparser.ast.type.UnknownType;
+
+public class CallableConstructorDecl implements CallableDecl
+{
+ private ConstructorDeclaration m_decl;
+
+ public CallableConstructorDecl(ConstructorDeclaration decl)
+ {
+ m_decl = decl;
+ }
+
+ public BodyDeclaration getWrappedNode()
+ {
+ return m_decl;
+ }
+
+ public String getName()
+ {
+ return m_decl.getName();
+ }
+
+ public List getTypeParameters()
+ {
+ return m_decl.getTypeParameters();
+ }
+
+ public List getParameters()
+ {
+ return m_decl.getParameters();
+ }
+
+ public Type getType()
+ {
+ return new UnknownType();
+ }
+}
diff --git a/java_indexer/src/io/coati/CallableDecl.java b/java_indexer/src/io/coati/CallableDecl.java
new file mode 100644
index 00000000..c5832fd5
--- /dev/null
+++ b/java_indexer/src/io/coati/CallableDecl.java
@@ -0,0 +1,17 @@
+package io.coati;
+
+import java.util.List;
+
+import com.github.javaparser.ast.TypeParameter;
+import com.github.javaparser.ast.body.BodyDeclaration;
+import com.github.javaparser.ast.body.Parameter;
+import com.github.javaparser.ast.type.Type;
+
+public interface CallableDecl
+{
+ public BodyDeclaration getWrappedNode();
+ public String getName();
+ public List getTypeParameters();
+ public List getParameters();
+ public Type getType();
+}
diff --git a/java_indexer/src/io/coati/CallableMethodDecl.java b/java_indexer/src/io/coati/CallableMethodDecl.java
new file mode 100644
index 00000000..b1b62401
--- /dev/null
+++ b/java_indexer/src/io/coati/CallableMethodDecl.java
@@ -0,0 +1,44 @@
+package io.coati;
+
+import java.util.List;
+
+import com.github.javaparser.ast.TypeParameter;
+import com.github.javaparser.ast.body.BodyDeclaration;
+import com.github.javaparser.ast.body.MethodDeclaration;
+import com.github.javaparser.ast.body.Parameter;
+import com.github.javaparser.ast.type.Type;
+
+public class CallableMethodDecl implements CallableDecl
+{
+ private MethodDeclaration m_decl;
+
+ public CallableMethodDecl(MethodDeclaration decl)
+ {
+ m_decl = decl;
+ }
+
+ public BodyDeclaration getWrappedNode()
+ {
+ return m_decl;
+ }
+
+ public String getName()
+ {
+ return m_decl.getName();
+ }
+
+ public List getTypeParameters()
+ {
+ return m_decl.getTypeParameters();
+ }
+
+ public List getParameters()
+ {
+ return m_decl.getParameters();
+ }
+
+ public Type getType()
+ {
+ return m_decl.getType();
+ }
+}
diff --git a/java_indexer/src/io/coati/DeclContext.java b/java_indexer/src/io/coati/DeclContext.java
new file mode 100644
index 00000000..83eeb84d
--- /dev/null
+++ b/java_indexer/src/io/coati/DeclContext.java
@@ -0,0 +1,16 @@
+package io.coati;
+
+public class DeclContext
+{
+ private String m_name = null;
+
+ public DeclContext(String name)
+ {
+ m_name = name;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+}
diff --git a/java_indexer/src/io/coati/HeapDumper.java b/java_indexer/src/io/coati/HeapDumper.java
new file mode 100644
index 00000000..240110fd
--- /dev/null
+++ b/java_indexer/src/io/coati/HeapDumper.java
@@ -0,0 +1,61 @@
+package io.coati;
+
+import javax.management.MBeanServer;
+import java.lang.management.ManagementFactory;
+import com.sun.management.HotSpotDiagnosticMXBean;
+
+public class HeapDumper {
+ // This is the name of the HotSpot Diagnostic MBean
+ private static final String HOTSPOT_BEAN_NAME =
+ "com.sun.management:type=HotSpotDiagnostic";
+
+ // field to store the hotspot diagnostic MBean
+ private static volatile HotSpotDiagnosticMXBean hotspotMBean;
+
+ /*\*
+ \* Call this method from your application whenever you
+ \* want to dump the heap snapshot into a file.
+ \*
+ \* @param fileName name of the heap dump file
+ \* @param live flag that tells whether to dump
+ \* only the live objects
+ \*/
+ static void dumpHeap(String fileName, boolean live) {
+ // initialize hotspot diagnostic MBean
+ initHotspotMBean();
+ try {
+ hotspotMBean.dumpHeap(fileName, live);
+ } catch (RuntimeException re) {
+ throw re;
+ } catch (Exception exp) {
+ throw new RuntimeException(exp);
+ }
+ }
+
+ // initialize the hotspot diagnostic MBean field
+ private static void initHotspotMBean() {
+ if (hotspotMBean == null) {
+ synchronized (HeapDumper.class) {
+ if (hotspotMBean == null) {
+ hotspotMBean = getHotspotMBean();
+ }
+ }
+ }
+ }
+
+ // get the hotspot diagnostic MBean from the
+ // platform MBean server
+ private static HotSpotDiagnosticMXBean getHotspotMBean() {
+ try {
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ HotSpotDiagnosticMXBean bean =
+ ManagementFactory.newPlatformMXBeanProxy(server,
+ HOTSPOT_BEAN_NAME, HotSpotDiagnosticMXBean.class);
+ return bean;
+ } catch (RuntimeException re) {
+ throw re;
+ } catch (Exception exp) {
+ throw new RuntimeException(exp);
+ }
+ }
+}
diff --git a/java_indexer/src/io/coati/JavaAstVisitor.java b/java_indexer/src/io/coati/JavaAstVisitor.java
new file mode 100644
index 00000000..31b738ab
--- /dev/null
+++ b/java_indexer/src/io/coati/JavaAstVisitor.java
@@ -0,0 +1,761 @@
+package io.coati;
+
+import java.lang.String;
+import java.util.List;
+import java.util.ArrayList;
+
+import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
+import com.github.javaparser.ast.body.ConstructorDeclaration;
+import com.github.javaparser.ast.body.EnumConstantDeclaration;
+import com.github.javaparser.ast.body.EnumDeclaration;
+import com.github.javaparser.ast.body.FieldDeclaration;
+import com.github.javaparser.ast.body.MethodDeclaration;
+import com.github.javaparser.ast.body.ModifierSet;
+import com.github.javaparser.ast.body.Parameter;
+import com.github.javaparser.ast.body.VariableDeclarator;
+import com.github.javaparser.ast.body.VariableDeclaratorId;
+import com.github.javaparser.ast.comments.BlockComment;
+import com.github.javaparser.ast.comments.LineComment;
+import com.github.javaparser.ast.expr.MethodCallExpr;
+import com.github.javaparser.ast.expr.NameExpr;
+import com.github.javaparser.ast.expr.VariableDeclarationExpr;
+import com.github.javaparser.ast.type.ClassOrInterfaceType;
+import com.github.javaparser.ast.type.PrimitiveType;
+import com.github.javaparser.ast.type.Type;
+import com.github.javaparser.ast.type.VoidType;
+import com.github.javaparser.ast.ImportDeclaration;
+import com.github.javaparser.ast.Node;
+import com.github.javaparser.ast.PackageDeclaration;
+import com.github.javaparser.ast.TypeParameter;
+
+import me.tomassetti.symbolsolver.javaparsermodel.JavaParserFacade;
+import me.tomassetti.symbolsolver.javaparsermodel.UnsolvedSymbolException;
+import me.tomassetti.symbolsolver.javaparsermodel.declarations.JavaParserMethodDeclaration;
+import me.tomassetti.symbolsolver.javaparsermodel.declarations.JavaParserSymbolDeclaration;
+import me.tomassetti.symbolsolver.model.declarations.MethodAmbiguityException;
+import me.tomassetti.symbolsolver.model.declarations.TypeDeclaration;
+import me.tomassetti.symbolsolver.model.declarations.ValueDeclaration;
+import me.tomassetti.symbolsolver.model.invokations.MethodUsage;
+import me.tomassetti.symbolsolver.model.resolution.SymbolReference;
+import me.tomassetti.symbolsolver.model.resolution.TypeSolver;
+import me.tomassetti.symbolsolver.model.typesystem.*;
+
+public class JavaAstVisitor extends JavaAstVisitorAdapter
+{
+ private int m_callbackId = -1;
+ private String m_filePath;
+ private TypeSolver m_typeSolver;
+ private List m_context = new ArrayList();
+ private boolean m_verbose = false;
+
+ public JavaAstVisitor(int callbackId, String filePath, TypeSolver typeSolver)
+ {
+ m_callbackId = callbackId;
+ m_filePath = filePath;
+ m_typeSolver = typeSolver;
+
+ String[] filePathParts = filePath.split("/");
+ String fileName = filePathParts[filePathParts.length - 1];
+ m_context.add(new DeclContext(fileName + "\t\r"));
+ }
+
+
+ // --- record declarations ---
+
+ @Override public void visit(final PackageDeclaration n, final Void v)
+ {
+ NameExpr nameExpr = n.getName();
+
+ String packageName = JavaDeclNameResolver.getQualifiedName(nameExpr).toNameHierarchy();
+
+ JavaIndexer.recordSymbolWithScope(
+ m_callbackId, packageName, SymbolType.PACKAGE,
+ nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
+ AccessKind.NONE, false
+ );
+
+ super.visit(n, v);
+ }
+
+ @Override public void visit(final ClassOrInterfaceDeclaration n, final Void v)
+ {
+ NameExpr nameExpr = n.getNameExpr();
+
+ String qualifiedName = JavaDeclNameResolver.getQualifiedDeclName(n, m_typeSolver).toNameHierarchy();
+
+ JavaIndexer.recordSymbolWithScope(
+ m_callbackId, qualifiedName, (n.isInterface() ? SymbolType.INTERFACE : SymbolType.CLASS),
+ nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
+ AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
+ );
+
+ List parentContext = m_context;
+ m_context = new ArrayList();
+ m_context.add(new DeclContext(qualifiedName));
+ super.visit(n, v);
+ m_context = parentContext;
+ }
+
+ @Override public void visit(final TypeParameter n, final Void v)
+ {
+ // todo: test recording of typeargument of type parameter bound type??
+
+
+
+ if (m_context.size() != 1)
+ {
+ // throw something!
+ }
+
+ String qualifiedName = m_context.get(0).getName();
+ qualifiedName += "\n";
+ qualifiedName += n.getName() + "\t\r";
+
+ JavaIndexer.recordSymbol(
+ m_callbackId, qualifiedName, SymbolType.TYPE_PARAMETER,
+ n.getBeginLine(), n.getBeginColumn(), n.getBeginLine(), n.getBeginColumn() + n.getName().length() - 1,
+ AccessKind.TYPE_PARAMETER, false
+ );
+
+ List parentContext = m_context;
+ m_context = new ArrayList();
+ m_context.add(new DeclContext(qualifiedName));
+ super.visit(n, v);
+ m_context = parentContext;
+ }
+
+ @Override public void visit(final EnumDeclaration n, final Void v)
+ {
+ NameExpr nameExpr = n.getNameExpr();
+
+ String qualifiedName = JavaDeclNameResolver.getQualifiedDeclName(n, m_typeSolver).toNameHierarchy();
+
+ JavaIndexer.recordSymbolWithScope(
+ m_callbackId, qualifiedName, SymbolType.ENUM,
+ nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
+ AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
+ );
+
+ List parentContext = m_context;
+ m_context = new ArrayList();
+ m_context.add(new DeclContext(qualifiedName));
+ super.visit(n, v);
+ m_context = parentContext;
+ }
+
+ @Override public void visit(final EnumConstantDeclaration n, final Void v)
+ {
+ String qualifiedName = JavaDeclNameResolver.getQualifiedDeclName(n, m_typeSolver).toNameHierarchy();
+
+ JavaIndexer.recordSymbol(
+ m_callbackId, qualifiedName, SymbolType.ENUM_CONSTANT,
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
+ AccessKind.NONE, false
+ );
+
+ List parentContext = m_context;
+ m_context = new ArrayList();
+ m_context.add(new DeclContext(qualifiedName));
+ super.visit(n, v);
+ m_context = parentContext;
+ }
+
+ @Override public void visit(final ConstructorDeclaration n, final Void v)
+ {
+ NameExpr nameExpr = n.getNameExpr();
+
+ String qualifiedName = JavaDeclNameResolver.getQualifiedDeclName(n, m_typeSolver).toNameHierarchy();
+
+ JavaIndexer.recordSymbolWithScope(
+ m_callbackId, qualifiedName, SymbolType.METHOD,
+ nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
+ AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
+ );
+
+ List parentContext = m_context;
+ m_context = new ArrayList();
+ m_context.add(new DeclContext(qualifiedName));
+ super.visit(n, v);
+ m_context = parentContext;
+ }
+
+ @Override public void visit(final MethodDeclaration n, final Void v)
+ {
+ NameExpr nameExpr = n.getNameExpr();
+
+ String qualifiedName = JavaDeclNameResolver.getQualifiedDeclName(n, m_typeSolver).toNameHierarchy();
+
+ JavaIndexer.recordSymbolWithScope(
+ m_callbackId, qualifiedName, SymbolType.METHOD,
+ nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn(),
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn(),
+ AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
+ );
+
+
+/// test this!
+ Node parent = n.getParentNode();
+
+ me.tomassetti.symbolsolver.model.declarations.MethodDeclaration overridden = getOverridden(n, parent);
+ if (overridden != null && (overridden instanceof JavaParserMethodDeclaration))
+ {
+ String overriddenName = JavaDeclNameResolver.getQualifiedDeclName(((JavaParserMethodDeclaration)overridden).getWrappedNode(), m_typeSolver).toNameHierarchy();
+
+ JavaIndexer.recordReference(
+ m_callbackId, ReferenceKind.OVERRIDE, overriddenName, qualifiedName,
+ nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn()
+ );
+ }
+
+
+
+
+
+
+ List parentContext = m_context;
+ m_context = new ArrayList();
+ m_context.add(new DeclContext(qualifiedName));
+ super.visit(n, v);
+ m_context = parentContext;
+ }
+
+ private me.tomassetti.symbolsolver.model.declarations.MethodDeclaration getOverridden(MethodDeclaration overrider, Node searchScope)
+ {
+ List ancestors = new ArrayList<>();
+
+ if (searchScope instanceof ClassOrInterfaceDeclaration)
+ {
+ ancestors.addAll(((ClassOrInterfaceDeclaration)searchScope).getImplements());
+ ancestors.addAll(((ClassOrInterfaceDeclaration)searchScope).getExtends());
+ }
+ if (searchScope instanceof EnumDeclaration)
+ {
+ ancestors.addAll(((EnumDeclaration)searchScope).getImplements());
+ }
+
+ if (!ancestors.isEmpty())
+ {
+ List parameterTypes = new ArrayList<>();
+ for (Parameter parameter: overrider.getParameters())
+ {
+ Type parameterType = parameter.getType();
+ parameterTypes.add(JavaParserFacade.get(m_typeSolver).convert(parameterType, parameterType));
+ }
+
+ for (ClassOrInterfaceType ancestor: ancestors)
+ {
+ try
+ {
+ TypeUsage ancestorTypeUsage = JavaParserFacade.get(m_typeSolver).convert(ancestor, ancestor);
+ if (ancestorTypeUsage.isReferenceType())
+ {
+ SymbolReference solvedMethod = ancestorTypeUsage.asReferenceTypeUsage().solveMethod(overrider.getName(), parameterTypes);
+ if (solvedMethod.isSolved())
+ {
+ return solvedMethod.getCorrespondingDeclaration();
+ }
+ }
+ }
+ catch (UnsolvedSymbolException e)
+ {
+ // nothing to do here, just try to solve in the next ancestor
+ }
+ catch (Exception e)
+ {
+ // hmm, maybe we should handle these cases. soon..
+ // don't do anything for parse exceptions. they are displayed as errors anyways.
+ }
+ }
+ }
+ return null;
+ }
+
+
+ @Override public void visit(final FieldDeclaration n, final Void v)
+ {
+ List parentContext = m_context;
+ m_context = new ArrayList();
+
+ List variableDeclarators = n.getVariables();
+ for (int i = 0; i < variableDeclarators.size(); i++)
+ {
+ VariableDeclarator varDecl = variableDeclarators.get(i);
+ String qualifiedName = JavaDeclNameResolver.getQualifiedDeclName(varDecl, m_typeSolver).toNameHierarchy();
+ VariableDeclaratorId varDeclId = varDecl.getId();
+
+ JavaIndexer.recordSymbol(
+ m_callbackId, qualifiedName, SymbolType.FIELD,
+ varDeclId.getBeginLine(), varDeclId.getBeginColumn(), varDeclId.getEndLine(), varDeclId.getEndColumn(),
+ AccessKind.fromAccessSpecifier(ModifierSet.getAccessSpecifier(n.getModifiers())), false
+ );
+
+ m_context.add(new DeclContext(qualifiedName));
+ }
+
+ super.visit(n, v);
+ m_context = parentContext;
+ }
+
+ @Override public void visit(final VariableDeclarationExpr n, final Void v)
+ {
+ for (VariableDeclarator declarator: n.getVars())
+ {
+ VariableDeclaratorId identifier = declarator.getId();
+ String qualifiedName = m_filePath + "<" + identifier.getBeginLine() + ":" + identifier.getBeginColumn() + ">";
+
+ JavaIndexer.recordLocalSymbol(
+ m_callbackId, qualifiedName,
+ identifier.getBeginLine(), identifier.getBeginColumn(), identifier.getEndLine(), identifier.getEndColumn()
+ );
+
+ }
+
+ // don't change the context here.
+ super.visit(n, v);
+ }
+
+ @Override public void visit(final Parameter n, final Void v)
+ {
+ VariableDeclaratorId identifier = n.getId();
+ String qualifiedName = m_filePath + "<" + identifier.getBeginLine() + ":" + identifier.getBeginColumn() + ">";
+
+ JavaIndexer.recordLocalSymbol(
+ m_callbackId, qualifiedName,
+ identifier.getBeginLine(), identifier.getBeginColumn(), identifier.getEndLine(), identifier.getEndColumn()
+ );
+
+ // don't change the context here.
+ super.visit(n, v);
+ }
+
+
+ // --- record references ---
+
+
+ @Override public void visit(final ImportDeclaration n, final Void v)
+ {
+ if (n.isAsterisk())
+ {
+ NameExpr nameExpr = n.getName();
+ String importedName = JavaDeclNameResolver.getQualifiedName(nameExpr).toNameHierarchy();
+ for (DeclContext context: m_context)
+ {
+ JavaIndexer.recordReference(
+ m_callbackId, ReferenceKind.IMPORT,
+ importedName, context.getName(),
+ nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn()
+ );
+ }
+ }
+ else
+ {
+ try
+ {
+ NameExpr nameExpr = n.getName();
+
+ JavaDeclName importedDeclName = null;
+
+ SymbolReference symbolReference = m_typeSolver.tryToSolveType(
+ JavaDeclNameResolver.getQualifiedName(nameExpr).toString()
+ );
+ if (symbolReference.isSolved())
+ {
+ importedDeclName = JavaDeclNameResolver.getQualifiedDeclName(symbolReference.getCorrespondingDeclaration(), m_typeSolver);
+ }
+
+ if (importedDeclName != null)
+ {
+ String importedName = importedDeclName.toNameHierarchy();
+ for (DeclContext context: m_context)
+ {
+ JavaIndexer.recordReference(
+ m_callbackId, ReferenceKind.IMPORT,
+ importedName, context.getName(),
+ nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn()
+ );
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ }
+ super.visit(n, v);
+ }
+
+ @Override public void visit(final ClassOrInterfaceType n, final Void v)
+ {
+ try
+ {
+ for (DeclContext context: m_context)
+ {
+ String referencedName = JavaTypeNameResolver.getQualifiedTypeName(n, m_typeSolver).toNameHierarchy();
+
+ int beginLine = n.getBeginLine();
+ int beginColumn = n.getBeginColumn();
+ int endLine = n.getBeginLine();
+ int endColumn = n.getBeginColumn() + n.getName().length() - 1;
+
+ if (n.getScope() != null)
+ {
+ endLine = n.getScope().getEndLine();
+ endColumn = n.getScope().getEndColumn() + n.getName().length() + 1; // +1 for separator
+ }
+
+ JavaIndexer.recordReference(
+ m_callbackId, getTypeReferenceKind(), referencedName, context.getName(),
+ beginLine, beginColumn, endLine, endColumn
+ );
+ }
+ }
+ catch (Exception e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ super.visit(n, v);
+ }
+
+ @Override public void visit(final PrimitiveType n, final Void v)
+ {
+ try
+ {
+ String referencedName = JavaTypeNameResolver.getQualifiedTypeName(n, m_typeSolver).toNameHierarchy();
+
+ JavaIndexer.recordSymbolWithoutLocation(
+ m_callbackId, referencedName, SymbolType.BUILTIN_TYPE,
+ AccessKind.NONE, true
+ );
+
+ for (DeclContext context: m_context)
+ {
+ JavaIndexer.recordReference(
+ m_callbackId, getTypeReferenceKind(), referencedName, context.getName(),
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn()
+ );
+ }
+ }
+ catch (Exception e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+
+ super.visit(n, v);
+ }
+
+ @Override public void visit(final VoidType n, final Void v)
+ {
+ try
+ {
+ String referencedName = JavaTypeNameResolver.getQualifiedTypeName(n, m_typeSolver).toNameHierarchy();
+
+ JavaIndexer.recordSymbolWithoutLocation(
+ m_callbackId, referencedName, SymbolType.BUILTIN_TYPE,
+ AccessKind.NONE, true
+ );
+
+ for (DeclContext context: m_context)
+ {
+ JavaIndexer.recordReference(
+ m_callbackId, getTypeReferenceKind(), referencedName, context.getName(),
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn()
+ );
+ }
+ }
+ catch (Exception e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+
+ super.visit(n, v);
+ }
+
+ @Override public void visit(final NameExpr n, final Void v)
+ {
+ try
+ {
+ recordRef(n);
+ }
+ catch (Exception e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+
+ super.visit(n, v);
+ }
+
+ private void recordRef(NameExpr e)
+ {
+ SymbolReference extends ValueDeclaration> ref = JavaParserFacade.get(m_typeSolver).solve(e);
+ if (ref.isSolved())
+ {
+ ValueDeclaration valueDecl = ref.getCorrespondingDeclaration();
+ if (valueDecl instanceof JavaParserSymbolDeclaration)
+ {
+ Node wrappedNode = null;
+ if (valueDecl instanceof JavaParserSymbolDeclaration)
+ {
+ wrappedNode = ((JavaParserSymbolDeclaration)valueDecl).getWrappedNode();
+ }
+ if (wrappedNode != null)
+ {
+ if (wrappedNode instanceof Parameter)
+ {
+ VariableDeclaratorId identifier = ((Parameter)wrappedNode).getId();
+ String qualifiedName = m_filePath + "<" + identifier.getBeginLine() + ":" + identifier.getBeginColumn() + ">";
+
+ JavaIndexer.recordLocalSymbol(
+ m_callbackId, qualifiedName,
+ e.getBeginLine(), e.getBeginColumn(), e.getEndLine(), e.getEndColumn()
+ );
+ }
+ else if (wrappedNode instanceof VariableDeclarator)
+ {
+ if (getFieldDeclarationInParentHierarchy(wrappedNode) != null)
+ {
+ String qualifiedName = JavaDeclNameResolver.getQualifiedDeclName((VariableDeclarator)wrappedNode, m_typeSolver).toNameHierarchy();
+
+ for (DeclContext context: m_context)
+ {
+ JavaIndexer.recordReference(
+ m_callbackId, ReferenceKind.USAGE, qualifiedName, context.getName(),
+ e.getBeginLine(), e.getBeginColumn(), e.getEndLine(), e.getEndColumn()
+ );
+ }
+ }
+ else
+ {
+ VariableDeclaratorId identifier = ((VariableDeclarator)wrappedNode).getId();
+ String qualifiedName = m_filePath + "<" + identifier.getBeginLine() + ":" + identifier.getBeginColumn() + ">";
+
+ JavaIndexer.recordLocalSymbol(
+ m_callbackId, qualifiedName,
+ e.getBeginLine(), e.getBeginColumn(), e.getEndLine(), e.getEndColumn()
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private static FieldDeclaration getFieldDeclarationInParentHierarchy(Node decl)
+ {
+ FieldDeclaration context = null;
+ {
+ Node parentNode = decl.getParentNode();
+ while (parentNode != null && !(parentNode instanceof FieldDeclaration))
+ {
+ parentNode = parentNode.getParentNode();
+ }
+
+ if (parentNode != null)
+ {
+ context = (FieldDeclaration)parentNode;
+ }
+ }
+ return context;
+ }
+
+ @Override public void visit(final MethodCallExpr n, final Void v)
+ {
+ String qualifiedName = "";
+ if (m_context.size() > 0)
+ {
+ try
+ {
+ MethodUsage solvedMethod = JavaParserFacade.get(m_typeSolver).solveMethodAsUsage(n);
+ qualifiedName = getQualifiedName(solvedMethod);
+ }
+ catch (UnsupportedOperationException e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ catch (MethodAmbiguityException e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ catch(StackOverflowError e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ catch (Exception e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ }
+
+ if (!qualifiedName.isEmpty())
+ {
+ NameExpr nameExpr = n.getNameExpr();
+ for (DeclContext context: m_context)
+ {
+ JavaIndexer.recordReference(
+ m_callbackId, ReferenceKind.CALL, qualifiedName, context.getName(),
+ nameExpr.getBeginLine(), nameExpr.getBeginColumn(), nameExpr.getEndLine(), nameExpr.getEndColumn()
+ );
+ }
+ }
+
+ super.visit(n, v);
+ }
+ /*
+ @Override public void visit(final ObjectCreationExpr n, final Void v)
+ {
+ String qualifiedName = "";
+ if (m_context.size() > 0)
+ {
+ try
+ {
+ ClassOrInterfaceDeclaration decl = Utility.getJavaparserDeclForType(n.getType(), m_typeSolver);
+ if (decl != null)
+ {
+ TODO: implement when there is a method to get the constructor decl for a constructor expression.
+
+ for (BodyDeclaration member: decl.getMembers())
+ {
+ if (member instanceof ConstructorDeclaration)
+ {
+ ConstructorDeclaration constructorDecl = (ConstructorDeclaration)member;
+
+ for (Expression arg: n.getArgs())
+ {
+ JavaParserFacade.get(m_typeSolver).getType(arg).asReferenceTypeUsage().getQualifiedName();
+ }
+
+ constructorDecl.getParameters().get(0).getType().;
+ }
+ }
+ }
+
+
+ qualifiedName = getQualifiedName(methodUsage.get());
+ }
+ catch (UnsupportedOperationException e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ catch (MethodAmbiguityException e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ catch(StackOverflowError e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ catch (Exception e)
+ {
+ if (m_verbose)
+ {
+ System.out.println(e + " at location " + n.getBeginLine() + ", " + n.getBeginColumn());
+ }
+ }
+ }
+
+ if (!qualifiedName.isEmpty())
+ {
+ ClassOrInterfaceType type = n.getType();
+ for (DeclContext context: m_context)
+ {
+ JavaIndexer.recordRef(
+ m_callbackId, ReferenceType.CALL.getValue(), qualifiedName, context.getName(),
+ type.getBeginLine(), type.getBeginColumn(), type.getEndLine(), type.getEndColumn()
+ );
+ }
+ }
+
+ super.visit(n, v);
+ }
+ */
+ private String getQualifiedName(MethodUsage solvedMethod)
+ {
+ me.tomassetti.symbolsolver.model.declarations.MethodDeclaration methodDecl = solvedMethod.getDeclaration();
+ String qualifiedName = "";
+ if (methodDecl instanceof JavaParserMethodDeclaration)
+ {
+ MethodDeclaration wrappedNode = ((JavaParserMethodDeclaration)methodDecl).getWrappedNode();
+ qualifiedName = JavaDeclNameResolver.getQualifiedDeclName(wrappedNode, m_typeSolver).toNameHierarchy();
+ }
+ else // todo: move this implementation somewhere else
+ {
+ qualifiedName = solvedMethod.declaringType().getQualifiedName();
+ qualifiedName = qualifiedName.replace(".", "\t\r\n");
+
+ qualifiedName += "\t\r\n" + solvedMethod.getName() + "\t";
+
+ String returnType = solvedMethod.returnType().describe();
+ qualifiedName += returnType;
+ // qualifiedName += returnType.substring(returnType.lastIndexOf(".") + 1);
+
+ qualifiedName += "\r(";
+ for (int i = 0; i < solvedMethod.getParamTypes().size(); i++)
+ {
+ if(i != 0)
+ {
+ qualifiedName += (", ");
+ }
+ String paramType = solvedMethod.getParamTypes().get(i).describe();
+ qualifiedName += paramType;
+ // qualifiedName += paramType.substring(paramType.lastIndexOf(".") + 1);
+ }
+ qualifiedName = qualifiedName.concat(")");
+ }
+ return qualifiedName;
+ }
+
+ @Override public void visit(final LineComment n, final Void v)
+ {
+ JavaIndexer.recordComment(
+ m_callbackId,
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn()
+ );
+ }
+
+ @Override public void visit(final BlockComment n, final Void v)
+ {
+ JavaIndexer.recordComment(
+ m_callbackId,
+ n.getBeginLine(), n.getBeginColumn(), n.getEndLine(), n.getEndColumn()
+ );
+ }
+}
\ No newline at end of file
diff --git a/java_indexer/src/io/coati/JavaAstVisitorAdapter.java b/java_indexer/src/io/coati/JavaAstVisitorAdapter.java
new file mode 100644
index 00000000..79166642
--- /dev/null
+++ b/java_indexer/src/io/coati/JavaAstVisitorAdapter.java
@@ -0,0 +1,1047 @@
+package io.coati;
+
+import com.github.javaparser.ast.comments.BlockComment;
+import com.github.javaparser.ast.comments.Comment;
+import com.github.javaparser.ast.CompilationUnit;
+import com.github.javaparser.ast.ImportDeclaration;
+import com.github.javaparser.ast.comments.LineComment;
+import com.github.javaparser.ast.PackageDeclaration;
+import com.github.javaparser.ast.TypeParameter;
+import com.github.javaparser.ast.body.AnnotationDeclaration;
+import com.github.javaparser.ast.body.AnnotationMemberDeclaration;
+import com.github.javaparser.ast.body.BodyDeclaration;
+import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
+import com.github.javaparser.ast.body.ConstructorDeclaration;
+import com.github.javaparser.ast.body.EmptyMemberDeclaration;
+import com.github.javaparser.ast.body.EmptyTypeDeclaration;
+import com.github.javaparser.ast.body.EnumConstantDeclaration;
+import com.github.javaparser.ast.body.EnumDeclaration;
+import com.github.javaparser.ast.body.FieldDeclaration;
+import com.github.javaparser.ast.body.InitializerDeclaration;
+import com.github.javaparser.ast.comments.JavadocComment;
+import com.github.javaparser.ast.body.MethodDeclaration;
+import com.github.javaparser.ast.body.MultiTypeParameter;
+import com.github.javaparser.ast.body.Parameter;
+import com.github.javaparser.ast.body.TypeDeclaration;
+import com.github.javaparser.ast.body.VariableDeclarator;
+import com.github.javaparser.ast.body.VariableDeclaratorId;
+import com.github.javaparser.ast.expr.*;
+import com.github.javaparser.ast.stmt.AssertStmt;
+import com.github.javaparser.ast.stmt.BlockStmt;
+import com.github.javaparser.ast.stmt.BreakStmt;
+import com.github.javaparser.ast.stmt.CatchClause;
+import com.github.javaparser.ast.stmt.ContinueStmt;
+import com.github.javaparser.ast.stmt.DoStmt;
+import com.github.javaparser.ast.stmt.EmptyStmt;
+import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt;
+import com.github.javaparser.ast.stmt.ExpressionStmt;
+import com.github.javaparser.ast.stmt.ForStmt;
+import com.github.javaparser.ast.stmt.ForeachStmt;
+import com.github.javaparser.ast.stmt.IfStmt;
+import com.github.javaparser.ast.stmt.LabeledStmt;
+import com.github.javaparser.ast.stmt.ReturnStmt;
+import com.github.javaparser.ast.stmt.Statement;
+import com.github.javaparser.ast.stmt.SwitchEntryStmt;
+import com.github.javaparser.ast.stmt.SwitchStmt;
+import com.github.javaparser.ast.stmt.SynchronizedStmt;
+import com.github.javaparser.ast.stmt.ThrowStmt;
+import com.github.javaparser.ast.stmt.TryStmt;
+import com.github.javaparser.ast.stmt.TypeDeclarationStmt;
+import com.github.javaparser.ast.stmt.WhileStmt;
+import com.github.javaparser.ast.type.*;
+import com.github.javaparser.ast.visitor.VoidVisitor;
+
+import static com.github.javaparser.ast.internal.Utils.isNullOrEmpty;
+
+import java.util.Stack;
+
+public abstract class JavaAstVisitorAdapter implements VoidVisitor
+{
+ private Stack m_typeRefKind = new Stack();
+
+ protected ReferenceKind getTypeReferenceKind()
+ {
+ if (!m_typeRefKind.isEmpty())
+ {
+ return m_typeRefKind.peek();
+ }
+ return ReferenceKind.TYPE_USAGE;
+ }
+
+ //- Compilation Unit ----------------------------------
+
+ @Override public void visit(CompilationUnit n, Void arg)
+ {
+ m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
+ visitComment(n.getComment(), arg);
+ if (n.getPackage() != null)
+ {
+ n.getPackage().accept(this, arg);
+ }
+ if (n.getImports() != null)
+ {
+ for (final ImportDeclaration i : n.getImports())
+ {
+ i.accept(this, arg);
+ }
+ }
+ if (n.getTypes() != null)
+ {
+ for (final TypeDeclaration typeDeclaration : n.getTypes())
+ {
+ typeDeclaration.accept(this, arg);
+ }
+ }
+ m_typeRefKind.pop();
+ }
+
+ @Override public void visit(PackageDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+ }
+// n.getName().accept(this, arg);
+ }
+
+ @Override public void visit(ImportDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+// n.getName().accept(this, arg);
+ }
+
+ @Override public void visit(TypeParameter n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getTypeBound() != null)
+ {
+ for (final ClassOrInterfaceType c : n.getTypeBound())
+ {
+ c.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(LineComment n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(BlockComment n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ //- Body ----------------------------------------------
+
+ @Override public void visit(ClassOrInterfaceDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+// n.getNameExpr().accept(this, arg);
+ for (final TypeParameter t : n.getTypeParameters())
+ {
+ t.accept(this, arg);
+ }
+
+ m_typeRefKind.push(ReferenceKind.INHERITANCE);
+ for (final ClassOrInterfaceType c : n.getExtends())
+ {
+ c.accept(this, arg);
+ }
+ for (final ClassOrInterfaceType c : n.getImplements())
+ {
+ c.accept(this, arg);
+ }
+ m_typeRefKind.pop();
+
+ for (final BodyDeclaration member : n.getMembers())
+ {
+ member.accept(this, arg);
+ }
+ }
+
+ @Override public void visit(EnumDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations()) {
+ a.accept(this, arg);
+ }
+ }
+// n.getNameExpr().accept(this, arg);
+
+ m_typeRefKind.push(ReferenceKind.INHERITANCE);
+ if (n.getImplements() != null)
+ {
+ for (final ClassOrInterfaceType c : n.getImplements())
+ {
+ c.accept(this, arg);
+ }
+ }
+ m_typeRefKind.pop();
+
+ if (n.getEntries() != null)
+ {
+ for (final EnumConstantDeclaration e : n.getEntries())
+ {
+ e.accept(this, arg);
+ }
+ }
+ if (n.getMembers() != null)
+ {
+ for (final BodyDeclaration member : n.getMembers())
+ {
+ member.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(EmptyTypeDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+// n.getNameExpr().accept(this, arg);
+ }
+
+ @Override public void visit(EnumConstantDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+ }
+ if (n.getArgs() != null)
+ {
+ for (final Expression e : n.getArgs())
+ {
+ e.accept(this, arg);
+ }
+ }
+ if (n.getClassBody() != null)
+ {
+ for (final BodyDeclaration member : n.getClassBody())
+ {
+ member.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(AnnotationDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+ }
+// n.getNameExpr().accept(this, arg);
+ if (n.getMembers() != null)
+ {
+ for (final BodyDeclaration member : n.getMembers())
+ {
+ member.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(AnnotationMemberDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+ }
+ n.getType().accept(this, arg);
+ if (n.getDefaultValue() != null)
+ {
+ n.getDefaultValue().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(FieldDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+ }
+ n.getType().accept(this, arg);
+ for (final VariableDeclarator var : n.getVariables())
+ {
+ var.accept(this, arg);
+ }
+ }
+
+ @Override public void visit(VariableDeclarator n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getId().accept(this, arg);
+ if (n.getInit() != null)
+ {
+ n.getInit().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(VariableDeclaratorId n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(ConstructorDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+ }
+ if (n.getTypeParameters() != null)
+ {
+ for (final TypeParameter t : n.getTypeParameters())
+ {
+ t.accept(this, arg);
+ }
+ }
+// n.getNameExpr().accept(this, arg);
+ if (n.getParameters() != null)
+ {
+ for (final Parameter p : n.getParameters())
+ {
+ p.accept(this, arg);
+ }
+ }
+ if (n.getThrows() != null)
+ {
+ for (final NameExpr name : n.getThrows())
+ {
+ name.accept(this, arg);
+ }
+ }
+ n.getBlock().accept(this, arg);
+ }
+
+ @Override public void visit(MethodDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+ }
+ if (n.getTypeParameters() != null)
+ {
+ for (final TypeParameter t : n.getTypeParameters())
+ {
+ t.accept(this, arg);
+ }
+ }
+ n.getType().accept(this, arg);
+// n.getNameExpr().accept(this, arg);
+ if (n.getParameters() != null)
+ {
+ for (final Parameter p : n.getParameters())
+ {
+ p.accept(this, arg);
+ }
+ }
+ if (n.getThrows() != null)
+ {
+ for (final ReferenceType name : n.getThrows())
+ {
+ name.accept(this, arg);
+ }
+ }
+ if (n.getBody() != null)
+ {
+ n.getBody().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(Parameter n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+ }
+ n.getType().accept(this, arg);
+ n.getId().accept(this, arg);
+ }
+
+ @Override public void visit(MultiTypeParameter n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getAnnotations() != null)
+ {
+ for (final AnnotationExpr a : n.getAnnotations())
+ {
+ a.accept(this, arg);
+ }
+ }
+ if (n.getType() != null)
+ {
+ n.getType().accept(this, arg);
+ }
+ n.getId().accept(this, arg);
+ }
+
+ @Override public void visit(EmptyMemberDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(InitializerDeclaration n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getJavaDoc() != null)
+ {
+ n.getJavaDoc().accept(this, arg);
+ }
+ n.getBlock().accept(this, arg);
+ }
+
+ @Override public void visit(JavadocComment n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ //- Type ----------------------------------------------
+
+ @Override public void visit(ClassOrInterfaceType n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+// if (n.getScope() != null) // don't visit the qualifier here.
+// {
+// n.getScope().accept(this, arg);
+// }
+ m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
+ if (n.getTypeArgs() != null)
+ {
+ for (final Type t : n.getTypeArgs())
+ {
+ t.accept(this, arg);
+ }
+ }
+ m_typeRefKind.pop();
+ }
+
+ @Override public void visit(PrimitiveType n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(ReferenceType n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getType().accept(this, arg);
+ }
+
+ @Override public void visit(IntersectionType n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ for (ReferenceType element : n.getElements())
+ {
+ element.accept(this, arg);
+ }
+ }
+
+ @Override public void visit(UnionType n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ for (ReferenceType element : n.getElements())
+ {
+ element.accept(this, arg);
+ }
+ }
+
+ @Override public void visit(VoidType n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(WildcardType n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getExtends() != null)
+ {
+ n.getExtends().accept(this, arg);
+ }
+ if (n.getSuper() != null)
+ {
+ n.getSuper().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(UnknownType n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ //- Expression ----------------------------------------
+
+ @Override public void visit(ArrayAccessExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getName().accept(this, arg);
+ n.getIndex().accept(this, arg);
+ }
+
+ @Override public void visit(ArrayCreationExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getType().accept(this, arg);
+ if (!isNullOrEmpty(n.getDimensions()))
+ {
+ for (final Expression dim : n.getDimensions())
+ {
+ dim.accept(this, arg);
+ }
+ } else
+ {
+ n.getInitializer().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(ArrayInitializerExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getValues() != null)
+ {
+ for (final Expression expr : n.getValues())
+ {
+ expr.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(AssignExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getTarget().accept(this, arg);
+ n.getValue().accept(this, arg);
+ }
+
+ @Override public void visit(BinaryExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getLeft().accept(this, arg);
+ n.getRight().accept(this, arg);
+ }
+
+ @Override public void visit(CastExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getType().accept(this, arg);
+ n.getExpr().accept(this, arg);
+ }
+
+ @Override public void visit(ClassExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getType().accept(this, arg);
+ }
+
+ @Override public void visit(ConditionalExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getCondition().accept(this, arg);
+ n.getThenExpr().accept(this, arg);
+ n.getElseExpr().accept(this, arg);
+ }
+
+ @Override public void visit(EnclosedExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getInner().accept(this, arg);
+ }
+
+ @Override public void visit(FieldAccessExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getScope().accept(this, arg);
+ n.getFieldExpr().accept(this, arg); // hmm.. this could be a name Expr
+ }
+
+ @Override public void visit(InstanceOfExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getExpr().accept(this, arg);
+ n.getType().accept(this, arg);
+ }
+
+ @Override public void visit(StringLiteralExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(IntegerLiteralExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(LongLiteralExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(IntegerLiteralMinValueExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(LongLiteralMinValueExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(CharLiteralExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(DoubleLiteralExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(BooleanLiteralExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(NullLiteralExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(MethodCallExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getScope() != null) {
+ n.getScope().accept(this, arg);
+ }
+
+ m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
+ if (n.getTypeArgs() != null) {
+ for (final Type t : n.getTypeArgs()) {
+ t.accept(this, arg);
+ }
+ }
+ m_typeRefKind.pop();
+
+// n.getNameExpr().accept(this, arg);
+ if (n.getArgs() != null) {
+ for (final Expression e : n.getArgs()) {
+ e.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(NameExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(ObjectCreationExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getScope() != null) {
+ n.getScope().accept(this, arg);
+ }
+
+ m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
+ if (n.getTypeArgs() != null) {
+ for (final Type t : n.getTypeArgs()) {
+ t.accept(this, arg);
+ }
+ }
+ m_typeRefKind.pop();
+
+ n.getType().accept(this, arg);
+ if (n.getArgs() != null) {
+ for (final Expression e : n.getArgs()) {
+ e.accept(this, arg);
+ }
+ }
+ if (n.getAnonymousClassBody() != null) {
+ for (final BodyDeclaration member : n.getAnonymousClassBody()) {
+ member.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(QualifiedNameExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getQualifier().accept(this, arg);
+ }
+
+ @Override public void visit(ThisExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getClassExpr() != null) {
+ n.getClassExpr().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(SuperExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getClassExpr() != null) {
+ n.getClassExpr().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(UnaryExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getExpr().accept(this, arg);
+ }
+
+ @Override public void visit(VariableDeclarationExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getAnnotations() != null) {
+ for (final AnnotationExpr a : n.getAnnotations()) {
+ a.accept(this, arg);
+ }
+ }
+ n.getType().accept(this, arg);
+ for (final VariableDeclarator v : n.getVars()) {
+ v.accept(this, arg);
+ }
+ }
+
+ @Override public void visit(MarkerAnnotationExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getName().accept(this, arg);
+ }
+
+ @Override public void visit(SingleMemberAnnotationExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getName().accept(this, arg);
+ n.getMemberValue().accept(this, arg);
+ }
+
+ @Override public void visit(NormalAnnotationExpr n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getName().accept(this, arg);
+ if (n.getPairs() != null) {
+ for (final MemberValuePair m : n.getPairs()) {
+ m.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(MemberValuePair n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getValue().accept(this, arg);
+ }
+
+ //- Statements ----------------------------------------
+
+ @Override public void visit(ExplicitConstructorInvocationStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (!n.isThis() && n.getExpr() != null) {
+ n.getExpr().accept(this, arg);
+ }
+
+ m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
+ if (n.getTypeArgs() != null) {
+ for (final Type t : n.getTypeArgs()) {
+ t.accept(this, arg);
+ }
+ }
+ m_typeRefKind.pop();
+
+ if (n.getArgs() != null) {
+ for (final Expression e : n.getArgs()) {
+ e.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(TypeDeclarationStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getTypeDeclaration().accept(this, arg);
+ }
+
+ @Override public void visit(AssertStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getCheck().accept(this, arg);
+ if (n.getMessage() != null) {
+ n.getMessage().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(BlockStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getStmts() != null) {
+ for (final Statement s : n.getStmts()) {
+ s.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(LabeledStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getStmt().accept(this, arg);
+ }
+
+ @Override public void visit(EmptyStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(ExpressionStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getExpression().accept(this, arg);
+ }
+
+ @Override public void visit(SwitchStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getSelector().accept(this, arg);
+ if (n.getEntries() != null) {
+ for (final SwitchEntryStmt e : n.getEntries()) {
+ e.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(SwitchEntryStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getLabel() != null) {
+ n.getLabel().accept(this, arg);
+ }
+ if (n.getStmts() != null) {
+ for (final Statement s : n.getStmts()) {
+ s.accept(this, arg);
+ }
+ }
+ }
+
+ @Override public void visit(BreakStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(ReturnStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getExpr() != null) {
+ n.getExpr().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(IfStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getCondition().accept(this, arg);
+ n.getThenStmt().accept(this, arg);
+ if (n.getElseStmt() != null) {
+ n.getElseStmt().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(WhileStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getCondition().accept(this, arg);
+ n.getBody().accept(this, arg);
+ }
+
+ @Override public void visit(ContinueStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ }
+
+ @Override public void visit(DoStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getBody().accept(this, arg);
+ n.getCondition().accept(this, arg);
+ }
+
+ @Override public void visit(ForeachStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getVariable().accept(this, arg);
+ n.getIterable().accept(this, arg);
+ n.getBody().accept(this, arg);
+ }
+
+ @Override public void visit(ForStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getInit() != null) {
+ for (final Expression e : n.getInit()) {
+ e.accept(this, arg);
+ }
+ }
+ if (n.getCompare() != null) {
+ n.getCompare().accept(this, arg);
+ }
+ if (n.getUpdate() != null) {
+ for (final Expression e : n.getUpdate()) {
+ e.accept(this, arg);
+ }
+ }
+ n.getBody().accept(this, arg);
+ }
+
+ @Override public void visit(ThrowStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getExpr().accept(this, arg);
+ }
+
+ @Override public void visit(SynchronizedStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getExpr().accept(this, arg);
+ n.getBlock().accept(this, arg);
+ }
+
+ @Override public void visit(TryStmt n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ if (n.getResources() != null) {
+ for (final VariableDeclarationExpr v : n.getResources()) {
+ v.accept(this, arg);
+ }
+ }
+ n.getTryBlock().accept(this, arg);
+ if (n.getCatchs() != null) {
+ for (final CatchClause c : n.getCatchs()) {
+ c.accept(this, arg);
+ }
+ }
+ if (n.getFinallyBlock() != null) {
+ n.getFinallyBlock().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(CatchClause n, Void arg)
+ {
+ visitComment(n.getComment(), arg);
+ n.getParam().accept(this, arg);
+ n.getCatchBlock().accept(this, arg);
+ }
+
+ @Override public void visit(LambdaExpr n, Void arg)
+ {
+ if (n.getParameters() != null) {
+ for (final Parameter a : n.getParameters()) {
+ a.accept(this, arg);
+ }
+ }
+ if (n.getBody() != null) {
+ n.getBody().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(MethodReferenceExpr n, Void arg)
+ {
+ if (n.getTypeParameters() != null) {
+ for (final TypeParameter a : n.getTypeParameters()) {
+ a.accept(this, arg);
+ }
+ }
+ if (n.getScope() != null) {
+ n.getScope().accept(this, arg);
+ }
+ }
+
+ @Override public void visit(TypeExpr n, Void arg)
+ {
+ if (n.getType() != null) {
+ n.getType().accept(this, arg);
+ }
+ }
+
+ private void visitComment(final Comment n, final Void arg)
+ {
+ if (n != null)
+ {
+ n.accept(this, arg);
+ }
+ }
+}
diff --git a/java_indexer/src/io/coati/JavaDeclName.java b/java_indexer/src/io/coati/JavaDeclName.java
new file mode 100644
index 00000000..f4c163d6
--- /dev/null
+++ b/java_indexer/src/io/coati/JavaDeclName.java
@@ -0,0 +1,147 @@
+package io.coati;
+
+import java.util.List;
+
+public class JavaDeclName
+{
+ private JavaDeclName m_parent = null;
+ private String m_name = "";
+ private List m_typeParameterNames = null;
+ private JavaTypeName m_returnTypeName = null;
+ private List m_parameterNames = null;
+
+ public static JavaDeclName fromDotSeparatedString(String s)
+ {
+
+ JavaDeclName declName = null;
+
+ int separatorIndex = s.lastIndexOf('.');
+ if (separatorIndex != -1)
+ {
+ declName = new JavaDeclName(s.substring(separatorIndex + 1));
+ declName.setParent(JavaDeclName.fromDotSeparatedString(s.substring(0, separatorIndex)));
+ }
+ else
+ {
+ declName = new JavaDeclName(s, null);
+ }
+
+ return declName;
+ }
+
+ public JavaDeclName(String name)
+ {
+ m_name = name;
+ }
+
+ public JavaDeclName(String name, JavaTypeName returnTypeName, List parameterNames)
+ {
+ m_name = name;
+ m_returnTypeName = returnTypeName;
+ m_parameterNames = parameterNames;
+ }
+
+ public JavaDeclName(String name, List typeParameterNames)
+ {
+ m_name = name;
+ m_typeParameterNames = typeParameterNames;
+ }
+ public JavaDeclName(String name, List typeParameterNames, JavaTypeName returnTypeName, List parameterNames)
+ {
+ m_name = name;
+ m_typeParameterNames = typeParameterNames;
+ m_returnTypeName = returnTypeName;
+ m_parameterNames = parameterNames;
+ }
+
+ public void setParent(JavaDeclName parent)
+ {
+ m_parent = parent;
+ }
+
+ public JavaDeclName getParent()
+ {
+ return m_parent;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String toNameHierarchy()
+ {
+ String nameHierarchy = "";
+ if (m_parent != null)
+ {
+ nameHierarchy = m_parent.toNameHierarchy();
+ nameHierarchy += "\n";
+ }
+
+ nameHierarchy += m_name;
+ nameHierarchy += getTypeParameterString();
+
+ nameHierarchy += "\t";
+ if (m_returnTypeName != null)
+ {
+ nameHierarchy += m_returnTypeName.toString();
+ }
+
+ nameHierarchy += "\r";
+ nameHierarchy += getParameterString();
+ return nameHierarchy;
+ }
+
+ public String toString()
+ {
+ String string = "";
+ if (m_parent != null)
+ {
+ string = m_parent.toString();
+ string += ".";
+ }
+
+ string += m_name;
+ string += getTypeParameterString();
+
+ return string;
+ }
+
+ private String getParameterString()
+ {
+ String string = "";
+ if (m_parameterNames != null)
+ {
+ string += "(";
+ for (int i = 0; i < m_parameterNames.size(); i++)
+ {
+ if (i != 0)
+ {
+ string += ", ";
+ }
+ string += m_parameterNames.get(i).toString();
+ }
+ string += ")";
+ }
+ return string;
+ }
+
+ private String getTypeParameterString()
+ {
+ String string = "";
+ if (m_typeParameterNames != null && !m_typeParameterNames.isEmpty())
+ {
+ string += "<";
+ for (int i = 0; i < m_typeParameterNames.size(); i++)
+ {
+ if (i != 0)
+ {
+ string += ", ";
+ }
+ string += m_typeParameterNames.get(i);
+ }
+ string += ">";
+ }
+ return string;
+ }
+}
diff --git a/java_indexer/src/io/coati/JavaDeclNameResolver.java b/java_indexer/src/io/coati/JavaDeclNameResolver.java
new file mode 100644
index 00000000..dfee523d
--- /dev/null
+++ b/java_indexer/src/io/coati/JavaDeclNameResolver.java
@@ -0,0 +1,312 @@
+package io.coati;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.github.javaparser.ast.CompilationUnit;
+import com.github.javaparser.ast.Node;
+import com.github.javaparser.ast.PackageDeclaration;
+import com.github.javaparser.ast.TypeParameter;
+import com.github.javaparser.ast.body.AnnotationMemberDeclaration;
+import com.github.javaparser.ast.body.BodyDeclaration;
+import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
+import com.github.javaparser.ast.body.ConstructorDeclaration;
+import com.github.javaparser.ast.body.EmptyMemberDeclaration;
+import com.github.javaparser.ast.body.EnumConstantDeclaration;
+import com.github.javaparser.ast.body.FieldDeclaration;
+import com.github.javaparser.ast.body.InitializerDeclaration;
+import com.github.javaparser.ast.body.MethodDeclaration;
+import com.github.javaparser.ast.body.Parameter;
+import com.github.javaparser.ast.body.TypeDeclaration;
+import com.github.javaparser.ast.body.VariableDeclarator;
+import com.github.javaparser.ast.expr.NameExpr;
+import com.github.javaparser.ast.expr.QualifiedNameExpr;
+
+import me.tomassetti.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration;
+import me.tomassetti.symbolsolver.javaparsermodel.declarations.JavaParserInterfaceDeclaration;
+import me.tomassetti.symbolsolver.model.resolution.TypeSolver;
+
+public class JavaDeclNameResolver extends JavaNameResolver
+{
+ public JavaDeclNameResolver(TypeSolver typeSolver, ArrayList ignoredContexts)
+ {
+ super(typeSolver, ignoredContexts);
+ }
+
+ public static JavaDeclName getQualifiedDeclName(VariableDeclarator decl, TypeSolver typeSolver)
+ {
+ return getQualifiedDeclName(decl, typeSolver, null);
+ }
+
+ public static JavaDeclName getQualifiedDeclName(VariableDeclarator decl, TypeSolver typeSolver, ArrayList ignoredContexts)
+ {
+ JavaDeclNameResolver resolver = new JavaDeclNameResolver(typeSolver, ignoredContexts);
+ return resolver.getQualifiedDeclName(decl);
+ }
+
+ public JavaDeclName getQualifiedDeclName(VariableDeclarator decl)
+ {
+ JavaDeclName declName = null;
+
+ if (decl != null)
+ {
+ declName = getDeclName(decl);
+
+ BodyDeclaration declContext = getBodyDeclContext(decl);
+ if (declContext != null)
+ {
+ if (!ignoresContext(declContext))
+ {
+ declName.setParent(getQualifiedDeclName(declContext));
+ }
+ }
+ else
+ {
+ CompilationUnit compilationUnit = getCompilationUnitContext(decl);
+
+ if (compilationUnit != null)
+ {
+ PackageDeclaration packageDecl = compilationUnit.getPackage();
+ if (packageDecl != null)
+ {
+ declName.setParent(getQualifiedName(packageDecl.getName()));
+ }
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+ }
+ return declName;
+ }
+
+ public static JavaDeclName getQualifiedDeclName(BodyDeclaration decl, TypeSolver typeSolver)
+ {
+ return getQualifiedDeclName(decl, typeSolver, null);
+ }
+
+ public static JavaDeclName getQualifiedDeclName(BodyDeclaration decl, TypeSolver typeSolver, ArrayList ignoredContexts)
+ {
+ JavaDeclNameResolver resolver = new JavaDeclNameResolver(typeSolver, ignoredContexts);
+ return resolver.getQualifiedDeclName(decl);
+ }
+
+ public JavaDeclName getQualifiedDeclName(BodyDeclaration decl)
+ {
+ JavaDeclName declName = null;
+
+ if (decl != null)
+ {
+ declName = getDeclName(decl);
+
+ BodyDeclaration declContext = getBodyDeclContext(decl);
+ if (declContext != null)
+ {
+ if (!ignoresContext(declContext))
+ {
+ declName.setParent(getQualifiedDeclName(declContext));
+ }
+ }
+ else
+ {
+ CompilationUnit compilationUnit = getCompilationUnitContext(decl);
+
+ if (compilationUnit != null)
+ {
+ PackageDeclaration packageDecl = compilationUnit.getPackage();
+ if (packageDecl != null)
+ {
+ declName.setParent(getQualifiedName(packageDecl.getName()));
+ }
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+ }
+ return declName;
+ }
+
+ public static JavaDeclName getQualifiedDeclName(me.tomassetti.symbolsolver.model.declarations.TypeDeclaration typeDecl, TypeSolver typeSolver)
+ {
+ return getQualifiedDeclName(typeDecl, typeSolver, null);
+ }
+
+ public static JavaDeclName getQualifiedDeclName(me.tomassetti.symbolsolver.model.declarations.TypeDeclaration typeDecl, TypeSolver typeSolver, ArrayList ignoredContexts)
+ {
+ JavaDeclNameResolver resolver = new JavaDeclNameResolver(typeSolver, ignoredContexts);
+ return resolver.getQualifiedDeclName(typeDecl);
+ }
+
+ public JavaDeclName getQualifiedDeclName(me.tomassetti.symbolsolver.model.declarations.TypeDeclaration typeDecl)
+ {
+ JavaDeclName declName = null;
+ if (typeDecl != null)
+ {
+ ClassOrInterfaceDeclaration decl = null;
+ if (typeDecl instanceof JavaParserClassDeclaration)
+ {
+ decl = ((JavaParserClassDeclaration)typeDecl).getWrappedNode();
+ }
+ else if (typeDecl instanceof JavaParserInterfaceDeclaration)
+ {
+ decl = ((JavaParserInterfaceDeclaration)typeDecl).getWrappedNode();
+ }
+
+ if (decl != null)
+ {
+ declName = JavaDeclNameResolver.getQualifiedDeclName(decl, m_typeSolver, m_ignoredContexts);
+ }
+ else
+ {
+ declName = JavaDeclName.fromDotSeparatedString(typeDecl.getQualifiedName());
+ }
+ }
+ return declName;
+ }
+
+ public JavaDeclName getDeclName(VariableDeclarator decl)
+ {
+ return new JavaDeclName(decl.getId().getName());
+ }
+
+ public JavaDeclName getDeclName(BodyDeclaration decl)
+ {
+ JavaDeclName declName = null;
+
+ if (decl != null)
+ {
+ if (decl instanceof AnnotationMemberDeclaration)
+ {
+ declName = new JavaDeclName("AnnotationMemberDeclaration");
+ }
+ else if (decl instanceof ConstructorDeclaration)
+ {
+ CallableConstructorDecl callableDecl = new CallableConstructorDecl((ConstructorDeclaration)decl);
+ declName = getDeclNameOfCallable(callableDecl);
+ }
+ else if (decl instanceof EmptyMemberDeclaration)
+ {
+ declName = new JavaDeclName("EmptyMemberDeclaration");
+ }
+ else if (decl instanceof EnumConstantDeclaration)
+ {
+ declName = new JavaDeclName(((EnumConstantDeclaration)decl).getName());
+ }
+ else if (decl instanceof FieldDeclaration)
+ {
+ throw new UnsupportedOperationException();
+ }
+ else if (decl instanceof InitializerDeclaration)
+ {
+ declName = new JavaDeclName("InitializerDeclaration");
+ }
+ else if (decl instanceof MethodDeclaration)
+ {
+ CallableMethodDecl callableDecl = new CallableMethodDecl((MethodDeclaration)decl);
+ declName = getDeclNameOfCallable(callableDecl);
+ }
+ else if (decl instanceof TypeDeclaration)
+ {
+ declName = new JavaDeclName(((TypeDeclaration)decl).getName(), getTypeParameterNames((TypeDeclaration)decl));
+ }
+ }
+
+ return declName;
+ }
+
+ private static List getTypeParameterNames(TypeDeclaration decl)
+ {
+ List typeParameters = null;
+ if (decl instanceof ClassOrInterfaceDeclaration)
+ {
+ typeParameters = ((ClassOrInterfaceDeclaration)decl).getTypeParameters();
+ }
+
+ return getTypeParameterNames(typeParameters);
+ }
+
+ private static List getTypeParameterNames(List typeParameters)
+ {
+ List typeParameterNames = new ArrayList<>();
+ if (typeParameters != null && typeParameters.size() > 0)
+ {
+ for (int i = 0; i < typeParameters.size(); i++)
+ {
+ typeParameterNames.add(typeParameters.get(i).getName());
+ }
+ }
+ return typeParameterNames;
+ }
+
+ public static JavaDeclName getQualifiedName(NameExpr nameExpr)
+ {
+ JavaDeclName declName = new JavaDeclName(nameExpr.getName());
+ if (nameExpr instanceof QualifiedNameExpr)
+ {
+ declName.setParent(getQualifiedName(((QualifiedNameExpr)nameExpr).getQualifier()));
+ }
+ return declName;
+ }
+
+ private JavaDeclName getDeclNameOfCallable(T decl)
+ {
+ ArrayList ignoredContextsForTypes = new ArrayList(m_ignoredContexts);
+ ignoredContextsForTypes.add(decl.getWrappedNode()); // adding own decl
+
+ String name = decl.getName();
+ List typeParameterNames = getTypeParameterNames(decl.getTypeParameters());
+ JavaTypeName returnTypeName = JavaTypeNameResolver.getQualifiedTypeName(decl.getType(), m_typeSolver, ignoredContextsForTypes);
+ List parameterNames = new ArrayList<>();
+ for (Parameter parameter: decl.getParameters())
+ {
+ parameterNames.add(JavaTypeNameResolver.getQualifiedTypeName(parameter.getType(), m_typeSolver, ignoredContextsForTypes));
+ }
+
+ return new JavaDeclName(name, typeParameterNames, returnTypeName, parameterNames);
+ }
+
+ private static BodyDeclaration getBodyDeclContext(Node decl)
+ {
+ BodyDeclaration context = null;
+
+ Node parentNode = decl.getParentNode();
+ while (
+ parentNode != null &&
+ !(
+ parentNode instanceof BodyDeclaration &&
+ (!(parentNode instanceof FieldDeclaration))
+ )
+ )
+ {
+ parentNode = parentNode.getParentNode();
+ }
+
+ if (parentNode != null)
+ {
+ context = (BodyDeclaration)parentNode;
+ }
+
+ return context;
+ }
+
+ private static CompilationUnit getCompilationUnitContext(Node decl)
+ {
+ CompilationUnit context = null;
+ {
+ Node parentNode = decl.getParentNode();
+ while (parentNode != null && !(parentNode instanceof CompilationUnit))
+ {
+ parentNode = parentNode.getParentNode();
+ }
+
+ if (parentNode != null)
+ {
+ context = (CompilationUnit)parentNode;
+ }
+ }
+ return context;
+ }
+}
diff --git a/java_indexer/src/io/coati/JavaIndexer.java b/java_indexer/src/io/coati/JavaIndexer.java
new file mode 100644
index 00000000..b3d5bbc2
--- /dev/null
+++ b/java_indexer/src/io/coati/JavaIndexer.java
@@ -0,0 +1,182 @@
+package io.coati;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.lang.String;
+
+import com.github.javaparser.ast.CompilationUnit;
+import com.github.javaparser.JavaParser;
+import com.github.javaparser.ParseException;
+import com.github.javaparser.Token;
+
+import me.tomassetti.symbolsolver.javaparsermodel.JavaParserFacade;
+import me.tomassetti.symbolsolver.resolution.typesolvers.CombinedTypeSolver;
+import me.tomassetti.symbolsolver.resolution.typesolvers.JarTypeSolver;
+import me.tomassetti.symbolsolver.resolution.typesolvers.JavaParserTypeSolver;
+import me.tomassetti.symbolsolver.resolution.typesolvers.JreTypeSolver;
+
+public class JavaIndexer
+{
+ public static void processFile(int address, String filePath, String fileContent, String classPath)
+ {
+ System.out.println("indexing file: " + filePath);
+
+ try
+ {
+ CombinedTypeSolver typeSolver = new CombinedTypeSolver();
+
+ typeSolver.add(new JreTypeSolver());
+ for (String path: classPath.split("\\;"))
+ {
+ if (path.endsWith(".jar"))
+ {
+ try
+ {
+ JarTypeSolver jarTypeSolver = new JarTypeSolver(path);
+ typeSolver.add(jarTypeSolver);
+ }
+ catch (IOException e)
+ {
+ System.out.println("unable to add jar file: " + path);
+ }
+ }
+ else
+ {
+ JavaParserTypeSolver solver = new JavaParserTypeSolver(new File(path));
+ typeSolver.add(solver);
+ }
+ }
+ CompilationUnit cu = JavaParser.parse(new StringReader(fileContent), true);
+
+ JavaAstVisitor astVisitor = new JavaAstVisitor(address, filePath, typeSolver);
+ // JavaAstVisitor astVisitor = new ASTDumper(address, filePath, typeSolver);
+ cu.accept(astVisitor, null);
+ }
+ catch (ParseException e)
+ {
+ if (e.expectedTokenSequences == null || e.expectedTokenSequences.length == 0)
+ {
+ Token token = e.currentToken;
+ recordError(
+ address, e.getMessage(), true, true,
+ token.beginLine, token.beginColumn, token.endLine, token.endColumn
+ );
+ }
+ else
+ {
+ Token token = e.currentToken.next;
+ recordError(
+ address, "Encountered unexpected token.", true, true,
+ token.beginLine, token.beginColumn, token.endLine, token.endColumn
+ );
+ }
+ }
+
+ JavaParserFacade.clearCaches();
+
+ // String fileName = filePath.substring(filePath.lastIndexOf("/"), filePath.lastIndexOf(".java"));
+
+ // System.gc();
+ // HeapDumper.dumpHeap("D:/dump/" + fileName, false);
+ }
+
+
+
+
+
+
+ static public void recordSymbol(
+ int address, String symbolName, SymbolType symbolType,
+ int beginLine, int beginColumn, int endLine, int endColumn,
+ AccessKind access, boolean isImplicit
+ )
+ {
+ recordSymbol(
+ address, symbolName, symbolType.getValue(),
+ beginLine, beginColumn, endLine, endColumn,
+ access.getValue(), (isImplicit ? 1 : 0)
+ );
+ }
+
+ static public void recordSymbolWithoutLocation(
+ int address, String symbolName, SymbolType symbolType,
+ AccessKind access, boolean isImplicit
+ )
+ {
+ recordSymbolWithoutLocation(
+ address, symbolName, symbolType.getValue(),
+ access.getValue(), (isImplicit ? 1 : 0)
+ );
+ }
+
+ static public void recordSymbolWithScope(
+ int address, String symbolName, SymbolType symbolType,
+ int beginLine, int beginColumn, int endLine, int endColumn,
+ int scopeBeginLine, int scopeBeginColumn, int scopeEndLine, int scopeEndColumn,
+ AccessKind access, boolean isImplicit
+ )
+ {
+ recordSymbolWithScope(
+ address, symbolName, symbolType.getValue(),
+ beginLine, beginColumn, endLine, endColumn,
+ scopeBeginLine, scopeBeginColumn, scopeEndLine, scopeEndColumn,
+ access.getValue(), (isImplicit ? 1 : 0)
+ );
+ }
+
+ static public void recordReference(
+ int address, ReferenceKind referenceKind, String referencedName, String contextName,
+ int beginLine, int beginColumn, int endLine, int endColumn
+ )
+ {
+ recordReference(
+ address, referenceKind.getValue(), referencedName, contextName,
+ beginLine, beginColumn, endLine, endColumn
+ );
+ }
+
+ static public void recordError(
+ int address, String message, boolean fatal, boolean indexed, int beginLine, int beginColumn, int endLine, int endColumn
+ )
+ {
+ recordError(
+ address, message, (fatal ? 1 : 0), (indexed ? 1 : 0),
+ beginLine, beginColumn, endLine, endColumn
+ );
+ }
+
+ static private native void recordSymbol(
+ int address, String symbolName, int symbolType,
+ int beginLine, int beginColumn, int endLine, int endColumn,
+ int access, int isImplicit
+ );
+
+ static private native void recordSymbolWithoutLocation(
+ int address, String symbolName, int symbolType,
+ int access, int isImplicit
+ );
+
+ static private native void recordSymbolWithScope(
+ 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 isImplicit
+ );
+
+ static private native void recordReference(
+ int address, int referenceKind, String referencedName, String contextName, int beginLine, int beginColumn, int endLine, int endColumn
+ );
+
+ static native void recordLocalSymbol(
+ int address, String symbolName, int beginLine, int beginColumn, int endLine, int endColumn
+ );
+
+ static native void recordComment(
+ int address, int beginLine, int beginColumn, int endLine, int endColumn
+ );
+
+ static private native void recordError(
+ int address, String message, int fatal, int indexed, int beginLine, int beginColumn, int endLine, int endColumn
+ );
+}
\ No newline at end of file
diff --git a/java_indexer/src/io/coati/JavaNameResolver.java b/java_indexer/src/io/coati/JavaNameResolver.java
new file mode 100644
index 00000000..a8281d77
--- /dev/null
+++ b/java_indexer/src/io/coati/JavaNameResolver.java
@@ -0,0 +1,42 @@
+package io.coati;
+
+import java.util.ArrayList;
+
+import com.github.javaparser.ast.body.BodyDeclaration;
+
+import me.tomassetti.symbolsolver.model.resolution.TypeSolver;
+
+public abstract class JavaNameResolver
+{
+ TypeSolver m_typeSolver = null;
+ ArrayList m_ignoredContexts = null;
+
+ public JavaNameResolver(TypeSolver typeSolver, ArrayList ignoredContexts)
+ {
+ m_typeSolver = typeSolver;
+ if (ignoredContexts != null)
+ {
+ m_ignoredContexts = ignoredContexts;
+ }
+ else
+ {
+ m_ignoredContexts = new ArrayList();
+ }
+ }
+
+ protected boolean ignoresContext(BodyDeclaration context)
+ {
+ if (m_ignoredContexts != null)
+ {
+ for (BodyDeclaration ignoredContext: m_ignoredContexts)
+ {
+ if (ignoredContext.equals(context))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/java_indexer/src/io/coati/JavaTypeName.java b/java_indexer/src/io/coati/JavaTypeName.java
new file mode 100644
index 00000000..0f9299f3
--- /dev/null
+++ b/java_indexer/src/io/coati/JavaTypeName.java
@@ -0,0 +1,100 @@
+package io.coati;
+
+import java.util.List;
+
+public class JavaTypeName
+{
+ private JavaDeclName m_parent = null;
+ private String m_name = "";
+ private List m_typeArgumentNames = null;
+
+ public static JavaTypeName fromDotSeparatedString(String s)
+ {
+ JavaTypeName typeName = null;
+
+ int separatorIndex = s.lastIndexOf('.');
+ if (separatorIndex != -1)
+ {
+ typeName = new JavaTypeName(s.substring(separatorIndex + 1), JavaDeclName.fromDotSeparatedString(s.substring(0, separatorIndex)));
+ }
+ else
+ {
+ typeName = new JavaTypeName(s, null);
+ }
+
+ return typeName;
+ }
+
+ public JavaTypeName(String name, JavaDeclName parent)
+ {
+ m_parent = parent;
+ m_name = name;
+ }
+
+ public JavaTypeName(String name, List typeArgumentNames, JavaDeclName parent)
+ {
+ m_parent = parent;
+ m_name = name;
+ m_typeArgumentNames = typeArgumentNames;
+ }
+
+ public JavaDeclName getParent()
+ {
+ return m_parent;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String toNameHierarchy()
+ {
+ String nameHierarchy = "";
+ if (m_parent != null)
+ {
+ nameHierarchy = m_parent.toNameHierarchy();
+ nameHierarchy += "\n";
+ }
+
+ nameHierarchy += m_name;
+ nameHierarchy += getTypeArgumentString();
+ nameHierarchy += "\t\r";
+
+ return nameHierarchy;
+ }
+
+ public String toString()
+ {
+ String string = "";
+ if (m_parent != null)
+ {
+ string = m_parent.toString();
+ string += ".";
+ }
+
+ string += m_name;
+ string += getTypeArgumentString();
+
+ return string;
+ }
+
+ private String getTypeArgumentString()
+ {
+ String string = "";
+ if (m_typeArgumentNames != null && !m_typeArgumentNames.isEmpty())
+ {
+ string += "<";
+ for (int i = 0; i < m_typeArgumentNames.size(); i++)
+ {
+ if (i != 0)
+ {
+ string += ", ";
+ }
+ string += m_typeArgumentNames.get(i).toString();
+ }
+ string += ">";
+ }
+ return string;
+ }
+}
diff --git a/java_indexer/src/io/coati/JavaTypeNameResolver.java b/java_indexer/src/io/coati/JavaTypeNameResolver.java
new file mode 100644
index 00000000..bf31412f
--- /dev/null
+++ b/java_indexer/src/io/coati/JavaTypeNameResolver.java
@@ -0,0 +1,130 @@
+package io.coati;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.github.javaparser.ast.Node;
+import com.github.javaparser.ast.body.BodyDeclaration;
+import com.github.javaparser.ast.type.*;
+
+import me.tomassetti.symbolsolver.javaparsermodel.JavaParserFacade;
+import me.tomassetti.symbolsolver.javaparsermodel.declarations.JavaParserTypeParameter;
+import me.tomassetti.symbolsolver.model.resolution.TypeParameter;
+import me.tomassetti.symbolsolver.model.resolution.TypeSolver;
+import me.tomassetti.symbolsolver.model.typesystem.TypeParameterUsage;
+import me.tomassetti.symbolsolver.model.typesystem.TypeUsage;
+
+public class JavaTypeNameResolver extends JavaNameResolver
+{
+ public JavaTypeNameResolver(TypeSolver typeSolver, ArrayList ignoredContexts)
+ {
+ super(typeSolver, ignoredContexts);
+ }
+
+ public static JavaTypeName getQualifiedTypeName(Type type, TypeSolver typeSolver)
+ {
+ return getQualifiedTypeName(type, typeSolver, null);
+ }
+
+ public static JavaTypeName getQualifiedTypeName(Type type, TypeSolver typeSolver, ArrayList ignoredContexts)
+ {
+ JavaTypeNameResolver resolver = new JavaTypeNameResolver(typeSolver, ignoredContexts);
+ return resolver.getQualifiedTypeName(type);
+ }
+
+ public JavaTypeName getQualifiedTypeName(Type type)
+ {
+ String fallbackTypeName = type.toString();
+
+ if (type instanceof ClassOrInterfaceType)
+ {
+ try
+ {
+ TypeUsage typeUsage = JavaParserFacade.get(m_typeSolver).convert(type, type);
+ if (typeUsage.isReferenceType())
+ {
+ JavaDeclName declName = JavaDeclNameResolver.getQualifiedDeclName(typeUsage.asReferenceTypeUsage().getTypeDeclaration(), m_typeSolver, m_ignoredContexts);
+
+ if (declName != null)
+ {
+ List typeArgumentNames = new ArrayList<>();
+ for (Type typeArgument: ((ClassOrInterfaceType)type).getTypeArgs())
+ {
+ typeArgumentNames.add(getQualifiedTypeName(typeArgument, m_typeSolver, m_ignoredContexts));
+ }
+ JavaTypeName ret = new JavaTypeName(declName.getName(), typeArgumentNames, declName.getParent());
+
+ return ret;
+ }
+ }
+ else if (typeUsage instanceof TypeParameterUsage)
+ {
+ TypeParameter typeParam = typeUsage.asTypeParameter();
+ if (typeParam instanceof JavaParserTypeParameter)
+ {
+ com.github.javaparser.ast.TypeParameter jpTypeParameter = ((JavaParserTypeParameter)typeParam).getWrappedNode();
+ Node genericDecl = jpTypeParameter.getParentNode();
+ if (genericDecl instanceof BodyDeclaration)
+ {
+ JavaDeclName genericName = null;
+ if (!ignoresContext((BodyDeclaration)genericDecl))
+ {
+ genericName = JavaDeclNameResolver.getQualifiedDeclName((BodyDeclaration)genericDecl, m_typeSolver, m_ignoredContexts);
+ }
+ return new JavaTypeName(jpTypeParameter.getName(), genericName);
+ }
+ }
+ else
+ {
+ // do we need to handle using type parameters of external code?
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // log...
+ }
+ }
+ else if (type instanceof IntersectionType)
+ {
+ // System.out.println(" IntersectionType: " + fallbackTypeName);
+
+ return JavaTypeName.fromDotSeparatedString(type.toString());
+ }
+ else if (type instanceof PrimitiveType)
+ {
+ return JavaTypeName.fromDotSeparatedString(type.toString());
+ }
+ else if (type instanceof ReferenceType)
+ {
+ ReferenceType referenceType = (ReferenceType)type;
+
+ boolean isArray = (referenceType.getArrayCount() == 0); // TODO: regard array info!
+ return getQualifiedTypeName(referenceType.getType());
+ }
+ else if (type instanceof UnionType)
+ {
+ // System.out.println(" UnionType: " + fallbackTypeName);
+ return JavaTypeName.fromDotSeparatedString(type.toString());
+ }
+ else if (type instanceof UnknownType)
+ {
+ // System.out.println(" UnknownType: " + fallbackTypeName);
+ return JavaTypeName.fromDotSeparatedString(type.toString());
+ }
+ else if (type instanceof VoidType)
+ {
+ return JavaTypeName.fromDotSeparatedString(type.toString());
+ }
+ else if (type instanceof WildcardType)
+ {
+ // System.out.println(" WildcardType: " + fallbackTypeName);
+ return JavaTypeName.fromDotSeparatedString(type.toString());
+ }
+
+ System.out.println("Unable to resolve qualified name of " + type.getClass().toString() + ": " + fallbackTypeName);
+ return new JavaTypeName("error-type", null);
+ }
+
+
+}
diff --git a/java_indexer/src/io/coati/ReferenceKind.java b/java_indexer/src/io/coati/ReferenceKind.java
new file mode 100644
index 00000000..f0272eaa
--- /dev/null
+++ b/java_indexer/src/io/coati/ReferenceKind.java
@@ -0,0 +1,31 @@
+package io.coati;
+
+public enum ReferenceKind
+{
+ UNDEFINED(0),
+ TYPE_USAGE(1),
+ USAGE(2),
+ CALL(3),
+ INHERITANCE(4),
+ OVERRIDE(5),
+ TEMPLATE_ARGUMENT(6),
+ TYPE_ARGUMENT(7),
+ TEMPLATE_DEFAULT_ARGUMENT(8),
+ TEMPLATE_SPECIALIZATION_OF(9),
+ TEMPLATE_MEMBER_SPECIALIZATION_OF(10),
+ INCLUDE(11),
+ IMPORT(12),
+ MACRO_USAGE(13);
+
+ private final int m_value;
+
+ private ReferenceKind(int value)
+ {
+ this.m_value = value;
+ }
+
+ public int getValue()
+ {
+ return m_value;
+ }
+}
diff --git a/java_indexer/src/io/coati/SymbolType.java b/java_indexer/src/io/coati/SymbolType.java
new file mode 100644
index 00000000..8bd7eb7f
--- /dev/null
+++ b/java_indexer/src/io/coati/SymbolType.java
@@ -0,0 +1,37 @@
+package io.coati;
+
+public enum SymbolType
+{ // these values need to be the same as SymbolType in C++ code
+ BUILTIN_TYPE(1),
+ CLASS(2),
+ ENUM(3),
+ ENUM_CONSTANT(4),
+ FIELD(5),
+ FUNCTION(6),
+ GLOBAL_VARIABLE(7),
+ INTERFACE(8),
+ LOCAL_VARIABLE(9),
+ MACRO(10),
+ METHOD(11),
+ NAMESPACE(12),
+ PACKAGE(13),
+ PARAMETER(14),
+ STRUCT(15),
+ TEMPLATE_PARAMETER(16),
+ TYPEDEF(17),
+ TYPE_PARAMETER(18),
+ UNION(19),
+ TYPE_MAX(20);
+
+ private final int m_value;
+
+ private SymbolType(int value)
+ {
+ this.m_value = value;
+ }
+
+ public int getValue()
+ {
+ return m_value;
+ }
+}
diff --git a/script/clean.sh b/script/clean.sh
index 313622e5..e67c44a7 100755
--- a/script/clean.sh
+++ b/script/clean.sh
@@ -1,6 +1,8 @@
#!/bin/bash
+ABORT="\033[31mAbort:\033[00m"
SUCCESS="\033[32mSuccess:\033[00m"
+INFO="\033[33mInfo:\033[00m"
# Determine current platform
PLATFORM='unknown'
@@ -12,7 +14,6 @@ elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
PLATFORM='Windows'
fi
-
if [ $PLATFORM == "Windows" ]; then
ORIGINAL_PATH_TO_SCRIPT="${0}"
CLEANED_PATH_TO_SCRIPT="${ORIGINAL_PATH_TO_SCRIPT//\\//}"
@@ -36,6 +37,7 @@ if [ $PLATFORM == "Windows" ]; then
fi
# Remove folders and contents
+rm -rf java_indexer/lib
rm -rf build
rm -rf bin/app/Debug
rm -rf bin/app/Release
diff --git a/script/setup.sh b/script/setup.sh
index 21bc8bbd..fa813a3a 100755
--- a/script/setup.sh
+++ b/script/setup.sh
@@ -24,9 +24,11 @@ fi
ROOT_DIR=$ROOT_DIR/..
+
# Enter masterproject directory
cd $ROOT_DIR
+
# git settings
echo -e $INFO "install git settings"
@@ -35,6 +37,22 @@ git config color.ui true
cp setup/git/git_pre_commit_hook.sh .git/hooks/pre-commit
cp setup/git/git_pre_push_hook.sh .git/hooks/pre-push
+
+# Copy necessary jars for java indexer
+echo -e $INFO "copy jars for java indexer"
+
+mkdir -p java_indexer/lib
+
+if [ $PLATFORM == "Windows" ]; then
+ cp -u -r setup/jars/windows/*.jar java_indexer/lib
+elif [ $PLATFORM == "Linux" ]; then
+ cp -u -r setup/jars/linux/*.jar java_indexer/lib
+ # what about 32/64 bit?
+elif [ $PLATFORM == "MacOS" ]; then
+ cp -u -r setup/jars/macos/*.jar java_indexer/lib
+fi
+
+
# Create Debug and Release folders
echo -e $INFO "create build folders"
@@ -46,6 +64,7 @@ mkdir -p bin/lib/Release
mkdir -p bin/test/Debug
mkdir -p bin/test/Release
+
# Copy necessary dynamic libraries to bin folder
if [ $PLATFORM == "Windows" ]; then
echo -e $INFO "copy dynamic libraries"
@@ -60,6 +79,7 @@ if [ $PLATFORM == "Windows" ]; then
BACKSLASHED_ROOT_DIR="${ROOT_DIR//\//\\}"
+ echo -e $INFO "create symbolic links for data"
cmd //c 'mklink /d /j '$BACKSLASHED_ROOT_DIR'\bin\app\Debug\data '$BACKSLASHED_ROOT_DIR'\bin\app\data' &
cmd //c 'mklink /d /j '$BACKSLASHED_ROOT_DIR'\bin\app\Debug\user '$BACKSLASHED_ROOT_DIR'\bin\app\user' &
cmd //c 'mklink /d /j '$BACKSLASHED_ROOT_DIR'\bin\app\Release\data '$BACKSLASHED_ROOT_DIR'\bin\app\data' &
diff --git a/script/update_java_indexer.sh b/script/update_java_indexer.sh
new file mode 100644
index 00000000..d42f19a4
--- /dev/null
+++ b/script/update_java_indexer.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+ABORT="\033[31mAbort:\033[00m"
+SUCCESS="\033[32mSuccess:\033[00m"
+INFO="\033[33mInfo:\033[00m"
+
+# Determine current platform
+PLATFORM='unknown'
+if [ "$(uname)" == "Darwin" ]; then
+ PLATFORM='MacOS'
+elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
+ PLATFORM='Linux'
+elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
+ PLATFORM='Windows'
+fi
+
+if [ $PLATFORM == "Windows" ]; then
+ ORIGINAL_PATH_TO_SCRIPT="${0}"
+ CLEANED_PATH_TO_SCRIPT="${ORIGINAL_PATH_TO_SCRIPT//\\//}"
+ ROOT_DIR=`dirname "$CLEANED_PATH_TO_SCRIPT"`
+else
+ ROOT_DIR="$( cd "$( dirname "$0" )" && pwd )"
+fi
+
+ROOT_DIR=$ROOT_DIR/..
+
+# Enter main directory
+cd $ROOT_DIR/
+
+
+echo -e $INFO "build java-indexer"
+java_indexer/build/build.sh
+
+
+echo -e $INFO "copy jars"
+mkdir -p bin/app/data/java
+cp -u -r java_indexer/lib/*.jar bin/app/data/java
+cp -u -r java_indexer/bin/*.jar bin/app/data/java
diff --git a/setup/jars/windows/asm-5.0.3.jar b/setup/jars/windows/asm-5.0.3.jar
new file mode 100644
index 00000000..573535b1
Binary files /dev/null and b/setup/jars/windows/asm-5.0.3.jar differ
diff --git a/setup/jars/windows/cglib-3.1.jar b/setup/jars/windows/cglib-3.1.jar
new file mode 100644
index 00000000..25a5df15
Binary files /dev/null and b/setup/jars/windows/cglib-3.1.jar differ
diff --git a/setup/jars/windows/easymock-3.3.1.jar b/setup/jars/windows/easymock-3.3.1.jar
new file mode 100644
index 00000000..c81899ce
Binary files /dev/null and b/setup/jars/windows/easymock-3.3.1.jar differ
diff --git a/setup/jars/windows/guava-18.0.jar b/setup/jars/windows/guava-18.0.jar
new file mode 100644
index 00000000..8f89e490
Binary files /dev/null and b/setup/jars/windows/guava-18.0.jar differ
diff --git a/setup/jars/windows/hamcrest-core-1.3.jar b/setup/jars/windows/hamcrest-core-1.3.jar
new file mode 100644
index 00000000..9d5fe16e
Binary files /dev/null and b/setup/jars/windows/hamcrest-core-1.3.jar differ
diff --git a/setup/jars/windows/java-symbol-solver-core-0.2.0-SNAPSHOT.jar b/setup/jars/windows/java-symbol-solver-core-0.2.0-SNAPSHOT.jar
new file mode 100644
index 00000000..74462d9f
Binary files /dev/null and b/setup/jars/windows/java-symbol-solver-core-0.2.0-SNAPSHOT.jar differ
diff --git a/setup/jars/windows/java-symbol-solver-logic-0.2.0-SNAPSHOT.jar b/setup/jars/windows/java-symbol-solver-logic-0.2.0-SNAPSHOT.jar
new file mode 100644
index 00000000..d00bb421
Binary files /dev/null and b/setup/jars/windows/java-symbol-solver-logic-0.2.0-SNAPSHOT.jar differ
diff --git a/setup/jars/windows/java-symbol-solver-model-0.2.0-SNAPSHOT.jar b/setup/jars/windows/java-symbol-solver-model-0.2.0-SNAPSHOT.jar
new file mode 100644
index 00000000..72130d67
Binary files /dev/null and b/setup/jars/windows/java-symbol-solver-model-0.2.0-SNAPSHOT.jar differ
diff --git a/setup/jars/windows/javaparser-core-2.4.1-SNAPSHOT.jar b/setup/jars/windows/javaparser-core-2.4.1-SNAPSHOT.jar
new file mode 100644
index 00000000..8fdbc0d0
Binary files /dev/null and b/setup/jars/windows/javaparser-core-2.4.1-SNAPSHOT.jar differ
diff --git a/setup/jars/windows/javaslang-2.0.0-beta.jar b/setup/jars/windows/javaslang-2.0.0-beta.jar
new file mode 100644
index 00000000..c3d7c757
Binary files /dev/null and b/setup/jars/windows/javaslang-2.0.0-beta.jar differ
diff --git a/setup/jars/windows/javassist-3.19.0-GA.jar b/setup/jars/windows/javassist-3.19.0-GA.jar
new file mode 100644
index 00000000..7ac42641
Binary files /dev/null and b/setup/jars/windows/javassist-3.19.0-GA.jar differ
diff --git a/setup/jars/windows/licenses/NOTICE.txt b/setup/jars/windows/licenses/NOTICE.txt
new file mode 100644
index 00000000..280fb8ae
--- /dev/null
+++ b/setup/jars/windows/licenses/NOTICE.txt
@@ -0,0 +1,4 @@
+
+- cglib
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file
diff --git a/setup/jars/windows/licenses/_license_easymock.txt b/setup/jars/windows/licenses/_license_easymock.txt
new file mode 100644
index 00000000..43975bca
--- /dev/null
+++ b/setup/jars/windows/licenses/_license_easymock.txt
@@ -0,0 +1,57 @@
+License
+EasyMock is provided under the terms of the Apache 2 license, which is one of the most liberal and complete open source licenses available.
+
+EasyMock License
+Apache License
+Version 2.0, January 2004
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+
+If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
+You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/setup/jars/windows/licenses/license_asm.txt b/setup/jars/windows/licenses/license_asm.txt
new file mode 100644
index 00000000..7676ba54
--- /dev/null
+++ b/setup/jars/windows/licenses/license_asm.txt
@@ -0,0 +1,29 @@
+Copyright (c) 2000-2011 INRIA, France Telecom
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/setup/jars/windows/licenses/license_cglib.txt b/setup/jars/windows/licenses/license_cglib.txt
new file mode 100644
index 00000000..f49a4e16
--- /dev/null
+++ b/setup/jars/windows/licenses/license_cglib.txt
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/setup/jars/windows/licenses/license_guava.txt b/setup/jars/windows/licenses/license_guava.txt
new file mode 100644
index 00000000..7a4a3ea2
--- /dev/null
+++ b/setup/jars/windows/licenses/license_guava.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/setup/jars/windows/licenses/license_hamcrest.txt b/setup/jars/windows/licenses/license_hamcrest.txt
new file mode 100644
index 00000000..0bf62645
--- /dev/null
+++ b/setup/jars/windows/licenses/license_hamcrest.txt
@@ -0,0 +1,27 @@
+BSD License
+
+Copyright (c) 2000-2015 www.hamcrest.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of Hamcrest nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
\ No newline at end of file
diff --git a/setup/jars/windows/licenses/license_java_symbol_solver.txt b/setup/jars/windows/licenses/license_java_symbol_solver.txt
new file mode 100644
index 00000000..358414c3
--- /dev/null
+++ b/setup/jars/windows/licenses/license_java_symbol_solver.txt
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Federico Tomassetti
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/setup/jars/windows/licenses/license_javaparser.txt b/setup/jars/windows/licenses/license_javaparser.txt
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/setup/jars/windows/licenses/license_javaparser.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/setup/jars/windows/licenses/license_javaslang.txt b/setup/jars/windows/licenses/license_javaslang.txt
new file mode 100644
index 00000000..46e391d4
--- /dev/null
+++ b/setup/jars/windows/licenses/license_javaslang.txt
@@ -0,0 +1,13 @@
+Copyright 2014-2016 Javaslang, http://javaslang.io
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
diff --git a/setup/jars/windows/licenses/license_javassist.txt b/setup/jars/windows/licenses/license_javassist.txt
new file mode 100644
index 00000000..b11aaa6c
--- /dev/null
+++ b/setup/jars/windows/licenses/license_javassist.txt
@@ -0,0 +1,141 @@
+MOZILLA PUBLIC LICENSE
+Version 1.1
+1. Definitions.
+
+1.0.1. "Commercial Use" means distribution or otherwise making the Covered Code available to a third party.
+1.1. ''Contributor'' means each entity that creates or contributes to the creation of Modifications.
+
+1.2. ''Contributor Version'' means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor.
+
+1.3. ''Covered Code'' means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof.
+
+1.4. ''Electronic Distribution Mechanism'' means a mechanism generally accepted in the software development community for the electronic transfer of data.
+
+1.5. ''Executable'' means Covered Code in any form other than Source Code.
+
+1.6. ''Initial Developer'' means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A.
+
+1.7. ''Larger Work'' means a work which combines Covered Code or portions thereof with code not governed by the terms of this License.
+
+1.8. ''License'' means this document.
+
+1.8.1. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
+
+1.9. ''Modifications'' means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is:
+
+A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications.
+B. Any new file that contains any part of the Original Code or previous Modifications.
+
+
+1.10. ''Original Code'' means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License.
+1.10.1. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
+
+1.11. ''Source Code'' means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge.
+
+1.12. "You'' (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You'' includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control'' means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
+
+2. Source Code License.
+2.1. The Initial Developer Grant.
+The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims:
+(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and
+(b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof).
+
+(c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License.
+(d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices.
+
+
+2.2. Contributor Grant.
+Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license
+
+(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and
+(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
+
+(c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code.
+
+(d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor.
+
+
+3. Distribution Obligations.
+
+3.1. Application of License.
+The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5.
+3.2. Availability of Source Code.
+Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party.
+
+3.3. Description of Modifications.
+You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code.
+
+3.4. Intellectual Property Matters
+
+(a) Third Party Claims.
+If Contributor has knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL'' which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained.
+(b) Contributor APIs.
+If Contributor's Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file.
+
+
+ (c) Representations.
+Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License.
+
+3.5. Required Notices.
+You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
+
+3.6. Distribution of Executable Versions.
+You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
+
+3.7. Larger Works.
+You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
+5. Application of this License.
+This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code.
+6. Versions of the License.
+6.1. New Versions.
+Netscape Communications Corporation (''Netscape'') may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number.
+6.2. Effect of New Versions.
+Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Netscape. No one other than Netscape has the right to modify the terms applicable to Covered Code created under this License.
+
+6.3. Derivative Works.
+If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases ''Mozilla'', ''MOZILLAPL'', ''MOZPL'', ''Netscape'', "MPL", ''NPL'' or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the Mozilla Public License and Netscape Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.)
+
+7. DISCLAIMER OF WARRANTY.
+COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS'' BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+8. TERMINATION.
+8.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
+8.2. If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You file such action is referred to as "Participant") alleging that:
+
+(a) such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above.
+
+(b) any software, hardware, or device, other than such Participant's Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant.
+
+8.3. If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license.
+
+8.4. In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+10. U.S. GOVERNMENT END USERS.
+The Covered Code is a ''commercial item,'' as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of ''commercial computer software'' and ''commercial computer software documentation,'' as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein.
+11. MISCELLANEOUS.
+This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License.
+12. RESPONSIBILITY FOR CLAIMS.
+As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
+13. MULTIPLE-LICENSED CODE.
+Initial Developer may designate portions of the Covered Code as "Multiple-Licensed". "Multiple-Licensed" means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the MPL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A.
+
+EXHIBIT A -Mozilla Public License.
+
+The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+http://www.mozilla.org/MPL/
+Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ANY KIND, either express or implied. See the License for the specific language governing rights and
+limitations under the License.
+
+The Original Code is Javassist.
+
+The Initial Developer of the Original Code is Shigeru Chiba. Portions created by the Initial Developer are
+ Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
+
+Contributor(s): __Bill Burke, Jason T. Greene______________.
+
+Alternatively, the contents of this software may be used under the terms of the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), or the Apache License Version 2.0 (the "AL"), in which case the provisions of the LGPL or the AL are applicable instead of those above. If you wish to allow use of your version of this software only under the terms of either the LGPL or the AL, and not to allow others to use your version of this software under the terms of the MPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the LGPL or the AL. If you do not delete the provisions above, a recipient may use your version of this software under the terms of any one of the MPL, the LGPL or the AL.
\ No newline at end of file
diff --git a/setup/jars/windows/licenses/license_objenesis.txt b/setup/jars/windows/licenses/license_objenesis.txt
new file mode 100644
index 00000000..fca6276e
--- /dev/null
+++ b/setup/jars/windows/licenses/license_objenesis.txt
@@ -0,0 +1,18 @@
+Copyright (c) 2003-2013, Objenesis Team and all contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/setup/jars/windows/objenesis-2.1.jar b/setup/jars/windows/objenesis-2.1.jar
new file mode 100644
index 00000000..7c1e9837
Binary files /dev/null and b/setup/jars/windows/objenesis-2.1.jar differ
diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt
index fe16c5f6..2f8af48c 100644
--- a/src/app/CMakeLists.txt
+++ b/src/app/CMakeLists.txt
@@ -3,6 +3,8 @@ add_files(
data/parser/cxx/TaskParseCxx.cpp
data/parser/cxx/TaskParseWrapper.cpp
+
+ data/parser/java/TaskParseJava.cpp
utility/commandline/CommandLineParser.cpp
utility/commandline/CommandLineParser.h
diff --git a/src/app/data/parser/cxx/TaskParseWrapper.cpp b/src/app/data/parser/cxx/TaskParseWrapper.cpp
index 77f378b1..998269d6 100644
--- a/src/app/data/parser/cxx/TaskParseWrapper.cpp
+++ b/src/app/data/parser/cxx/TaskParseWrapper.cpp
@@ -7,32 +7,34 @@
#include "utility/utility.h"
TaskParseWrapper::TaskParseWrapper(
- std::shared_ptr child,
PersistentStorage* storage,
std::shared_ptr fileRegister
)
- : m_child(child)
- , m_storage(storage)
+ : m_storage(storage)
, m_fileRegister(fileRegister)
{
}
+TaskParseWrapper::~TaskParseWrapper()
+{
+}
+
void TaskParseWrapper::enter()
{
m_start = utility::durationStart();
m_storage->startParsing();
- m_child->enter();
+ m_task->enter();
}
Task::TaskState TaskParseWrapper::update()
{
- return m_child->update();
+ return m_task->update();
}
void TaskParseWrapper::exit()
{
- m_child->exit();
+ m_task->exit();
MessageStatus("optimizing database", false, true).dispatch();
@@ -52,10 +54,10 @@ void TaskParseWrapper::exit()
void TaskParseWrapper::interrupt()
{
MessageStatus("indexing files interrupted", false, true).dispatch();
- m_child->interrupt();
+ m_task->interrupt();
}
void TaskParseWrapper::revert()
{
- m_child->revert();
+ m_task->revert();
}
diff --git a/src/app/data/parser/java/TaskParseJava.cpp b/src/app/data/parser/java/TaskParseJava.cpp
new file mode 100644
index 00000000..63a2e998
--- /dev/null
+++ b/src/app/data/parser/java/TaskParseJava.cpp
@@ -0,0 +1,78 @@
+#include "data/parser/java/TaskParseJava.h"
+
+#include "data/parser/java/JavaParser.h"
+#include "data/parser/ParserClientImpl.h"
+#include "data/PersistentStorage.h"
+#include "utility/file/FileRegister.h"
+#include "utility/messaging/type/MessageFinishedParsing.h"
+#include "utility/messaging/type/MessageStatus.h"
+#include "utility/text/TextAccess.h"
+#include "utility/utility.h"
+
+TaskParseJava::TaskParseJava(
+ PersistentStorage* storage,
+ std::shared_ptr storageMutex,
+ std::shared_ptr fileRegister,
+ const Parser::Arguments& arguments
+)
+ : m_storage(storage)
+ , m_storageMutex(storageMutex)
+ , m_fileRegister(fileRegister)
+ , m_arguments(arguments)
+{
+}
+
+void TaskParseJava::enter()
+{
+}
+
+Task::TaskState TaskParseJava::update()
+{
+ std::shared_ptr parserClient = std::make_shared();
+ std::shared_ptr parser = std::make_shared(parserClient.get());
+
+ FilePath sourcePath = m_fileRegister->consumeSourceFile();
+
+ if (sourcePath.empty())
+ {
+ return Task::STATE_FINISHED;
+ }
+
+ std::stringstream ss;
+ ss << "indexing files (ESC to quit): [";
+ ss << m_fileRegister->getParsedSourceFilesCount() << "/";
+ ss << m_fileRegister->getSourceFilesCount() << "] ";
+ ss << sourcePath.str();
+ MessageStatus(ss.str(), false, true).dispatch();
+
+ std::shared_ptr intermediateStorage = std::make_shared();
+
+ parserClient->setStorage(intermediateStorage);
+ parserClient->startParsingFile();
+
+ parser->parseFile(sourcePath, TextAccess::createFromFile(sourcePath.str()), m_arguments);
+
+ parserClient->finishParsingFile();
+ parserClient->resetStorage();
+
+ {
+ std::lock_guard lock(*(m_storageMutex.get()));
+ m_storage->inject(intermediateStorage.get());
+ }
+
+ m_fileRegister->markThreadFilesParsed(); // todo: rename to markThreadFilesProcessed
+
+ return Task::STATE_RUNNING;
+}
+
+void TaskParseJava::exit()
+{
+}
+
+void TaskParseJava::interrupt()
+{
+}
+
+void TaskParseJava::revert()
+{
+}
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index efe94d6f..26f54186 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -128,7 +128,15 @@ add_files(
data/parser/cxx/TaskParseCxx.h
data/parser/cxx/TaskParseWrapper.h
-
+
+ data/parser/java/JavaEnvironment.cpp
+ data/parser/java/JavaEnvironment.h
+ data/parser/java/JavaEnvironmentFactory.cpp
+ data/parser/java/JavaEnvironmentFactory.h
+ data/parser/java/TaskParseJava.h
+
+ data/parser/AccessKind.cpp
+ data/parser/AccessKind.h
data/parser/ParseLocation.cpp
data/parser/ParseLocation.h
data/parser/Parser.cpp
@@ -137,7 +145,10 @@ add_files(
data/parser/ParserClient.h
data/parser/ParserClientImpl.cpp
data/parser/ParserClientImpl.h
- data/parser/SymbolType.h
+ data/parser/ReferenceKind.cpp
+ data/parser/ReferenceKind.h
+ data/parser/SymbolKind.cpp
+ data/parser/SymbolKind.h
data/search/SearchIndex.cpp
data/search/SearchIndex.h
@@ -279,6 +290,8 @@ add_files(
utility/scheduling/Task.cpp
utility/scheduling/Task.h
+ utility/scheduling/TaskDecorator.cpp
+ utility/scheduling/TaskDecorator.h
utility/scheduling/TaskGroup.cpp
utility/scheduling/TaskGroup.h
utility/scheduling/TaskGroupParallel.cpp
diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp
index d47454ed..22ce11bc 100644
--- a/src/lib/Project.cpp
+++ b/src/lib/Project.cpp
@@ -4,6 +4,8 @@
#include "data/graph/Token.h"
#include "data/parser/cxx/TaskParseCxx.h"
#include "data/parser/cxx/TaskParseWrapper.h"
+#include "data/parser/java/JavaEnvironmentFactory.h"
+#include "data/parser/java/TaskParseJava.h"
#include "data/PersistentStorage.h"
#include "data/TaskCleanStorage.h"
#include "settings/ApplicationSettings.h"
@@ -16,6 +18,7 @@
#include "utility/scheduling/TaskGroupSequential.h"
#include "utility/scheduling/TaskGroupParallel.h"
#include "utility/utility.h"
+#include "utility/utilityString.h"
#include "utility/Version.h"
std::shared_ptr Project::create(StorageAccessProxy* storageAccessProxy)
@@ -144,24 +147,78 @@ void Project::parseCode()
std::shared_ptr fileRegister = std::make_shared(&m_fileManager, indexerThreadCount > 1);
fileRegister->setFilePaths(filesToParse);
- std::shared_ptr taskParallel = std::make_shared();
+ if (ProjectSettings::getInstance()->getLanguage() == "Java")
+ {
+ if (!JavaEnvironmentFactory::getInstance())
+ {
+ JavaEnvironmentFactory::createInstance(
+ "data/java/asm-5.0.3.jar;"
+ "data/java/cglib-3.1.jar;"
+ "data/java/easymock-3.3.1.jar;"
+ "data/java/guava-18.0.jar;"
+ "data/java/hamcrest-core-1.3.jar;"
+ "data/java/java-indexer.jar;"
+ "data/java/javaparser-core-2.4.1-SNAPSHOT.jar;"
+ "data/java/javaslang-2.0.0-beta.jar;"
+ "data/java/javassist-3.19.0-GA.jar;"
+ "data/java/java-symbol-solver-core-0.2.0-SNAPSHOT.jar;"
+ "data/java/java-symbol-solver-logic-0.2.0-SNAPSHOT.jar;"
+ "data/java/java-symbol-solver-model-0.2.0-SNAPSHOT.jar;"
+ "data/java/objenesis-2.1.jar;"
+ );
+ }
+ }
- taskSequential->addTask(std::make_shared(
- taskParallel,
+ std::shared_ptr taskParserWrapper = std::make_shared(
m_storage.get(),
fileRegister
- ));
+ );
+ taskSequential->addTask(taskParserWrapper);
+
+ std::shared_ptr taskParallelIndexing = std::make_shared();
+ taskParserWrapper->setTask(taskParallelIndexing);
std::shared_ptr storageMutex = std::make_shared();
for (int i = 0; i < indexerThreadCount; i++)
{
- taskParallel->addTask(std::make_shared(
- m_storage.get(),
- storageMutex,
- fileRegister,
- getParserArguments()
- ));
+ if (ProjectSettings::getInstance()->getLanguage() == "Java")
+ {
+ std::shared_ptr projSettings = ProjectSettings::getInstance();
+
+ Parser::Arguments arguments;
+
+ for (FilePath classpath: projSettings->getAbsoluteJavaClasspaths())
+ {
+ arguments.javaClassPaths.push_back(classpath.str());
+ }
+
+ for (FilePath sourcePath: projSettings->getAbsoluteSourcePaths())
+ {
+ if (sourcePath.extension().empty())
+ {
+ arguments.javaClassPaths.push_back(sourcePath.str());
+ }
+ }
+
+ taskParallelIndexing->addTask(
+ std::make_shared(
+ m_storage.get(),
+ storageMutex,
+ fileRegister,
+ arguments
+ )
+ );
+ }
+ else // c or cxx
+ {
+ taskParallelIndexing->addTask(std::make_shared(
+ m_storage.get(),
+ storageMutex,
+ fileRegister,
+ getParserArguments()
+ ));
+ }
}
Task::dispatch(taskSequential);
@@ -247,7 +304,6 @@ Parser::Arguments Project::getParserArguments() const
Parser::Arguments args;
utility::append(args.compilerFlags, projSettings->getCompilerFlags());
- utility::append(args.compilerFlags, appSettings->getCompilerFlags());
// Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files.
utility::append(args.systemHeaderSearchPaths, m_fileManager.getSourcePaths());
diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp
index c9c46d7b..f0c92f9e 100644
--- a/src/lib/component/controller/GraphController.cpp
+++ b/src/lib/component/controller/GraphController.cpp
@@ -11,6 +11,7 @@
#include "component/view/GraphView.h"
#include "component/view/GraphViewStyle.h"
#include "data/access/StorageAccess.h"
+#include "data/parser/AccessKind.h"
#include "data/graph/Graph.h"
GraphController::GraphController(StorageAccess* storageAccess)
@@ -278,31 +279,14 @@ std::shared_ptr GraphController::createDummyNodeTopDown(Node* node, I
{
DummyNode* parent = nullptr;
- Edge* edge = child->getMemberEdge();
- TokenComponentAccess* access = edge->getComponent();
- TokenComponentAccess::AccessType accessType = TokenComponentAccess::ACCESS_NONE;
+ TokenComponentAccess* access = child->getComponent();
- if (access)
- {
- accessType = access->getAccess();
- }
- else
- {
- if (node->isType(Node::NODE_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT))
- {
- accessType = TokenComponentAccess::ACCESS_PUBLIC;
- }
- else
- {
- parent = result.get();
- }
- }
-
- if (accessType != TokenComponentAccess::ACCESS_NONE)
+ if (access && access->getAccess() != ACCESS_NONE)
{
+ AccessKind accessKind = access->getAccess();
for (std::shared_ptr dummy : result->subNodes)
{
- if (dummy->accessType == accessType)
+ if (dummy->accessKind == accessKind)
{
parent = dummy.get();
break;
@@ -312,12 +296,15 @@ std::shared_ptr GraphController::createDummyNodeTopDown(Node* node, I
if (!parent)
{
std::shared_ptr accessNode = std::make_shared();
- accessNode->accessType = accessType;
+ accessNode->accessKind = accessKind;
result->subNodes.push_back(accessNode);
parent = accessNode.get();
}
}
-
+ else
+ {
+ parent = result.get();
+ }
parent->subNodes.push_back(createDummyNodeTopDown(child, parentId));
}
);
@@ -853,7 +840,10 @@ void GraphController::bundleNodesByType()
}
BUNDLE_BY_TYPE(nodes, Node::NODE_NAMESPACE, "Namespaces");
+ BUNDLE_BY_TYPE(nodes, Node::NODE_PACKAGE, "Packages");
+ BUNDLE_BY_TYPE(nodes, Node::NODE_BUILTIN_TYPE, "Builtin Types");
BUNDLE_BY_TYPE(nodes, Node::NODE_CLASS, "Classes");
+ BUNDLE_BY_TYPE(nodes, Node::NODE_INTERFACE, "Interfaces");
BUNDLE_BY_TYPE(nodes, Node::NODE_STRUCT, "Structs");
BUNDLE_BY_TYPE(nodes, Node::NODE_FUNCTION, "Functions");
@@ -872,6 +862,7 @@ void GraphController::bundleNodesByType()
BUNDLE_BY_TYPE(nodes, Node::NODE_FIELD, "Fields");
BUNDLE_BY_TYPE(nodes, Node::NODE_ENUM_CONSTANT, "Enum Constants");
BUNDLE_BY_TYPE(nodes, Node::NODE_TEMPLATE_PARAMETER_TYPE, "Template Parameter Types");
+ BUNDLE_BY_TYPE(nodes, Node::NODE_TYPE_PARAMETER, "Type Parameters");
BUNDLE_BY_TYPE(nodes, Node::NODE_UNDEFINED, "Undefined Symbols");
for (std::shared_ptr node : m_dummyNodes)
@@ -918,7 +909,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
}
else if (node->isAccessNode())
{
- margins = GraphViewStyle::getMarginsOfAccessNode(node->accessType);
+ margins = GraphViewStyle::getMarginsOfAccessNode(node->accessKind);
}
else if (node->isExpandToggleNode())
{
@@ -944,7 +935,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
width = margins.charWidth * node->name.size();
- if (node->data->isType(Node::NODE_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT | Node::NODE_ENUM) &&
+ if (node->data->isType(Node::NODE_TYPE | Node::NODE_BUILTIN_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT | Node::NODE_ENUM) &&
node->subNodes.size())
{
addExpandToggleNode(node);
@@ -1178,6 +1169,9 @@ void GraphController::forEachDummyEdge(std::function func)
void GraphController::handleMessage(MessageColorSchemeTest* message)
{
+ // todo: add nodes: package, interface, type_parameter, builtin_type
+ // todo: add edges: EDGE_TYPE_ARGUMENT, EDGE_IMPORT
+ // todo: add access: TYPE_PARAMETER
clear();
std::shared_ptr graph = std::make_shared();
@@ -1205,15 +1199,15 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
createNodes(60, Node::NODE_FILE);
createNodes(70, Node::NODE_MACRO);
- std::function createChild(
- [&](Node* parent, Id id, Node::NodeType type, std::string name, TokenComponentAccess::AccessType access)
+ std::function createChild(
+ [&](Node* parent, Id id, Node::NodeType type, std::string name, AccessKind access)
{
Node* node = graph->createNode(id + 1000, type, NameHierarchy(name), true);
Edge* edge = graph->createEdge(id + 10000, Edge::EDGE_MEMBER, parent, node);
- if (access != TokenComponentAccess::ACCESS_NONE)
+ if (access != ACCESS_NONE)
{
- edge->addComponentAccess(std::make_shared(access));
+ node->addComponentAccess(std::make_shared(access));
}
return node;
@@ -1225,8 +1219,7 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
{
Node* enumNode = graph->createNode(id, Node::NODE_ENUM,
NameHierarchy(name + Node::getTypeString(Node::NODE_ENUM)), true);
- createChild(enumNode, id + 10, Node::NODE_ENUM_CONSTANT, name + Node::getTypeString(Node::NODE_ENUM_CONSTANT),
- TokenComponentAccess::ACCESS_NONE);
+ createChild(enumNode, id + 10, Node::NODE_ENUM_CONSTANT, name + Node::getTypeString(Node::NODE_ENUM_CONSTANT), ACCESS_NONE);
}
);
@@ -1245,17 +1238,15 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
if (type == Node::NODE_CLASS)
{
- createChild(classNode, id, Node::NODE_TEMPLATE_PARAMETER_TYPE, name + "temp_param",
- TokenComponentAccess::ACCESS_TEMPLATE);
+ createChild(classNode, id, Node::NODE_TEMPLATE_PARAMETER_TYPE, name + "temp_param", ACCESS_TEMPLATE_PARAMETER);
}
- createChild(classNode, id + 10, Node::NODE_METHOD, name + "method", TokenComponentAccess::ACCESS_PUBLIC);
+ createChild(classNode, id + 10, Node::NODE_METHOD, name + "method", ACCESS_PUBLIC);
if (type == Node::NODE_CLASS)
{
- createChild(classNode, id + 30, Node::NODE_METHOD, name + "method",
- TokenComponentAccess::ACCESS_PROTECTED);
+ createChild(classNode, id + 30, Node::NODE_METHOD, name + "method", ACCESS_PROTECTED);
}
- createChild(classNode, id + 60, Node::NODE_FIELD, name + "field", TokenComponentAccess::ACCESS_PRIVATE);
+ createChild(classNode, id + 60, Node::NODE_FIELD, name + "field", ACCESS_PRIVATE);
}
);
@@ -1284,8 +1275,7 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
{
Node* classNode = graph->createNode(id + 101, Node::NODE_CLASS,
NameHierarchy(name + Node::getTypeString(Node::NODE_CLASS)), true);
- originNode = createChild(classNode, id + 111, Node::NODE_METHOD, name + Edge::getTypeString(type),
- TokenComponentAccess::ACCESS_PUBLIC);
+ originNode = createChild(classNode, id + 111, Node::NODE_METHOD, name + Edge::getTypeString(type), ACCESS_PUBLIC);
}
else
{
@@ -1297,8 +1287,7 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
{
Node* classNode = graph->createNode(id + 201, Node::NODE_CLASS,
NameHierarchy(name + Node::getTypeString(Node::NODE_CLASS)), true);
- targetNode = createChild(classNode, id + 211, Node::NODE_METHOD, name + Edge::getTypeString(type),
- TokenComponentAccess::ACCESS_PUBLIC);
+ targetNode = createChild(classNode, id + 211, Node::NODE_METHOD, name + Edge::getTypeString(type), ACCESS_PUBLIC);
}
else
{
@@ -1331,20 +1320,18 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
createEdges( 100000, Edge::EDGE_CALL, Node::NODE_FUNCTION, Node::NODE_FUNCTION);
createEdges( 200000, Edge::EDGE_USAGE, Node::NODE_GLOBAL_VARIABLE, Node::NODE_GLOBAL_VARIABLE);
createEdges( 300000, Edge::EDGE_TYPE_USAGE, Node::NODE_FUNCTION, Node::NODE_TYPE);
- createEdges( 400000, Edge::EDGE_TYPE_OF, Node::NODE_GLOBAL_VARIABLE, Node::NODE_TYPE);
- createEdges( 500000, Edge::EDGE_TYPEDEF_OF, Node::NODE_TYPEDEF, Node::NODE_TYPE);
- createEdges( 600000, Edge::EDGE_AGGREGATION, Node::NODE_TYPE, Node::NODE_TYPE);
- createEdges( 700000, Edge::EDGE_INCLUDE, Node::NODE_FILE, Node::NODE_FILE);
- createEdges( 800000, Edge::EDGE_MACRO_USAGE, Node::NODE_MACRO, Node::NODE_MACRO);
+ createEdges( 400000, Edge::EDGE_AGGREGATION, Node::NODE_TYPE, Node::NODE_TYPE);
+ createEdges( 500000, Edge::EDGE_INCLUDE, Node::NODE_FILE, Node::NODE_FILE);
+ createEdges( 600000, Edge::EDGE_MACRO_USAGE, Node::NODE_MACRO, Node::NODE_MACRO);
- createEdges( 900000, Edge::EDGE_INHERITANCE, Node::NODE_CLASS, Node::NODE_CLASS);
- createEdges(1000000, Edge::EDGE_OVERRIDE, Node::NODE_METHOD, Node::NODE_METHOD);
+ createEdges( 700000, Edge::EDGE_INHERITANCE, Node::NODE_CLASS, Node::NODE_CLASS);
+ createEdges( 800000, Edge::EDGE_OVERRIDE, Node::NODE_METHOD, Node::NODE_METHOD);
- createEdges(1100000, Edge::EDGE_TEMPLATE_ARGUMENT, Node::NODE_TYPE, Node::NODE_TYPE);
- createEdges(1200000, Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT, Node::NODE_TYPE, Node::NODE_TYPE);
- createEdges(1300000, Edge::EDGE_TEMPLATE_SPECIALIZATION_OF, Node::NODE_TYPE, Node::NODE_TYPE);
- createEdges(1400000, Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF, Node::NODE_METHOD, Node::NODE_METHOD);
+ createEdges( 900000, Edge::EDGE_TEMPLATE_ARGUMENT, Node::NODE_TYPE, Node::NODE_TYPE);
+ createEdges(1000000, Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT, Node::NODE_TYPE, Node::NODE_TYPE);
+ createEdges(1100000, Edge::EDGE_TEMPLATE_SPECIALIZATION_OF, Node::NODE_TYPE, Node::NODE_TYPE);
+ createEdges(1200000, Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF, Node::NODE_METHOD, Node::NODE_METHOD);
std::vector focusedTokenIds;
std::vector activeTokenIds;
diff --git a/src/lib/component/controller/helper/DummyNode.h b/src/lib/component/controller/helper/DummyNode.h
index 724b47b9..62b96fa8 100644
--- a/src/lib/component/controller/helper/DummyNode.h
+++ b/src/lib/component/controller/helper/DummyNode.h
@@ -40,7 +40,7 @@ public:
, connected(false)
, expanded(false)
, hasParent(true)
- , accessType(TokenComponentAccess::ACCESS_NONE)
+ , accessKind(ACCESS_NONE)
, invisibleSubNodeCount(0)
, layoutBucket(0, 0)
, bundledNodeCount(0)
@@ -54,7 +54,7 @@ public:
bool isAccessNode() const
{
- return accessType != TokenComponentAccess::ACCESS_NONE;
+ return accessKind != ACCESS_NONE;
}
bool isExpandToggleNode() const
@@ -223,7 +223,7 @@ public:
bool hasParent;
// AccessNode
- TokenComponentAccess::AccessType accessType;
+ AccessKind accessKind;
// ExpandToggleNode
size_t invisibleSubNodeCount;
diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp
index bff79f14..0cb445cd 100644
--- a/src/lib/component/view/GraphViewStyle.cpp
+++ b/src/lib/component/view/GraphViewStyle.cpp
@@ -130,12 +130,16 @@ size_t GraphViewStyle::getFontSizeForNodeType(Node::NodeType type)
{
case Node::NODE_UNDEFINED:
case Node::NODE_NAMESPACE:
+ case Node::NODE_PACKAGE:
case Node::NODE_TYPE:
+ case Node::NODE_BUILTIN_TYPE:
case Node::NODE_STRUCT:
case Node::NODE_CLASS:
+ case Node::NODE_INTERFACE:
case Node::NODE_ENUM:
case Node::NODE_TYPEDEF:
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
+ case Node::NODE_TYPE_PARAMETER:
case Node::NODE_FILE:
case Node::NODE_MACRO:
return s_fontSize;
@@ -194,10 +198,14 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
margins.iconWidth = s_fontSize + 11;
case Node::NODE_UNDEFINED:
case Node::NODE_NAMESPACE:
+ case Node::NODE_PACKAGE:
case Node::NODE_TYPE:
+ case Node::NODE_BUILTIN_TYPE:
case Node::NODE_STRUCT:
case Node::NODE_CLASS:
+ case Node::NODE_INTERFACE:
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
+ case Node::NODE_TYPE_PARAMETER:
if (hasChildren)
{
margins.left = margins.right = 10;
@@ -237,7 +245,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
return margins;
}
-GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfAccessNode(TokenComponentAccess::AccessType type)
+GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfAccessNode(AccessKind access)
{
NodeMargins margins;
margins.spacingX = margins.spacingY = 8;
@@ -246,21 +254,22 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfAccessNode(TokenComponen
margins.top = 40;
margins.bottom = 10;
- switch (type)
+ switch (access)
{
- case TokenComponentAccess::ACCESS_NONE:
+ case ACCESS_NONE:
margins.minWidth = 30;
break;
- case TokenComponentAccess::ACCESS_PUBLIC:
+ case ACCESS_PUBLIC:
margins.minWidth = 56;
break;
- case TokenComponentAccess::ACCESS_PROTECTED:
+ case ACCESS_PROTECTED:
margins.minWidth = 72;
break;
- case TokenComponentAccess::ACCESS_PRIVATE:
+ case ACCESS_PRIVATE:
margins.minWidth = 58;
break;
- case TokenComponentAccess::ACCESS_TEMPLATE:
+ case ACCESS_TEMPLATE_PARAMETER:
+ case ACCESS_TYPE_PARAMETER:
margins.minWidth = 133;
break;
}
@@ -299,12 +308,16 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
style.borderDashed = true;
case Node::NODE_NAMESPACE:
+ case Node::NODE_PACKAGE:
case Node::NODE_TYPE:
+ case Node::NODE_BUILTIN_TYPE:
case Node::NODE_STRUCT:
case Node::NODE_CLASS:
+ case Node::NODE_INTERFACE:
case Node::NODE_ENUM:
case Node::NODE_TYPEDEF:
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
+ case Node::NODE_TYPE_PARAMETER:
case Node::NODE_FILE:
case Node::NODE_MACRO:
if (hasChildren)
diff --git a/src/lib/component/view/GraphViewStyle.h b/src/lib/component/view/GraphViewStyle.h
index 38fc5743..8440edac 100644
--- a/src/lib/component/view/GraphViewStyle.h
+++ b/src/lib/component/view/GraphViewStyle.h
@@ -108,7 +108,7 @@ public:
static std::string getFontNameOfExpandToggleNode();
static NodeMargins getMarginsForNodeType(Node::NodeType type, bool hasChildren);
- static NodeMargins getMarginsOfAccessNode(TokenComponentAccess::AccessType type);
+ static NodeMargins getMarginsOfAccessNode(AccessKind access);
static NodeMargins getMarginsOfExpandToggleNode();
static NodeMargins getMarginsOfBundleNode();
diff --git a/src/lib/data/IntermediateStorage.cpp b/src/lib/data/IntermediateStorage.cpp
index f765deed..76413031 100644
--- a/src/lib/data/IntermediateStorage.cpp
+++ b/src/lib/data/IntermediateStorage.cpp
@@ -121,9 +121,9 @@ void IntermediateStorage::addSourceLocation(Id elementId, Id fileNodeId, uint st
));
}
-void IntermediateStorage::addComponentAccess(Id edgeId, int type)
+void IntermediateStorage::addComponentAccess(Id nodeId, int type)
{
- m_componentAccesses.push_back(StorageComponentAccess(edgeId, type));
+ m_componentAccesses.push_back(StorageComponentAccess(nodeId, type));
}
void IntermediateStorage::addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol)
diff --git a/src/lib/data/IntermediateStorage.h b/src/lib/data/IntermediateStorage.h
index 4e03fac7..b75c1209 100644
--- a/src/lib/data/IntermediateStorage.h
+++ b/src/lib/data/IntermediateStorage.h
@@ -19,7 +19,7 @@ public:
virtual Id addEdge(int type, Id sourceId, Id targetId);
virtual Id addLocalSymbol(const std::string& name);
virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
- virtual void addComponentAccess(Id edgeId , int type);
+ virtual void addComponentAccess(Id nodeId , int type);
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol);
diff --git a/src/lib/data/PersistentStorage.cpp b/src/lib/data/PersistentStorage.cpp
index 69085de6..1a1bf90a 100644
--- a/src/lib/data/PersistentStorage.cpp
+++ b/src/lib/data/PersistentStorage.cpp
@@ -119,9 +119,9 @@ void PersistentStorage::addSourceLocation(
);
}
-void PersistentStorage::addComponentAccess(Id edgeId , int type)
+void PersistentStorage::addComponentAccess(Id nodeId , int type)
{
- m_sqliteStorage.addComponentAccess(edgeId, type);
+ m_sqliteStorage.addComponentAccess(nodeId, type);
}
void PersistentStorage::addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol)
@@ -668,8 +668,14 @@ std::shared_ptr PersistentStorage::getGraphForAll() const
for (StorageNode node: m_sqliteStorage.getAllNodes())
{
if (intToDefinitionType(node.definitionType) == DEFINITION_EXPLICIT &&
- (!m_hierarchyCache.isChildOfVisibleNodeOrInvisible(node.id) ||
- Node::intToType(node.type) == Node::NODE_NAMESPACE))
+ (
+ !m_hierarchyCache.isChildOfVisibleNodeOrInvisible(node.id) ||
+ (
+ Node::intToType(node.type) == Node::NODE_NAMESPACE || // TODO: use & here
+ Node::intToType(node.type) == Node::NODE_PACKAGE
+ )
+ )
+ )
{
tokenIds.push_back(node.id);
}
@@ -701,7 +707,8 @@ std::shared_ptr PersistentStorage::getGraphForActiveTokenIds(const std::v
if (node.id > 0)
{
- if (Node::intToType(node.type) == Node::NODE_NAMESPACE)
+ if (Node::intToType(node.type) == Node::NODE_NAMESPACE || // TODO: use & here
+ Node::intToType(node.type) == Node::NODE_PACKAGE)
{
ids.clear();
m_hierarchyCache.addFirstChildIdsForNodeId(elementId, &ids);
@@ -1352,27 +1359,21 @@ void PersistentStorage::addComponentAccessToGraph(Graph* graph) const
{
TRACE();
- std::vector memberEdgeIds;
-
- graph->forEachEdge(
- [&memberEdgeIds](Edge* edge)
+ std::vector nodeIds;
+ graph->forEachNode(
+ [&nodeIds](Node* node)
{
- if (!edge->isType(Edge::EDGE_MEMBER))
- {
- return;
- }
-
- memberEdgeIds.push_back(edge->getId());
+ nodeIds.push_back(node->getId());
}
);
- std::vector accesses = m_sqliteStorage.getComponentAccessByMemberEdgeIds(memberEdgeIds);
+ std::vector accesses = m_sqliteStorage.getComponentAccessesByNodeIds(nodeIds);
for (const StorageComponentAccess& access : accesses)
{
- if (access.memberEdgeId && access.type)
+ if (access.nodeId != 0)
{
- graph->getEdgeById(access.memberEdgeId)->addComponentAccess(
- std::make_shared(TokenComponentAccess::intToType(access.type)));
+ graph->getNodeById(access.nodeId)->addComponentAccess(
+ std::make_shared(intToAccessKind(access.type)));
}
}
}
diff --git a/src/lib/data/PersistentStorage.h b/src/lib/data/PersistentStorage.h
index 277293fb..07525ddb 100644
--- a/src/lib/data/PersistentStorage.h
+++ b/src/lib/data/PersistentStorage.h
@@ -32,7 +32,7 @@ public:
virtual Id addEdge(int type, Id sourceId, Id targetId);
virtual Id addLocalSymbol(const std::string& name);
virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
- virtual void addComponentAccess(Id edgeId , int type);
+ virtual void addComponentAccess(Id nodeId , int type);
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol);
diff --git a/src/lib/data/SqliteStorage.cpp b/src/lib/data/SqliteStorage.cpp
index 9fd45563..1d92a90f 100644
--- a/src/lib/data/SqliteStorage.cpp
+++ b/src/lib/data/SqliteStorage.cpp
@@ -11,7 +11,7 @@
#include "utility/utilityString.h"
#include "utility/Version.h"
-const size_t SqliteStorage::STORAGE_VERSION = 1;
+const size_t SqliteStorage::STORAGE_VERSION = 2;
SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
: m_dbFilePath(dbFilePath)
@@ -178,11 +178,11 @@ Id SqliteStorage::addSourceLocation(
return m_database.lastRowId();
}
-Id SqliteStorage::addComponentAccess(Id memberEdgeId, int type)
+Id SqliteStorage::addComponentAccess(Id nodeId, int type)
{
m_database.execDML((
- "INSERT INTO component_access(id, edge_id, type) "
- "VALUES (NULL, " + std::to_string(memberEdgeId) + ", " + std::to_string(type) + ");"
+ "INSERT INTO component_access(id, node_id, type) "
+ "VALUES (NULL, " + std::to_string(nodeId) + ", " + std::to_string(type) + ");"
).c_str());
return m_database.lastRowId();
@@ -534,14 +534,14 @@ Id SqliteStorage::getElementIdByLocationId(Id locationId) const
return 0;
}
-StorageComponentAccess SqliteStorage::getComponentAccessByMemberEdgeId(Id memberEdgeId) const
+StorageComponentAccess SqliteStorage::getComponentAccessByNodeId(Id nodeId) const
{
- return getFirst("WHERE edge_id == " + std::to_string(memberEdgeId));
+ return getFirst("WHERE node_id == " + std::to_string(nodeId));
}
-std::vector SqliteStorage::getComponentAccessByMemberEdgeIds(const std::vector& memberEdgeIds) const
+std::vector SqliteStorage::getComponentAccessesByNodeIds(const std::vector& nodeIds) const
{
- return getAll("WHERE edge_id IN (" + utility::join(utility::toStrings(memberEdgeIds), ',') + ")");
+ return getAll("WHERE node_id IN (" + utility::join(utility::toStrings(nodeIds), ',') + ")");
}
std::vector SqliteStorage::getCommentLocationsInFile(const FilePath& filePath) const
@@ -722,13 +722,13 @@ void SqliteStorage::setupTables()
m_database.execDML(
"CREATE TABLE IF NOT EXISTS component_access("
"id INTEGER NOT NULL, "
- "edge_id INTEGER, "
+ "node_id INTEGER, "
"type INTEGER NOT NULL, "
"PRIMARY KEY(id), "
- "FOREIGN KEY(edge_id) REFERENCES edge(id) ON DELETE CASCADE);"
+ "FOREIGN KEY(node_id) REFERENCES node(id) ON DELETE CASCADE);"
);
- SqliteIndex("component_access_edge_id_index", "component_access(edge_id)").createOnDatabase(m_database);
+ SqliteIndex("component_access_node_id_index", "component_access(node_id)").createOnDatabase(m_database);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS comment_location("
@@ -965,7 +965,7 @@ template <>
std::vector SqliteStorage::getAll(const std::string& query) const
{
CppSQLite3Query q = m_database.execQuery((
- "SELECT id, edge_id, type FROM component_access " + query + ";"
+ "SELECT id, node_id, type FROM component_access " + query + ";"
).c_str());
std::vector componentAccesses;
@@ -973,12 +973,12 @@ std::vector SqliteStorage::getAll getComponentAccessByMemberEdgeIds(const std::vector& memberEdgeIds) const;
+ StorageComponentAccess getComponentAccessByNodeId(Id memberEdgeId) const;
+ std::vector getComponentAccessesByNodeIds(const std::vector& memberEdgeIds) const;
void optimizeMemory() const;
diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp
index 17d1d8b6..21850468 100644
--- a/src/lib/data/Storage.cpp
+++ b/src/lib/data/Storage.cpp
@@ -132,14 +132,14 @@ void Storage::inject(Storage* injected)
[&](const StorageComponentAccess& injectedData)
{
std::unordered_map::const_iterator it;
- it = injectedIdToOwnId.find(injectedData.memberEdgeId);
+ it = injectedIdToOwnId.find(injectedData.nodeId);
if (it == injectedIdToOwnId.end())
{
return;
}
- Id ownMemberEdgeId = it->second;
+ Id ownNodeId = it->second;
- addComponentAccess(ownMemberEdgeId, injectedData.type);
+ addComponentAccess(ownNodeId, injectedData.type);
}
);
diff --git a/src/lib/data/Storage.h b/src/lib/data/Storage.h
index 23c37b9e..84c48050 100644
--- a/src/lib/data/Storage.h
+++ b/src/lib/data/Storage.h
@@ -19,7 +19,7 @@ public:
virtual Id addEdge(int type, Id sourceId, Id targetId) = 0;
virtual Id addLocalSymbol(const std::string& name) = 0;
virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type) = 0;
- virtual void addComponentAccess(Id edgeId , int type) = 0;
+ virtual void addComponentAccess(Id nodeId , int type) = 0;
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol) = 0;
virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol) = 0;
diff --git a/src/lib/data/StorageTypes.h b/src/lib/data/StorageTypes.h
index b6dbbc6e..fe865cde 100644
--- a/src/lib/data/StorageTypes.h
+++ b/src/lib/data/StorageTypes.h
@@ -125,16 +125,16 @@ struct StorageSourceLocation
struct StorageComponentAccess
{
StorageComponentAccess()
- : memberEdgeId(0)
+ : nodeId(0)
, type(0)
{}
- StorageComponentAccess(Id memberEdgeId, int type)
- : memberEdgeId(memberEdgeId)
+ StorageComponentAccess(Id nodeId, int type)
+ : nodeId(nodeId)
, type(type)
{}
- Id memberEdgeId;
+ Id nodeId;
int type;
};
diff --git a/src/lib/data/graph/Edge.cpp b/src/lib/data/graph/Edge.cpp
index 64ea10b4..0ea9ce53 100644
--- a/src/lib/data/graph/Edge.cpp
+++ b/src/lib/data/graph/Edge.cpp
@@ -17,45 +17,39 @@ Edge::EdgeType Edge::intToType(int value)
{
switch (value)
{
- case 0x1:
+ case EDGE_MEMBER:
return EDGE_MEMBER;
- case 0x2:
- return EDGE_TYPE_OF;
- case 0x4:
- return EDGE_RETURN_TYPE_OF;
- case 0x8:
- return EDGE_PARAMETER_TYPE_OF;
- case 0x10:
+ case EDGE_TYPE_USAGE:
return EDGE_TYPE_USAGE;
- case 0x20:
+ case EDGE_USAGE:
return EDGE_USAGE;
- case 0x40:
+ case EDGE_CALL:
return EDGE_CALL;
- case 0x80:
+ case EDGE_INHERITANCE:
return EDGE_INHERITANCE;
- case 0x100:
+ case EDGE_OVERRIDE:
return EDGE_OVERRIDE;
- case 0x200:
- return EDGE_TYPEDEF_OF;
- case 0x400:
- return EDGE_TEMPLATE_PARAMETER;
- case 0x800:
+ case EDGE_TEMPLATE_ARGUMENT:
return EDGE_TEMPLATE_ARGUMENT;
- case 0x1000:
+ case EDGE_TYPE_ARGUMENT:
+ return EDGE_TYPE_ARGUMENT;
+ case EDGE_TEMPLATE_DEFAULT_ARGUMENT:
return EDGE_TEMPLATE_DEFAULT_ARGUMENT;
- case 0x2000:
+ case EDGE_TEMPLATE_SPECIALIZATION_OF:
return EDGE_TEMPLATE_SPECIALIZATION_OF;
- case 0x4000:
+ case EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF:
return EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF;
- case 0x8000:
+ case EDGE_INCLUDE:
return EDGE_INCLUDE;
- case 0x10000:
+ case EDGE_IMPORT:
+ return EDGE_IMPORT;
+ case EDGE_AGGREGATION:
return EDGE_AGGREGATION;
- case 0x20000:
+ case EDGE_MACRO_USAGE:
return EDGE_MACRO_USAGE;
}
- return EDGE_NONE;
+ return EDGE_UNDEFINED;
}
Edge::Edge(Id id, EdgeType type, Node* from, Node* to)
@@ -141,53 +135,28 @@ void Edge::addComponentAggregation(std::shared_ptr co
}
}
-void Edge::addComponentAccess(std::shared_ptr component)
-{
- if (getComponent())
- {
- // LOG_ERROR("TokenComponentAccess has been set before!");
- return;
- }
- else if (m_type != EDGE_MEMBER && m_type != EDGE_INHERITANCE)
- {
- LOG_ERROR("TokenComponentAccess can't be set on edge of type: " + getTypeString());
- }
- else
- {
- addComponent(component);
- }
-}
-
std::string Edge::getTypeString(EdgeType type)
{
switch (type)
{
- case EDGE_NONE:
- return "none";
+ case EDGE_UNDEFINED:
+ return "undefined";
case EDGE_MEMBER:
return "child";
- case EDGE_TYPE_OF:
- return "type_of";
- case EDGE_RETURN_TYPE_OF:
- return "return_type";
- case EDGE_PARAMETER_TYPE_OF:
- return "parameter_type";
case EDGE_TYPE_USAGE:
return "type_use";
+ case EDGE_USAGE:
+ return "use";
+ case EDGE_CALL:
+ return "call";
case EDGE_INHERITANCE:
return "inheritance";
case EDGE_OVERRIDE:
return "override";
- case EDGE_CALL:
- return "call";
- case EDGE_USAGE:
- return "use";
- case EDGE_TYPEDEF_OF:
- return "typedef";
- case EDGE_TEMPLATE_PARAMETER:
- return "template_parameter";
case EDGE_TEMPLATE_ARGUMENT:
return "template_argument";
+ case EDGE_TYPE_ARGUMENT:
+ return "type_argument";
case EDGE_TEMPLATE_DEFAULT_ARGUMENT:
return "template_default_argument";
case EDGE_TEMPLATE_SPECIALIZATION_OF:
@@ -196,6 +165,8 @@ std::string Edge::getTypeString(EdgeType type)
return "template_member_specialization";
case EDGE_INCLUDE:
return "include";
+ case EDGE_IMPORT:
+ return "import";
case EDGE_AGGREGATION:
return "aggregation";
case EDGE_MACRO_USAGE:
@@ -215,12 +186,6 @@ std::string Edge::getAsString() const
std::stringstream str;
str << "[" << getId() << "] " << getTypeString() << ": \"" << m_from->getName() << "\" -> \"" + m_to->getName() << "\"";
- TokenComponentAccess* access = getComponent();
- if (access)
- {
- str << " " << access->getAccessString();
- }
-
TokenComponentAggregation* aggregation = getComponent();
if (aggregation)
{
diff --git a/src/lib/data/graph/Edge.h b/src/lib/data/graph/Edge.h
index 47529a14..0498872c 100644
--- a/src/lib/data/graph/Edge.h
+++ b/src/lib/data/graph/Edge.h
@@ -18,27 +18,22 @@ public:
typedef int EdgeTypeMask;
enum EdgeType : EdgeTypeMask
{
- EDGE_NONE = 0x0,
+ EDGE_UNDEFINED = 0x0,
EDGE_MEMBER = 0x1,
- EDGE_TYPE_OF = 0x2,
- EDGE_RETURN_TYPE_OF = 0x4, // unused: see Storage::addFunctionNode()
- EDGE_PARAMETER_TYPE_OF = 0x8, // unused: see Storage::addFunctionNode()
- EDGE_TYPE_USAGE = 0x10,
- EDGE_USAGE = 0x20,
- EDGE_CALL = 0x40,
- EDGE_INHERITANCE = 0x80,
- EDGE_OVERRIDE = 0x100,
- EDGE_TYPEDEF_OF = 0x200,
- EDGE_TEMPLATE_PARAMETER = 0x400, // unused since template parameters are children
- EDGE_TEMPLATE_ARGUMENT = 0x800,
- EDGE_TEMPLATE_DEFAULT_ARGUMENT = 0x1000,
- EDGE_TEMPLATE_SPECIALIZATION_OF = 0x2000,
- EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF = 0x4000,
-
- EDGE_INCLUDE = 0x8000,
-
- EDGE_AGGREGATION = 0x10000,
- EDGE_MACRO_USAGE = 0x20000,
+ EDGE_TYPE_USAGE = 0x2,
+ EDGE_USAGE = 0x4,
+ EDGE_CALL = 0x8,
+ EDGE_INHERITANCE = 0x10,
+ EDGE_OVERRIDE = 0x20,
+ EDGE_TEMPLATE_ARGUMENT = 0x40,
+ EDGE_TYPE_ARGUMENT = 0x80,
+ EDGE_TEMPLATE_DEFAULT_ARGUMENT = 0x100,
+ EDGE_TEMPLATE_SPECIALIZATION_OF = 0x200,
+ EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF = 0x400,
+ EDGE_INCLUDE = 0x800,
+ EDGE_IMPORT = 0x1000,
+ EDGE_AGGREGATION = 0x2000,
+ EDGE_MACRO_USAGE = 0x4000
};
static int typeToInt(EdgeType type);
@@ -62,7 +57,6 @@ public:
// Component setters
void addComponentAggregation(std::shared_ptr component);
- void addComponentAccess(std::shared_ptr component);
// Logging.
static std::string getTypeString(EdgeType type);
diff --git a/src/lib/data/graph/Graph.cpp b/src/lib/data/graph/Graph.cpp
index 9bd2f06b..3efec90d 100644
--- a/src/lib/data/graph/Graph.cpp
+++ b/src/lib/data/graph/Graph.cpp
@@ -164,25 +164,6 @@ void Graph::removeEdge(Edge* edge)
m_edges.erase(it);
}
-bool Graph::removeNodeIfUnreferencedRecursive(Node* node)
-{
- if (!node->hasReferences())
- {
- Node* parent = node->getParentNode();
-
- removeNode(node);
-
- if (parent)
- {
- removeNodeIfUnreferencedRecursive(parent);
- }
-
- return true;
- }
-
- return false;
-}
-
Node* Graph::findNode(std::function func) const
{
std::map>::const_iterator it = find_if(m_nodes.begin(), m_nodes.end(),
diff --git a/src/lib/data/graph/Graph.h b/src/lib/data/graph/Graph.h
index 39daa411..82c6f7b1 100644
--- a/src/lib/data/graph/Graph.h
+++ b/src/lib/data/graph/Graph.h
@@ -34,7 +34,6 @@ public:
void removeNode(Node* node);
void removeEdge(Edge* edge);
- bool removeNodeIfUnreferencedRecursive(Node* node);
Node* findNode(std::function func) const;
Edge* findEdge(std::function func) const;
diff --git a/src/lib/data/graph/Node.cpp b/src/lib/data/graph/Node.cpp
index a85f4c47..4bc445c8 100644
--- a/src/lib/data/graph/Node.cpp
+++ b/src/lib/data/graph/Node.cpp
@@ -5,12 +5,13 @@
#include "utility/logging/logging.h"
#include "data/graph/token_component/TokenComponentAbstraction.h"
+#include "data/graph/token_component/TokenComponentAccess.h"
#include "data/graph/token_component/TokenComponentConst.h"
#include "data/graph/token_component/TokenComponentStatic.h"
#include "data/graph/token_component/TokenComponentFilePath.h"
#include "data/graph/token_component/TokenComponentSignature.h"
-const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = Node::NODE_UNDEFINED | Node::NODE_NAMESPACE;
+const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = Node::NODE_UNDEFINED | Node::NODE_NAMESPACE | Node::NODE_PACKAGE;
std::string Node::getTypeString(NodeType type)
{
@@ -18,14 +19,20 @@ std::string Node::getTypeString(NodeType type)
{
case NODE_UNDEFINED:
return "undefined";
+ case NODE_BUILTIN_TYPE:
+ return "builtin_type";
case NODE_TYPE:
return "type";
case NODE_NAMESPACE:
return "namespace";
- case NODE_CLASS:
- return "class";
+ case NODE_PACKAGE:
+ return "package";
case NODE_STRUCT:
return "struct";
+ case NODE_CLASS:
+ return "class";
+ case NODE_INTERFACE:
+ return "interface";
case NODE_GLOBAL_VARIABLE:
return "global_variable";
case NODE_FIELD:
@@ -42,6 +49,8 @@ std::string Node::getTypeString(NodeType type)
return "typedef";
case NODE_TEMPLATE_PARAMETER_TYPE:
return "template_parameter_type";
+ case NODE_TYPE_PARAMETER:
+ return "type_parameter";
case NODE_FILE:
return "file";
case NODE_MACRO:
@@ -60,33 +69,41 @@ Node::NodeType Node::intToType(int value)
{
switch (value)
{
- case 0x2:
+ case NODE_TYPE:
return NODE_TYPE;
- case 0x4:
+ case NODE_BUILTIN_TYPE:
+ return NODE_BUILTIN_TYPE;
+ case NODE_NAMESPACE:
return NODE_NAMESPACE;
- case 0x8:
+ case NODE_PACKAGE:
+ return NODE_PACKAGE;
+ case NODE_STRUCT:
return NODE_STRUCT;
- case 0x10:
+ case NODE_CLASS:
return NODE_CLASS;
- case 0x20:
+ case NODE_INTERFACE:
+ return NODE_INTERFACE;
+ case NODE_GLOBAL_VARIABLE:
return NODE_GLOBAL_VARIABLE;
- case 0x40:
+ case NODE_FIELD:
return NODE_FIELD;
- case 0x80:
+ case NODE_FUNCTION:
return NODE_FUNCTION;
- case 0x100:
+ case NODE_METHOD:
return NODE_METHOD;
- case 0x200:
+ case NODE_ENUM:
return NODE_ENUM;
- case 0x400:
+ case NODE_ENUM_CONSTANT:
return NODE_ENUM_CONSTANT;
- case 0x800:
+ case NODE_TYPEDEF:
return NODE_TYPEDEF;
- case 0x1000:
+ case NODE_TEMPLATE_PARAMETER_TYPE:
return NODE_TEMPLATE_PARAMETER_TYPE;
- case 0x2000:
+ case NODE_TYPE_PARAMETER:
+ return NODE_TYPE_PARAMETER;
+ case NODE_FILE:
return NODE_FILE;
- case 0x4000:
+ case NODE_MACRO:
return NODE_MACRO;
}
@@ -324,37 +341,6 @@ void Node::forEachNodeRecursive(std::function func) const
);
}
-bool Node::hasReferences() const
-{
- if (getLocationIds().size() > 0)
- {
- return true;
- }
-
- bool hasChildrenWithReferences = false;
- size_t childNodeCount = 0;
-
- forEachEdgeOfType(
- Edge::EDGE_MEMBER,
- [&](Edge* edge)
- {
- childNodeCount++;
-
- if (!hasChildrenWithReferences && edge->getTo() != this && edge->getTo()->hasReferences())
- {
- hasChildrenWithReferences = true;
- }
- }
- );
-
- if (hasChildrenWithReferences || getEdges().size() > childNodeCount)
- {
- return true;
- }
-
- return false;
-}
-
bool Node::isNode() const
{
return true;
@@ -450,6 +436,19 @@ void Node::addComponentSignature(std::shared_ptr compon
}
}
+void Node::addComponentAccess(std::shared_ptr component)
+{
+ if (getComponent())
+ {
+ LOG_ERROR("TokenComponentAccess has been set before!");
+ return;
+ }
+ else
+ {
+ addComponent(component);
+ }
+}
+
std::string Node::getTypeString() const
{
return getTypeString(m_type);
@@ -460,6 +459,12 @@ std::string Node::getAsString() const
std::stringstream str;
str << "[" << getId() << "] " << getTypeString() << ": " << "\"" << getName() << "\"";
+ TokenComponentAccess* access = getComponent();
+ if (access)
+ {
+ str << " " << access->getAccessString();
+ }
+
if (getComponent())
{
str << " static";
diff --git a/src/lib/data/graph/Node.h b/src/lib/data/graph/Node.h
index 7631a7f0..d4b8edb3 100644
--- a/src/lib/data/graph/Node.h
+++ b/src/lib/data/graph/Node.h
@@ -11,6 +11,7 @@
#include "data/name/NameHierarchy.h"
class TokenComponentAbstraction;
+class TokenComponentAccess;
class TokenComponentConst;
class TokenComponentStatic;
class TokenComponentFilePath;
@@ -22,25 +23,29 @@ class Node
public:
typedef int NodeTypeMask;
enum NodeType : NodeTypeMask
- {
+ { // make sure that the value of 0x0 is not used here because it doesn't work for bitmasking.
NODE_UNDEFINED = 0x1,
NODE_TYPE = 0x2,
+ NODE_BUILTIN_TYPE = 0x4,
- NODE_NAMESPACE = 0x4,
- NODE_STRUCT = 0x8,
- NODE_CLASS = 0x10,
- NODE_GLOBAL_VARIABLE = 0x20,
- NODE_FIELD = 0x40,
- NODE_FUNCTION = 0x80,
- NODE_METHOD = 0x100,
+ NODE_NAMESPACE = 0x8,
+ NODE_PACKAGE = 0x10,
+ NODE_STRUCT = 0x20,
+ NODE_CLASS = 0x40,
+ NODE_INTERFACE = 0x80,
+ NODE_GLOBAL_VARIABLE = 0x100,
+ NODE_FIELD = 0x200,
+ NODE_FUNCTION = 0x400,
+ NODE_METHOD = 0x800,
- NODE_ENUM = 0x200,
- NODE_ENUM_CONSTANT = 0x400,
- NODE_TYPEDEF = 0x800,
- NODE_TEMPLATE_PARAMETER_TYPE = 0x1000,
+ NODE_ENUM = 0x1000,
+ NODE_ENUM_CONSTANT = 0x2000,
+ NODE_TYPEDEF = 0x4000,
+ NODE_TEMPLATE_PARAMETER_TYPE = 0x8000,
+ NODE_TYPE_PARAMETER = 0x10000,
- NODE_FILE = 0x2000,
- NODE_MACRO = 0x4000
+ NODE_FILE = 0x20000,
+ NODE_MACRO = 0x40000
};
static std::string getTypeString(NodeType type);
@@ -88,8 +93,6 @@ public:
void forEachChildNode(std::function func) const;
void forEachNodeRecursive(std::function func) const;
- bool hasReferences() const;
-
// Token implementation.
virtual bool isNode() const;
virtual bool isEdge() const;
@@ -100,6 +103,7 @@ public:
void addComponentStatic(std::shared_ptr component);
void addComponentFilePath(std::shared_ptr component);
void addComponentSignature(std::shared_ptr component);
+ void addComponentAccess(std::shared_ptr component);
// Logging.
virtual std::string getTypeString() const;
diff --git a/src/lib/data/graph/token_component/TokenComponentAccess.cpp b/src/lib/data/graph/token_component/TokenComponentAccess.cpp
index c6fcd1eb..b4196991 100644
--- a/src/lib/data/graph/token_component/TokenComponentAccess.cpp
+++ b/src/lib/data/graph/token_component/TokenComponentAccess.cpp
@@ -1,6 +1,6 @@
#include "data/graph/token_component/TokenComponentAccess.h"
-std::string TokenComponentAccess::getAccessString(AccessType access)
+std::string TokenComponentAccess::getAccessString(AccessKind access)
{
switch (access)
{
@@ -10,38 +10,18 @@ std::string TokenComponentAccess::getAccessString(AccessType access)
return "protected";
case ACCESS_PRIVATE:
return "private";
- case ACCESS_TEMPLATE:
+ case ACCESS_DEFAULT:
+ return "default";
+ case ACCESS_TEMPLATE_PARAMETER:
return "template parameter";
- case ACCESS_NONE:
- return "";
+ case ACCESS_TYPE_PARAMETER:
+ return "type parameter";
}
return "";
}
-int TokenComponentAccess::typeToInt(AccessType type)
-{
- return type;
-}
-TokenComponentAccess::AccessType TokenComponentAccess::intToType(int value)
-{
- switch (value)
- {
- case 0x1:
- return ACCESS_PUBLIC;
- case 0x2:
- return ACCESS_PROTECTED;
- case 0x4:
- return ACCESS_PRIVATE;
- case 0x8:
- return ACCESS_TEMPLATE;
- default:
- break;
- }
- return ACCESS_NONE;
-}
-
-TokenComponentAccess::TokenComponentAccess(AccessType access)
+TokenComponentAccess::TokenComponentAccess(AccessKind access)
: m_access(access)
{
}
@@ -55,7 +35,7 @@ std::shared_ptr TokenComponentAccess::copy() const
return std::make_shared(*this);
}
-TokenComponentAccess::AccessType TokenComponentAccess::getAccess() const
+AccessKind TokenComponentAccess::getAccess() const
{
return m_access;
}
diff --git a/src/lib/data/graph/token_component/TokenComponentAccess.h b/src/lib/data/graph/token_component/TokenComponentAccess.h
index 78a2747e..5bc4a523 100644
--- a/src/lib/data/graph/token_component/TokenComponentAccess.h
+++ b/src/lib/data/graph/token_component/TokenComponentAccess.h
@@ -4,35 +4,24 @@
#include
#include "data/graph/token_component/TokenComponent.h"
+#include "data/parser/AccessKind.h"
class TokenComponentAccess
: public TokenComponent
{
public:
- enum AccessType : int // todo: use normal numbers here. not 2^x
- {
- ACCESS_PUBLIC = 0x1,
- ACCESS_PROTECTED = 0x2,
- ACCESS_PRIVATE = 0x4,
- ACCESS_TEMPLATE = 0x8,
- ACCESS_NONE = 0x0
- };
+ static std::string getAccessString(AccessKind access);
- static std::string getAccessString(AccessType access);
-
- static int typeToInt(AccessType type);
- static AccessType intToType(int value);
-
- TokenComponentAccess(AccessType access);
+ TokenComponentAccess(AccessKind access);
virtual ~TokenComponentAccess();
virtual std::shared_ptr copy() const;
- AccessType getAccess() const;
+ AccessKind getAccess() const;
std::string getAccessString() const;
private:
- const AccessType m_access;
+ const AccessKind m_access;
};
#endif // TOKEN_COMPONENT_ACCESS_H
diff --git a/src/lib/data/name/NameElement.cpp b/src/lib/data/name/NameElement.cpp
index 9bddeac8..c5116654 100644
--- a/src/lib/data/name/NameElement.cpp
+++ b/src/lib/data/name/NameElement.cpp
@@ -38,7 +38,11 @@ std::string NameElement::Signature::qualifyName(const std::string& name) const
std::string qualifiedName = m_prefix;
if (name.size() > 0)
{
- qualifiedName += " " + name;
+ if (!m_prefix.empty())
+ {
+ qualifiedName += " ";
+ }
+ qualifiedName += name;
}
qualifiedName += m_postfix;
diff --git a/src/lib/data/name/NameHierarchy.cpp b/src/lib/data/name/NameHierarchy.cpp
index 9e97e49e..14b944d4 100644
--- a/src/lib/data/name/NameHierarchy.cpp
+++ b/src/lib/data/name/NameHierarchy.cpp
@@ -87,26 +87,26 @@ size_t NameHierarchy::size() const
return m_elements.size();
}
-std::string NameHierarchy::getQualifiedName() const
+std::string NameHierarchy::getQualifiedName(const std::string& delimiter) const
{
std::string name;
for (size_t i = 0; i < m_elements.size(); i++)
{
if (i > 0)
{
- name += "::";
+ name += delimiter;
}
name += m_elements[i]->getName();
}
return name;
}
-std::string NameHierarchy::getQualifiedNameWithSignature() const
+std::string NameHierarchy::getQualifiedNameWithSignature(const std::string& delimiter) const
{
- std::string name = getQualifiedName();
+ std::string name = getQualifiedName(delimiter);
if (m_elements.size())
{
- name = m_elements.back()->getSignature().qualifyName(name);
+ name = m_elements.back()->getSignature().qualifyName(name); // todo: use separator for signature!
}
return name;
}
diff --git a/src/lib/data/name/NameHierarchy.h b/src/lib/data/name/NameHierarchy.h
index e11172b9..78d7da95 100644
--- a/src/lib/data/name/NameHierarchy.h
+++ b/src/lib/data/name/NameHierarchy.h
@@ -24,8 +24,8 @@ public:
std::shared_ptr operator[](size_t pos) const;
size_t size() const;
- std::string getQualifiedName() const;
- std::string getQualifiedNameWithSignature() const;
+ std::string getQualifiedName(const std::string& delimiter = "::") const;
+ std::string getQualifiedNameWithSignature(const std::string& delimiter = "::") const;
std::string getRawName() const;
std::string getRawNameWithSignature() const;
diff --git a/src/lib/data/parser/AccessKind.cpp b/src/lib/data/parser/AccessKind.cpp
new file mode 100644
index 00000000..057a599e
--- /dev/null
+++ b/src/lib/data/parser/AccessKind.cpp
@@ -0,0 +1,27 @@
+#include "data/parser/AccessKind.h"
+
+AccessKind intToAccessKind(int v)
+{
+ switch (v)
+ {
+ case ACCESS_PUBLIC:
+ return ACCESS_PUBLIC;
+ case ACCESS_PROTECTED:
+ return ACCESS_PROTECTED;
+ case ACCESS_PRIVATE:
+ return ACCESS_PRIVATE;
+ case ACCESS_DEFAULT:
+ return ACCESS_DEFAULT;
+ case ACCESS_TEMPLATE_PARAMETER:
+ return ACCESS_TEMPLATE_PARAMETER;
+ case ACCESS_TYPE_PARAMETER:
+ return ACCESS_TYPE_PARAMETER;
+ }
+ return ACCESS_NONE;
+}
+
+int accessKindToInt(AccessKind t)
+{
+ return t;
+}
+
diff --git a/src/lib/data/parser/AccessKind.h b/src/lib/data/parser/AccessKind.h
new file mode 100644
index 00000000..e29be3d9
--- /dev/null
+++ b/src/lib/data/parser/AccessKind.h
@@ -0,0 +1,18 @@
+#ifndef ACCESS_KIND_H
+#define ACCESS_KIND_H
+
+enum AccessKind
+{ // these values need to be the same as AccessType in Java code
+ ACCESS_NONE = 0,
+ ACCESS_PUBLIC = 1,
+ ACCESS_PROTECTED = 2,
+ ACCESS_PRIVATE = 3,
+ ACCESS_DEFAULT = 4,
+ ACCESS_TEMPLATE_PARAMETER = 5,
+ ACCESS_TYPE_PARAMETER = 6
+};
+
+AccessKind intToAccessKind(int v);
+int accessKindToInt(AccessKind t);
+
+#endif // ACCESS_KIND_H
diff --git a/src/lib/data/parser/Parser.h b/src/lib/data/parser/Parser.h
index e1198503..e1a615d5 100644
--- a/src/lib/data/parser/Parser.h
+++ b/src/lib/data/parser/Parser.h
@@ -17,6 +17,8 @@ public:
{
Arguments();
+ std::vector javaClassPaths;
+
std::vector headerSearchPaths;
std::vector systemHeaderSearchPaths;
std::vector frameworkSearchPaths;
diff --git a/src/lib/data/parser/ParserClient.cpp b/src/lib/data/parser/ParserClient.cpp
index 134cf9d9..cba9cccb 100644
--- a/src/lib/data/parser/ParserClient.cpp
+++ b/src/lib/data/parser/ParserClient.cpp
@@ -6,7 +6,7 @@
#include "data/type/DataType.h"
#include "utility/utilityString.h"
-std::string ParserClient::addAccessPrefix(const std::string& str, AccessType access)
+std::string ParserClient::addAccessPrefix(const std::string& str, AccessKind access)
{
switch (access)
{
@@ -16,9 +16,10 @@ std::string ParserClient::addAccessPrefix(const std::string& str, AccessType acc
return "protected " + str;
case ACCESS_PRIVATE:
return "private " + str;
- case ACCESS_NONE:
- return str;
+ case ACCESS_DEFAULT:
+ return "default " + str;
}
+ return str;
}
std::string ParserClient::addAbstractionPrefix(const std::string& str, AbstractionType abstraction)
diff --git a/src/lib/data/parser/ParserClient.h b/src/lib/data/parser/ParserClient.h
index de458b2e..8623d104 100644
--- a/src/lib/data/parser/ParserClient.h
+++ b/src/lib/data/parser/ParserClient.h
@@ -5,7 +5,9 @@
#include
#include "data/name/NameHierarchy.h"
-#include "data/parser/SymbolType.h"
+#include "data/parser/AccessKind.h"
+#include "data/parser/ReferenceKind.h"
+#include "data/parser/SymbolKind.h"
#include "utility/file/FileInfo.h"
#include "utility/types.h"
@@ -15,20 +17,13 @@ class DataType;
class ParserClient
{
public:
- enum AccessType {
- ACCESS_PUBLIC,
- ACCESS_PROTECTED,
- ACCESS_PRIVATE,
- ACCESS_NONE
- };
-
enum AbstractionType {
ABSTRACTION_VIRTUAL,
ABSTRACTION_PURE_VIRTUAL,
ABSTRACTION_NONE
};
- static std::string addAccessPrefix(const std::string& str, AccessType access);
+ static std::string addAccessPrefix(const std::string& str, AccessKind access);
static std::string addAbstractionPrefix(const std::string& str, AbstractionType abstraction);
static std::string addStaticPrefix(const std::string& str, bool isStatic);
static std::string addConstPrefix(const std::string& str, bool isConst, bool atFront);
@@ -42,28 +37,46 @@ public:
virtual void startParsingFile() = 0;
virtual void finishParsingFile() = 0;
+ virtual Id recordSymbol(
+ const NameHierarchy& symbolName, SymbolKind symbolType,
+ AccessKind access = ACCESS_NONE, bool isImplicit = false) = 0;
+
+ virtual Id recordSymbol(
+ const NameHierarchy& symbolName, SymbolKind symbolType,
+ const ParseLocation& location,
+ AccessKind access = ACCESS_NONE, bool isImplicit = false) = 0;
+
+ virtual Id recordSymbol(
+ const NameHierarchy& symbolName, SymbolKind symbolType,
+ const ParseLocation& location, const ParseLocation& scopeLocation,
+ AccessKind access = ACCESS_NONE, bool isImplicit = false) = 0;
+
+ virtual void recordReference(
+ ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
+ const ParseLocation& location) = 0;
+
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed) = 0;
virtual void onTypedefParsed(
- const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit) = 0;
+ const ParseLocation& location, const NameHierarchy& typedefName, AccessKind access, bool isImplicit) = 0;
virtual void onClassParsed(
- const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
+ const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
const ParseLocation& scopeLocation, bool isImplicit) = 0;
virtual void onStructParsed(
- const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
+ const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
const ParseLocation& scopeLocation, bool isImplicit) = 0;
virtual void onGlobalVariableParsed(const ParseLocation& location, const NameHierarchy& variable, bool isImplicit) = 0;
- virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessType access, bool isImplicit) = 0;
+ virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessKind access, bool isImplicit) = 0;
virtual void onFunctionParsed(
const ParseLocation& location, const NameHierarchy& function, const ParseLocation& scopeLocation, bool isImplicit) = 0;
virtual void onMethodParsed(
- const ParseLocation& location, const NameHierarchy& method, AccessType access, AbstractionType abstraction,
+ const ParseLocation& location, const NameHierarchy& method, AccessKind access, AbstractionType abstraction,
const ParseLocation& scopeLocation, bool isImplicit) = 0;
virtual void onNamespaceParsed(
const ParseLocation& location, const NameHierarchy& nameHierarchy,
const ParseLocation& scopeLocation, bool isImplicit) = 0;
virtual void onEnumParsed(
- const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
+ const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
const ParseLocation& scopeLocation, bool isImplicit) = 0;
virtual void onEnumConstantParsed(const ParseLocation& location, const NameHierarchy& nameHierarchy, bool isImplicit) = 0;
virtual void onTemplateParameterTypeParsed(
@@ -76,13 +89,13 @@ public:
virtual void onInheritanceParsed(
const ParseLocation& location, const NameHierarchy& nameHierarchy,
- const NameHierarchy& baseNameHierarchy, AccessType access) = 0;
+ const NameHierarchy& baseNameHierarchy) = 0;
virtual void onMethodOverrideParsed(
const ParseLocation& location, const NameHierarchy& overridden, const NameHierarchy& overrider) = 0;
virtual void onCallParsed(
const ParseLocation& location, const NameHierarchy& caller, const NameHierarchy& callee) = 0;
virtual void onUsageParsed(
- const ParseLocation& location, const NameHierarchy& userName, SymbolType usedType, const NameHierarchy& usedName) = 0;
+ const ParseLocation& location, const NameHierarchy& userName, SymbolKind usedType, const NameHierarchy& usedName) = 0;
virtual void onTypeUsageParsed(const ParseLocation& location, const NameHierarchy& user, const NameHierarchy& used) = 0;
virtual void onTemplateArgumentTypeParsed(
diff --git a/src/lib/data/parser/ParserClientImpl.cpp b/src/lib/data/parser/ParserClientImpl.cpp
index 455a5e55..ddcdad22 100644
--- a/src/lib/data/parser/ParserClientImpl.cpp
+++ b/src/lib/data/parser/ParserClientImpl.cpp
@@ -27,13 +27,57 @@ void ParserClientImpl::resetStorage()
void ParserClientImpl::startParsingFile()
{
- m_nodeIdsToMemberEdgeIds.clear(); // remove this when one parserclient is created per file
}
void ParserClientImpl::finishParsingFile()
{
}
+
+Id ParserClientImpl::recordSymbol(
+ const NameHierarchy& symbolName, SymbolKind symbolType,
+ AccessKind access, bool isImplicit
+)
+{
+ Id nodeId = addNodeHierarchy(symbolKindToNodeType(symbolType), symbolName, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
+ addAccess(nodeId, access);
+ return nodeId;
+}
+
+Id ParserClientImpl::recordSymbol(
+ const NameHierarchy& symbolName, SymbolKind symbolType,
+ const ParseLocation& location,
+ AccessKind access, bool isImplicit
+)
+{
+ Id nodeId = recordSymbol(symbolName, symbolType, access, isImplicit);
+ addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
+ return nodeId;
+}
+
+Id ParserClientImpl::recordSymbol(
+ const NameHierarchy& symbolName, SymbolKind symbolType,
+ const ParseLocation& location, const ParseLocation& scopeLocation,
+ AccessKind access, bool isImplicit
+)
+{
+ Id nodeId = recordSymbol(symbolName, symbolType, location, access, isImplicit);
+ addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
+ return nodeId;
+}
+
+void ParserClientImpl::recordReference(
+ ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
+ const ParseLocation& location)
+{
+ Id contextNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, contextName, DEFINITION_NONE);
+ Id referencedNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, referencedName, DEFINITION_NONE);
+ Id edgeId = addEdge(referenceKindToEdgeType(referenceKind), contextNodeId, referencedNodeId);
+ addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
+}
+
+
+
void ParserClientImpl::onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
{
log(std::string(fatal ? "FATAL: " : "ERROR: "), message, location);
@@ -47,7 +91,7 @@ void ParserClientImpl::onError(const ParseLocation& location, const std::string&
}
void ParserClientImpl::onTypedefParsed(
- const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit)
+ const ParseLocation& location, const NameHierarchy& typedefName, AccessKind access, bool isImplicit)
{
log("typedef", typedefName.getQualifiedName(), location);
@@ -57,7 +101,7 @@ void ParserClientImpl::onTypedefParsed(
}
void ParserClientImpl::onClassParsed(
- const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
+ const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
const ParseLocation& scopeLocation, bool isImplicit)
{
log("class", nameHierarchy.getQualifiedName(), location);
@@ -73,7 +117,7 @@ void ParserClientImpl::onClassParsed(
}
void ParserClientImpl::onStructParsed(
- const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
+ const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
const ParseLocation& scopeLocation, bool isImplicit)
{
log("struct", nameHierarchy.getQualifiedName(), location);
@@ -96,7 +140,7 @@ void ParserClientImpl::onGlobalVariableParsed(const ParseLocation& location, con
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
}
-void ParserClientImpl::onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessType access, bool isImplicit)
+void ParserClientImpl::onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessKind access, bool isImplicit)
{
log("field", field.getQualifiedName(), location);
@@ -116,7 +160,7 @@ void ParserClientImpl::onFunctionParsed(
}
void ParserClientImpl::onMethodParsed(
- const ParseLocation& location, const NameHierarchy& method, AccessType access, AbstractionType abstraction,
+ const ParseLocation& location, const NameHierarchy& method, AccessKind access, AbstractionType abstraction, // todo: remove abstractio... better: remove this method!
const ParseLocation& scopeLocation, bool isImplicit)
{
log("method", method.getQualifiedNameWithSignature(), location);
@@ -142,7 +186,7 @@ void ParserClientImpl::onNamespaceParsed(
}
void ParserClientImpl::onEnumParsed(
- const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
+ const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
const ParseLocation& scopeLocation, bool isImplicit)
{
log("enum", nameHierarchy.getQualifiedName(), location);
@@ -168,7 +212,7 @@ void ParserClientImpl::onTemplateParameterTypeParsed(
Id nodeId = addNodeHierarchy(Node::NODE_TEMPLATE_PARAMETER_TYPE, templateParameterTypeNameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
- addAccess(nodeId, TokenComponentAccess::ACCESS_TEMPLATE);
+ addAccess(nodeId, ACCESS_TEMPLATE_PARAMETER);
}
void ParserClientImpl::onLocalSymbolParsed(const std::string& name, const ParseLocation& location)
@@ -214,7 +258,7 @@ void ParserClientImpl::onCommentParsed(const ParseLocation& location)
void ParserClientImpl::onInheritanceParsed(
const ParseLocation& location, const NameHierarchy& childNameHierarchy,
- const NameHierarchy& parentNameHierarchy, AccessType access)
+ const NameHierarchy& parentNameHierarchy)
{
log("inheritance", childNameHierarchy.getQualifiedName() + " : " + parentNameHierarchy.getQualifiedName(), location);
@@ -246,12 +290,12 @@ void ParserClientImpl::onCallParsed(const ParseLocation& location, const NameHie
}
void ParserClientImpl::onUsageParsed(
- const ParseLocation& location, const NameHierarchy& userName, SymbolType usedType, const NameHierarchy& usedName)
+ const ParseLocation& location, const NameHierarchy& userName, SymbolKind usedType, const NameHierarchy& usedName)
{
log("usage", userName.getQualifiedNameWithSignature() + " -> " + usedName.getQualifiedName(), location);
Id userNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, userName, DEFINITION_NONE);
- Id usedNodeId = addNodeHierarchy(symbolTypeToNodeType(usedType), usedName, DEFINITION_NONE);
+ Id usedNodeId = addNodeHierarchy(symbolKindToNodeType(usedType), usedName, DEFINITION_NONE);
Id edgeId = addEdge(Edge::EDGE_USAGE, userNodeId, usedNodeId);
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
}
@@ -354,10 +398,12 @@ void ParserClientImpl::onMacroExpandParsed(const ParseLocation &location, const
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
}
-Node::NodeType ParserClientImpl::symbolTypeToNodeType(SymbolType symbolType) const
+Node::NodeType ParserClientImpl::symbolKindToNodeType(SymbolKind symbolType) const
{
switch (symbolType)
{
+ case SYMBOL_BUILTIN_TYPE:
+ return Node::NODE_BUILTIN_TYPE;
case SYMBOL_CLASS:
return Node::NODE_CLASS;
case SYMBOL_ENUM:
@@ -370,18 +416,24 @@ Node::NodeType ParserClientImpl::symbolTypeToNodeType(SymbolType symbolType) con
return Node::NODE_FUNCTION;
case SYMBOL_GLOBAL_VARIABLE:
return Node::NODE_GLOBAL_VARIABLE;
+ case SYMBOL_INTERFACE:
+ return Node::NODE_INTERFACE;
case SYMBOL_MACRO:
return Node::NODE_MACRO;
case SYMBOL_METHOD:
return Node::NODE_METHOD;
case SYMBOL_NAMESPACE:
return Node::NODE_NAMESPACE;
+ case SYMBOL_PACKAGE:
+ return Node::NODE_PACKAGE;
case SYMBOL_STRUCT:
return Node::NODE_STRUCT;
- case SYMBOL_TYPEDEF:
- return Node::NODE_TYPEDEF;
case SYMBOL_TEMPLATE_PARAMETER:
return Node::NODE_TEMPLATE_PARAMETER_TYPE;
+ case SYMBOL_TYPEDEF:
+ return Node::NODE_TYPEDEF;
+ case SYMBOL_TYPE_PARAMETER:
+ return Node::NODE_TYPE_PARAMETER;
case SYMBOL_UNION:
return Node::NODE_TYPE;
default:
@@ -390,34 +442,48 @@ Node::NodeType ParserClientImpl::symbolTypeToNodeType(SymbolType symbolType) con
return Node::NODE_UNDEFINED;
}
-TokenComponentAccess::AccessType ParserClientImpl::convertAccessType(ParserClient::AccessType access) const
+Edge::EdgeType ParserClientImpl::referenceKindToEdgeType(ReferenceKind referenceKind) const
{
- switch (access)
+ switch (referenceKind)
{
- case ACCESS_PUBLIC:
- return TokenComponentAccess::ACCESS_PUBLIC;
- case ACCESS_PROTECTED:
- return TokenComponentAccess::ACCESS_PROTECTED;
- case ACCESS_PRIVATE:
- return TokenComponentAccess::ACCESS_PRIVATE;
- case ACCESS_NONE:
- return TokenComponentAccess::ACCESS_NONE;
+ case REFERENCE_TYPE_USAGE:
+ return Edge::EDGE_TYPE_USAGE;
+ case REFERENCE_USAGE:
+ return Edge::EDGE_USAGE;
+ case REFERENCE_CALL:
+ return Edge::EDGE_CALL;
+ case REFERENCE_INHERITANCE:
+ return Edge::EDGE_INHERITANCE;
+ case REFERENCE_OVERRIDE:
+ return Edge::EDGE_OVERRIDE;
+ case REFERENCE_TEMPLATE_ARGUMENT:
+ return Edge::EDGE_TEMPLATE_ARGUMENT;
+ case REFERENCE_TYPE_ARGUMENT:
+ return Edge::EDGE_TYPE_ARGUMENT;
+ case REFERENCE_TEMPLATE_DEFAULT_ARGUMENT:
+ return Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT;
+ case REFERENCE_TEMPLATE_SPECIALIZATION_OF:
+ return Edge::EDGE_TEMPLATE_SPECIALIZATION_OF;
+ case REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF:
+ return Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF;
+ case REFERENCE_INCLUDE:
+ return Edge::EDGE_INCLUDE;
+ case REFERENCE_IMPORT:
+ return Edge::EDGE_IMPORT;
+ case REFERENCE_MACRO_USAGE:
+ return Edge::EDGE_MACRO_USAGE;
+ default:
+ break;
}
+ return Edge::EDGE_UNDEFINED;
}
-void ParserClientImpl::addAccess(Id nodeId, ParserClient::AccessType access)
+void ParserClientImpl::addAccess(Id nodeId, AccessKind access)
{
- addAccess(nodeId, convertAccessType(access));
-}
-
-void ParserClientImpl::addAccess(Id nodeId, TokenComponentAccess::AccessType access)
-{
- if (access == TokenComponentAccess::ACCESS_NONE)
+ if (access != ACCESS_NONE)
{
- return;
+ addComponentAccess(nodeId, accessKindToInt(access));
}
-
- addComponentAccess(nodeId, access);
}
Id ParserClientImpl::addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, DefinitionType definitionType)
@@ -493,14 +559,7 @@ Id ParserClientImpl::addEdge(int type, Id sourceId, Id targetId)
return 0;
}
- Id edgeId = m_storage->addEdge(type, sourceId, targetId);
-
- if (type == Edge::EDGE_MEMBER)
- {
- m_nodeIdsToMemberEdgeIds[targetId] = edgeId;
- }
-
- return edgeId;
+ return m_storage->addEdge(type, sourceId, targetId);
}
Id ParserClientImpl::addLocalSymbol(const std::string& name)
@@ -549,15 +608,7 @@ void ParserClientImpl::addComponentAccess(Id nodeId , int type)
return;
}
- std::unordered_map::const_iterator it = m_nodeIdsToMemberEdgeIds.find(nodeId);
- if (it != m_nodeIdsToMemberEdgeIds.end())
- {
- m_storage->addComponentAccess(it->second, type);
- }
- else
- {
- LOG_ERROR_STREAM(<< "Cannot assign access" << type << " to node id " << nodeId << " because it's not a child node.");
- }
+ m_storage->addComponentAccess(nodeId, type);
}
void ParserClientImpl::addCommentLocation(const ParseLocation& location)
diff --git a/src/lib/data/parser/ParserClientImpl.h b/src/lib/data/parser/ParserClientImpl.h
index b587de18..6542e51f 100644
--- a/src/lib/data/parser/ParserClientImpl.h
+++ b/src/lib/data/parser/ParserClientImpl.h
@@ -1,6 +1,8 @@
#ifndef PARSER_CLIENT_IMPL_H
#define PARSER_CLIENT_IMPL_H
+#include
+
#include "data/graph/Node.h"
#include "data/parser/ParserClient.h"
#include "data/IntermediateStorage.h"
@@ -21,28 +23,47 @@ public:
virtual void startParsingFile();
virtual void finishParsingFile();
+
+ virtual Id recordSymbol(
+ const NameHierarchy& symbolName, SymbolKind symbolType,
+ AccessKind access = ACCESS_NONE, bool isImplicit = false);
+
+ virtual Id recordSymbol(
+ const NameHierarchy& symbolName, SymbolKind symbolType,
+ const ParseLocation& location,
+ AccessKind access = ACCESS_NONE, bool isImplicit = false);
+
+ virtual Id recordSymbol(
+ const NameHierarchy& symbolName, SymbolKind symbolType,
+ const ParseLocation& location, const ParseLocation& scopeLocation,
+ AccessKind access = ACCESS_NONE, bool isImplicit = false);
+
+ virtual void recordReference(
+ ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
+ const ParseLocation& location);
+
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed);
virtual void onTypedefParsed(
- const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit);
+ const ParseLocation& location, const NameHierarchy& typedefName, AccessKind access, bool isImplicit);
virtual void onClassParsed(
- const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
+ const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
const ParseLocation& scopeLocation, bool isImplicit);
virtual void onStructParsed(
- const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
+ const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
const ParseLocation& scopeLocation, bool isImplicit);
virtual void onGlobalVariableParsed(const ParseLocation& location, const NameHierarchy& variable, bool isImplicit);
- virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessType access, bool isImplicit);
+ virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessKind access, bool isImplicit);
virtual void onFunctionParsed(
const ParseLocation& location, const NameHierarchy& function, const ParseLocation& scopeLocation, bool isImplicit);
virtual void onMethodParsed(
- const ParseLocation& location, const NameHierarchy& method, AccessType access, AbstractionType abstraction,
+ const ParseLocation& location, const NameHierarchy& method, AccessKind access, AbstractionType abstraction,
const ParseLocation& scopeLocation, bool isImplicit);
virtual void onNamespaceParsed(
const ParseLocation& location, const NameHierarchy& nameHierarchy,
const ParseLocation& scopeLocation, bool isImplicit);
virtual void onEnumParsed(
- const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
+ const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
const ParseLocation& scopeLocation, bool isImplicit);
virtual void onEnumConstantParsed(const ParseLocation& location, const NameHierarchy& nameHierarchy, bool isImplicit);
virtual void onTemplateParameterTypeParsed(
@@ -55,13 +76,13 @@ public:
virtual void onInheritanceParsed(
const ParseLocation& location, const NameHierarchy& nameHierarchy,
- const NameHierarchy& baseNameHierarchy, AccessType access);
+ const NameHierarchy& baseNameHierarchy);
virtual void onMethodOverrideParsed(
const ParseLocation& location, const NameHierarchy& overridden, const NameHierarchy& overrider);
virtual void onCallParsed(
const ParseLocation& location, const NameHierarchy& caller, const NameHierarchy& callee);
virtual void onUsageParsed(
- const ParseLocation& location, const NameHierarchy& userName, SymbolType usedType, const NameHierarchy& usedName);
+ const ParseLocation& location, const NameHierarchy& userName, SymbolKind usedType, const NameHierarchy& usedName);
virtual void onTypeUsageParsed(const ParseLocation& location, const NameHierarchy& user, const NameHierarchy& used);
virtual void onTemplateArgumentTypeParsed(
@@ -83,10 +104,9 @@ public:
const ParseLocation& location, const NameHierarchy& macroNameHierarchy);
private:
- Node::NodeType symbolTypeToNodeType(SymbolType symbolType) const;
- TokenComponentAccess::AccessType convertAccessType(ParserClient::AccessType access) const;
- void addAccess(Id nodeId, ParserClient::AccessType access);
- void addAccess(Id nodeId, TokenComponentAccess::AccessType access);
+ Node::NodeType symbolKindToNodeType(SymbolKind symbolType) const;
+ Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const;
+ void addAccess(Id nodeId, AccessKind access);
Id addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, DefinitionType definitionType);
Id addFile(const std::string& name, const std::string& filePath, const std::string& modificationTime);
@@ -102,7 +122,6 @@ private:
void log(std::string type, std::string str, const ParseLocation& location) const;
std::shared_ptr m_storage;
- std::unordered_map m_nodeIdsToMemberEdgeIds;
};
#endif // PARSER_CLIENT_IMPL_H
diff --git a/src/lib/data/parser/ReferenceKind.cpp b/src/lib/data/parser/ReferenceKind.cpp
new file mode 100644
index 00000000..4ab8f8a0
--- /dev/null
+++ b/src/lib/data/parser/ReferenceKind.cpp
@@ -0,0 +1,40 @@
+#include "data/parser/ReferenceKind.h"
+
+ReferenceKind intToReferenceKind(int v)
+{
+ switch (v)
+ {
+ case REFERENCE_TYPE_USAGE:
+ return REFERENCE_TYPE_USAGE;
+ case REFERENCE_USAGE:
+ return REFERENCE_USAGE;
+ case REFERENCE_CALL:
+ return REFERENCE_CALL;
+ case REFERENCE_INHERITANCE:
+ return REFERENCE_INHERITANCE;
+ case REFERENCE_OVERRIDE:
+ return REFERENCE_OVERRIDE;
+ case REFERENCE_TEMPLATE_ARGUMENT:
+ return REFERENCE_TEMPLATE_ARGUMENT;
+ case REFERENCE_TYPE_ARGUMENT:
+ return REFERENCE_TYPE_ARGUMENT;
+ case REFERENCE_TEMPLATE_DEFAULT_ARGUMENT:
+ return REFERENCE_TEMPLATE_DEFAULT_ARGUMENT;
+ case REFERENCE_TEMPLATE_SPECIALIZATION_OF:
+ return REFERENCE_TEMPLATE_SPECIALIZATION_OF;
+ case REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF:
+ return REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF;
+ case REFERENCE_INCLUDE:
+ return REFERENCE_INCLUDE;
+ case REFERENCE_IMPORT:
+ return REFERENCE_IMPORT;
+ case REFERENCE_MACRO_USAGE:
+ return REFERENCE_MACRO_USAGE;
+ }
+ return REFERENCE_UNDEFINED;
+}
+
+int referenceKindToInt(ReferenceKind t)
+{
+ return t;
+}
diff --git a/src/lib/data/parser/ReferenceKind.h b/src/lib/data/parser/ReferenceKind.h
new file mode 100644
index 00000000..5c8965bc
--- /dev/null
+++ b/src/lib/data/parser/ReferenceKind.h
@@ -0,0 +1,25 @@
+#ifndef REFERENCE_KIND_H
+#define REFERENCE_KIND_H
+
+enum ReferenceKind
+{ // these values need to be the same as ReferenceKind in Java code
+ REFERENCE_UNDEFINED = 0,
+ REFERENCE_TYPE_USAGE = 1,
+ REFERENCE_USAGE = 2,
+ REFERENCE_CALL = 3,
+ REFERENCE_INHERITANCE = 4,
+ REFERENCE_OVERRIDE = 5,
+ REFERENCE_TEMPLATE_ARGUMENT = 6,
+ REFERENCE_TYPE_ARGUMENT = 7,
+ REFERENCE_TEMPLATE_DEFAULT_ARGUMENT = 8,
+ REFERENCE_TEMPLATE_SPECIALIZATION_OF = 9,
+ REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF = 10,
+ REFERENCE_INCLUDE = 11,
+ REFERENCE_IMPORT = 12,
+ REFERENCE_MACRO_USAGE = 13
+};
+
+ReferenceKind intToReferenceKind(int v);
+int referenceKindToInt(ReferenceKind t);
+
+#endif // REFERENCE_KIND_H
diff --git a/src/lib/data/parser/SymbolKind.cpp b/src/lib/data/parser/SymbolKind.cpp
new file mode 100644
index 00000000..7c0edcf4
--- /dev/null
+++ b/src/lib/data/parser/SymbolKind.cpp
@@ -0,0 +1,53 @@
+#include "data/parser/SymbolKind.h"
+
+SymbolKind intToSymbolKind(int v)
+{
+ switch (v)
+ {
+ case SYMBOL_BUILTIN_TYPE:
+ return SYMBOL_BUILTIN_TYPE;
+ case SYMBOL_CLASS:
+ return SYMBOL_CLASS;
+ case SYMBOL_ENUM:
+ return SYMBOL_ENUM;
+ case SYMBOL_ENUM_CONSTANT:
+ return SYMBOL_ENUM_CONSTANT;
+ case SYMBOL_FIELD:
+ return SYMBOL_FIELD;
+ case SYMBOL_FUNCTION:
+ return SYMBOL_FUNCTION;
+ case SYMBOL_GLOBAL_VARIABLE:
+ return SYMBOL_GLOBAL_VARIABLE;
+ case SYMBOL_INTERFACE:
+ return SYMBOL_INTERFACE;
+ case SYMBOL_LOCAL_VARIABLE:
+ return SYMBOL_LOCAL_VARIABLE;
+ case SYMBOL_MACRO:
+ return SYMBOL_MACRO;
+ case SYMBOL_METHOD:
+ return SYMBOL_METHOD;
+ case SYMBOL_NAMESPACE:
+ return SYMBOL_NAMESPACE;
+ case SYMBOL_PACKAGE:
+ return SYMBOL_PACKAGE;
+ case SYMBOL_PARAMETER:
+ return SYMBOL_PARAMETER;
+ case SYMBOL_STRUCT:
+ return SYMBOL_STRUCT;
+ case SYMBOL_TEMPLATE_PARAMETER:
+ return SYMBOL_TEMPLATE_PARAMETER;
+ case SYMBOL_TYPEDEF:
+ return SYMBOL_TYPEDEF;
+ case SYMBOL_TYPE_PARAMETER:
+ return SYMBOL_TYPE_PARAMETER;
+ case SYMBOL_UNION:
+ return SYMBOL_UNION;
+ }
+ return SYMBOL_KIND_MAX;
+}
+
+int symbolKindToInt(SymbolKind t)
+{
+ return t;
+}
+
diff --git a/src/lib/data/parser/SymbolKind.h b/src/lib/data/parser/SymbolKind.h
new file mode 100644
index 00000000..d475e2eb
--- /dev/null
+++ b/src/lib/data/parser/SymbolKind.h
@@ -0,0 +1,31 @@
+#ifndef SYMBOL_KIND_H
+#define SYMBOL_KIND_H
+
+enum SymbolKind
+{ // these values need to be the same as SymbolType in Java code
+ SYMBOL_BUILTIN_TYPE = 1,
+ SYMBOL_CLASS = 2,
+ SYMBOL_ENUM = 3,
+ SYMBOL_ENUM_CONSTANT = 4,
+ SYMBOL_FIELD = 5,
+ SYMBOL_FUNCTION = 6,
+ SYMBOL_GLOBAL_VARIABLE = 7,
+ SYMBOL_INTERFACE = 8,
+ SYMBOL_LOCAL_VARIABLE = 9,
+ SYMBOL_MACRO = 10,
+ SYMBOL_METHOD = 11,
+ SYMBOL_NAMESPACE = 12,
+ SYMBOL_PACKAGE = 13,
+ SYMBOL_PARAMETER = 14,
+ SYMBOL_STRUCT = 15,
+ SYMBOL_TEMPLATE_PARAMETER = 16,
+ SYMBOL_TYPEDEF = 17,
+ SYMBOL_TYPE_PARAMETER = 18,
+ SYMBOL_UNION = 19,
+ SYMBOL_KIND_MAX = 20
+};
+
+SymbolKind intToSymbolKind(int v);
+int symbolKindToInt(SymbolKind t);
+
+#endif // SYMBOL_KIND_H
diff --git a/src/lib/data/parser/SymbolType.h b/src/lib/data/parser/SymbolType.h
deleted file mode 100644
index 66b1bd70..00000000
--- a/src/lib/data/parser/SymbolType.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef SYMBOL_TYPE_H
-#define SYMBOL_TYPE_H
-
-enum SymbolType
-{
- SYMBOL_CLASS,
- SYMBOL_ENUM,
- SYMBOL_ENUM_CONSTANT,
- SYMBOL_FIELD,
- SYMBOL_FUNCTION,
- SYMBOL_GLOBAL_VARIABLE,
- SYMBOL_LOCAL_VARIABLE,
- SYMBOL_MACRO,
- SYMBOL_METHOD,
- SYMBOL_NAMESPACE,
- SYMBOL_PARAMETER,
- SYMBOL_STRUCT,
- SYMBOL_TYPEDEF,
- SYMBOL_TEMPLATE_PARAMETER,
- SYMBOL_UNION,
- SYMBOL_TYPE_MAX
-};
-
-#endif // SYMBOL_TYPE_H
diff --git a/src/lib/data/parser/cxx/TaskParseWrapper.h b/src/lib/data/parser/cxx/TaskParseWrapper.h
index a31ebff2..e1b4eb4a 100644
--- a/src/lib/data/parser/cxx/TaskParseWrapper.h
+++ b/src/lib/data/parser/cxx/TaskParseWrapper.h
@@ -5,22 +5,21 @@
#include "data/parser/Parser.h"
#include "data/parser/ParserClientImpl.h"
-#include "utility/scheduling/Task.h"
+#include "utility/scheduling/TaskDecorator.h"
#include "utility/TimePoint.h"
class PersistentStorage;
class FileRegister;
-class CxxParser;
class TaskParseWrapper
- : public Task
+ : public TaskDecorator
{
public:
TaskParseWrapper(
- std::shared_ptr child,
PersistentStorage* storage,
std::shared_ptr fileRegister
);
+ virtual ~TaskParseWrapper();
virtual void enter();
virtual TaskState update();
@@ -30,10 +29,8 @@ public:
virtual void revert();
private:
- std::shared_ptr m_child;
PersistentStorage* m_storage;
std::shared_ptr m_fileRegister;
-
TimePoint m_start;
};
diff --git a/src/lib/data/parser/java/JavaEnvironment.cpp b/src/lib/data/parser/java/JavaEnvironment.cpp
new file mode 100644
index 00000000..21c886c1
--- /dev/null
+++ b/src/lib/data/parser/java/JavaEnvironment.cpp
@@ -0,0 +1,92 @@
+#include "data/parser/java/JavaEnvironment.h"
+
+#include
+
+#include "utility/logging/logging.h"
+#include "data/parser/java/JavaEnvironmentFactory.h"
+
+JavaEnvironment::~JavaEnvironment()
+{
+ JavaEnvironmentFactory::getInstance()->unregisterEnvironment();
+}
+
+bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4)
+{
+ jclass javaClass = m_env->FindClass(className.c_str());
+ if(javaClass == nullptr)
+ {
+ LOG_ERROR("class " + className + " not found in JVM environment");
+ jthrowable exc = m_env->ExceptionOccurred();
+ if(exc)
+ {
+ m_env->ExceptionDescribe();
+ m_env->ExceptionClear();
+ }
+ }
+ else
+ {
+ jmethodID javaMethodId = m_env->GetStaticMethodID(javaClass, methodName.c_str(), "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
+ if(javaMethodId == nullptr)
+ {
+ LOG_ERROR("method void " + methodName + "(int, String, String, String) not found in JVM environment");
+ }
+ else
+ {
+ jint jarg1 = arg1;
+ jstring jarg2 = m_env->NewStringUTF(arg2.c_str());
+ jstring jarg3 = m_env->NewStringUTF(arg3.c_str());
+ jstring jarg4 = m_env->NewStringUTF(arg4.c_str());
+ m_env->CallStaticVoidMethod(javaClass, javaMethodId, jarg1, jarg2, jarg3, jarg4);
+ return true;
+ }
+ }
+ return false;
+}
+
+std::string JavaEnvironment::toStdString(jstring s)
+{
+ const char *nativeString = m_env->GetStringUTFChars(s, 0);
+ std::string ret = nativeString;
+ m_env->ReleaseStringUTFChars(s, nativeString);
+ return ret;
+}
+
+jstring JavaEnvironment::toJString(std::string s)
+{
+ return m_env->NewStringUTF(s.c_str());
+}
+
+JavaEnvironment::JavaEnvironment(JavaVM* jvm, JNIEnv* env)
+ : m_jvm(jvm)
+ , m_env(env)
+{
+ JavaEnvironmentFactory::getInstance()->registerEnvironment();
+}
+
+void JavaEnvironment::registerNativeMethods(std::string className, std::vector methods)
+{
+ JNINativeMethod* jniMethods = new JNINativeMethod[methods.size()];
+
+ for (int i = 0; i < methods.size(); i++)
+ {
+ jniMethods[i].name = const_cast(methods[i].name.c_str());
+ jniMethods[i].signature = const_cast(methods[i].signature.c_str());
+ jniMethods[i].fnPtr = methods[i].function;
+ }
+
+ jclass javaClass = m_env->FindClass(className.c_str());
+ if (javaClass)
+ {
+ if (m_env->RegisterNatives(javaClass, jniMethods, methods.size()) < 0)
+ {
+ LOG_ERROR("RegisterNatives failed");
+ }
+ }
+ else
+ {
+ LOG_ERROR("class \"" + className + "\" not found while registering native methods");
+ }
+
+ delete [] jniMethods;
+}
+
diff --git a/src/lib/data/parser/java/JavaEnvironment.h b/src/lib/data/parser/java/JavaEnvironment.h
new file mode 100644
index 00000000..4613073f
--- /dev/null
+++ b/src/lib/data/parser/java/JavaEnvironment.h
@@ -0,0 +1,44 @@
+#ifndef JAVA_ENVIRONMENT_H
+#define JAVA_ENVIRONMENT_H
+
+#include
+#include
+
+struct JavaVM_;
+typedef JavaVM_ JavaVM;
+
+struct JNIEnv_;
+typedef JNIEnv_ JNIEnv;
+
+class _jstring;
+typedef _jstring *jstring;
+
+class JavaEnvironmentFactory;
+
+class JavaEnvironment
+{
+public:
+ struct NativeMethod
+ {
+ std::string name;
+ std::string signature;
+ void *function;
+ };
+
+ ~JavaEnvironment();
+ bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4);
+
+ std::string toStdString(jstring s);
+ jstring toJString(std::string s);
+
+ void registerNativeMethods(std::string className, std::vector methods);
+private:
+ friend class JavaEnvironmentFactory;
+
+ JavaEnvironment(JavaVM* jvm, JNIEnv* env);
+
+ JavaVM* m_jvm;
+ JNIEnv* m_env;
+};
+
+#endif // JAVA_ENVIRONMENT_H
diff --git a/src/lib/data/parser/java/JavaEnvironmentFactory.cpp b/src/lib/data/parser/java/JavaEnvironmentFactory.cpp
new file mode 100644
index 00000000..be6748ae
--- /dev/null
+++ b/src/lib/data/parser/java/JavaEnvironmentFactory.cpp
@@ -0,0 +1,170 @@
+#include "data/parser/java/JavaEnvironmentFactory.h"
+
+#include
+
+#include "data/parser/java/JavaEnvironment.h"
+#include "settings/ApplicationSettings.h"
+#include "utility/logging/logging.h"
+
+void JavaEnvironmentFactory::createInstance(std::string classPath)
+{
+ if (s_instance)
+ {
+ if (classPath == s_classPath)
+ {
+ return;
+ }
+ else
+ {
+ LOG_ERROR("java classpath cannot be changed!");
+ // todo: implement destroying the old factory instance and create a new one.
+ return;
+ }
+ }
+
+ s_classPath = classPath;
+
+#ifdef _WIN32
+ { // todo: make this windows only
+ std::string env1 = getenv("path");
+
+ std::string javapath = ApplicationSettings::getInstance()->getJavaPath() + "/client/";
+ putenv(("path=" + env1 + ";" + javapath).c_str()); // path env is only modified in the scope of this process.
+ }
+#endif
+ using namespace std;
+
+ JavaVM* jvm; // Pointer to the JVM (Java Virtual Machine)
+ JNIEnv* env; // Pointer to native interface
+
+ JavaVMInitArgs vm_args; // Initialization arguments
+ JavaVMOption* options = new JavaVMOption[3]; // JVM invocation options
+ std::string classPathOption = "-Djava.class.path=" + classPath;
+ options[0].optionString = const_cast(classPathOption.c_str());
+ options[1].optionString = "-Xms1m";
+ std::string maximumMemoryOprionString = "-Xmx" + std::to_string(ApplicationSettings::getInstance()->getJavaMaximumMemory()) + "m";
+ options[2].optionString = const_cast(maximumMemoryOprionString.c_str());
+// options[3].optionString = "-verbose:jni";
+ vm_args.version = JNI_VERSION_1_6; // minimum Java version
+ vm_args.nOptions = 3; // number of options
+ vm_args.options = options;
+ vm_args.ignoreUnrecognized = false; // invalid options make the JVM init fail
+
+ jint rc = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); // YES !!
+
+ delete options;
+
+ if(rc != JNI_OK)
+ {
+ if(rc == JNI_EVERSION)
+ {
+ LOG_ERROR("JVM is oudated and doesn't meet requirements");
+ }
+ else if(rc == JNI_ENOMEM)
+ {
+ LOG_ERROR("not enough memory for JVM");
+ }
+ else if(rc == JNI_EINVAL)
+ {
+ LOG_ERROR("invalid ragument for launching JVM");
+ }
+ else if(rc == JNI_EEXIST)
+ {
+ LOG_ERROR("the process can only launch one JVM an not more");
+ }
+ else
+ {
+ LOG_ERROR_STREAM(<< "could not create the JVM instance (error code " << rc << ")");
+ }
+ }
+ else
+ {
+ jvm->DetachCurrentThread();
+ s_instance = std::shared_ptr(new JavaEnvironmentFactory(jvm));
+ }
+}
+
+std::shared_ptr JavaEnvironmentFactory::getInstance()
+{
+ return s_instance;
+}
+
+JavaEnvironmentFactory::~JavaEnvironmentFactory()
+{
+// todo: what if there are threads running using the jvm?? log something!
+ m_jvm->DestroyJavaVM();
+}
+
+std::shared_ptr JavaEnvironmentFactory::createEnvironment()
+{
+ std::thread::id currentThreadId = std::this_thread::get_id();
+
+ JNIEnv* env;
+
+ {
+ std::lock_guard lock(m_threadIdToEnvAndUserCountMutex);
+
+ std::map>::const_iterator it = m_threadIdToEnvAndUserCount.find(currentThreadId);
+ if (it != m_threadIdToEnvAndUserCount.end())
+ {
+ env = it->second.first;
+ }
+ else
+ {
+ m_jvm->AttachCurrentThread((void**)&env, NULL);
+ m_threadIdToEnvAndUserCount.insert(std::make_pair(currentThreadId, std::make_pair(env, 0)));
+ }
+ }
+
+ return std::shared_ptr(new JavaEnvironment(m_jvm, env));
+}
+
+std::shared_ptr JavaEnvironmentFactory::s_instance;
+
+std::string JavaEnvironmentFactory::s_classPath;
+
+JavaEnvironmentFactory::JavaEnvironmentFactory(JavaVM* jvm)
+ : m_jvm(jvm)
+{
+}
+
+void JavaEnvironmentFactory::registerEnvironment()
+{
+ std::thread::id currentThreadId = std::this_thread::get_id();
+ {
+ std::lock_guard lock(m_threadIdToEnvAndUserCountMutex);
+ std::map>::iterator it = m_threadIdToEnvAndUserCount.find(currentThreadId);
+ if (it != m_threadIdToEnvAndUserCount.end())
+ {
+ it->second.second++;
+ }
+ else
+ {
+ LOG_ERROR("something went horribly wrong while registering a java environment");
+ }
+ }
+}
+
+void JavaEnvironmentFactory::unregisterEnvironment()
+{
+ std::thread::id currentThreadId = std::this_thread::get_id();
+ {
+ std::lock_guard lock(m_threadIdToEnvAndUserCountMutex);
+ std::map>::iterator it = m_threadIdToEnvAndUserCount.find(currentThreadId);
+ if (it != m_threadIdToEnvAndUserCount.end())
+ {
+ it->second.second--;
+ if (it->second.second == 0)
+ { // TODO: currently this happens quite often. do something about that.
+ m_jvm->DetachCurrentThread();
+ m_threadIdToEnvAndUserCount.erase(it);
+ }
+ }
+ else
+ {
+ LOG_ERROR("something went horribly wrong while unregistering a java environment");
+ }
+ }
+}
+
+
diff --git a/src/lib/data/parser/java/JavaEnvironmentFactory.h b/src/lib/data/parser/java/JavaEnvironmentFactory.h
new file mode 100644
index 00000000..36345c01
--- /dev/null
+++ b/src/lib/data/parser/java/JavaEnvironmentFactory.h
@@ -0,0 +1,44 @@
+#ifndef JAVA_ENVIRONMENT_FACTORY_H
+#define JAVA_ENVIRONMENT_FACTORY_H
+
+#include