rename recordCommentLocation to recordAtomicSourceRange

This is done because the feature can be useful for all kind of multi-line symbols that should not be split being part of a code snippet.
This commit is contained in:
mlangkabel
2019-02-26 17:12:18 +01:00
parent b8664ce131
commit 3b76c403dc
8 changed files with 27 additions and 24 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ namespace sourcetrail
QUALIFIER = 2, QUALIFIER = 2,
LOCAL_SYMBOL = 3, LOCAL_SYMBOL = 3,
SIGNATURE = 4, SIGNATURE = 4,
COMMENT = 5, ATOMIC_RANGE = 5,
INDEXER_ERROR = 6, INDEXER_ERROR = 6,
FULLTEXT_SEARCH = 7, FULLTEXT_SEARCH = 7,
SCREEN_SEARCH = 8 SCREEN_SEARCH = 8
+8 -5
View File
@@ -411,18 +411,21 @@ namespace sourcetrail
bool recordLocalSymbolLocation(int localSymbolId, const SourceRange& location); 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 * 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 comments imcomplete. * 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. * return: true if successful. false on failure. getLastError() provides the error message.
* *
* see: SourceRange * see: SourceRange
*/ */
bool recordCommentLocation(const SourceRange& location); bool recordAtomicSourceRange(const SourceRange& sourceRange);
/** /**
* Stores an indexing error to the database * Stores an indexing error to the database
+1 -1
View File
@@ -33,7 +33,7 @@ namespace sourcetrail
LocationKind::QUALIFIER, LocationKind::QUALIFIER,
LocationKind::LOCAL_SYMBOL, LocationKind::LOCAL_SYMBOL,
LocationKind::SIGNATURE, LocationKind::SIGNATURE,
LocationKind::COMMENT, LocationKind::ATOMIC_RANGE,
LocationKind::INDEXER_ERROR, LocationKind::INDEXER_ERROR,
LocationKind::FULLTEXT_SEARCH, LocationKind::FULLTEXT_SEARCH,
LocationKind::SCREEN_SEARCH LocationKind::SCREEN_SEARCH
+8 -8
View File
@@ -541,23 +541,23 @@ namespace sourcetrail
} }
} }
bool SourcetrailDBWriter::recordCommentLocation(const SourceRange& location) bool SourcetrailDBWriter::recordAtomicSourceRange(const SourceRange& sourceRange)
{ {
if (!m_storage) 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; return false;
} }
try try
{ {
const int sourceLocationId = m_storage->addSourceLocation(StorageSourceLocationData( const int sourceLocationId = m_storage->addSourceLocation(StorageSourceLocationData(
location.fileId, sourceRange.fileId,
location.startLine, sourceRange.startLine,
location.startColumn, sourceRange.startColumn,
location.endLine, sourceRange.endLine,
location.endColumn, sourceRange.endColumn,
locationKindToInt(LocationKind::COMMENT) locationKindToInt(LocationKind::ATOMIC_RANGE)
)); ));
return true; return true;
+4 -4
View File
@@ -435,7 +435,7 @@ namespace sourcetrail
const int endLine = 3; const int endLine = 3;
const int endCol = 4; const int endCol = 4;
const bool success1 = writer.recordCommentLocation( const bool success1 = writer.recordAtomicSourceRange(
{ fileId, startLine, startCol, endLine, endCol } { fileId, startLine, startCol, endLine, endCol }
); );
REQUIRE(success1); REQUIRE(success1);
@@ -445,7 +445,7 @@ namespace sourcetrail
{ {
const std::vector<StorageSourceLocation> sourceLocations = storage->getAll<StorageSourceLocation>(); const std::vector<StorageSourceLocation> sourceLocations = storage->getAll<StorageSourceLocation>();
REQUIRE(sourceLocations.size() == 1); 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().startLineNumber == startLine);
REQUIRE(sourceLocations.front().startColumnNumber == startCol); REQUIRE(sourceLocations.front().startColumnNumber == startCol);
REQUIRE(sourceLocations.front().endLineNumber == endLine); REQUIRE(sourceLocations.front().endLineNumber == endLine);
@@ -457,9 +457,9 @@ namespace sourcetrail
REQUIRE(sourceLocations.front().fileNodeId == files.front().id); 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 } { fileId, startLine, startCol, endLine, endCol }
); );
REQUIRE(success2); REQUIRE(success2);
+2 -2
View File
@@ -58,8 +58,8 @@ int main(int argc, const char *argv[])
dbWriter.recordFileLanguage(fileId, "cpp"); // record file language for syntax highlighting dbWriter.recordFileLanguage(fileId, "cpp"); // record file language for syntax highlighting
// record comment // record atomic source range for multi line comment
dbWriter.recordCommentLocation({ fileId, 2, 1, 6, 3 }); dbWriter.recordAtomicSourceRange({ fileId, 2, 1, 6, 3 });
// record namespace "api" // record namespace "api"
+1 -1
View File
@@ -101,7 +101,7 @@ int recordLocalSymbol(std::string name);
bool recordLocalSymbolLocation(int localSymbolId, int fileId, int startLine, int startColumn, int endLine, int endColumn); 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); bool recordError(std::string message, bool fatal, int fileId, int startLine, int startColumn, int endLine, int endColumn);
+2 -2
View File
@@ -240,9 +240,9 @@ bool recordLocalSymbolLocation(int localSymbolId, int fileId, int startLine, int
return dbWriter.recordLocalSymbolLocation(localSymbolId, { fileId, startLine, startColumn, endLine, endColumn }); 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) bool recordError(std::string message, bool fatal, int fileId, int startLine, int startColumn, int endLine, int endColumn)