src: added optional indexer AST logging
* removed old AstVisitor * added new implementation called CxxAstVisitor * added CxxVerboseAstVisitor that may wrap the CxxAstVisitor to log the AST while visiting * added the same structure for the Java visitors * removed all the logs that were fired when recording stuff * Added UI setting for verbose indexer logging. * implemented AST name obfuscation for Java and Cxx * unified test visitors for Java and Cxx * implemented recording using directive decl * removed most of the old onXxxParsed methods
This commit is contained in:
@@ -10,17 +10,18 @@ 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)
|
||||
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5)
|
||||
{
|
||||
jclass javaClass = getJavaClass(className);
|
||||
jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");
|
||||
if(javaMethodId != nullptr)
|
||||
{
|
||||
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);
|
||||
jint jarg5 = arg5;
|
||||
m_env->CallStaticVoidMethod(javaClass, javaMethodId, jarg1, jarg2, jarg3, jarg4, jarg5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
};
|
||||
|
||||
~JavaEnvironment();
|
||||
bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4);
|
||||
bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5);
|
||||
bool callStaticMethod(std::string className, std::string methodName, std::string& ret, std::string arg1);
|
||||
|
||||
std::string toStdString(jstring s);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ReferenceKind.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utilityString.h"
|
||||
@@ -22,9 +23,12 @@ JavaParser::JavaParser(ParserClient* client)
|
||||
|
||||
std::vector<JavaEnvironment::NativeMethod> methods;
|
||||
|
||||
methods.push_back({"recordSymbol", "(ILjava/lang/String;IIIIIII)V", (void*)&JavaParser::RecordSymbol});
|
||||
methods.push_back({"recordSymbolWithoutLocation", "(ILjava/lang/String;III)V", (void*)&JavaParser::RecordSymbolWithoutLocation});
|
||||
methods.push_back({"recordSymbolWithScope", "(ILjava/lang/String;IIIIIIIIIII)V", (void*)&JavaParser::RecordSymbolWithScope});
|
||||
methods.push_back({"logInfo", "(ILjava/lang/String;)V", (void*)&JavaParser::LogInfo});
|
||||
methods.push_back({"logWarning", "(ILjava/lang/String;)V", (void*)&JavaParser::LogWarning});
|
||||
methods.push_back({"logError", "(ILjava/lang/String;)V", (void*)&JavaParser::LogError});
|
||||
methods.push_back({"recordSymbol", "(ILjava/lang/String;III)V", (void*)&JavaParser::RecordSymbol});
|
||||
methods.push_back({"recordSymbolWithLocation", "(ILjava/lang/String;IIIIIII)V", (void*)&JavaParser::RecordSymbolWithLocation});
|
||||
methods.push_back({"recordSymbolWithLocationAndScope", "(ILjava/lang/String;IIIIIIIIIII)V", (void*)&JavaParser::RecordSymbolWithLocationAndScope});
|
||||
methods.push_back({"recordReference", "(IILjava/lang/String;Ljava/lang/String;IIII)V", (void*)&JavaParser::RecordReference});
|
||||
methods.push_back({"recordLocalSymbol", "(ILjava/lang/String;IIII)V", (void*)&JavaParser::RecordLocalSymbol});
|
||||
methods.push_back({"recordComment", "(IIIII)V", (void*)&JavaParser::RecordComment});
|
||||
@@ -73,7 +77,15 @@ void JavaParser::parseFile(const FilePath& filePath, std::shared_ptr<TextAccess>
|
||||
// remove tabs because they screw with javaparser's location resolver
|
||||
std::string fileContent = utility::replace(textAccess->getText(), "\t", " ");
|
||||
|
||||
m_javaEnvironment->callStaticVoidMethod("io/coati/JavaIndexer", "processFile", m_id, filePath.str(), fileContent, classPath);
|
||||
m_javaEnvironment->callStaticVoidMethod(
|
||||
"io/coati/JavaIndexer",
|
||||
"processFile",
|
||||
m_id,
|
||||
filePath.str(),
|
||||
fileContent,
|
||||
classPath,
|
||||
ApplicationSettings::getInstance()->getVerboseInderxerLoggingEnabled() ? 1 : 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,13 +111,40 @@ std::mutex JavaParser::s_parsersMutex;
|
||||
|
||||
|
||||
|
||||
// definition of native methods
|
||||
|
||||
void JavaParser::doLogInfo(jstring jInfo)
|
||||
{
|
||||
LOG_INFO_STREAM_BARE(<< "Indexer - " << m_javaEnvironment->toStdString(jInfo));
|
||||
}
|
||||
|
||||
void JavaParser::doLogWarning(jstring jWarning)
|
||||
{
|
||||
LOG_WARNING_STREAM_BARE(<< "Indexer - " << m_javaEnvironment->toStdString(jWarning));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void JavaParser::doLogError(jstring jError)
|
||||
{
|
||||
LOG_ERROR_STREAM_BARE(<< "Indexer - " << m_javaEnvironment->toStdString(jError));
|
||||
}
|
||||
|
||||
void JavaParser::doRecordSymbol(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint jAccess, jint jIsImplicit
|
||||
)
|
||||
{
|
||||
AccessKind access = intToAccessKind(jAccess);
|
||||
bool isImplicit = jIsImplicit;
|
||||
|
||||
m_client->recordSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)),
|
||||
intToSymbolKind(jSymbolType),
|
||||
access,
|
||||
isImplicit
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordSymbolWithLocation(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
@@ -123,23 +162,7 @@ void JavaParser::doRecordSymbol(
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordSymbolWithoutLocation(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint jAccess, jint jIsImplicit
|
||||
)
|
||||
{
|
||||
AccessKind access = intToAccessKind(jAccess);
|
||||
bool isImplicit = jIsImplicit;
|
||||
|
||||
m_client->recordSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)),
|
||||
intToSymbolKind(jSymbolType),
|
||||
access,
|
||||
isImplicit
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordSymbolWithScope(
|
||||
void JavaParser::doRecordSymbolWithLocationAndScope(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint scopeBeginLine, jint scopeBeginColumn, jint scopeEndLine, jint scopeEndColumn,
|
||||
|
||||
@@ -70,6 +70,14 @@ private:
|
||||
//.. add as many MAKE_ARGS_* as there are MAKE_PARAMS_*
|
||||
|
||||
|
||||
#define DEF_RELAYING_METHOD_1(NAME, t1) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_1(t1), MAKE_ARGS_1(t1))
|
||||
|
||||
#define DEF_RELAYING_METHOD_2(NAME, t1, t2) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_2(t1, t2), MAKE_ARGS_2(t1, t2))
|
||||
|
||||
#define DEF_RELAYING_METHOD_3(NAME, t1, t2, t3) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_3(t1, t2, t3), MAKE_ARGS_3(t1, t2, t3))
|
||||
|
||||
#define DEF_RELAYING_METHOD_4(NAME, t1, t2, t3, t4) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_4(t1, t2, t3, t4), MAKE_ARGS_4(t1, t2, t3, t4))
|
||||
@@ -112,9 +120,12 @@ private:
|
||||
} \
|
||||
}
|
||||
|
||||
DEF_RELAYING_METHOD_8(RecordSymbol, jstring, jint, jint, jint, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_4(RecordSymbolWithoutLocation, jstring, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_12(RecordSymbolWithScope, jstring, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_1(LogInfo, jstring)
|
||||
DEF_RELAYING_METHOD_1(LogWarning, jstring)
|
||||
DEF_RELAYING_METHOD_1(LogError, jstring)
|
||||
DEF_RELAYING_METHOD_4(RecordSymbol, jstring, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_8(RecordSymbolWithLocation, jstring, jint, jint, jint, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_12(RecordSymbolWithLocationAndScope, jstring, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_7(RecordReference, jint, jstring, jstring, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_5(RecordLocalSymbol, jstring, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_4(RecordComment, jint, jint, jint, jint)
|
||||
@@ -128,19 +139,24 @@ private:
|
||||
|
||||
|
||||
|
||||
void doLogInfo(jstring jInfo);
|
||||
|
||||
void doLogWarning(jstring jWarning);
|
||||
|
||||
void doLogError(jstring jError);
|
||||
|
||||
void doRecordSymbol(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint jAccess, jint jIsImplicit
|
||||
);
|
||||
|
||||
void doRecordSymbolWithLocation(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
);
|
||||
|
||||
void doRecordSymbolWithoutLocation(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint jAccess, jint jIsImplicit
|
||||
);
|
||||
|
||||
void doRecordSymbolWithScope(
|
||||
void doRecordSymbolWithLocationAndScope(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint scopeBeginLine, jint scopeBeginColumn, jint scopeEndLine, jint scopeEndColumn,
|
||||
|
||||
Reference in New Issue
Block a user