data: showing local symbols
- added local symbols to storage - added tests for local symbol parsing - added MessageActivateLocalSymbols to activate local symbols in code view - TokenLocations now store their LocationType instead of a plain bool "isScope" - moved LocationType from TokenLocation to separate file, since it is also used in Annotations now. - added local_symbol in stylesheet to define a style for hovering and activating these elements - renamed location to token in stylesheet
This commit is contained in:
@@ -87,7 +87,7 @@
|
|||||||
</syntax>
|
</syntax>
|
||||||
|
|
||||||
<selection>
|
<selection>
|
||||||
<location>
|
<token>
|
||||||
<normal>
|
<normal>
|
||||||
<border>transparent</border>
|
<border>transparent</border>
|
||||||
<fill>transparent</fill>
|
<fill>transparent</fill>
|
||||||
@@ -100,7 +100,21 @@
|
|||||||
<border>#B2B2B2</border>
|
<border>#B2B2B2</border>
|
||||||
<fill>#4A4A4A</fill>
|
<fill>#4A4A4A</fill>
|
||||||
</active>
|
</active>
|
||||||
</location>
|
</token>
|
||||||
|
<local_symbol>
|
||||||
|
<normal>
|
||||||
|
<border>transparent</border>
|
||||||
|
<fill>transparent</fill>
|
||||||
|
</normal>
|
||||||
|
<focus>
|
||||||
|
<border>#FF9C3C</border>
|
||||||
|
<fill>transparent</fill>
|
||||||
|
</focus>
|
||||||
|
<active>
|
||||||
|
<border>#FF9C3C</border>
|
||||||
|
<fill>#695540</fill>
|
||||||
|
</active>
|
||||||
|
</local_symbol>
|
||||||
<scope>
|
<scope>
|
||||||
<normal>
|
<normal>
|
||||||
<border>transparent</border>
|
<border>transparent</border>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
</syntax>
|
</syntax>
|
||||||
|
|
||||||
<selection>
|
<selection>
|
||||||
<location>
|
<token>
|
||||||
<normal>
|
<normal>
|
||||||
<border>transparent</border>
|
<border>transparent</border>
|
||||||
<fill>transparent</fill>
|
<fill>transparent</fill>
|
||||||
@@ -100,7 +100,21 @@
|
|||||||
<border>#B2B2B2</border>
|
<border>#B2B2B2</border>
|
||||||
<fill>#EDEDED</fill>
|
<fill>#EDEDED</fill>
|
||||||
</active>
|
</active>
|
||||||
</location>
|
</token>
|
||||||
|
<local_symbol>
|
||||||
|
<normal>
|
||||||
|
<border>transparent</border>
|
||||||
|
<fill>transparent</fill>
|
||||||
|
</normal>
|
||||||
|
<focus>
|
||||||
|
<border>#FF9C3C</border>
|
||||||
|
<fill>transparent</fill>
|
||||||
|
</focus>
|
||||||
|
<active>
|
||||||
|
<border>#FF9C3C</border>
|
||||||
|
<fill>#FFDFC0</fill>
|
||||||
|
</active>
|
||||||
|
</local_symbol>
|
||||||
<scope>
|
<scope>
|
||||||
<normal>
|
<normal>
|
||||||
<border>transparent</border>
|
<border>transparent</border>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
</syntax>
|
</syntax>
|
||||||
|
|
||||||
<selection>
|
<selection>
|
||||||
<location>
|
<token>
|
||||||
<normal>
|
<normal>
|
||||||
<border>transparent</border>
|
<border>transparent</border>
|
||||||
<fill>transparent</fill>
|
<fill>transparent</fill>
|
||||||
@@ -100,7 +100,21 @@
|
|||||||
<border>#B2B2B2</border>
|
<border>#B2B2B2</border>
|
||||||
<fill>#4A4A4A</fill>
|
<fill>#4A4A4A</fill>
|
||||||
</active>
|
</active>
|
||||||
</location>
|
</token>
|
||||||
|
<local_symbol>
|
||||||
|
<normal>
|
||||||
|
<border>transparent</border>
|
||||||
|
<fill>transparent</fill>
|
||||||
|
</normal>
|
||||||
|
<focus>
|
||||||
|
<border>#FF9C3C</border>
|
||||||
|
<fill>transparent</fill>
|
||||||
|
</focus>
|
||||||
|
<active>
|
||||||
|
<border>#FF9C3C</border>
|
||||||
|
<fill>#695540</fill>
|
||||||
|
</active>
|
||||||
|
</local_symbol>
|
||||||
<scope>
|
<scope>
|
||||||
<normal>
|
<normal>
|
||||||
<border>transparent</border>
|
<border>transparent</border>
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ add_files(
|
|||||||
data/graph/Token.cpp
|
data/graph/Token.cpp
|
||||||
data/graph/Token.h
|
data/graph/Token.h
|
||||||
|
|
||||||
|
data/location/LocationType.cpp
|
||||||
|
data/location/LocationType.h
|
||||||
data/location/TokenLocation.cpp
|
data/location/TokenLocation.cpp
|
||||||
data/location/TokenLocation.h
|
data/location/TokenLocation.h
|
||||||
data/location/TokenLocationCollection.cpp
|
data/location/TokenLocationCollection.cpp
|
||||||
@@ -215,6 +217,7 @@ add_files(
|
|||||||
utility/messaging/type/MessageActivateAll.h
|
utility/messaging/type/MessageActivateAll.h
|
||||||
utility/messaging/type/MessageActivateEdge.h
|
utility/messaging/type/MessageActivateEdge.h
|
||||||
utility/messaging/type/MessageActivateFile.h
|
utility/messaging/type/MessageActivateFile.h
|
||||||
|
utility/messaging/type/MessageActivateLocalSymbols.h
|
||||||
utility/messaging/type/MessageActivateNodes.h
|
utility/messaging/type/MessageActivateNodes.h
|
||||||
utility/messaging/type/MessageActivateTokenLocations.h
|
utility/messaging/type/MessageActivateTokenLocations.h
|
||||||
utility/messaging/type/MessageActivateTokenIds.h
|
utility/messaging/type/MessageActivateTokenIds.h
|
||||||
|
|||||||
@@ -86,6 +86,12 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
|||||||
showContents(message);
|
showContents(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeController::handleMessage(MessageActivateLocalSymbols* message)
|
||||||
|
{
|
||||||
|
CodeView* view = getView();
|
||||||
|
view->showActiveLocalSymbolIds(message->symbolIds);
|
||||||
|
}
|
||||||
|
|
||||||
void CodeController::handleMessage(MessageActivateTokens* message)
|
void CodeController::handleMessage(MessageActivateTokens* message)
|
||||||
{
|
{
|
||||||
CodeView* view = getView();
|
CodeView* view = getView();
|
||||||
@@ -358,7 +364,7 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(std::shared_pt
|
|||||||
fileLocations->forEachStartTokenLocation(
|
fileLocations->forEachStartTokenLocation(
|
||||||
[&](TokenLocation* startLoc) -> void
|
[&](TokenLocation* startLoc) -> void
|
||||||
{
|
{
|
||||||
if (startLoc->getType() == TokenLocation::LOCATION_SCOPE)
|
if (startLoc->getType() == LOCATION_SCOPE)
|
||||||
{
|
{
|
||||||
TokenLocation* endLoc = startLoc->getOtherTokenLocation();
|
TokenLocation* endLoc = startLoc->getOtherTokenLocation();
|
||||||
TokenLocation* scopeLoc = scopeLocations->addTokenLocation(
|
TokenLocation* scopeLoc = scopeLocations->addTokenLocation(
|
||||||
@@ -368,7 +374,7 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(std::shared_pt
|
|||||||
startLoc->getColumnNumber(),
|
startLoc->getColumnNumber(),
|
||||||
endLoc->getLineNumber(),
|
endLoc->getLineNumber(),
|
||||||
endLoc->getColumnNumber());
|
endLoc->getColumnNumber());
|
||||||
scopeLoc->setType(TokenLocation::LOCATION_SCOPE);
|
scopeLoc->setType(LOCATION_SCOPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "utility/messaging/MessageListener.h"
|
#include "utility/messaging/MessageListener.h"
|
||||||
#include "utility/messaging/type/MessageActivateAll.h"
|
#include "utility/messaging/type/MessageActivateAll.h"
|
||||||
|
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
|
||||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||||
#include "utility/messaging/type/MessageChangeFileView.h"
|
#include "utility/messaging/type/MessageChangeFileView.h"
|
||||||
#include "utility/messaging/type/MessageFlushUpdates.h"
|
#include "utility/messaging/type/MessageFlushUpdates.h"
|
||||||
@@ -27,6 +28,7 @@ class TokenLocationFile;
|
|||||||
class CodeController
|
class CodeController
|
||||||
: public Controller
|
: public Controller
|
||||||
, public MessageListener<MessageActivateAll>
|
, public MessageListener<MessageActivateAll>
|
||||||
|
, public MessageListener<MessageActivateLocalSymbols>
|
||||||
, public MessageListener<MessageActivateTokens>
|
, public MessageListener<MessageActivateTokens>
|
||||||
, public MessageListener<MessageChangeFileView>
|
, public MessageListener<MessageChangeFileView>
|
||||||
, public MessageListener<MessageFlushUpdates>
|
, public MessageListener<MessageFlushUpdates>
|
||||||
@@ -44,6 +46,7 @@ private:
|
|||||||
static const uint s_lineRadius;
|
static const uint s_lineRadius;
|
||||||
|
|
||||||
virtual void handleMessage(MessageActivateAll* message);
|
virtual void handleMessage(MessageActivateAll* message);
|
||||||
|
virtual void handleMessage(MessageActivateLocalSymbols* message);
|
||||||
virtual void handleMessage(MessageActivateTokens* message);
|
virtual void handleMessage(MessageActivateTokens* message);
|
||||||
virtual void handleMessage(MessageChangeFileView* message);
|
virtual void handleMessage(MessageChangeFileView* message);
|
||||||
virtual void handleMessage(MessageFlushUpdates* message);
|
virtual void handleMessage(MessageFlushUpdates* message);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ void FeatureController::handleMessage(MessageActivateTokenLocations* message)
|
|||||||
nodeId,
|
nodeId,
|
||||||
m_storageAccess->getNodeTypeForNodeWithId(nodeId),
|
m_storageAccess->getNodeTypeForNodeWithId(nodeId),
|
||||||
m_storageAccess->getNameHierarchyForNodeWithId(nodeId)
|
m_storageAccess->getNameHierarchyForNodeWithId(nodeId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
m.dispatchImmediately();
|
m.dispatchImmediately();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "utility/logging/logging.h"
|
#include "utility/logging/logging.h"
|
||||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||||
#include "utility/messaging/type/MessageFlushUpdates.h"
|
#include "utility/messaging/type/MessageFlushUpdates.h"
|
||||||
|
#include "utility/utility.h"
|
||||||
|
|
||||||
#include "component/view/UndoRedoView.h"
|
#include "component/view/UndoRedoView.h"
|
||||||
#include "data/access/StorageAccess.h"
|
#include "data/access/StorageAccess.h"
|
||||||
@@ -52,10 +53,26 @@ void UndoRedoController::handleMessage(MessageActivateFile* message)
|
|||||||
processCommand(command);
|
processCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UndoRedoController::handleMessage(MessageActivateLocalSymbols* message)
|
||||||
|
{
|
||||||
|
if (m_lastCommand.message &&
|
||||||
|
m_lastCommand.message->getType() == message->getType() &&
|
||||||
|
utility::isPermutation(
|
||||||
|
message->symbolIds,
|
||||||
|
static_cast<MessageActivateLocalSymbols*>(m_lastCommand.message.get())->symbolIds)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command command(std::make_shared<MessageActivateLocalSymbols>(*message), 1);
|
||||||
|
processCommand(command);
|
||||||
|
}
|
||||||
|
|
||||||
void UndoRedoController::handleMessage(MessageActivateNodes* message)
|
void UndoRedoController::handleMessage(MessageActivateNodes* message)
|
||||||
{
|
{
|
||||||
if (m_lastCommand.message &&
|
if (m_lastCommand.message &&
|
||||||
m_lastCommand.message->getType() == message->getType() &&
|
m_lastCommand.message->getType() == message->getType() &&
|
||||||
message->nodes.size() &&
|
message->nodes.size() &&
|
||||||
static_cast<MessageActivateNodes*>(m_lastCommand.message.get())->nodes.size() == message->nodes.size() &&
|
static_cast<MessageActivateNodes*>(m_lastCommand.message.get())->nodes.size() == message->nodes.size() &&
|
||||||
static_cast<MessageActivateNodes*>(m_lastCommand.message.get())->nodes[0].nameHierarchy.getQualifiedNameWithSignature() ==
|
static_cast<MessageActivateNodes*>(m_lastCommand.message.get())->nodes[0].nameHierarchy.getQualifiedNameWithSignature() ==
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "utility/messaging/MessageListener.h"
|
#include "utility/messaging/MessageListener.h"
|
||||||
#include "utility/messaging/type/MessageActivateEdge.h"
|
#include "utility/messaging/type/MessageActivateEdge.h"
|
||||||
#include "utility/messaging/type/MessageActivateFile.h"
|
#include "utility/messaging/type/MessageActivateFile.h"
|
||||||
|
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
|
||||||
#include "utility/messaging/type/MessageActivateNodes.h"
|
#include "utility/messaging/type/MessageActivateNodes.h"
|
||||||
#include "utility/messaging/type/MessageActivateTokenIds.h"
|
#include "utility/messaging/type/MessageActivateTokenIds.h"
|
||||||
#include "utility/messaging/type/MessageChangeFileView.h"
|
#include "utility/messaging/type/MessageChangeFileView.h"
|
||||||
@@ -32,6 +33,7 @@ class UndoRedoController
|
|||||||
: public Controller
|
: public Controller
|
||||||
, public MessageListener<MessageActivateEdge>
|
, public MessageListener<MessageActivateEdge>
|
||||||
, public MessageListener<MessageActivateFile>
|
, public MessageListener<MessageActivateFile>
|
||||||
|
, public MessageListener<MessageActivateLocalSymbols>
|
||||||
, public MessageListener<MessageActivateNodes>
|
, public MessageListener<MessageActivateNodes>
|
||||||
, public MessageListener<MessageActivateTokenIds>
|
, public MessageListener<MessageActivateTokenIds>
|
||||||
, public MessageListener<MessageChangeFileView>
|
, public MessageListener<MessageChangeFileView>
|
||||||
@@ -65,6 +67,7 @@ private:
|
|||||||
|
|
||||||
virtual void handleMessage(MessageActivateEdge* message);
|
virtual void handleMessage(MessageActivateEdge* message);
|
||||||
virtual void handleMessage(MessageActivateFile* message);
|
virtual void handleMessage(MessageActivateFile* message);
|
||||||
|
virtual void handleMessage(MessageActivateLocalSymbols* message);
|
||||||
virtual void handleMessage(MessageActivateNodes* message);
|
virtual void handleMessage(MessageActivateNodes* message);
|
||||||
virtual void handleMessage(MessageActivateTokenIds* message);
|
virtual void handleMessage(MessageActivateTokenIds* message);
|
||||||
virtual void handleMessage(MessageChangeFileView* message);
|
virtual void handleMessage(MessageChangeFileView* message);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
|
|
||||||
virtual void showFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo) = 0;
|
virtual void showFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo) = 0;
|
||||||
virtual void showActiveTokenIds(const std::vector<Id>& activeTokenIds) = 0;
|
virtual void showActiveTokenIds(const std::vector<Id>& activeTokenIds) = 0;
|
||||||
|
virtual void showActiveLocalSymbolIds(const std::vector<Id>& activeLocalSymbolIds) = 0;
|
||||||
|
|
||||||
virtual void focusTokenIds(const std::vector<Id>& focusedTokenIds) = 0;
|
virtual void focusTokenIds(const std::vector<Id>& focusedTokenIds) = 0;
|
||||||
virtual void defocusTokenIds() = 0;
|
virtual void defocusTokenIds() = 0;
|
||||||
|
|||||||
@@ -108,7 +108,25 @@ Id IntermediateStorage::addFile(const std::string& filePath)
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntermediateStorage::addSourceLocation(Id elementId, const ParseLocation& location, bool isScope)
|
Id IntermediateStorage::addLocalSymbol(const std::string& name)
|
||||||
|
{
|
||||||
|
std::shared_ptr<StorageLocalSymbol> localSymbol = std::make_shared<StorageLocalSymbol>(0, name);
|
||||||
|
|
||||||
|
std::string serialized = serialize(*(localSymbol.get()));
|
||||||
|
std::unordered_map<std::string, Id>::const_iterator it = m_localSymbolNamesToIds.find(serialized);
|
||||||
|
if (it != m_localSymbolNamesToIds.end())
|
||||||
|
{
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
Id id = m_nextId++;
|
||||||
|
m_localSymbolNamesToIds[serialized] = id;
|
||||||
|
m_localSymbolIdsToData[id] = localSymbol;
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntermediateStorage::addSourceLocation(Id elementId, const ParseLocation& location, int type)
|
||||||
{
|
{
|
||||||
Id fileNodeId = addFile(location.filePath.str());
|
Id fileNodeId = addFile(location.filePath.str());
|
||||||
m_sourceLocations.push_back(StorageSourceLocation(
|
m_sourceLocations.push_back(StorageSourceLocation(
|
||||||
@@ -119,7 +137,7 @@ void IntermediateStorage::addSourceLocation(Id elementId, const ParseLocation& l
|
|||||||
location.startColumnNumber,
|
location.startColumnNumber,
|
||||||
location.endLineNumber,
|
location.endLineNumber,
|
||||||
location.endColumnNumber,
|
location.endColumnNumber,
|
||||||
isScope
|
type
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,6 +256,18 @@ void IntermediateStorage::transferToStorage(SqliteStorage& storage)
|
|||||||
clientIdToStorageId[it->first] = edgeId;
|
clientIdToStorageId[it->first] = edgeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (std::map<Id, std::shared_ptr<StorageLocalSymbol>>::const_iterator it = m_localSymbolIdsToData.begin(); it != m_localSymbolIdsToData.end(); it++)
|
||||||
|
{
|
||||||
|
StorageLocalSymbol clientLocalSymbol = *(it->second.get());
|
||||||
|
StorageLocalSymbol storageLocalSymbol = storage.getLocalSymbolByName(clientLocalSymbol.name);
|
||||||
|
Id storageLocalSymbolId = storageLocalSymbol.id;
|
||||||
|
if (storageLocalSymbolId == 0)
|
||||||
|
{
|
||||||
|
storageLocalSymbolId = storage.addLocalSymbol(clientLocalSymbol.name);
|
||||||
|
}
|
||||||
|
clientIdToStorageId[it->first] = storageLocalSymbolId;
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < m_sourceLocations.size(); i++)
|
for (size_t i = 0; i < m_sourceLocations.size(); i++)
|
||||||
{
|
{
|
||||||
StorageSourceLocation sourceLocation = m_sourceLocations[i];
|
StorageSourceLocation sourceLocation = m_sourceLocations[i];
|
||||||
@@ -263,7 +293,7 @@ void IntermediateStorage::transferToStorage(SqliteStorage& storage)
|
|||||||
sourceLocation.startCol,
|
sourceLocation.startCol,
|
||||||
sourceLocation.endLine,
|
sourceLocation.endLine,
|
||||||
sourceLocation.endCol,
|
sourceLocation.endCol,
|
||||||
sourceLocation.isScope
|
sourceLocation.type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,3 +423,8 @@ std::string IntermediateStorage::serialize(const StorageFile& file)
|
|||||||
{
|
{
|
||||||
return file.filePath;
|
return file.filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string IntermediateStorage::serialize(const StorageLocalSymbol& localSymbol)
|
||||||
|
{
|
||||||
|
return localSymbol.name;
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ public:
|
|||||||
Id addNode(int type, const NameHierarchy& nameHierarchy, int definitionType);
|
Id addNode(int type, const NameHierarchy& nameHierarchy, int definitionType);
|
||||||
Id addFile(const std::string& name, const std::string& filePath, const std::string& modificationTime);
|
Id addFile(const std::string& name, const std::string& filePath, const std::string& modificationTime);
|
||||||
Id addFile(const std::string& filePath);
|
Id addFile(const std::string& filePath);
|
||||||
void addSourceLocation(Id elementId, const ParseLocation& location, bool isScope);
|
Id addLocalSymbol(const std::string& name);
|
||||||
|
void addSourceLocation(Id elementId, const ParseLocation& location, int type);
|
||||||
void addComponentAccess(Id nodeId , int type);
|
void addComponentAccess(Id nodeId , int type);
|
||||||
void addCommentLocation(const ParseLocation& location);
|
void addCommentLocation(const ParseLocation& location);
|
||||||
void addError(const std::string& message, bool fatal, const ParseLocation& location);
|
void addError(const std::string& message, bool fatal, const ParseLocation& location);
|
||||||
@@ -40,6 +41,7 @@ private:
|
|||||||
std::string serialize(const StorageEdge& edge);
|
std::string serialize(const StorageEdge& edge);
|
||||||
std::string serialize(const StorageNode& node);
|
std::string serialize(const StorageNode& node);
|
||||||
std::string serialize(const StorageFile& file);
|
std::string serialize(const StorageFile& file);
|
||||||
|
std::string serialize(const StorageLocalSymbol& localSymbol);
|
||||||
|
|
||||||
std::unordered_map<std::string, Id> m_fileNamesToIds; // this is used to prevent duplicates (unique)
|
std::unordered_map<std::string, Id> m_fileNamesToIds; // this is used to prevent duplicates (unique)
|
||||||
std::unordered_map<Id, std::shared_ptr<StorageFile>> m_fileIdsToData;
|
std::unordered_map<Id, std::shared_ptr<StorageFile>> m_fileIdsToData;
|
||||||
@@ -50,6 +52,10 @@ private:
|
|||||||
std::unordered_map<std::string, Id> m_edgeNamesToIds; // this is used to prevent duplicates (unique)
|
std::unordered_map<std::string, Id> m_edgeNamesToIds; // this is used to prevent duplicates (unique)
|
||||||
std::map<Id, std::shared_ptr<StorageEdge>> m_edgeIdsToData;
|
std::map<Id, std::shared_ptr<StorageEdge>> m_edgeIdsToData;
|
||||||
|
|
||||||
|
|
||||||
|
std::unordered_map<std::string, Id> m_localSymbolNamesToIds; // this is used to prevent duplicates (unique)
|
||||||
|
std::map<Id, std::shared_ptr<StorageLocalSymbol>> m_localSymbolIdsToData;
|
||||||
|
|
||||||
std::vector<StorageSourceLocation> m_sourceLocations;
|
std::vector<StorageSourceLocation> m_sourceLocations;
|
||||||
std::vector<StorageComponentAccess> m_componentAccesses;
|
std::vector<StorageComponentAccess> m_componentAccesses;
|
||||||
std::vector<StorageCommentLocation> m_commentLocations;
|
std::vector<StorageCommentLocation> m_commentLocations;
|
||||||
|
|||||||
@@ -136,14 +136,29 @@ Id SqliteStorage::addFile(const std::string& serializedName, const std::string&
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Id SqliteStorage::addLocalSymbol(const std::string& name)
|
||||||
|
{
|
||||||
|
m_database.execDML(
|
||||||
|
"INSERT INTO element(id) VALUES(NULL);"
|
||||||
|
);
|
||||||
|
Id id = m_database.lastRowId();
|
||||||
|
|
||||||
|
m_database.execDML((
|
||||||
|
"INSERT INTO local_symbol(id, name) VALUES("
|
||||||
|
+ std::to_string(id) + ", '" + name + "');"
|
||||||
|
).c_str());
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
Id SqliteStorage::addSourceLocation(
|
Id SqliteStorage::addSourceLocation(
|
||||||
Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, bool isScope)
|
Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type)
|
||||||
{
|
{
|
||||||
m_database.execDML((
|
m_database.execDML((
|
||||||
"INSERT INTO source_location(id, element_id, file_node_id, start_line, start_column, end_line, end_column, is_scope) "
|
"INSERT INTO source_location(id, element_id, file_node_id, start_line, start_column, end_line, end_column, type) "
|
||||||
"VALUES(NULL, " + std::to_string(elementId) + ", " + std::to_string(fileNodeId) + ", "
|
"VALUES(NULL, " + std::to_string(elementId) + ", " + std::to_string(fileNodeId) + ", "
|
||||||
+ std::to_string(startLine) + ", " + std::to_string(startCol) + ", "
|
+ std::to_string(startLine) + ", " + std::to_string(startCol) + ", "
|
||||||
+ std::to_string(endLine) + ", " + std::to_string(endCol) + ", " + std::to_string(isScope) + ");"
|
+ std::to_string(endLine) + ", " + std::to_string(endCol) + ", " + std::to_string(type) + ");"
|
||||||
).c_str());
|
).c_str());
|
||||||
|
|
||||||
return m_database.lastRowId();
|
return m_database.lastRowId();
|
||||||
@@ -420,6 +435,18 @@ std::vector<StorageNode> SqliteStorage::getNodesByIds(const std::vector<Id>& nod
|
|||||||
return getAllNodes("WHERE id IN (" + utility::join(utility::toStrings(nodeIds), ',') + ")");
|
return getAllNodes("WHERE id IN (" + utility::join(utility::toStrings(nodeIds), ',') + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StorageLocalSymbol SqliteStorage::getLocalSymbolByName(const std::string& name) const
|
||||||
|
{
|
||||||
|
StorageLocalSymbol localSymbol(
|
||||||
|
getFirstResult<Id>(
|
||||||
|
"SELECT id FROM local_symbol WHERE "
|
||||||
|
"name == '" + name + "';"
|
||||||
|
),
|
||||||
|
name
|
||||||
|
);
|
||||||
|
return localSymbol;
|
||||||
|
}
|
||||||
|
|
||||||
StorageFile SqliteStorage::getFileById(const Id id) const
|
StorageFile SqliteStorage::getFileById(const Id id) const
|
||||||
{
|
{
|
||||||
return getFirstFile(
|
return getFirstFile(
|
||||||
@@ -474,7 +501,7 @@ void SqliteStorage::setNodeDefinitionType(int definitionType, Id nodeId)
|
|||||||
StorageSourceLocation SqliteStorage::getSourceLocationById(const Id id) const
|
StorageSourceLocation SqliteStorage::getSourceLocationById(const Id id) const
|
||||||
{
|
{
|
||||||
return getFirstSourceLocation(
|
return getFirstSourceLocation(
|
||||||
"SELECT id, element_id, file_node_id, start_line, start_column, end_line, end_column, is_scope FROM source_location WHERE id == " + std::to_string(id) + ";"
|
"SELECT id, element_id, file_node_id, start_line, start_column, end_line, end_column, type FROM source_location WHERE id == " + std::to_string(id) + ";"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,7 +516,7 @@ std::shared_ptr<TokenLocationFile> SqliteStorage::getTokenLocationsForFile(const
|
|||||||
}
|
}
|
||||||
|
|
||||||
CppSQLite3Query q = m_database.execQuery((
|
CppSQLite3Query q = m_database.execQuery((
|
||||||
"SELECT id, element_id, start_line, start_column, end_line, end_column, is_scope FROM source_location WHERE file_node_id == " + std::to_string(fileNodeId) + ";"
|
"SELECT id, element_id, start_line, start_column, end_line, end_column, type FROM source_location WHERE file_node_id == " + std::to_string(fileNodeId) + ";"
|
||||||
).c_str());
|
).c_str());
|
||||||
|
|
||||||
while (!q.eof())
|
while (!q.eof())
|
||||||
@@ -500,12 +527,12 @@ std::shared_ptr<TokenLocationFile> SqliteStorage::getTokenLocationsForFile(const
|
|||||||
const int startColNumber = q.getIntField(3, -1);
|
const int startColNumber = q.getIntField(3, -1);
|
||||||
const int endLineNumber = q.getIntField(4, -1);
|
const int endLineNumber = q.getIntField(4, -1);
|
||||||
const int endColNumber = q.getIntField(5, -1);
|
const int endColNumber = q.getIntField(5, -1);
|
||||||
const int isScope = q.getIntField(6, -1);
|
const int type = q.getIntField(6, -1);
|
||||||
|
|
||||||
if (locationId != 0 && elementId != 0 && startLineNumber != -1 && startColNumber != -1 && endLineNumber != -1 && endColNumber != -1 && isScope != -1)
|
if (locationId != 0 && elementId != 0 && startLineNumber != -1 && startColNumber != -1 && endLineNumber != -1 && endColNumber != -1 && type != -1)
|
||||||
{
|
{
|
||||||
TokenLocation* loc = ret->addTokenLocation(locationId, elementId, startLineNumber, startColNumber, endLineNumber, endColNumber);
|
TokenLocation* loc = ret->addTokenLocation(locationId, elementId, startLineNumber, startColNumber, endLineNumber, endColNumber);
|
||||||
loc->setType(isScope ? TokenLocation::LOCATION_SCOPE : TokenLocation::LOCATION_TOKEN);
|
loc->setType(intToLocationType(type));
|
||||||
}
|
}
|
||||||
q.nextRow();
|
q.nextRow();
|
||||||
}
|
}
|
||||||
@@ -524,7 +551,7 @@ std::vector<StorageSourceLocation> SqliteStorage::getTokenLocationsForElementIds
|
|||||||
std::vector<StorageSourceLocation> locations;
|
std::vector<StorageSourceLocation> locations;
|
||||||
|
|
||||||
CppSQLite3Query q = m_database.execQuery((
|
CppSQLite3Query q = m_database.execQuery((
|
||||||
"SELECT id, element_id, file_node_id, start_line, start_column, end_line, end_column, is_scope FROM source_location WHERE element_id IN (" + utility::join(utility::toStrings(elementIds), ',') + ");"
|
"SELECT id, element_id, file_node_id, start_line, start_column, end_line, end_column, type FROM source_location WHERE element_id IN (" + utility::join(utility::toStrings(elementIds), ',') + ");"
|
||||||
).c_str());
|
).c_str());
|
||||||
|
|
||||||
while (!q.eof())
|
while (!q.eof())
|
||||||
@@ -536,12 +563,12 @@ std::vector<StorageSourceLocation> SqliteStorage::getTokenLocationsForElementIds
|
|||||||
const int startColNumber = q.getIntField(4, -1);
|
const int startColNumber = q.getIntField(4, -1);
|
||||||
const int endLineNumber = q.getIntField(5, -1);
|
const int endLineNumber = q.getIntField(5, -1);
|
||||||
const int endColNumber = q.getIntField(6, -1);
|
const int endColNumber = q.getIntField(6, -1);
|
||||||
const int isScope = q.getIntField(7, -1);
|
const int type = q.getIntField(7, -1);
|
||||||
|
|
||||||
if (id != 0 && elementId != 0 && fileNodeId != 0 && startLineNumber != -1 && startColNumber != -1 && endLineNumber != -1 && endColNumber != -1 && isScope != -1)
|
if (id != 0 && elementId != 0 && fileNodeId != 0 && startLineNumber != -1 && startColNumber != -1 && endLineNumber != -1 && endColNumber != -1 && type != -1)
|
||||||
{
|
{
|
||||||
locations.push_back(StorageSourceLocation(
|
locations.push_back(StorageSourceLocation(
|
||||||
id, elementId, fileNodeId, startLineNumber, startColNumber, endLineNumber, endColNumber, isScope
|
id, elementId, fileNodeId, startLineNumber, startColNumber, endLineNumber, endColNumber, type
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
q.nextRow();
|
q.nextRow();
|
||||||
@@ -700,6 +727,7 @@ void SqliteStorage::clearTables()
|
|||||||
m_database.execDML("DROP TABLE IF EXISTS main.comment_location;");
|
m_database.execDML("DROP TABLE IF EXISTS main.comment_location;");
|
||||||
m_database.execDML("DROP TABLE IF EXISTS main.component_access;");
|
m_database.execDML("DROP TABLE IF EXISTS main.component_access;");
|
||||||
m_database.execDML("DROP TABLE IF EXISTS main.source_location;");
|
m_database.execDML("DROP TABLE IF EXISTS main.source_location;");
|
||||||
|
m_database.execDML("DROP TABLE IF EXISTS main.local_symbol;");
|
||||||
m_database.execDML("DROP TABLE IF EXISTS main.file;");
|
m_database.execDML("DROP TABLE IF EXISTS main.file;");
|
||||||
m_database.execDML("DROP TABLE IF EXISTS main.node;");
|
m_database.execDML("DROP TABLE IF EXISTS main.node;");
|
||||||
m_database.execDML("DROP TABLE IF EXISTS main.edge;");
|
m_database.execDML("DROP TABLE IF EXISTS main.edge;");
|
||||||
@@ -764,6 +792,14 @@ void SqliteStorage::setupTables()
|
|||||||
"FOREIGN KEY(id) REFERENCES node(id) ON DELETE CASCADE);"
|
"FOREIGN KEY(id) REFERENCES node(id) ON DELETE CASCADE);"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
m_database.execDML(
|
||||||
|
"CREATE TABLE IF NOT EXISTS local_symbol("
|
||||||
|
"id INTEGER NOT NULL, "
|
||||||
|
"name TEXT, "
|
||||||
|
"PRIMARY KEY(id), "
|
||||||
|
"FOREIGN KEY(id) REFERENCES element(id) ON DELETE CASCADE);"
|
||||||
|
);
|
||||||
|
|
||||||
m_database.execDML(
|
m_database.execDML(
|
||||||
"CREATE TABLE IF NOT EXISTS source_location("
|
"CREATE TABLE IF NOT EXISTS source_location("
|
||||||
"id INTEGER NOT NULL, "
|
"id INTEGER NOT NULL, "
|
||||||
@@ -773,7 +809,7 @@ void SqliteStorage::setupTables()
|
|||||||
"start_column INTEGER, "
|
"start_column INTEGER, "
|
||||||
"end_line INTEGER, "
|
"end_line INTEGER, "
|
||||||
"end_column INTEGER, "
|
"end_column INTEGER, "
|
||||||
"is_scope INTEGER, "
|
"type INTEGER, "
|
||||||
"PRIMARY KEY(id), "
|
"PRIMARY KEY(id), "
|
||||||
"FOREIGN KEY(element_id) REFERENCES element(id) ON DELETE CASCADE, "
|
"FOREIGN KEY(element_id) REFERENCES element(id) ON DELETE CASCADE, "
|
||||||
"FOREIGN KEY(file_node_id) REFERENCES node(id) ON DELETE CASCADE);"
|
"FOREIGN KEY(file_node_id) REFERENCES node(id) ON DELETE CASCADE);"
|
||||||
@@ -907,12 +943,12 @@ StorageSourceLocation SqliteStorage::getFirstSourceLocation(const std::string& q
|
|||||||
const int startColNumber = q.getIntField(4, -1);
|
const int startColNumber = q.getIntField(4, -1);
|
||||||
const int endLineNumber = q.getIntField(5, -1);
|
const int endLineNumber = q.getIntField(5, -1);
|
||||||
const int endColNumber = q.getIntField(6, -1);
|
const int endColNumber = q.getIntField(6, -1);
|
||||||
const int isScope = q.getIntField(7, -1);
|
const int type = q.getIntField(7, -1);
|
||||||
|
|
||||||
if (id != 0 && elementId != 0 && fileNodeId != 0 && startLineNumber != -1 && startColNumber != -1 && endLineNumber != -1 && endColNumber != -1 && isScope != -1)
|
if (id != 0 && elementId != 0 && fileNodeId != 0 && startLineNumber != -1 && startColNumber != -1 && endLineNumber != -1 && endColNumber != -1 && type != -1)
|
||||||
{
|
{
|
||||||
return StorageSourceLocation(
|
return StorageSourceLocation(
|
||||||
id, elementId, fileNodeId, startLineNumber, startColNumber, endLineNumber, endColNumber, isScope
|
id, elementId, fileNodeId, startLineNumber, startColNumber, endLineNumber, endColNumber, type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ public:
|
|||||||
Id addEdge(int type, Id sourceNodeId, Id targetNodeId);
|
Id addEdge(int type, Id sourceNodeId, Id targetNodeId);
|
||||||
Id addNode(int type, const std::string& serializedName, int definitionType);
|
Id addNode(int type, const std::string& serializedName, int definitionType);
|
||||||
Id addFile(const std::string& serializedName, const std::string& filePath, const std::string& modificationTime);
|
Id addFile(const std::string& serializedName, const std::string& filePath, const std::string& modificationTime);
|
||||||
Id addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, bool isScope);
|
Id addLocalSymbol(const std::string& name);
|
||||||
|
Id addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
|
||||||
|
|
||||||
Id addComponentAccess(Id memberEdgeId, int type);
|
Id addComponentAccess(Id memberEdgeId, int type);
|
||||||
|
|
||||||
@@ -75,6 +76,8 @@ public:
|
|||||||
StorageNode getNodeBySerializedName(const std::string& serializedName) const;
|
StorageNode getNodeBySerializedName(const std::string& serializedName) const;
|
||||||
std::vector<StorageNode> getNodesByIds(const std::vector<Id>& nodeIds) const;
|
std::vector<StorageNode> getNodesByIds(const std::vector<Id>& nodeIds) const;
|
||||||
|
|
||||||
|
StorageLocalSymbol getLocalSymbolByName(const std::string& name) const;
|
||||||
|
|
||||||
StorageFile getFileById(const Id id) const;
|
StorageFile getFileById(const Id id) const;
|
||||||
StorageFile getFileByPath(const std::string& filePath) const;
|
StorageFile getFileByPath(const std::string& filePath) const;
|
||||||
std::vector<StorageFile> getAllFiles() const;
|
std::vector<StorageFile> getAllFiles() const;
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ std::vector<Id> Storage::getNodeIdsForLocationIds(const std::vector<Id>& locatio
|
|||||||
{
|
{
|
||||||
edgeIds.insert(edge.targetNodeId);
|
edgeIds.insert(edge.targetNodeId);
|
||||||
}
|
}
|
||||||
else
|
else if(m_sqliteStorage.isNode(elementId))
|
||||||
{
|
{
|
||||||
StorageNode node = m_sqliteStorage.getNodeById(elementId);
|
StorageNode node = m_sqliteStorage.getNodeById(elementId);
|
||||||
if (node.id != 0 && intToDefinitionType(node.definitionType) == DEFINITION_EXPLICIT)
|
if (node.id != 0 && intToDefinitionType(node.definitionType) == DEFINITION_EXPLICIT)
|
||||||
@@ -474,6 +474,23 @@ std::vector<Id> Storage::getNodeIdsForLocationIds(const std::vector<Id>& locatio
|
|||||||
return utility::toVector(edgeIds);
|
return utility::toVector(edgeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Id> Storage::getLocalSymbolIdsForLocationIds(const std::vector<Id>& locationIds) const
|
||||||
|
{
|
||||||
|
std::set<Id> localSymbolIds;
|
||||||
|
|
||||||
|
for (Id locationId : locationIds)
|
||||||
|
{
|
||||||
|
Id elementId = m_sqliteStorage.getElementIdByLocationId(locationId);
|
||||||
|
|
||||||
|
if (m_sqliteStorage.getNodeById(elementId).id == 0 && m_sqliteStorage.getEdgeById(elementId).id == 0)
|
||||||
|
{
|
||||||
|
localSymbolIds.insert(elementId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return utility::toVector(localSymbolIds);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Id> Storage::getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const
|
std::vector<Id> Storage::getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const
|
||||||
{
|
{
|
||||||
std::set<Id> idSet;
|
std::set<Id> idSet;
|
||||||
@@ -584,7 +601,7 @@ std::shared_ptr<TokenLocationCollection> Storage::getTokenLocationsForTokenIds(c
|
|||||||
|
|
||||||
if (loc)
|
if (loc)
|
||||||
{
|
{
|
||||||
loc->setType(location.isScope ? TokenLocation::LOCATION_SCOPE : TokenLocation::LOCATION_TOKEN);
|
loc->setType(intToLocationType(location.type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,8 +622,8 @@ std::shared_ptr<TokenLocationCollection> Storage::getTokenLocationsForLocationId
|
|||||||
location.startLine,
|
location.startLine,
|
||||||
location.startCol,
|
location.startCol,
|
||||||
location.endLine,
|
location.endLine,
|
||||||
location.endCol)->setType(location.isScope ? TokenLocation::LOCATION_SCOPE : TokenLocation::LOCATION_TOKEN
|
location.endCol
|
||||||
);
|
)->setType(intToLocationType(location.type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return collection;
|
return collection;
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public:
|
|||||||
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const;
|
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const;
|
||||||
|
|
||||||
virtual std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const;
|
virtual std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const;
|
||||||
|
virtual std::vector<Id> getLocalSymbolIdsForLocationIds(const std::vector<Id>& locationIds) const;
|
||||||
|
|
||||||
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const;
|
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const;
|
||||||
virtual Id getTokenIdForFileNode(const FilePath& filePath) const;
|
virtual Id getTokenIdForFileNode(const FilePath& filePath) const;
|
||||||
|
|||||||
@@ -50,9 +50,20 @@ struct StorageFile
|
|||||||
std::string modificationTime;
|
std::string modificationTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct StorageLocalSymbol
|
||||||
|
{
|
||||||
|
StorageLocalSymbol(Id id, const std::string& name)
|
||||||
|
: id(id)
|
||||||
|
, name(name)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Id id;
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
struct StorageSourceLocation
|
struct StorageSourceLocation
|
||||||
{
|
{
|
||||||
StorageSourceLocation(Id id, Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, bool isScope)
|
StorageSourceLocation(Id id, Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type)
|
||||||
: id(id)
|
: id(id)
|
||||||
, elementId(elementId)
|
, elementId(elementId)
|
||||||
, fileNodeId(fileNodeId)
|
, fileNodeId(fileNodeId)
|
||||||
@@ -60,7 +71,7 @@ struct StorageSourceLocation
|
|||||||
, startCol(startCol)
|
, startCol(startCol)
|
||||||
, endLine(endLine)
|
, endLine(endLine)
|
||||||
, endCol(endCol)
|
, endCol(endCol)
|
||||||
, isScope(isScope)
|
, type(type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Id id;
|
Id id;
|
||||||
@@ -70,7 +81,7 @@ struct StorageSourceLocation
|
|||||||
uint startCol;
|
uint startCol;
|
||||||
uint endLine;
|
uint endLine;
|
||||||
uint endCol;
|
uint endCol;
|
||||||
bool isScope;
|
int type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StorageComponentAccess
|
struct StorageComponentAccess
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public:
|
|||||||
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const = 0;
|
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const = 0;
|
||||||
|
|
||||||
virtual std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const = 0;
|
virtual std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const = 0;
|
||||||
|
virtual std::vector<Id> getLocalSymbolIdsForLocationIds(const std::vector<Id>& locationIds) const = 0;
|
||||||
|
|
||||||
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const = 0;
|
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const = 0;
|
||||||
virtual Id getTokenIdForFileNode(const FilePath& filePath) const = 0;
|
virtual Id getTokenIdForFileNode(const FilePath& filePath) const = 0;
|
||||||
|
|||||||
@@ -143,6 +143,16 @@ std::vector<Id> StorageAccessProxy::getNodeIdsForLocationIds(const std::vector<I
|
|||||||
return std::vector<Id>();
|
return std::vector<Id>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Id> StorageAccessProxy::getLocalSymbolIdsForLocationIds(const std::vector<Id>& locationIds) const
|
||||||
|
{
|
||||||
|
if (hasSubject())
|
||||||
|
{
|
||||||
|
return m_subject->getLocalSymbolIdsForLocationIds(locationIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::vector<Id>();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Id> StorageAccessProxy::getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const
|
std::vector<Id> StorageAccessProxy::getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const
|
||||||
{
|
{
|
||||||
if (hasSubject())
|
if (hasSubject())
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const;
|
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const;
|
||||||
|
|
||||||
virtual std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const;
|
virtual std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const;
|
||||||
|
virtual std::vector<Id> getLocalSymbolIdsForLocationIds(const std::vector<Id>& locationIds) const;
|
||||||
|
|
||||||
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const;
|
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const;
|
||||||
virtual Id getTokenIdForFileNode(const FilePath& filePath) const;
|
virtual Id getTokenIdForFileNode(const FilePath& filePath) const;
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include "data/location/LocationType.h"
|
||||||
|
|
||||||
|
int locationTypeToInt(LocationType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case LOCATION_TOKEN:
|
||||||
|
return 0;
|
||||||
|
case LOCATION_SCOPE:
|
||||||
|
return 1;
|
||||||
|
case LOCATION_LOCAL_SYMBOL:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LocationType intToLocationType(int value)
|
||||||
|
{
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return LOCATION_TOKEN;
|
||||||
|
case 1:
|
||||||
|
return LOCATION_SCOPE;
|
||||||
|
case 2:
|
||||||
|
return LOCATION_LOCAL_SYMBOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef LOCATION_TYPE_H
|
||||||
|
#define LOCATION_TYPE_H
|
||||||
|
|
||||||
|
enum LocationType
|
||||||
|
{
|
||||||
|
LOCATION_TOKEN,
|
||||||
|
LOCATION_SCOPE,
|
||||||
|
LOCATION_LOCAL_SYMBOL
|
||||||
|
};
|
||||||
|
|
||||||
|
int locationTypeToInt(LocationType type);
|
||||||
|
LocationType intToLocationType(int value);
|
||||||
|
|
||||||
|
#endif // LOCATION_TYPE_H
|
||||||
@@ -69,7 +69,7 @@ Id TokenLocation::getTokenId() const
|
|||||||
return m_tokenId;
|
return m_tokenId;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenLocation::LocationType TokenLocation::getType() const
|
LocationType TokenLocation::getType() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "data/location/LocationType.h"
|
||||||
#include "utility/file/FilePath.h"
|
#include "utility/file/FilePath.h"
|
||||||
#include "utility/types.h"
|
#include "utility/types.h"
|
||||||
|
|
||||||
@@ -15,13 +16,6 @@ class TokenLocationLine;
|
|||||||
class TokenLocation
|
class TokenLocation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum LocationType
|
|
||||||
{
|
|
||||||
LOCATION_TOKEN,
|
|
||||||
LOCATION_SCOPE
|
|
||||||
};
|
|
||||||
|
|
||||||
TokenLocation(Id tokenId, TokenLocationLine* line, unsigned int columnNumber, bool isStart);
|
|
||||||
TokenLocation(Id locationId, Id tokenId, TokenLocationLine* line, unsigned int columnNumber, bool isStart);
|
TokenLocation(Id locationId, Id tokenId, TokenLocationLine* line, unsigned int columnNumber, bool isStart);
|
||||||
TokenLocation(TokenLocation* other, TokenLocationLine* line, unsigned int columnNumber, bool isStart);
|
TokenLocation(TokenLocation* other, TokenLocationLine* line, unsigned int columnNumber, bool isStart);
|
||||||
TokenLocation(const TokenLocation& other, TokenLocationLine* line);
|
TokenLocation(const TokenLocation& other, TokenLocationLine* line);
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ public:
|
|||||||
virtual Id onTemplateMemberFunctionSpecializationParsed(
|
virtual Id onTemplateMemberFunctionSpecializationParsed(
|
||||||
const ParseLocation& location, const NameHierarchy& instantiatedFunction, const NameHierarchy& specializedFunction) = 0;
|
const ParseLocation& location, const NameHierarchy& instantiatedFunction, const NameHierarchy& specializedFunction) = 0;
|
||||||
|
|
||||||
|
virtual Id onLocalSymbolParsed(const std::string& name, const ParseLocation& location) = 0;
|
||||||
|
|
||||||
virtual Id onFileParsed(const FileInfo& fileInfo) = 0;
|
virtual Id onFileParsed(const FileInfo& fileInfo) = 0;
|
||||||
virtual Id onFileIncludeParsed(
|
virtual Id onFileIncludeParsed(
|
||||||
const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo) = 0;
|
const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo) = 0;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "data/graph/Edge.h"
|
#include "data/graph/Edge.h"
|
||||||
#include "utility/logging/logging.h"
|
#include "utility/logging/logging.h"
|
||||||
#include "utility/utility.h"
|
#include "utility/utility.h"
|
||||||
|
#include "data/location/TokenLocation.h"
|
||||||
|
|
||||||
ParserClientImpl::ParserClientImpl()
|
ParserClientImpl::ParserClientImpl()
|
||||||
{
|
{
|
||||||
@@ -58,7 +59,7 @@ Id ParserClientImpl::onTypedefParsed(
|
|||||||
log("typedef", typedefName.getQualifiedName(), location);
|
log("typedef", typedefName.getQualifiedName(), location);
|
||||||
|
|
||||||
Id nodeId = addNodeHierarchy(Node::NODE_TYPEDEF, typedefName, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
Id nodeId = addNodeHierarchy(Node::NODE_TYPEDEF, typedefName, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addAccess(nodeId, access);
|
addAccess(nodeId, access);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -75,8 +76,8 @@ Id ParserClientImpl::onClassParsed(
|
|||||||
nameHierarchy,
|
nameHierarchy,
|
||||||
(isImplicit ? DEFINITION_IMPLICIT : (scopeLocation.isValid() ? DEFINITION_EXPLICIT : DEFINITION_NONE))
|
(isImplicit ? DEFINITION_IMPLICIT : (scopeLocation.isValid() ? DEFINITION_EXPLICIT : DEFINITION_NONE))
|
||||||
);
|
);
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addSourceLocation(nodeId, scopeLocation, true);
|
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||||
addAccess(nodeId, access);
|
addAccess(nodeId, access);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -93,8 +94,8 @@ Id ParserClientImpl::onStructParsed(
|
|||||||
nameHierarchy,
|
nameHierarchy,
|
||||||
(isImplicit ? DEFINITION_IMPLICIT : (scopeLocation.isValid() ? DEFINITION_EXPLICIT : DEFINITION_NONE))
|
(isImplicit ? DEFINITION_IMPLICIT : (scopeLocation.isValid() ? DEFINITION_EXPLICIT : DEFINITION_NONE))
|
||||||
);
|
);
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addSourceLocation(nodeId, scopeLocation, true);
|
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||||
addAccess(nodeId, access);
|
addAccess(nodeId, access);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -105,7 +106,7 @@ Id ParserClientImpl::onGlobalVariableParsed(const ParseLocation& location, const
|
|||||||
log("global", variable.getQualifiedName(), location);
|
log("global", variable.getQualifiedName(), location);
|
||||||
|
|
||||||
Id nodeId = addNodeHierarchy(Node::NODE_GLOBAL_VARIABLE, variable, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
Id nodeId = addNodeHierarchy(Node::NODE_GLOBAL_VARIABLE, variable, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -115,7 +116,7 @@ Id ParserClientImpl::onFieldParsed(const ParseLocation& location, const NameHier
|
|||||||
log("field", field.getQualifiedName(), location);
|
log("field", field.getQualifiedName(), location);
|
||||||
|
|
||||||
Id nodeId = addNodeHierarchy(Node::NODE_FIELD, field, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
Id nodeId = addNodeHierarchy(Node::NODE_FIELD, field, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addAccess(nodeId, access);
|
addAccess(nodeId, access);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -127,8 +128,8 @@ Id ParserClientImpl::onFunctionParsed(
|
|||||||
log("function", function.getQualifiedNameWithSignature(), location);
|
log("function", function.getQualifiedNameWithSignature(), location);
|
||||||
|
|
||||||
Id nodeId = addNodeHierarchy(Node::NODE_FUNCTION, function, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
Id nodeId = addNodeHierarchy(Node::NODE_FUNCTION, function, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addSourceLocation(nodeId, scopeLocation, true);
|
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -144,8 +145,8 @@ Id ParserClientImpl::onMethodParsed(
|
|||||||
method,
|
method,
|
||||||
(isImplicit ? DEFINITION_IMPLICIT : ((location.isValid() && scopeLocation.isValid()) ? (DEFINITION_EXPLICIT) : DEFINITION_NONE))
|
(isImplicit ? DEFINITION_IMPLICIT : ((location.isValid() && scopeLocation.isValid()) ? (DEFINITION_EXPLICIT) : DEFINITION_NONE))
|
||||||
);
|
);
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addSourceLocation(nodeId, scopeLocation, true);
|
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||||
addAccess(nodeId, access);
|
addAccess(nodeId, access);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -157,8 +158,8 @@ Id ParserClientImpl::onNamespaceParsed(
|
|||||||
log("namespace", nameHierarchy.getQualifiedName(), location);
|
log("namespace", nameHierarchy.getQualifiedName(), location);
|
||||||
|
|
||||||
Id nodeId = addNodeHierarchy(Node::NODE_NAMESPACE, nameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
Id nodeId = addNodeHierarchy(Node::NODE_NAMESPACE, nameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addSourceLocation(nodeId, scopeLocation, true);
|
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -170,8 +171,8 @@ Id ParserClientImpl::onEnumParsed(
|
|||||||
log("enum", nameHierarchy.getQualifiedName(), location);
|
log("enum", nameHierarchy.getQualifiedName(), location);
|
||||||
|
|
||||||
Id nodeId = addNodeHierarchy(Node::NODE_ENUM, nameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
Id nodeId = addNodeHierarchy(Node::NODE_ENUM, nameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addSourceLocation(nodeId, scopeLocation, true);
|
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||||
addAccess(nodeId, access);
|
addAccess(nodeId, access);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -182,7 +183,7 @@ Id ParserClientImpl::onEnumConstantParsed(const ParseLocation& location, const N
|
|||||||
log("enum constant", nameHierarchy.getQualifiedName(), location);
|
log("enum constant", nameHierarchy.getQualifiedName(), location);
|
||||||
|
|
||||||
Id nodeId = addNodeHierarchy(Node::NODE_ENUM_CONSTANT, nameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
Id nodeId = addNodeHierarchy(Node::NODE_ENUM_CONSTANT, nameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -193,7 +194,7 @@ Id ParserClientImpl::onTemplateParameterTypeParsed(
|
|||||||
log("template parameter type", templateParameterTypeNameHierarchy.getQualifiedName(), location);
|
log("template parameter type", templateParameterTypeNameHierarchy.getQualifiedName(), location);
|
||||||
|
|
||||||
Id nodeId = addNodeHierarchy(Node::NODE_TEMPLATE_PARAMETER_TYPE, templateParameterTypeNameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
Id nodeId = addNodeHierarchy(Node::NODE_TEMPLATE_PARAMETER_TYPE, templateParameterTypeNameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||||
addSourceLocation(nodeId, location, false);
|
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addAccess(nodeId, TokenComponentAccess::ACCESS_TEMPLATE);
|
addAccess(nodeId, TokenComponentAccess::ACCESS_TEMPLATE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -208,7 +209,7 @@ Id ParserClientImpl::onInheritanceParsed(
|
|||||||
Id childNodeId = addNodeHierarchy(Node::NODE_TYPE, childNameHierarchy, DEFINITION_NONE);
|
Id childNodeId = addNodeHierarchy(Node::NODE_TYPE, childNameHierarchy, DEFINITION_NONE);
|
||||||
Id parentNodeId = addNodeHierarchy(Node::NODE_TYPE, parentNameHierarchy, DEFINITION_NONE);
|
Id parentNodeId = addNodeHierarchy(Node::NODE_TYPE, parentNameHierarchy, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_INHERITANCE, childNodeId, parentNodeId);
|
Id edgeId = addEdge(Edge::EDGE_INHERITANCE, childNodeId, parentNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
@@ -221,7 +222,7 @@ Id ParserClientImpl::onMethodOverrideParsed(
|
|||||||
Id overriddenNodeId = addNodeHierarchy(Node::NODE_FUNCTION, overridden, DEFINITION_NONE);
|
Id overriddenNodeId = addNodeHierarchy(Node::NODE_FUNCTION, overridden, DEFINITION_NONE);
|
||||||
Id overriderNodeId = addNodeHierarchy(Node::NODE_FUNCTION, overrider, DEFINITION_NONE);
|
Id overriderNodeId = addNodeHierarchy(Node::NODE_FUNCTION, overrider, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_OVERRIDE, overriderNodeId, overriddenNodeId);
|
Id edgeId = addEdge(Edge::EDGE_OVERRIDE, overriderNodeId, overriddenNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
@@ -233,7 +234,7 @@ Id ParserClientImpl::onCallParsed(const ParseLocation& location, const NameHiera
|
|||||||
Id callerNodeId = addNodeHierarchy(Node::NODE_FUNCTION, caller, DEFINITION_NONE);
|
Id callerNodeId = addNodeHierarchy(Node::NODE_FUNCTION, caller, DEFINITION_NONE);
|
||||||
Id calleeNodeId = addNodeHierarchy(Node::NODE_FUNCTION, callee, DEFINITION_NONE);
|
Id calleeNodeId = addNodeHierarchy(Node::NODE_FUNCTION, callee, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_CALL, callerNodeId, calleeNodeId);
|
Id edgeId = addEdge(Edge::EDGE_CALL, callerNodeId, calleeNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
@@ -246,7 +247,7 @@ Id ParserClientImpl::onFieldUsageParsed(
|
|||||||
Id userNodeId = addNodeHierarchy(Node::NODE_FUNCTION, userNameHierarchy, DEFINITION_NONE);
|
Id userNodeId = addNodeHierarchy(Node::NODE_FUNCTION, userNameHierarchy, DEFINITION_NONE);
|
||||||
Id usedNodeId = addNodeHierarchy(Node::NODE_FIELD, usedNameHierarchy, DEFINITION_NONE);
|
Id usedNodeId = addNodeHierarchy(Node::NODE_FIELD, usedNameHierarchy, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_USAGE, userNodeId, usedNodeId);
|
Id edgeId = addEdge(Edge::EDGE_USAGE, userNodeId, usedNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
@@ -259,7 +260,7 @@ Id ParserClientImpl::onGlobalVariableUsageParsed( // or static variable used
|
|||||||
Id userNodeId = addNodeHierarchy(Node::NODE_FUNCTION, userNameHierarchy, DEFINITION_NONE);
|
Id userNodeId = addNodeHierarchy(Node::NODE_FUNCTION, userNameHierarchy, DEFINITION_NONE);
|
||||||
Id usedNodeId = addNodeHierarchy(Node::NODE_GLOBAL_VARIABLE, usedNameHierarchy, DEFINITION_NONE);
|
Id usedNodeId = addNodeHierarchy(Node::NODE_GLOBAL_VARIABLE, usedNameHierarchy, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_USAGE, userNodeId, usedNodeId);
|
Id edgeId = addEdge(Edge::EDGE_USAGE, userNodeId, usedNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
@@ -272,7 +273,7 @@ Id ParserClientImpl::onEnumConstantUsageParsed(
|
|||||||
Id userNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, userNameHierarchy, DEFINITION_NONE);
|
Id userNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, userNameHierarchy, DEFINITION_NONE);
|
||||||
Id usedNodeId = addNodeHierarchy(Node::NODE_ENUM_CONSTANT, usedNameHierarchy, DEFINITION_NONE);
|
Id usedNodeId = addNodeHierarchy(Node::NODE_ENUM_CONSTANT, usedNameHierarchy, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_USAGE, userNodeId, usedNodeId);
|
Id edgeId = addEdge(Edge::EDGE_USAGE, userNodeId, usedNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
@@ -289,7 +290,7 @@ Id ParserClientImpl::onTypeUsageParsed(const ParseLocation& location, const Name
|
|||||||
Id functionNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, user, DEFINITION_NONE);
|
Id functionNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, user, DEFINITION_NONE);
|
||||||
Id typeNodeId = addNodeHierarchy(Node::NODE_TYPE, used, DEFINITION_NONE);
|
Id typeNodeId = addNodeHierarchy(Node::NODE_TYPE, used, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_TYPE_USAGE, functionNodeId, typeNodeId);
|
Id edgeId = addEdge(Edge::EDGE_TYPE_USAGE, functionNodeId, typeNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
@@ -307,7 +308,7 @@ Id ParserClientImpl::onTemplateArgumentTypeParsed(
|
|||||||
Id argumentNodeId = addNodeHierarchy(Node::NODE_TYPE, argumentTypeNameHierarchy, DEFINITION_NONE);
|
Id argumentNodeId = addNodeHierarchy(Node::NODE_TYPE, argumentTypeNameHierarchy, DEFINITION_NONE);
|
||||||
Id templateNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, templateNameHierarchy, DEFINITION_NONE);
|
Id templateNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, templateNameHierarchy, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_ARGUMENT, templateNodeId, argumentNodeId);
|
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_ARGUMENT, templateNodeId, argumentNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return argumentNodeId;
|
return argumentNodeId;
|
||||||
}
|
}
|
||||||
@@ -325,7 +326,7 @@ Id ParserClientImpl::onTemplateDefaultArgumentTypeParsed(
|
|||||||
Id defaultArgumentNodeId = addNodeHierarchy(Node::NODE_TYPE, defaultArgumentTypeNameHierarchy, DEFINITION_NONE);
|
Id defaultArgumentNodeId = addNodeHierarchy(Node::NODE_TYPE, defaultArgumentTypeNameHierarchy, DEFINITION_NONE);
|
||||||
Id parameterNodeId = addNodeHierarchy(Node::NODE_TYPE, templateParameterNameHierarchy, DEFINITION_NONE);
|
Id parameterNodeId = addNodeHierarchy(Node::NODE_TYPE, templateParameterNameHierarchy, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT, parameterNodeId, defaultArgumentNodeId);
|
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT, parameterNodeId, defaultArgumentNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return defaultArgumentNodeId;
|
return defaultArgumentNodeId;
|
||||||
}
|
}
|
||||||
@@ -343,7 +344,7 @@ Id ParserClientImpl::onTemplateSpecializationParsed(
|
|||||||
Id specializedId = addNodeHierarchy(Node::NODE_TYPE, specializedNameHierarchy, DEFINITION_NONE);
|
Id specializedId = addNodeHierarchy(Node::NODE_TYPE, specializedNameHierarchy, DEFINITION_NONE);
|
||||||
Id recordNodeId = addNodeHierarchy(Node::NODE_TYPE, specializedFromNameHierarchy, DEFINITION_NONE);
|
Id recordNodeId = addNodeHierarchy(Node::NODE_TYPE, specializedFromNameHierarchy, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_SPECIALIZATION_OF, specializedId, recordNodeId);
|
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_SPECIALIZATION_OF, specializedId, recordNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
@@ -355,16 +356,30 @@ Id ParserClientImpl::onTemplateMemberFunctionSpecializationParsed(
|
|||||||
"template member function specialization",
|
"template member function specialization",
|
||||||
instantiatedFunction.getQualifiedNameWithSignature() + " -> " + specializedFunction.getQualifiedNameWithSignature(),
|
instantiatedFunction.getQualifiedNameWithSignature() + " -> " + specializedFunction.getQualifiedNameWithSignature(),
|
||||||
location
|
location
|
||||||
);
|
);
|
||||||
|
|
||||||
Id instantiatedFunctionNodeId = addNodeHierarchy(Node::NODE_FUNCTION, instantiatedFunction, DEFINITION_NONE);
|
Id instantiatedFunctionNodeId = addNodeHierarchy(Node::NODE_FUNCTION, instantiatedFunction, DEFINITION_NONE);
|
||||||
Id specializedFunctionNodeId = addNodeHierarchy(Node::NODE_FUNCTION, specializedFunction, DEFINITION_NONE);
|
Id specializedFunctionNodeId = addNodeHierarchy(Node::NODE_FUNCTION, specializedFunction, DEFINITION_NONE);
|
||||||
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF, instantiatedFunctionNodeId, specializedFunctionNodeId);
|
Id edgeId = addEdge(Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF, instantiatedFunctionNodeId, specializedFunctionNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Id ParserClientImpl::onLocalSymbolParsed(const std::string& name, const ParseLocation& location)
|
||||||
|
{
|
||||||
|
log(
|
||||||
|
"local symbol",
|
||||||
|
name,
|
||||||
|
location
|
||||||
|
);
|
||||||
|
|
||||||
|
Id localSymbolId = addLocalSymbol(name);
|
||||||
|
addSourceLocation(localSymbolId, location, locationTypeToInt(LOCATION_LOCAL_SYMBOL));
|
||||||
|
|
||||||
|
return localSymbolId;
|
||||||
|
}
|
||||||
|
|
||||||
Id ParserClientImpl::onFileParsed(const FileInfo& fileInfo) // TODO: move up to nodes
|
Id ParserClientImpl::onFileParsed(const FileInfo& fileInfo) // TODO: move up to nodes
|
||||||
{
|
{
|
||||||
log("file", fileInfo.path.str(), ParseLocation());
|
log("file", fileInfo.path.str(), ParseLocation());
|
||||||
@@ -381,7 +396,7 @@ Id ParserClientImpl::onFileIncludeParsed(const ParseLocation& location, const Fi
|
|||||||
Id fileNodeId = addFile(fileInfo.path.fileName(), fileInfo.path.str(), utility::timeToString(fileInfo.lastWriteTime));
|
Id fileNodeId = addFile(fileInfo.path.fileName(), fileInfo.path.str(), utility::timeToString(fileInfo.lastWriteTime));
|
||||||
Id includedFileNodeId = addFile(includedFileInfo.path.fileName(), includedFileInfo.path.str(), utility::timeToString(includedFileInfo.lastWriteTime));
|
Id includedFileNodeId = addFile(includedFileInfo.path.fileName(), includedFileInfo.path.str(), utility::timeToString(includedFileInfo.lastWriteTime));
|
||||||
Id edgeId = addEdge(Edge::EDGE_INCLUDE, fileNodeId, includedFileNodeId);
|
Id edgeId = addEdge(Edge::EDGE_INCLUDE, fileNodeId, includedFileNodeId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return fileNodeId;
|
return fileNodeId;
|
||||||
}
|
}
|
||||||
@@ -392,8 +407,8 @@ Id ParserClientImpl::onMacroDefineParsed(
|
|||||||
log("macro", macroNameHierarchy.getQualifiedName(), location);
|
log("macro", macroNameHierarchy.getQualifiedName(), location);
|
||||||
|
|
||||||
Id macroId = addNodeHierarchy(Node::NODE_MACRO, macroNameHierarchy, DEFINITION_EXPLICIT);
|
Id macroId = addNodeHierarchy(Node::NODE_MACRO, macroNameHierarchy, DEFINITION_EXPLICIT);
|
||||||
addSourceLocation(macroId, location, false);
|
addSourceLocation(macroId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
addSourceLocation(macroId, scopeLocation, true);
|
addSourceLocation(macroId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||||
//Id fileNodeId = getFileNodeId(location.filePath); // do we need this???
|
//Id fileNodeId = getFileNodeId(location.filePath); // do we need this???
|
||||||
//addEdge(Edge::EDGE_MACRO_USAGE, fileNodeId, macroId, , location);
|
//addEdge(Edge::EDGE_MACRO_USAGE, fileNodeId, macroId, , location);
|
||||||
|
|
||||||
@@ -407,7 +422,7 @@ Id ParserClientImpl::onMacroExpandParsed(const ParseLocation &location, const Na
|
|||||||
Id macroExpandId = addNodeHierarchy(Node::NODE_MACRO, macroNameHierarchy, DEFINITION_NONE);
|
Id macroExpandId = addNodeHierarchy(Node::NODE_MACRO, macroNameHierarchy, DEFINITION_NONE);
|
||||||
Id fileNodeId = addFile(location.filePath.str());
|
Id fileNodeId = addFile(location.filePath.str());
|
||||||
Id edgeId = addEdge(Edge::EDGE_MACRO_USAGE, fileNodeId, macroExpandId);
|
Id edgeId = addEdge(Edge::EDGE_MACRO_USAGE, fileNodeId, macroExpandId);
|
||||||
addSourceLocation(edgeId, location, false);
|
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||||
|
|
||||||
return edgeId;
|
return edgeId;
|
||||||
}
|
}
|
||||||
@@ -531,8 +546,17 @@ Id ParserClientImpl::addEdge(int type, Id sourceId, Id targetId)
|
|||||||
return m_storage->addEdge(type, sourceId, targetId);
|
return m_storage->addEdge(type, sourceId, targetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Id ParserClientImpl::addLocalSymbol(const std::string& name)
|
||||||
|
{
|
||||||
|
if (!m_storage)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ParserClientImpl::addSourceLocation(Id elementId, const ParseLocation& location, bool isScope)
|
return m_storage->addLocalSymbol(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParserClientImpl::addSourceLocation(Id elementId, const ParseLocation& location, int type)
|
||||||
{
|
{
|
||||||
if (!m_storage)
|
if (!m_storage)
|
||||||
{
|
{
|
||||||
@@ -550,7 +574,7 @@ void ParserClientImpl::addSourceLocation(Id elementId, const ParseLocation& loca
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_storage->addSourceLocation(elementId, location, isScope);
|
m_storage->addSourceLocation(elementId, location, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserClientImpl::addComponentAccess(Id nodeId , int type)
|
void ParserClientImpl::addComponentAccess(Id nodeId , int type)
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ public:
|
|||||||
virtual Id onTemplateMemberFunctionSpecializationParsed(
|
virtual Id onTemplateMemberFunctionSpecializationParsed(
|
||||||
const ParseLocation& location, const NameHierarchy& instantiatedFunction, const NameHierarchy& specializedFunction);
|
const ParseLocation& location, const NameHierarchy& instantiatedFunction, const NameHierarchy& specializedFunction);
|
||||||
|
|
||||||
|
virtual Id onLocalSymbolParsed(const std::string& name, const ParseLocation& location);
|
||||||
|
|
||||||
virtual Id onFileParsed(const FileInfo& fileInfo);
|
virtual Id onFileParsed(const FileInfo& fileInfo);
|
||||||
virtual Id onFileIncludeParsed(
|
virtual Id onFileIncludeParsed(
|
||||||
const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo);
|
const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo);
|
||||||
@@ -99,7 +101,8 @@ private:
|
|||||||
Id addFile(const std::string& filePath);
|
Id addFile(const std::string& filePath);
|
||||||
Id addNode(Node::NodeType nodeType, NameHierarchy nameHierarchy, DefinitionType definitionType);
|
Id addNode(Node::NodeType nodeType, NameHierarchy nameHierarchy, DefinitionType definitionType);
|
||||||
Id addEdge(int type, Id sourceId, Id targetId);
|
Id addEdge(int type, Id sourceId, Id targetId);
|
||||||
void addSourceLocation(Id elementId, const ParseLocation& location, bool isScope);
|
Id addLocalSymbol(const std::string& name);
|
||||||
|
void addSourceLocation(Id elementId, const ParseLocation& location, int type);
|
||||||
void addComponentAccess(Id nodeId , int type);
|
void addComponentAccess(Id nodeId , int type);
|
||||||
void addCommentLocation(const ParseLocation& location);
|
void addCommentLocation(const ParseLocation& location);
|
||||||
void addError(const std::string& message, bool fatal, const ParseLocation& location);
|
void addError(const std::string& message, bool fatal, const ParseLocation& location);
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef MESSAGE_ACTIVATE_LOCAL_SYMBOLS_H
|
||||||
|
#define MESSAGE_ACTIVATE_LOCAL_SYMBOLS_H
|
||||||
|
|
||||||
|
#include "utility/messaging/Message.h"
|
||||||
|
#include "utility/types.h"
|
||||||
|
|
||||||
|
class MessageActivateLocalSymbols
|
||||||
|
: public Message<MessageActivateLocalSymbols>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MessageActivateLocalSymbols()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageActivateLocalSymbols(const std::vector<Id>& symbolIds)
|
||||||
|
: symbolIds(symbolIds)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void addSymbol(Id symbolId)
|
||||||
|
{
|
||||||
|
symbolIds.push_back(symbolId);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const std::string getStaticType()
|
||||||
|
{
|
||||||
|
return "MessageActivateLocalSymbols";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void print(std::ostream& os) const
|
||||||
|
{
|
||||||
|
for (const Id& symbolId : symbolIds)
|
||||||
|
{
|
||||||
|
os << symbolId << " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Id> symbolIds;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MESSAGE_ACTIVATE_LOCAL_SYMBOLS_H
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
#include <qscrollbar.h>
|
#include <qscrollbar.h>
|
||||||
|
|
||||||
|
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
|
||||||
#include "utility/messaging/type/MessageActivateTokenLocations.h"
|
#include "utility/messaging/type/MessageActivateTokenLocations.h"
|
||||||
#include "utility/messaging/type/MessageActivateTokenIds.h"
|
#include "utility/messaging/type/MessageActivateTokenIds.h"
|
||||||
#include "utility/messaging/type/MessageFocusIn.h"
|
#include "utility/messaging/type/MessageFocusIn.h"
|
||||||
@@ -355,7 +356,7 @@ void QtCodeArea::paintEvent(QPaintEvent* event)
|
|||||||
painter.setPen(QPen(color.border.c_str()));
|
painter.setPen(QPen(color.border.c_str()));
|
||||||
painter.setBrush(QBrush(color.fill.c_str()));
|
painter.setBrush(QBrush(color.fill.c_str()));
|
||||||
|
|
||||||
if (annotation.isScope)
|
if (annotation.locationType == LOCATION_SCOPE)
|
||||||
{
|
{
|
||||||
painter.drawRoundedRect(
|
painter.drawRoundedRect(
|
||||||
0, top + (annotation.startLine - m_startLineNumber) * blockHeight,
|
0, top + (annotation.startLine - m_startLineNumber) * blockHeight,
|
||||||
@@ -425,42 +426,10 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
else if (!m_fileWidget->getErrorMessages().size())
|
else if (!m_fileWidget->getErrorMessages().size())
|
||||||
{
|
{
|
||||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||||
std::vector<const Annotation*> annotations = getAnnotationsForPosition(cursor.position());
|
std::vector<const Annotation*> annotations = getNonScopeAnnotationsForPosition(cursor.position());
|
||||||
|
|
||||||
std::vector<Id> locationIds;
|
activateTokenLocations(annotations);
|
||||||
std::set<Id> tokenIds;
|
activateLocalSymbols(annotations);
|
||||||
|
|
||||||
bool allActive = true;
|
|
||||||
for (const Annotation* annotation : annotations)
|
|
||||||
{
|
|
||||||
if (!annotation->isActive)
|
|
||||||
{
|
|
||||||
allActive = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (annotation->locationId > 0)
|
|
||||||
{
|
|
||||||
locationIds.push_back(annotation->locationId);
|
|
||||||
}
|
|
||||||
if (annotation->tokenId > 0)
|
|
||||||
{
|
|
||||||
tokenIds.insert(annotation->tokenId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allActive)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (locationIds.size())
|
|
||||||
{
|
|
||||||
MessageActivateTokenLocations(locationIds).dispatch();
|
|
||||||
}
|
|
||||||
else if (tokenIds.size()) // fallback for links in project description
|
|
||||||
{
|
|
||||||
MessageActivateTokenIds(utility::toVector(tokenIds)).dispatch();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -481,7 +450,7 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
|
|||||||
|
|
||||||
|
|
||||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||||
std::vector<const Annotation*> annotations = getAnnotationsForPosition(cursor.position());
|
std::vector<const Annotation*> annotations = getNonScopeAnnotationsForPosition(cursor.position());
|
||||||
|
|
||||||
bool same = annotations.size() == m_hoveredAnnotations.size();
|
bool same = annotations.size() == m_hoveredAnnotations.size();
|
||||||
if (same)
|
if (same)
|
||||||
@@ -558,13 +527,13 @@ void QtCodeArea::setIDECursorPosition()
|
|||||||
MessageMoveIDECursor(m_locationFile->getFilePath().str(), lineColumn.first, lineColumn.second).dispatch();
|
MessageMoveIDECursor(m_locationFile->getFilePath().str(), lineColumn.first, lineColumn.second).dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const QtCodeArea::Annotation*> QtCodeArea::getAnnotationsForPosition(int pos) const
|
std::vector<const QtCodeArea::Annotation*> QtCodeArea::getNonScopeAnnotationsForPosition(int pos) const
|
||||||
{
|
{
|
||||||
std::vector<const QtCodeArea::Annotation*> annotations;
|
std::vector<const QtCodeArea::Annotation*> annotations;
|
||||||
|
|
||||||
for (const Annotation& annotation : m_annotations)
|
for (const Annotation& annotation : m_annotations)
|
||||||
{
|
{
|
||||||
if (!annotation.isScope && pos >= annotation.start && pos <= annotation.end)
|
if (annotation.locationType != LOCATION_SCOPE && pos >= annotation.start && pos <= annotation.end)
|
||||||
{
|
{
|
||||||
annotations.push_back(&annotation);
|
annotations.push_back(&annotation);
|
||||||
}
|
}
|
||||||
@@ -573,6 +542,75 @@ std::vector<const QtCodeArea::Annotation*> QtCodeArea::getAnnotationsForPosition
|
|||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCodeArea::activateTokenLocations(const std::vector<const Annotation*>& annotations)
|
||||||
|
{
|
||||||
|
std::vector<Id> tokenLocationIds;
|
||||||
|
std::set<Id> tokenIds;
|
||||||
|
|
||||||
|
bool allActive = true;
|
||||||
|
for (const Annotation* annotation : annotations)
|
||||||
|
{
|
||||||
|
if (annotation->locationType == LOCATION_TOKEN)
|
||||||
|
{
|
||||||
|
if (!annotation->isActive)
|
||||||
|
{
|
||||||
|
allActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (annotation->locationId > 0)
|
||||||
|
{
|
||||||
|
tokenLocationIds.push_back(annotation->locationId);
|
||||||
|
}
|
||||||
|
if (annotation->tokenId > 0)
|
||||||
|
{
|
||||||
|
tokenIds.insert(annotation->tokenId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allActive)
|
||||||
|
{
|
||||||
|
if (tokenLocationIds.size())
|
||||||
|
{
|
||||||
|
MessageActivateTokenLocations(tokenLocationIds).dispatch();
|
||||||
|
}
|
||||||
|
else if (tokenIds.size()) // fallback for links in project description
|
||||||
|
{
|
||||||
|
MessageActivateTokenIds(utility::toVector(tokenIds)).dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtCodeArea::activateLocalSymbols(const std::vector<const Annotation*>& annotations)
|
||||||
|
{
|
||||||
|
std::vector<Id> localSymbolIds;
|
||||||
|
|
||||||
|
bool allActive = true;
|
||||||
|
for (const Annotation* annotation : annotations)
|
||||||
|
{
|
||||||
|
if (annotation->locationType == LOCATION_LOCAL_SYMBOL)
|
||||||
|
{
|
||||||
|
if (!annotation->isActive)
|
||||||
|
{
|
||||||
|
allActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (annotation->tokenId > 0)
|
||||||
|
{
|
||||||
|
localSymbolIds.push_back(annotation->tokenId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allActive)
|
||||||
|
{
|
||||||
|
if (localSymbolIds.size())
|
||||||
|
{
|
||||||
|
MessageActivateLocalSymbols(localSymbolIds).dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QtCodeArea::createAnnotations(std::shared_ptr<TokenLocationFile> locationFile)
|
void QtCodeArea::createAnnotations(std::shared_ptr<TokenLocationFile> locationFile)
|
||||||
{
|
{
|
||||||
locationFile->forEachStartTokenLocation(
|
locationFile->forEachStartTokenLocation(
|
||||||
@@ -624,7 +662,7 @@ void QtCodeArea::createAnnotations(std::shared_ptr<TokenLocationFile> locationFi
|
|||||||
annotation.tokenId = startLocation->getTokenId();
|
annotation.tokenId = startLocation->getTokenId();
|
||||||
annotation.locationId = startLocation->getId();
|
annotation.locationId = startLocation->getId();
|
||||||
|
|
||||||
annotation.isScope = (startLocation->getType() == TokenLocation::LOCATION_SCOPE);
|
annotation.locationType = startLocation->getType();
|
||||||
annotation.isError = false;
|
annotation.isError = false;
|
||||||
|
|
||||||
annotation.isActive = false;
|
annotation.isActive = false;
|
||||||
@@ -637,7 +675,8 @@ void QtCodeArea::createAnnotations(std::shared_ptr<TokenLocationFile> locationFi
|
|||||||
|
|
||||||
void QtCodeArea::annotateText()
|
void QtCodeArea::annotateText()
|
||||||
{
|
{
|
||||||
const std::vector<Id>& activeIds = m_fileWidget->getActiveTokenIds();
|
const std::vector<Id>& activeTokenIds = m_fileWidget->getActiveTokenIds();
|
||||||
|
const std::vector<Id>& activeLocalSymbolIds = m_fileWidget->getActiveLocalSymbolIds();
|
||||||
const std::vector<Id>& focusIds = m_fileWidget->getFocusedTokenIds();
|
const std::vector<Id>& focusIds = m_fileWidget->getFocusedTokenIds();
|
||||||
|
|
||||||
bool isError = m_fileWidget->hasErrors();
|
bool isError = m_fileWidget->hasErrors();
|
||||||
@@ -648,7 +687,10 @@ void QtCodeArea::annotateText()
|
|||||||
bool wasActive = annotation.isActive;
|
bool wasActive = annotation.isActive;
|
||||||
bool wasFocused = annotation.isFocused;
|
bool wasFocused = annotation.isFocused;
|
||||||
|
|
||||||
annotation.isActive = std::find(activeIds.begin(), activeIds.end(), annotation.tokenId) != activeIds.end();
|
annotation.isActive = (
|
||||||
|
std::find(activeTokenIds.begin(), activeTokenIds.end(), annotation.tokenId) != activeTokenIds.end() ||
|
||||||
|
std::find(activeLocalSymbolIds.begin(), activeLocalSymbolIds.end(), annotation.tokenId) != activeLocalSymbolIds.end()
|
||||||
|
);
|
||||||
annotation.isFocused = std::find(focusIds.begin(), focusIds.end(), annotation.tokenId) != focusIds.end();
|
annotation.isFocused = std::find(focusIds.begin(), focusIds.end(), annotation.tokenId) != focusIds.end();
|
||||||
|
|
||||||
annotation.isError = isError;
|
annotation.isError = isError;
|
||||||
@@ -827,7 +869,8 @@ const QtCodeArea::AnnotationColor& QtCodeArea::getAnnotationColorForAnnotation(c
|
|||||||
{
|
{
|
||||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||||
std::vector<std::string> types;
|
std::vector<std::string> types;
|
||||||
types.push_back("location");
|
types.push_back("token");
|
||||||
|
types.push_back("local_symbol");
|
||||||
types.push_back("scope");
|
types.push_back("scope");
|
||||||
types.push_back("error");
|
types.push_back("error");
|
||||||
|
|
||||||
@@ -850,14 +893,18 @@ const QtCodeArea::AnnotationColor& QtCodeArea::getAnnotationColorForAnnotation(c
|
|||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
if (annotation.isScope)
|
if (annotation.locationType == LOCATION_LOCAL_SYMBOL)
|
||||||
{
|
{
|
||||||
i = 3;
|
i = 3;
|
||||||
}
|
}
|
||||||
else if (annotation.isError)
|
else if (annotation.locationType == LOCATION_SCOPE)
|
||||||
{
|
{
|
||||||
i = 6;
|
i = 6;
|
||||||
}
|
}
|
||||||
|
else if (annotation.isError)
|
||||||
|
{
|
||||||
|
i = 9;
|
||||||
|
}
|
||||||
|
|
||||||
if (annotation.isActive)
|
if (annotation.isActive)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
|
#include "data/location/LocationType.h"
|
||||||
#include "utility/types.h"
|
#include "utility/types.h"
|
||||||
|
|
||||||
class QDragMoveEvent;
|
class QDragMoveEvent;
|
||||||
@@ -124,7 +125,7 @@ private:
|
|||||||
Id tokenId;
|
Id tokenId;
|
||||||
Id locationId;
|
Id locationId;
|
||||||
|
|
||||||
bool isScope;
|
LocationType locationType;
|
||||||
bool isError;
|
bool isError;
|
||||||
|
|
||||||
bool isActive;
|
bool isActive;
|
||||||
@@ -137,7 +138,9 @@ private:
|
|||||||
std::string fill;
|
std::string fill;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<const Annotation*> getAnnotationsForPosition(int pos) const;
|
std::vector<const Annotation*> getNonScopeAnnotationsForPosition(int pos) const;
|
||||||
|
void activateTokenLocations(const std::vector<const Annotation*>& annotations);
|
||||||
|
void activateLocalSymbols(const std::vector<const Annotation*>& annotations);
|
||||||
|
|
||||||
void createAnnotations(std::shared_ptr<TokenLocationFile> locationFile);
|
void createAnnotations(std::shared_ptr<TokenLocationFile> locationFile);
|
||||||
void annotateText();
|
void annotateText();
|
||||||
|
|||||||
@@ -129,6 +129,11 @@ const std::vector<Id>& QtCodeFile::getActiveTokenIds() const
|
|||||||
return m_parent->getActiveTokenIds();
|
return m_parent->getActiveTokenIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<Id>& QtCodeFile::getActiveLocalSymbolIds() const
|
||||||
|
{
|
||||||
|
return m_parent->getActiveLocalSymbolIds();
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<Id>& QtCodeFile::getFocusedTokenIds() const
|
const std::vector<Id>& QtCodeFile::getFocusedTokenIds() const
|
||||||
{
|
{
|
||||||
return m_parent->getFocusedTokenIds();
|
return m_parent->getFocusedTokenIds();
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
std::string getFileName() const;
|
std::string getFileName() const;
|
||||||
|
|
||||||
const std::vector<Id>& getActiveTokenIds() const;
|
const std::vector<Id>& getActiveTokenIds() const;
|
||||||
|
const std::vector<Id>& getActiveLocalSymbolIds() const;
|
||||||
const std::vector<Id>& getFocusedTokenIds() const;
|
const std::vector<Id>& getFocusedTokenIds() const;
|
||||||
|
|
||||||
const std::vector<std::string>& getErrorMessages() const;
|
const std::vector<std::string>& getErrorMessages() const;
|
||||||
|
|||||||
@@ -85,6 +85,17 @@ const std::vector<Id>& QtCodeFileList::getActiveTokenIds() const
|
|||||||
void QtCodeFileList::setActiveTokenIds(const std::vector<Id>& activeTokenIds)
|
void QtCodeFileList::setActiveTokenIds(const std::vector<Id>& activeTokenIds)
|
||||||
{
|
{
|
||||||
m_activeTokenIds = activeTokenIds;
|
m_activeTokenIds = activeTokenIds;
|
||||||
|
m_activeLocalSymbolIds.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Id>& QtCodeFileList::getActiveLocalSymbolIds() const
|
||||||
|
{
|
||||||
|
return m_activeLocalSymbolIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtCodeFileList::setActiveLocalSymbolIds(const std::vector<Id>& activeLocalSymbolIds)
|
||||||
|
{
|
||||||
|
m_activeLocalSymbolIds = activeLocalSymbolIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Id>& QtCodeFileList::getFocusedTokenIds() const
|
const std::vector<Id>& QtCodeFileList::getFocusedTokenIds() const
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ public:
|
|||||||
const std::vector<Id>& getActiveTokenIds() const;
|
const std::vector<Id>& getActiveTokenIds() const;
|
||||||
void setActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
void setActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
||||||
|
|
||||||
|
const std::vector<Id>& getActiveLocalSymbolIds() const;
|
||||||
|
void setActiveLocalSymbolIds(const std::vector<Id>& activeLocalSymbolIds);
|
||||||
|
|
||||||
const std::vector<Id>& getFocusedTokenIds() const;
|
const std::vector<Id>& getFocusedTokenIds() const;
|
||||||
void setFocusedTokenIds(const std::vector<Id>& focusedTokenIds);
|
void setFocusedTokenIds(const std::vector<Id>& focusedTokenIds);
|
||||||
|
|
||||||
@@ -77,6 +80,7 @@ private:
|
|||||||
std::vector<std::shared_ptr<QtCodeFile>> m_files;
|
std::vector<std::shared_ptr<QtCodeFile>> m_files;
|
||||||
|
|
||||||
std::vector<Id> m_activeTokenIds;
|
std::vector<Id> m_activeTokenIds;
|
||||||
|
std::vector<Id> m_activeLocalSymbolIds;
|
||||||
std::vector<Id> m_focusedTokenIds;
|
std::vector<Id> m_focusedTokenIds;
|
||||||
std::vector<std::string> m_errorMessages;
|
std::vector<std::string> m_errorMessages;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ QtCodeView::QtCodeView(ViewLayout* viewLayout)
|
|||||||
, m_setFileStateFunctor(std::bind(&QtCodeView::doSetFileState, this, std::placeholders::_1, std::placeholders::_2))
|
, m_setFileStateFunctor(std::bind(&QtCodeView::doSetFileState, this, std::placeholders::_1, std::placeholders::_2))
|
||||||
, m_doShowFirstActiveSnippetFunctor(std::bind(&QtCodeView::doShowFirstActiveSnippet, this, std::placeholders::_1, std::placeholders::_2))
|
, m_doShowFirstActiveSnippetFunctor(std::bind(&QtCodeView::doShowFirstActiveSnippet, this, std::placeholders::_1, std::placeholders::_2))
|
||||||
, m_doShowActiveTokenIdsFunctor(std::bind(&QtCodeView::doShowActiveTokenIds, this, std::placeholders::_1))
|
, m_doShowActiveTokenIdsFunctor(std::bind(&QtCodeView::doShowActiveTokenIds, this, std::placeholders::_1))
|
||||||
|
, m_doShowActiveLocalSymbolIdsFunctor(std::bind(&QtCodeView::doShowActiveLocalSymbolIds, this, std::placeholders::_1))
|
||||||
, m_focusTokenIdsFunctor(std::bind(&QtCodeView::doFocusTokenIds, this, std::placeholders::_1))
|
, m_focusTokenIdsFunctor(std::bind(&QtCodeView::doFocusTokenIds, this, std::placeholders::_1))
|
||||||
, m_defocusTokenIdsFunctor(std::bind(&QtCodeView::doDefocusTokenIds, this))
|
, m_defocusTokenIdsFunctor(std::bind(&QtCodeView::doDefocusTokenIds, this))
|
||||||
, m_showContentsFunctor(std::bind(&QtCodeView::doShowContents, this))
|
, m_showContentsFunctor(std::bind(&QtCodeView::doShowContents, this))
|
||||||
@@ -91,6 +92,11 @@ void QtCodeView::showActiveTokenIds(const std::vector<Id>& activeTokenIds)
|
|||||||
m_doShowActiveTokenIdsFunctor(activeTokenIds);
|
m_doShowActiveTokenIdsFunctor(activeTokenIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCodeView::showActiveLocalSymbolIds(const std::vector<Id>& activeLocalSymbolIds)
|
||||||
|
{
|
||||||
|
m_doShowActiveLocalSymbolIdsFunctor(activeLocalSymbolIds);
|
||||||
|
}
|
||||||
|
|
||||||
void QtCodeView::focusTokenIds(const std::vector<Id>& focusedTokenIds)
|
void QtCodeView::focusTokenIds(const std::vector<Id>& focusedTokenIds)
|
||||||
{
|
{
|
||||||
m_focusTokenIdsFunctor(focusedTokenIds);
|
m_focusTokenIdsFunctor(focusedTokenIds);
|
||||||
@@ -194,6 +200,12 @@ void QtCodeView::doShowActiveTokenIds(const std::vector<Id>& activeTokenIds)
|
|||||||
m_widget->showActiveTokenIds();
|
m_widget->showActiveTokenIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCodeView::doShowActiveLocalSymbolIds(const std::vector<Id>& localSymbolIds)
|
||||||
|
{
|
||||||
|
m_widget->setActiveLocalSymbolIds(localSymbolIds);
|
||||||
|
m_widget->showActiveTokenIds();
|
||||||
|
}
|
||||||
|
|
||||||
void QtCodeView::doFocusTokenIds(const std::vector<Id>& focusedTokenIds)
|
void QtCodeView::doFocusTokenIds(const std::vector<Id>& focusedTokenIds)
|
||||||
{
|
{
|
||||||
m_widget->focusTokenIds(focusedTokenIds);
|
m_widget->focusTokenIds(focusedTokenIds);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
|
|
||||||
virtual void showFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo);
|
virtual void showFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo);
|
||||||
virtual void showActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
virtual void showActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
||||||
|
virtual void showActiveLocalSymbolIds(const std::vector<Id>& activeLocalSymbolIds);
|
||||||
|
|
||||||
virtual void focusTokenIds(const std::vector<Id>& focusedTokenIds);
|
virtual void focusTokenIds(const std::vector<Id>& focusedTokenIds);
|
||||||
virtual void defocusTokenIds();
|
virtual void defocusTokenIds();
|
||||||
@@ -59,6 +60,7 @@ private:
|
|||||||
|
|
||||||
void doShowFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo);
|
void doShowFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo);
|
||||||
void doShowActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
void doShowActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
||||||
|
void doShowActiveLocalSymbolIds(const std::vector<Id>& localSymbolIds);
|
||||||
|
|
||||||
void doFocusTokenIds(const std::vector<Id>& focusedTokenIds);
|
void doFocusTokenIds(const std::vector<Id>& focusedTokenIds);
|
||||||
void doDefocusTokenIds();
|
void doDefocusTokenIds();
|
||||||
@@ -77,6 +79,7 @@ private:
|
|||||||
QtThreadedFunctor<const FilePath, FileState> m_setFileStateFunctor;
|
QtThreadedFunctor<const FilePath, FileState> m_setFileStateFunctor;
|
||||||
QtThreadedFunctor<const std::vector<Id>&, bool> m_doShowFirstActiveSnippetFunctor;
|
QtThreadedFunctor<const std::vector<Id>&, bool> m_doShowFirstActiveSnippetFunctor;
|
||||||
QtThreadedFunctor<const std::vector<Id>&> m_doShowActiveTokenIdsFunctor;
|
QtThreadedFunctor<const std::vector<Id>&> m_doShowActiveTokenIdsFunctor;
|
||||||
|
QtThreadedFunctor<const std::vector<Id>&> m_doShowActiveLocalSymbolIdsFunctor;
|
||||||
QtThreadedFunctor<const std::vector<Id>&> m_focusTokenIdsFunctor;
|
QtThreadedFunctor<const std::vector<Id>&> m_focusTokenIdsFunctor;
|
||||||
QtThreadedFunctor<> m_defocusTokenIdsFunctor;
|
QtThreadedFunctor<> m_defocusTokenIdsFunctor;
|
||||||
QtThreadedFunctor<> m_showContentsFunctor;
|
QtThreadedFunctor<> m_showContentsFunctor;
|
||||||
|
|||||||
@@ -1305,7 +1305,18 @@ void ASTVisitor::RecordDeclRef(
|
|||||||
break;
|
break;
|
||||||
case ST_LocalVariable:
|
case ST_LocalVariable:
|
||||||
case ST_Parameter:
|
case ST_Parameter:
|
||||||
// Do nothing.
|
if (clang::VarDecl* varDecl = clang::dyn_cast<clang::VarDecl>(d))
|
||||||
|
{
|
||||||
|
ParseLocation declLocation = getParseLocation(varDecl->getSourceRange()); // i think we dont need this since this is the decl/def
|
||||||
|
std::string name =
|
||||||
|
declLocation.filePath.str() + "::" +
|
||||||
|
varDecl->getNameAsString() + "<" +
|
||||||
|
std::to_string(declLocation.startLineNumber) + ":" +
|
||||||
|
std::to_string(declLocation.startColumnNumber) + ">";
|
||||||
|
m_client->onLocalSymbolParsed(
|
||||||
|
name,
|
||||||
|
parseLocation);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fallback = true;
|
fallback = true;
|
||||||
@@ -1374,6 +1385,21 @@ void ASTVisitor::RecordDeclRef(
|
|||||||
contextNameHierarchy,
|
contextNameHierarchy,
|
||||||
declNameHierarchy);
|
declNameHierarchy);
|
||||||
break;
|
break;
|
||||||
|
case ST_LocalVariable:
|
||||||
|
case ST_Parameter:
|
||||||
|
if (clang::VarDecl* varDecl = clang::dyn_cast<clang::VarDecl>(d))
|
||||||
|
{
|
||||||
|
ParseLocation declLocation = getParseLocation(varDecl->getSourceRange()); // i think we dont need this since this is the decl/def
|
||||||
|
std::string name =
|
||||||
|
declLocation.filePath.str() + "::" +
|
||||||
|
varDecl->getNameAsString() + "<" +
|
||||||
|
std::to_string(declLocation.startLineNumber) + ":" +
|
||||||
|
std::to_string(declLocation.startColumnNumber) + ">";
|
||||||
|
m_client->onLocalSymbolParsed(
|
||||||
|
name,
|
||||||
|
parseLocation);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ST_Max:
|
case ST_Max:
|
||||||
switch (refType)
|
switch (refType)
|
||||||
{
|
{
|
||||||
@@ -1408,10 +1434,6 @@ void ASTVisitor::RecordDeclRef(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ST_LocalVariable:
|
|
||||||
case ST_Parameter:
|
|
||||||
// Do nothing.
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
fallback = true;
|
fallback = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+223
-164
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user