src: renamed recording methods
This commit is contained in:
@@ -79,10 +79,10 @@ ParserClient::~ParserClient()
|
||||
{
|
||||
}
|
||||
|
||||
void ParserClient::onErrorParsed(
|
||||
void ParserClient::recordError(
|
||||
const ParseLocation& location, const std::string& message, const std::string& commandline, bool fatal, bool indexed)
|
||||
{
|
||||
this->onError(location, message, commandline, fatal, indexed);
|
||||
doRecordError(location, message, commandline, fatal, indexed);
|
||||
|
||||
if (fatal)
|
||||
{
|
||||
|
||||
@@ -49,19 +49,19 @@ public:
|
||||
virtual void recordQualifierLocation(
|
||||
const NameHierarchy& qualifierName, const ParseLocation& location) = 0;
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed) = 0;
|
||||
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location) = 0;
|
||||
virtual void onFileParsed(const FileInfo& fileInfo) = 0;
|
||||
virtual void onCommentParsed(const ParseLocation& location) = 0;
|
||||
|
||||
void onErrorParsed(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
void recordError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed);
|
||||
|
||||
virtual void recordLocalSymbol(const std::string& name, const ParseLocation& location) = 0;
|
||||
virtual void recordFile(const FileInfo& fileInfo) = 0;
|
||||
virtual void recordComment(const ParseLocation& location) = 0;
|
||||
|
||||
bool hasFatalErrors() const;
|
||||
|
||||
protected:
|
||||
virtual void doRecordError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed) = 0;
|
||||
|
||||
bool m_hasFatalErrors;
|
||||
};
|
||||
|
||||
|
||||
@@ -73,32 +73,32 @@ void ParserClientImpl::recordQualifierLocation(const NameHierarchy& qualifierNam
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_QUALIFIER));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onError(
|
||||
const ParseLocation& location, const std::string& message, const std::string& commandline,bool fatal, bool indexed)
|
||||
{
|
||||
if (location.isValid())
|
||||
{
|
||||
addError(message, commandline, fatal, indexed, location);
|
||||
}
|
||||
}
|
||||
|
||||
void ParserClientImpl::onLocalSymbolParsed(const std::string& name, const ParseLocation& location)
|
||||
void ParserClientImpl::recordLocalSymbol(const std::string& name, const ParseLocation& location)
|
||||
{
|
||||
const Id localSymbolId = addLocalSymbol(name);
|
||||
addSourceLocation(localSymbolId, location, locationTypeToInt(LOCATION_LOCAL_SYMBOL));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onFileParsed(const FileInfo& fileInfo)
|
||||
void ParserClientImpl::recordFile(const FileInfo& fileInfo)
|
||||
{
|
||||
const Id nodeId = addNodeHierarchy(NameHierarchy(fileInfo.path.str(), NAME_DELIMITER_FILE), Node::NODE_FILE);
|
||||
addFile(nodeId, fileInfo.path, fileInfo.lastWriteTime.toString());
|
||||
}
|
||||
|
||||
void ParserClientImpl::onCommentParsed(const ParseLocation& location)
|
||||
void ParserClientImpl::recordComment(const ParseLocation& location)
|
||||
{
|
||||
addCommentLocation(location);
|
||||
}
|
||||
|
||||
void ParserClientImpl::doRecordError(
|
||||
const ParseLocation& location, const std::string& message, const std::string& commandline, bool fatal, bool indexed)
|
||||
{
|
||||
if (location.isValid())
|
||||
{
|
||||
addError(message, commandline, fatal, indexed, location);
|
||||
}
|
||||
}
|
||||
|
||||
Node::NodeType ParserClientImpl::symbolKindToNodeType(SymbolKind symbolKind) const
|
||||
{
|
||||
switch (symbolKind)
|
||||
|
||||
@@ -20,33 +20,33 @@ public:
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
AccessKind access, DefinitionKind definitionKind) override;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
AccessKind access, DefinitionKind definitionKind) override;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
AccessKind access, DefinitionKind definitionKind) override;
|
||||
|
||||
virtual void recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location);
|
||||
const ParseLocation& location) override;
|
||||
|
||||
virtual void recordQualifierLocation(
|
||||
const NameHierarchy& qualifierName, const ParseLocation& location);
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed);
|
||||
const NameHierarchy& qualifierName, const ParseLocation& location) override;
|
||||
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location);
|
||||
virtual void onFileParsed(const FileInfo& fileInfo);
|
||||
virtual void onCommentParsed(const ParseLocation& location);
|
||||
virtual void recordLocalSymbol(const std::string& name, const ParseLocation& location) override;
|
||||
virtual void recordFile(const FileInfo& fileInfo) override;
|
||||
virtual void recordComment(const ParseLocation& location) override;
|
||||
|
||||
private:
|
||||
virtual void doRecordError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed) override;
|
||||
|
||||
Node::NodeType symbolKindToNodeType(SymbolKind symbolType) const;
|
||||
Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const;
|
||||
void addAccess(Id nodeId, AccessKind access);
|
||||
|
||||
@@ -38,7 +38,7 @@ bool CommentHandler::HandleComment(clang::Preprocessor& preprocessor, clang::Sou
|
||||
FilePath filePath = m_canonicalFilePathCache->getCanonicalFilePath(fileEntry);
|
||||
if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->fileIsIndexed(filePath))
|
||||
{
|
||||
m_client->onCommentParsed(ParseLocation(
|
||||
m_client->recordComment(ParseLocation(
|
||||
filePath,
|
||||
presumedBegin.getLine(),
|
||||
presumedBegin.getColumn(),
|
||||
|
||||
@@ -150,7 +150,7 @@ void CxxAstVisitorComponentIndexer::beginTraverseLambdaCapture(clang::LambdaExpr
|
||||
declLocation.filePath.fileName() + "<" +
|
||||
std::to_string(declLocation.startLineNumber) + ":" +
|
||||
std::to_string(declLocation.startColumnNumber) + ">";
|
||||
m_client->onLocalSymbolParsed(name, getParseLocation(capture->getLocation()));
|
||||
m_client->recordLocalSymbol(name, getParseLocation(capture->getLocation()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,7 +238,7 @@ void CxxAstVisitorComponentIndexer::visitVarDecl(clang::VarDecl* d)
|
||||
declLocation.filePath.fileName() + "<" +
|
||||
std::to_string(declLocation.startLineNumber) + ":" +
|
||||
std::to_string(declLocation.startColumnNumber) + ">";
|
||||
m_client->onLocalSymbolParsed(name, getParseLocation(d->getLocation()));
|
||||
m_client->recordLocalSymbol(name, getParseLocation(d->getLocation()));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -554,7 +554,7 @@ void CxxAstVisitorComponentIndexer::visitDeclRefExpr(clang::DeclRefExpr* s)
|
||||
std::to_string(declLocation.startLineNumber) + ":" +
|
||||
std::to_string(declLocation.startColumnNumber) + ">";
|
||||
|
||||
m_client->onLocalSymbolParsed(name, getParseLocation(s->getLocation()));
|
||||
m_client->recordLocalSymbol(name, getParseLocation(s->getLocation()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -91,7 +91,7 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
|
||||
|
||||
ParseLocation location(filePath, line, column);
|
||||
|
||||
m_client->onErrorParsed(
|
||||
m_client->recordError(
|
||||
location,
|
||||
message,
|
||||
m_commandline,
|
||||
|
||||
@@ -40,7 +40,7 @@ void PreprocessorCallbacks::FileChanged(
|
||||
|
||||
if (!filePath.empty() && m_fileRegister->hasFilePath(filePath))
|
||||
{
|
||||
m_client->onFileParsed(FileSystem::getFileInfoForPath(filePath)); // todo: fix for tests
|
||||
m_client->recordFile(FileSystem::getFileInfoForPath(filePath)); // todo: fix for tests
|
||||
|
||||
if (!m_fileRegister->fileIsIndexed(filePath))
|
||||
{
|
||||
|
||||
@@ -100,7 +100,7 @@ void JavaParser::buildIndex(
|
||||
{
|
||||
m_currentFilePath = sourceFilePath;
|
||||
|
||||
m_client->onFileParsed(FileSystem::getFileInfoForPath(sourceFilePath));
|
||||
m_client->recordFile(FileSystem::getFileInfoForPath(sourceFilePath));
|
||||
|
||||
// remove tabs because they screw with javaparser's location resolver
|
||||
std::string fileContent = utility::replace(textAccess->getText(), "\t", " ");
|
||||
@@ -238,7 +238,7 @@ void JavaParser::doRecordQualifierLocation(
|
||||
|
||||
void JavaParser::doRecordLocalSymbol(jstring jSymbolName, jint beginLine, jint beginColumn, jint endLine, jint endColumn)
|
||||
{
|
||||
m_client->onLocalSymbolParsed(
|
||||
m_client->recordLocalSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)).getQualifiedName(),
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn)
|
||||
);
|
||||
@@ -248,7 +248,7 @@ void JavaParser::doRecordComment(
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn
|
||||
)
|
||||
{
|
||||
m_client->onCommentParsed(
|
||||
m_client->recordComment(
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn)
|
||||
);
|
||||
}
|
||||
@@ -261,7 +261,7 @@ void JavaParser::doRecordError(
|
||||
bool fatal = jFatal;
|
||||
bool indexed = jIndexed;
|
||||
|
||||
m_client->onError(
|
||||
m_client->recordError(
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
|
||||
m_javaEnvironment->toStdString(jMessage),
|
||||
"",
|
||||
|
||||
@@ -64,23 +64,17 @@ public:
|
||||
recordLine("QUALIFIER: " + addLocationSuffix(qualifierName.getQualifiedNameWithSignature() + " [" + location.filePath.fileName(), location) + "]\n");
|
||||
}
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed) override
|
||||
{
|
||||
recordLine("ERROR: " + addLocationSuffix(message + " [" + location.filePath.fileName(), location) + "]\n");
|
||||
}
|
||||
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location) override
|
||||
virtual void recordLocalSymbol(const std::string& name, const ParseLocation& location) override
|
||||
{
|
||||
recordLine("LOCAL_SYMBOL: " + addLocationSuffix(name + " [" + location.filePath.fileName(), location) + "]\n");
|
||||
}
|
||||
|
||||
virtual void onFileParsed(const FileInfo& fileInfo) override
|
||||
virtual void recordFile(const FileInfo& fileInfo) override
|
||||
{
|
||||
recordLine("FILE: " + fileInfo.path.fileName() + "\n");
|
||||
}
|
||||
|
||||
virtual void onCommentParsed(const ParseLocation& location) override
|
||||
virtual void recordComment(const ParseLocation& location) override
|
||||
{
|
||||
recordLine("COMMENT: " + addLocationSuffix("comment [" + location.filePath.fileName(), location) + "]\n");
|
||||
}
|
||||
@@ -88,6 +82,12 @@ public:
|
||||
std::string m_lines;
|
||||
|
||||
private:
|
||||
virtual void doRecordError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed) override
|
||||
{
|
||||
recordLine("ERROR: " + addLocationSuffix(message + " [" + location.filePath.fileName(), location) + "]\n");
|
||||
}
|
||||
|
||||
void recordLine(const std::string& message)
|
||||
{
|
||||
if (m_recordedLines.find(message) == m_recordedLines.end())
|
||||
|
||||
@@ -9,7 +9,7 @@ class TestParserClient: public ParserClient
|
||||
public:
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access, DefinitionKind definitionKind)
|
||||
AccessKind access, DefinitionKind definitionKind) override
|
||||
{
|
||||
std::vector<std::string>* bin = getBinForSymbolKind(symbolKind);
|
||||
if (bin != nullptr)
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, DefinitionKind definitionKind)
|
||||
AccessKind access, DefinitionKind definitionKind) override
|
||||
{
|
||||
std::vector<std::string>* bin = getBinForSymbolKind(symbolKind);
|
||||
if (bin != nullptr)
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, DefinitionKind definitionKind)
|
||||
AccessKind access, DefinitionKind definitionKind) override
|
||||
{
|
||||
std::vector<std::string>* bin = getBinForSymbolKind(symbolKind);
|
||||
if (bin != nullptr)
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
void recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location)
|
||||
const ParseLocation& location) override
|
||||
{
|
||||
std::vector<std::string>* referenceContainer = nullptr;
|
||||
switch (referenceKind)
|
||||
@@ -103,28 +103,22 @@ public:
|
||||
}
|
||||
|
||||
virtual void recordQualifierLocation(
|
||||
const NameHierarchy& qualifierName, const ParseLocation& location)
|
||||
const NameHierarchy& qualifierName, const ParseLocation& location) override
|
||||
{
|
||||
qualifiers.push_back(addLocationSuffix(qualifierName.getQualifiedNameWithSignature(), location));
|
||||
}
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed)
|
||||
{
|
||||
errors.push_back(addLocationSuffix(message, location));
|
||||
}
|
||||
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location)
|
||||
virtual void recordLocalSymbol(const std::string& name, const ParseLocation& location) override
|
||||
{
|
||||
localSymbols.push_back(addLocationSuffix(name, location));
|
||||
}
|
||||
|
||||
virtual void onFileParsed(const FileInfo& fileInfo)
|
||||
virtual void recordFile(const FileInfo& fileInfo) override
|
||||
{
|
||||
files.insert(fileInfo.path.str());
|
||||
}
|
||||
|
||||
virtual void onCommentParsed(const ParseLocation& location)
|
||||
virtual void recordComment(const ParseLocation& location) override
|
||||
{
|
||||
comments.push_back(addLocationSuffix("comment", location));
|
||||
}
|
||||
@@ -168,6 +162,12 @@ public:
|
||||
std::vector<std::string> imports;
|
||||
|
||||
private:
|
||||
virtual void doRecordError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed) override
|
||||
{
|
||||
errors.push_back(addLocationSuffix(message, location));
|
||||
}
|
||||
|
||||
std::vector<std::string>* getBinForSymbolKind(SymbolKind symbolType)
|
||||
{
|
||||
switch (symbolType)
|
||||
|
||||
Reference in New Issue
Block a user