diff --git a/core/include/SourcetrailDBWriter.h b/core/include/SourcetrailDBWriter.h index 84cee13..636b9fa 100644 --- a/core/include/SourcetrailDBWriter.h +++ b/core/include/SourcetrailDBWriter.h @@ -349,6 +349,26 @@ namespace sourcetrail */ bool recordReferenceLocation(int referenceId, const SourceRange& location); + /** + * Stores a location for the usage of a symbol's name as qualifier to the database + * + * This method allows to store a location where a specific symbol is used as a qualifier to the + * database. Calling this method with the same referencedSymbolId multiple times adds multiple locations + * for the respective reference. The stored location will be clickable but not displayable: When the + * reference location is clicked Sourcetrail will activate the symbol referenced by the respective + * reference. When the symbol with the specified id is activated, this location will NOT be displayed and + * highlighted by Sourcetrail. + * + * param: referencedSymbolId - the id of the symbol that is used as qualifier at the current location. + * param: location - the SourceRange that shall be recorded as location for the symbol's occurrence as + * qualifier + * + * return: true if successful. false on failure. getLastError() provides the error message. + * + * see: SourceRange + */ + bool recordQualifierLocation(int referencedSymbolId, const SourceRange& location); + /** * Stores a file to the database * diff --git a/core/src/SourcetrailDBWriter.cpp b/core/src/SourcetrailDBWriter.cpp index d2bafab..5247623 100644 --- a/core/src/SourcetrailDBWriter.cpp +++ b/core/src/SourcetrailDBWriter.cpp @@ -446,7 +446,7 @@ namespace sourcetrail { if (!m_storage) { - m_lastError = "Unable to record symbol signature location, because no database is currently open."; + m_lastError = "Unable to record symbol reference location, because no database is currently open."; return false; } @@ -462,6 +462,26 @@ namespace sourcetrail } } + bool SourcetrailDBWriter::recordQualifierLocation(int referencedSymbolId, const SourceRange& location) + { + if (!m_storage) + { + m_lastError = "Unable to record symbol qualifier location, because no database is currently open."; + return false; + } + + try + { + addSourceLocation(referencedSymbolId, location, LocationKind::QUALIFIER); + return true; + } + catch (const SourcetrailException e) + { + m_lastError = e.getMessage(); + return false; + } + } + int SourcetrailDBWriter::recordFile(const std::string& filePath) { if (!m_storage) diff --git a/resources_swig/include/sourcetraildb.h b/resources_swig/include/sourcetraildb.h index 4bc9e40..d9f3e6d 100644 --- a/resources_swig/include/sourcetraildb.h +++ b/resources_swig/include/sourcetraildb.h @@ -93,6 +93,8 @@ int recordReference(int contextSymbolId, int referencedSymbolId, ReferenceKind r bool recordReferenceLocation(int referenceId, int fileId, int startLine, int startColumn, int endLine, int endColumn); +bool recordQualifierLocation(int referencedSymbolId, int fileId, int startLine, int startColumn, int endLine, int endColumn); + int recordFile(std::string filePath); bool recordFileLanguage(int fileId, std::string languageIdentifier); diff --git a/resources_swig/src/sourcetraildb.cpp b/resources_swig/src/sourcetraildb.cpp index bdf5262..74b6b8d 100644 --- a/resources_swig/src/sourcetraildb.cpp +++ b/resources_swig/src/sourcetraildb.cpp @@ -220,6 +220,11 @@ bool recordReferenceLocation(int referenceId, int fileId, int startLine, int sta return dbWriter.recordReferenceLocation(referenceId, { fileId, startLine, startColumn, endLine, endColumn }); } +bool recordQualifierLocation(int referencedSymbolId, int fileId, int startLine, int startColumn, int endLine, int endColumn) +{ + return dbWriter.recordQualifierLocation(referencedSymbolId, { fileId, startLine, startColumn, endLine, endColumn }); +} + int recordFile(std::string filePath) { return dbWriter.recordFile(filePath);