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:
@@ -24,19 +24,6 @@ std::string ParserClient::addAccessPrefix(const std::string& str, AccessKind acc
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string ParserClient::addAbstractionPrefix(const std::string& str, AbstractionType abstraction)
|
||||
{
|
||||
switch (abstraction)
|
||||
{
|
||||
case ABSTRACTION_VIRTUAL:
|
||||
return "virtual " + str;
|
||||
case ABSTRACTION_PURE_VIRTUAL:
|
||||
return "pure virtual " + str;
|
||||
case ABSTRACTION_NONE:
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
std::string ParserClient::addStaticPrefix(const std::string& str, bool isStatic)
|
||||
{
|
||||
if (isStatic)
|
||||
|
||||
@@ -17,14 +17,7 @@ class DataType;
|
||||
class ParserClient
|
||||
{
|
||||
public:
|
||||
enum AbstractionType {
|
||||
ABSTRACTION_VIRTUAL,
|
||||
ABSTRACTION_PURE_VIRTUAL,
|
||||
ABSTRACTION_NONE
|
||||
};
|
||||
|
||||
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);
|
||||
static std::string addLocationSuffix(const std::string& str, const ParseLocation& location);
|
||||
@@ -56,65 +49,9 @@ public:
|
||||
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, AccessKind access, bool isImplicit) = 0;
|
||||
virtual void onClassParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit) = 0;
|
||||
virtual void onStructParsed(
|
||||
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, 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, 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, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit) = 0;
|
||||
virtual void onEnumConstantParsed(const ParseLocation& location, const NameHierarchy& nameHierarchy, bool isImplicit) = 0;
|
||||
virtual void onTemplateParameterTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& templateParameterTypeNameHierarchy, bool isImplicit) = 0;
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location) = 0;
|
||||
virtual void onFileParsed(const FileInfo& fileInfo) = 0;
|
||||
virtual void onMacroDefineParsed(
|
||||
const ParseLocation& location, const NameHierarchy& macroNameHierarchy, const ParseLocation& scopeLocation) = 0;
|
||||
virtual void onCommentParsed(const ParseLocation& location) = 0;
|
||||
|
||||
virtual void onInheritanceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy,
|
||||
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, SymbolKind usedType, const NameHierarchy& usedName) = 0;
|
||||
virtual void onTypeUsageParsed(const ParseLocation& location, const NameHierarchy& user, const NameHierarchy& used) = 0;
|
||||
|
||||
virtual void onTemplateArgumentTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& argumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateNameHierarchy) = 0;
|
||||
virtual void onTemplateDefaultArgumentTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& defaultArgumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateParameterNameHierarchy) = 0;
|
||||
virtual void onTemplateSpecializationParsed(
|
||||
const ParseLocation& location, const NameHierarchy& specializedNameHierarchy,
|
||||
const NameHierarchy& specializedFromNameHierarchy) = 0;
|
||||
virtual void onTemplateMemberFunctionSpecializationParsed(
|
||||
const ParseLocation& location, const NameHierarchy& instantiatedFunction, const NameHierarchy& specializedFunction) = 0;
|
||||
|
||||
virtual void onFileIncludeParsed(
|
||||
const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo) = 0;
|
||||
|
||||
virtual void onMacroExpandParsed(
|
||||
const ParseLocation& location, const NameHierarchy& macroNameHierarchy) = 0;
|
||||
};
|
||||
|
||||
#endif // PARSER_CLIENT_H
|
||||
|
||||
@@ -76,328 +76,31 @@ void ParserClientImpl::recordReference(
|
||||
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);
|
||||
|
||||
if (!location.isValid())
|
||||
if (location.isValid())
|
||||
{
|
||||
return;
|
||||
addError(message, fatal, indexed, location);
|
||||
}
|
||||
|
||||
addError(message, fatal, indexed, location);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onTypedefParsed(
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessKind access, bool isImplicit)
|
||||
{
|
||||
log("typedef", typedefName.getQualifiedName(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(Node::NODE_TYPEDEF, typedefName, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addAccess(nodeId, access);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onClassParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
log("class", nameHierarchy.getQualifiedName(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(
|
||||
Node::NODE_CLASS,
|
||||
nameHierarchy,
|
||||
(isImplicit ? DEFINITION_IMPLICIT : (scopeLocation.isValid() ? DEFINITION_EXPLICIT : DEFINITION_NONE))
|
||||
);
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
addAccess(nodeId, access);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onStructParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
log("struct", nameHierarchy.getQualifiedName(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(
|
||||
Node::NODE_STRUCT,
|
||||
nameHierarchy,
|
||||
(isImplicit ? DEFINITION_IMPLICIT : (scopeLocation.isValid() ? DEFINITION_EXPLICIT : DEFINITION_NONE))
|
||||
);
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
addAccess(nodeId, access);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onGlobalVariableParsed(const ParseLocation& location, const NameHierarchy& variable, bool isImplicit)
|
||||
{
|
||||
log("global", variable.getQualifiedName(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(Node::NODE_GLOBAL_VARIABLE, variable, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessKind access, bool isImplicit)
|
||||
{
|
||||
log("field", field.getQualifiedName(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(Node::NODE_FIELD, field, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addAccess(nodeId, access);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onFunctionParsed(
|
||||
const ParseLocation& location, const NameHierarchy& function, const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
log("function", function.getQualifiedNameWithSignature(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(Node::NODE_FUNCTION, function, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onMethodParsed(
|
||||
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);
|
||||
|
||||
Id nodeId = addNodeHierarchy(
|
||||
Node::NODE_METHOD,
|
||||
method,
|
||||
(isImplicit ? DEFINITION_IMPLICIT : ((location.isValid() && scopeLocation.isValid()) ? (DEFINITION_EXPLICIT) : DEFINITION_NONE))
|
||||
);
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
addAccess(nodeId, access);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onNamespaceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
log("namespace", nameHierarchy.getQualifiedName(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(Node::NODE_NAMESPACE, nameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onEnumParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
log("enum", nameHierarchy.getQualifiedName(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(Node::NODE_ENUM, nameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
addAccess(nodeId, access);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onEnumConstantParsed(const ParseLocation& location, const NameHierarchy& nameHierarchy, bool isImplicit)
|
||||
{
|
||||
log("enum constant", nameHierarchy.getQualifiedName(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(Node::NODE_ENUM_CONSTANT, nameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onTemplateParameterTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& templateParameterTypeNameHierarchy, bool isImplicit)
|
||||
{
|
||||
log("template parameter type", templateParameterTypeNameHierarchy.getQualifiedName(), location);
|
||||
|
||||
Id nodeId = addNodeHierarchy(Node::NODE_TEMPLATE_PARAMETER_TYPE, templateParameterTypeNameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addAccess(nodeId, ACCESS_TEMPLATE_PARAMETER);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onLocalSymbolParsed(const std::string& name, const ParseLocation& location)
|
||||
{
|
||||
log(
|
||||
"local symbol",
|
||||
name,
|
||||
location
|
||||
);
|
||||
|
||||
Id localSymbolId = addLocalSymbol(name);
|
||||
addSourceLocation(localSymbolId, location, locationTypeToInt(LOCATION_LOCAL_SYMBOL));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onFileParsed(const FileInfo& fileInfo)
|
||||
{
|
||||
log("file", fileInfo.path.str(), ParseLocation());
|
||||
|
||||
addFile(fileInfo.path.fileName(), fileInfo.path.str(), fileInfo.lastWriteTime.toString());
|
||||
}
|
||||
|
||||
void ParserClientImpl::onMacroDefineParsed(
|
||||
const ParseLocation& location, const NameHierarchy& macroNameHierarchy, const ParseLocation& scopeLocation)
|
||||
{
|
||||
log("macro", macroNameHierarchy.getQualifiedName(), location);
|
||||
|
||||
Id macroId = addNodeHierarchy(Node::NODE_MACRO, macroNameHierarchy, DEFINITION_EXPLICIT);
|
||||
addSourceLocation(macroId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addSourceLocation(macroId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
|
||||
Id fileNodeId = addFile(location.filePath.str());
|
||||
Id edgeId = addEdge(Edge::EDGE_MACRO_USAGE, fileNodeId, macroId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onCommentParsed(const ParseLocation& location)
|
||||
{
|
||||
log("comment", "no name", location);
|
||||
|
||||
addFile(location.filePath.str());
|
||||
addCommentLocation(location);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onInheritanceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& childNameHierarchy,
|
||||
const NameHierarchy& parentNameHierarchy)
|
||||
{
|
||||
log("inheritance", childNameHierarchy.getQualifiedName() + " : " + parentNameHierarchy.getQualifiedName(), location);
|
||||
|
||||
Id childNodeId = addNodeHierarchy(Node::NODE_TYPE, childNameHierarchy, DEFINITION_NONE);
|
||||
Id parentNodeId = addNodeHierarchy(Node::NODE_TYPE, parentNameHierarchy, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_INHERITANCE, childNodeId, parentNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onMethodOverrideParsed(
|
||||
const ParseLocation& location, const NameHierarchy& overridden, const NameHierarchy& overrider)
|
||||
{
|
||||
log("override", overridden.getQualifiedNameWithSignature() + " -> " + overrider.getQualifiedNameWithSignature(), location);
|
||||
|
||||
Id overriddenNodeId = addNodeHierarchy(Node::NODE_FUNCTION, overridden, DEFINITION_NONE);
|
||||
Id overriderNodeId = addNodeHierarchy(Node::NODE_FUNCTION, overrider, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_OVERRIDE, overriderNodeId, overriddenNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onCallParsed(const ParseLocation& location, const NameHierarchy& caller, const NameHierarchy& callee)
|
||||
{
|
||||
log("call", caller.getQualifiedNameWithSignature() + " -> " + callee.getQualifiedNameWithSignature(), location);
|
||||
|
||||
Id callerNodeId = addNodeHierarchy(Node::NODE_FUNCTION, caller, DEFINITION_NONE);
|
||||
Id calleeNodeId = addNodeHierarchy(Node::NODE_FUNCTION, callee, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_CALL, callerNodeId, calleeNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onUsageParsed(
|
||||
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(symbolKindToNodeType(usedType), usedName, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_USAGE, userNodeId, usedNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onTypeUsageParsed(const ParseLocation& location, const NameHierarchy& user, const NameHierarchy& used)
|
||||
{
|
||||
log("type usage", user.getQualifiedNameWithSignature() + " -> " + used.getQualifiedName(), location);
|
||||
|
||||
if (!location.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Id functionNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, user, DEFINITION_NONE);
|
||||
Id typeNodeId = addNodeHierarchy(Node::NODE_TYPE, used, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_TYPE_USAGE, functionNodeId, typeNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onTemplateArgumentTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& argumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateNameHierarchy)
|
||||
{
|
||||
log(
|
||||
"template argument type",
|
||||
argumentTypeNameHierarchy.getQualifiedName() + " -> " + templateNameHierarchy.getQualifiedName(),
|
||||
location
|
||||
);
|
||||
|
||||
Id argumentNodeId = addNodeHierarchy(Node::NODE_TYPE, argumentTypeNameHierarchy, DEFINITION_NONE);
|
||||
Id templateNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, templateNameHierarchy, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_ARGUMENT, templateNodeId, argumentNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onTemplateDefaultArgumentTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& defaultArgumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateParameterNameHierarchy)
|
||||
{
|
||||
log(
|
||||
"template default argument",
|
||||
defaultArgumentTypeNameHierarchy.getQualifiedNameWithSignature() + " -> " + templateParameterNameHierarchy.getQualifiedName(),
|
||||
location
|
||||
);
|
||||
|
||||
Id defaultArgumentNodeId = addNodeHierarchy(Node::NODE_TYPE, defaultArgumentTypeNameHierarchy, DEFINITION_NONE);
|
||||
Id parameterNodeId = addNodeHierarchy(Node::NODE_TYPE, templateParameterNameHierarchy, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT, parameterNodeId, defaultArgumentNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onTemplateSpecializationParsed(
|
||||
const ParseLocation& location, const NameHierarchy& specializedNameHierarchy,
|
||||
const NameHierarchy& specializedFromNameHierarchy)
|
||||
{
|
||||
log(
|
||||
"template record specialization",
|
||||
specializedNameHierarchy.getQualifiedName() + " -> " + specializedFromNameHierarchy.getQualifiedName(),
|
||||
location
|
||||
);
|
||||
|
||||
Id specializedId = addNodeHierarchy(Node::NODE_TYPE, specializedNameHierarchy, DEFINITION_NONE);
|
||||
Id recordNodeId = addNodeHierarchy(Node::NODE_TYPE, specializedFromNameHierarchy, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_SPECIALIZATION_OF, specializedId, recordNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onTemplateMemberFunctionSpecializationParsed(
|
||||
const ParseLocation& location, const NameHierarchy& instantiatedFunction, const NameHierarchy& specializedFunction)
|
||||
{
|
||||
log(
|
||||
"template member function specialization",
|
||||
instantiatedFunction.getQualifiedNameWithSignature() + " -> " + specializedFunction.getQualifiedNameWithSignature(),
|
||||
location
|
||||
);
|
||||
|
||||
Id instantiatedFunctionNodeId = addNodeHierarchy(Node::NODE_FUNCTION, instantiatedFunction, DEFINITION_NONE);
|
||||
Id specializedFunctionNodeId = addNodeHierarchy(Node::NODE_FUNCTION, specializedFunction, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF, instantiatedFunctionNodeId, specializedFunctionNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onFileIncludeParsed(const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo)
|
||||
{
|
||||
log("include", includedFileInfo.path.str(), location);
|
||||
|
||||
Id fileNodeId = addFile(fileInfo.path.fileName(), fileInfo.path.str(), fileInfo.lastWriteTime.toString());
|
||||
Id includedFileNodeId = addFile(includedFileInfo.path.fileName(), includedFileInfo.path.str(), includedFileInfo.lastWriteTime.toString());
|
||||
Id edgeId = addEdge(Edge::EDGE_INCLUDE, fileNodeId, includedFileNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onMacroExpandParsed(const ParseLocation &location, const NameHierarchy& macroNameHierarchy)
|
||||
{
|
||||
log("macro use", macroNameHierarchy.getQualifiedName(), location);
|
||||
|
||||
Id macroExpandId = addNodeHierarchy(Node::NODE_MACRO, macroNameHierarchy, DEFINITION_NONE);
|
||||
Id fileNodeId = addFile(location.filePath.str());
|
||||
Id edgeId = addEdge(Edge::EDGE_MACRO_USAGE, fileNodeId, macroExpandId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
Node::NodeType ParserClientImpl::symbolKindToNodeType(SymbolKind symbolType) const
|
||||
{
|
||||
switch (symbolType)
|
||||
@@ -636,12 +339,3 @@ void ParserClientImpl::addError(const std::string& message, bool fatal, bool ind
|
||||
|
||||
m_storage->addError(message, location.filePath, location.startLineNumber, location.startColumnNumber, fatal, indexed);
|
||||
}
|
||||
|
||||
void ParserClientImpl::log(std::string type, std::string str, const ParseLocation& location) const
|
||||
{
|
||||
LOG_INFO_STREAM_BARE(
|
||||
<< type << ": " << str << " <" << location.filePath.str() << " "
|
||||
<< location.startLineNumber << ":" << location.startColumnNumber << " "
|
||||
<< location.endLineNumber << ":" << location.endColumnNumber << ">"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ public:
|
||||
virtual void startParsingFile();
|
||||
virtual void finishParsingFile();
|
||||
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false);
|
||||
@@ -42,66 +41,10 @@ public:
|
||||
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, AccessKind access, bool isImplicit);
|
||||
virtual void onClassParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit);
|
||||
virtual void onStructParsed(
|
||||
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, 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, 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, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit);
|
||||
virtual void onEnumConstantParsed(const ParseLocation& location, const NameHierarchy& nameHierarchy, bool isImplicit);
|
||||
virtual void onTemplateParameterTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& templateParameterTypeNameHierarchy, bool isImplicit);
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location);
|
||||
virtual void onFileParsed(const FileInfo& fileInfo);
|
||||
virtual void onMacroDefineParsed(
|
||||
const ParseLocation& location, const NameHierarchy& macroNameHierarchy, const ParseLocation& scopeLocation);
|
||||
virtual void onCommentParsed(const ParseLocation& location);
|
||||
|
||||
virtual void onInheritanceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy,
|
||||
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, SymbolKind usedType, const NameHierarchy& usedName);
|
||||
virtual void onTypeUsageParsed(const ParseLocation& location, const NameHierarchy& user, const NameHierarchy& used);
|
||||
|
||||
virtual void onTemplateArgumentTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& argumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateNameHierarchy);
|
||||
virtual void onTemplateDefaultArgumentTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& defaultArgumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateParameterNameHierarchy);
|
||||
virtual void onTemplateSpecializationParsed(
|
||||
const ParseLocation& location, const NameHierarchy& specializedNameHierarchy,
|
||||
const NameHierarchy& specializedFromNameHierarchy);
|
||||
virtual void onTemplateMemberFunctionSpecializationParsed(
|
||||
const ParseLocation& location, const NameHierarchy& instantiatedFunction, const NameHierarchy& specializedFunction);
|
||||
|
||||
virtual void onFileIncludeParsed(
|
||||
const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo);
|
||||
|
||||
virtual void onMacroExpandParsed(
|
||||
const ParseLocation& location, const NameHierarchy& macroNameHierarchy);
|
||||
|
||||
private:
|
||||
Node::NodeType symbolKindToNodeType(SymbolKind symbolType) const;
|
||||
Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const;
|
||||
@@ -118,8 +61,6 @@ private:
|
||||
void addCommentLocation(const ParseLocation& location);
|
||||
void addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location);
|
||||
|
||||
void log(std::string type, std::string str, const ParseLocation& location) const;
|
||||
|
||||
std::shared_ptr<IntermediateStorage> m_storage;
|
||||
};
|
||||
|
||||
|
||||
@@ -160,9 +160,19 @@ bool ApplicationSettings::getLoggingEnabled() const
|
||||
return getValue<bool>("application/logging_enabled", false);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setLoggingEnabled(bool loggingEnabled)
|
||||
void ApplicationSettings::setLoggingEnabled(bool value)
|
||||
{
|
||||
setValue<bool>("application/logging_enabled", loggingEnabled);
|
||||
setValue<bool>("application/logging_enabled", value);
|
||||
}
|
||||
|
||||
bool ApplicationSettings::getVerboseInderxerLoggingEnabled() const
|
||||
{
|
||||
return getValue<bool>("application/verbose_indexer_logging_enabled", false);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setVerboseInderxerLoggingEnabled(bool value)
|
||||
{
|
||||
setValue<bool>("application/verbose_indexer_logging_enabled", value);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getIndexerThreadCount() const
|
||||
|
||||
@@ -50,6 +50,9 @@ public:
|
||||
bool getLoggingEnabled() const;
|
||||
void setLoggingEnabled(bool loggingEnabled);
|
||||
|
||||
bool getVerboseInderxerLoggingEnabled() const;
|
||||
void setVerboseInderxerLoggingEnabled(bool loggingEnabled);
|
||||
|
||||
// indexing
|
||||
int getIndexerThreadCount() const;
|
||||
void setIndexerThreadCount(const int count);
|
||||
|
||||
@@ -106,6 +106,7 @@ void FileLogger::logMessage(const std::string& type, const LogMessage& message)
|
||||
std::ofstream fileStream;
|
||||
fileStream.open(m_logDirectory + m_currentLogFileName, std::ios::app);
|
||||
fileStream << message.getTimeString("%H:%M:%S") << " | ";
|
||||
fileStream << message.threadId << " | ";
|
||||
|
||||
if (message.filePath.size())
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ void LogManagerImplementation::logInfo(
|
||||
std::lock_guard<std::mutex> lockGuardLogger(m_loggerMutex);
|
||||
for (unsigned int i = 0; i < m_loggers.size(); i++)
|
||||
{
|
||||
m_loggers[i]->onInfo(LogMessage(message, file, function, line, getTime()));
|
||||
m_loggers[i]->onInfo(LogMessage(message, file, function, line, getTime(), std::this_thread::get_id()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ void LogManagerImplementation::logWarning(
|
||||
std::lock_guard<std::mutex> lockGuardLogger(m_loggerMutex);
|
||||
for (unsigned int i = 0; i < m_loggers.size(); i++)
|
||||
{
|
||||
m_loggers[i]->onWarning(LogMessage(message, file, function, line, getTime()));
|
||||
m_loggers[i]->onWarning(LogMessage(message, file, function, line, getTime(), std::this_thread::get_id()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ void LogManagerImplementation::logError(
|
||||
std::lock_guard<std::mutex> lockGuardLogger(m_loggerMutex);
|
||||
for (unsigned int i = 0; i < m_loggers.size(); i++)
|
||||
{
|
||||
m_loggers[i]->onError(LogMessage(message, file, function, line, getTime()));
|
||||
m_loggers[i]->onError(LogMessage(message, file, function, line, getTime(), std::this_thread::get_id()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
struct LogMessage
|
||||
{
|
||||
@@ -12,13 +13,15 @@ public:
|
||||
const std::string& filePath,
|
||||
const std::string& functionName,
|
||||
const unsigned int line,
|
||||
const std::tm& time
|
||||
const std::tm& time,
|
||||
const std::thread::id& threadId
|
||||
)
|
||||
: message(message)
|
||||
, filePath(filePath)
|
||||
, functionName(functionName)
|
||||
, line(line)
|
||||
, time(time)
|
||||
, threadId(threadId)
|
||||
{}
|
||||
|
||||
std::string getTimeString(const std::string& format) const
|
||||
@@ -38,6 +41,7 @@ public:
|
||||
const std::string functionName;
|
||||
const unsigned int line;
|
||||
const std::tm time;
|
||||
const std::thread::id threadId;
|
||||
};
|
||||
|
||||
#endif // LOG_MESSAGE_H
|
||||
|
||||
@@ -65,4 +65,22 @@
|
||||
} \
|
||||
while(0)
|
||||
|
||||
#define LOG_WARNING_STREAM_BARE(__s__) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream __ss__; \
|
||||
__ss__ __s__; \
|
||||
LogManager::getInstance()->logWarning(__ss__.str(), "", "", 0); \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
#define LOG_ERROR_STREAM_BARE(__s__) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream __ss__; \
|
||||
__ss__ __s__; \
|
||||
LogManager::getInstance()->logError(__ss__.str(), "", "", 0); \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
#endif // LOGGING_H
|
||||
|
||||
Reference in New Issue
Block a user