data, ui: comment handling

* CodeView displays comments as atomic regions. They are either displayed as a whole or not at all. Do nothing halfway!
* added CommentHandler that handles comments detected by clang.
* stored CommentLocations in database.
This commit is contained in:
malte_langkabel
2015-11-06 14:03:20 +01:00
parent e186eefdff
commit 50bc970c30
17 changed files with 282 additions and 31 deletions
+37 -1
View File
@@ -713,6 +713,22 @@ Id Storage::onMacroExpandParsed(const ParseLocation &location, const NameHierarc
return edgeId;
}
Id Storage::onCommentParsed(const ParseLocation& location)
{
log("comment", "no name", location);
Id fileNodeId = m_sqliteStorage.getFileByPath(location.filePath.str()).id;
Id commentId = m_sqliteStorage.addCommentLocation(
fileNodeId,
location.startLineNumber,
location.startColumnNumber,
location.endLineNumber,
location.endColumnNumber
);
return commentId;
}
Id Storage::getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) const
{
Id currentId = 0;
@@ -1167,7 +1183,7 @@ std::shared_ptr<TokenLocationFile> Storage::getTokenLocationOfParentScope(const
const TokenLocation* parent = child;
const FilePath filePath = child->getFilePath();
std::shared_ptr<TokenLocationFile> locationFile = m_sqliteStorage.getTokenLocationsForFile(filePath);
std::shared_ptr<TokenLocationFile> locationFile = m_sqliteStorage.getTokenLocationsForFile(filePath); // TODO: sqlite should not know TokenLocationFile!
locationFile->forEachStartTokenLocation(
[&](TokenLocation* tokenLocation) -> void
{
@@ -1197,6 +1213,26 @@ std::shared_ptr<TokenLocationFile> Storage::getTokenLocationOfParentScope(const
return file;
}
std::shared_ptr<TokenLocationFile> Storage::getCommentLocationsInFile(const FilePath& filePath) const
{
std::shared_ptr<TokenLocationFile> file = std::make_shared<TokenLocationFile>(filePath);
std::vector<StorageCommentLocation> storageLocations = m_sqliteStorage.getCommentLocationsInFile(filePath);
for (size_t i = 0; i < storageLocations.size(); i++)
{
TokenLocation* loc = file->addTokenLocation(
storageLocations[i].id,
0, // comment token location has no element.
storageLocations[i].startLine,
storageLocations[i].startCol,
storageLocations[i].endLine,
storageLocations[i].endCol
);
}
return file;
}
std::shared_ptr<TextAccess> Storage::getFileContent(const FilePath& filePath) const
{
return m_sqliteStorage.getFileContentByPath(filePath.str());