diff --git a/core/include/LocationKind.h b/core/include/LocationKind.h index 7ac2bf6..fc46396 100644 --- a/core/include/LocationKind.h +++ b/core/include/LocationKind.h @@ -29,7 +29,7 @@ namespace sourcetrail QUALIFIER = 2, LOCAL_SYMBOL = 3, SIGNATURE = 4, - COMMENT = 5, + ATOMIC_RANGE = 5, INDEXER_ERROR = 6, FULLTEXT_SEARCH = 7, SCREEN_SEARCH = 8 diff --git a/core/include/SourcetrailDBWriter.h b/core/include/SourcetrailDBWriter.h index 0e54cba..84cee13 100644 --- a/core/include/SourcetrailDBWriter.h +++ b/core/include/SourcetrailDBWriter.h @@ -411,18 +411,21 @@ namespace sourcetrail bool recordLocalSymbolLocation(int localSymbolId, const SourceRange& location); /** - * Stores a comment location to the database + * Stores an atomic SourceRange to the database * - * This method allows to store a comment location to the database. These comment locations will - * be used by Sourcetrail to prevent the code view from displaying comments imcomplete. + * This method allows to store an atomic SourceRange to the database. These ranges will + * be used by Sourcetrail to prevent the code view from displaying only a part of the range. Thus, + * if any line that lies within one of the project's atomic ranges is dispayed, the remaining + * lines will be displayed as well. This may be useful for dealing with multi-line comments or + * multi-line strings. * - * param: location - the SourceRange of the comment to record. + * param: sourceRange - the SourceRange to record. * * return: true if successful. false on failure. getLastError() provides the error message. * * see: SourceRange */ - bool recordCommentLocation(const SourceRange& location); + bool recordAtomicSourceRange(const SourceRange& sourceRange); /** * Stores an indexing error to the database diff --git a/core/src/LocationKind.cpp b/core/src/LocationKind.cpp index 2295ca3..a30846f 100644 --- a/core/src/LocationKind.cpp +++ b/core/src/LocationKind.cpp @@ -33,7 +33,7 @@ namespace sourcetrail LocationKind::QUALIFIER, LocationKind::LOCAL_SYMBOL, LocationKind::SIGNATURE, - LocationKind::COMMENT, + LocationKind::ATOMIC_RANGE, LocationKind::INDEXER_ERROR, LocationKind::FULLTEXT_SEARCH, LocationKind::SCREEN_SEARCH diff --git a/core/src/SourcetrailDBWriter.cpp b/core/src/SourcetrailDBWriter.cpp index c300137..d2bafab 100644 --- a/core/src/SourcetrailDBWriter.cpp +++ b/core/src/SourcetrailDBWriter.cpp @@ -541,23 +541,23 @@ namespace sourcetrail } } - bool SourcetrailDBWriter::recordCommentLocation(const SourceRange& location) + bool SourcetrailDBWriter::recordAtomicSourceRange(const SourceRange& sourceRange) { if (!m_storage) { - m_lastError = "Unable to record comment location, because no database is currently open."; + m_lastError = "Unable to record atomic source range, because no database is currently open."; return false; } try { const int sourceLocationId = m_storage->addSourceLocation(StorageSourceLocationData( - location.fileId, - location.startLine, - location.startColumn, - location.endLine, - location.endColumn, - locationKindToInt(LocationKind::COMMENT) + sourceRange.fileId, + sourceRange.startLine, + sourceRange.startColumn, + sourceRange.endLine, + sourceRange.endColumn, + locationKindToInt(LocationKind::ATOMIC_RANGE) )); return true; diff --git a/core/test/test.cpp b/core/test/test.cpp index 070fc3a..00d63c7 100644 --- a/core/test/test.cpp +++ b/core/test/test.cpp @@ -435,7 +435,7 @@ namespace sourcetrail const int endLine = 3; const int endCol = 4; - const bool success1 = writer.recordCommentLocation( + const bool success1 = writer.recordAtomicSourceRange( { fileId, startLine, startCol, endLine, endCol } ); REQUIRE(success1); @@ -445,7 +445,7 @@ namespace sourcetrail { const std::vector sourceLocations = storage->getAll(); REQUIRE(sourceLocations.size() == 1); - REQUIRE(sourceLocations.front().locationKind == locationKindToInt(LocationKind::COMMENT)); + REQUIRE(sourceLocations.front().locationKind == locationKindToInt(LocationKind::ATOMIC_RANGE)); REQUIRE(sourceLocations.front().startLineNumber == startLine); REQUIRE(sourceLocations.front().startColumnNumber == startCol); REQUIRE(sourceLocations.front().endLineNumber == endLine); @@ -457,9 +457,9 @@ namespace sourcetrail REQUIRE(sourceLocations.front().fileNodeId == files.front().id); } - SECTION("writer does not record comment location twice") + SECTION("writer does not record atomic source range twice") { - const bool success2 = writer.recordCommentLocation( + const bool success2 = writer.recordAtomicSourceRange( { fileId, startLine, startCol, endLine, endCol } ); REQUIRE(success2); diff --git a/examples/cpp_api_example/src/main.cpp b/examples/cpp_api_example/src/main.cpp index 0830064..dd82209 100644 --- a/examples/cpp_api_example/src/main.cpp +++ b/examples/cpp_api_example/src/main.cpp @@ -58,8 +58,8 @@ int main(int argc, const char *argv[]) dbWriter.recordFileLanguage(fileId, "cpp"); // record file language for syntax highlighting - // record comment - dbWriter.recordCommentLocation({ fileId, 2, 1, 6, 3 }); + // record atomic source range for multi line comment + dbWriter.recordAtomicSourceRange({ fileId, 2, 1, 6, 3 }); // record namespace "api" diff --git a/resources_swig/include/sourcetraildb.h b/resources_swig/include/sourcetraildb.h index 95f2afb..4bc9e40 100644 --- a/resources_swig/include/sourcetraildb.h +++ b/resources_swig/include/sourcetraildb.h @@ -101,7 +101,7 @@ int recordLocalSymbol(std::string name); bool recordLocalSymbolLocation(int localSymbolId, int fileId, int startLine, int startColumn, int endLine, int endColumn); -bool recordCommentLocation(int fileId, int startLine, int startColumn, int endLine, int endColumn); +bool recordAtomicSourceRange(int fileId, int startLine, int startColumn, int endLine, int endColumn); bool recordError(std::string message, bool fatal, int fileId, int startLine, int startColumn, int endLine, int endColumn); diff --git a/resources_swig/src/sourcetraildb.cpp b/resources_swig/src/sourcetraildb.cpp index a7901af..bdf5262 100644 --- a/resources_swig/src/sourcetraildb.cpp +++ b/resources_swig/src/sourcetraildb.cpp @@ -240,9 +240,9 @@ bool recordLocalSymbolLocation(int localSymbolId, int fileId, int startLine, int return dbWriter.recordLocalSymbolLocation(localSymbolId, { fileId, startLine, startColumn, endLine, endColumn }); } -bool recordCommentLocation(int fileId, int startLine, int startColumn, int endLine, int endColumn) +bool recordAtomicSourceRange(int fileId, int startLine, int startColumn, int endLine, int endColumn) { - return dbWriter.recordCommentLocation({ fileId, startLine, startColumn, endLine, endColumn }); + return dbWriter.recordAtomicSourceRange({ fileId, startLine, startColumn, endLine, endColumn }); } bool recordError(std::string message, bool fatal, int fileId, int startLine, int startColumn, int endLine, int endColumn)