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,
LOCAL_SYMBOL = 3,
SIGNATURE = 4,
COMMENT = 5,
ATOMIC_RANGE = 5,
INDEXER_ERROR = 6,
FULLTEXT_SEARCH = 7,
SCREEN_SEARCH = 8
+8 -5
View File
@@ -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
+1 -1
View File
@@ -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
+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)
{
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;
+4 -4
View File
@@ -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<StorageSourceLocation> sourceLocations = storage->getAll<StorageSourceLocation>();
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);
+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
// 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"
+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 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);
+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 });
}
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)