data: improved ParserClientImpl recording performance
* Removed storage checks and single use methods * cache file ids in ParserClientImpl to avoid lookup for every source location * NameHierarchy::serialize with range to avoid copies when adding nodes * removed duplicate code in IndexerCxx and IndexerJava, moved to Indexer
This commit is contained in:
@@ -5,27 +5,49 @@
|
|||||||
|
|
||||||
#include "IndexerBase.h"
|
#include "IndexerBase.h"
|
||||||
#include "IndexerCommand.h"
|
#include "IndexerCommand.h"
|
||||||
|
#include "IndexerStateInfo.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
#include "ParserClientImpl.h"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class Indexer
|
class Indexer
|
||||||
: public IndexerBase
|
: public IndexerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Indexer();
|
||||||
IndexerCommandType getSupportedIndexerCommandType() const override;
|
IndexerCommandType getSupportedIndexerCommandType() const override;
|
||||||
std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommand> indexerCommand) override;
|
std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommand> indexerCommand) override;
|
||||||
|
void interrupt() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::shared_ptr<IntermediateStorage> doIndex(std::shared_ptr<T> indexerCommand) = 0;
|
virtual void doIndex(
|
||||||
|
std::shared_ptr<T> indexerCommand,
|
||||||
|
std::shared_ptr<ParserClientImpl> parserClient,
|
||||||
|
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo) = 0;
|
||||||
|
|
||||||
|
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Indexer<T>::Indexer()
|
||||||
|
: m_indexerStateInfo(std::make_shared<IndexerStateInfo>())
|
||||||
|
{
|
||||||
|
m_indexerStateInfo->indexingInterrupted = false;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
IndexerCommandType Indexer<T>::getSupportedIndexerCommandType() const
|
IndexerCommandType Indexer<T>::getSupportedIndexerCommandType() const
|
||||||
{
|
{
|
||||||
return T::getStaticIndexerCommandType();
|
return T::getStaticIndexerCommandType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void Indexer<T>::interrupt()
|
||||||
|
{
|
||||||
|
m_indexerStateInfo->indexingInterrupted = true;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::shared_ptr<IntermediateStorage> Indexer<T>::index(std::shared_ptr<IndexerCommand> indexerCommand)
|
std::shared_ptr<IntermediateStorage> Indexer<T>::index(std::shared_ptr<IndexerCommand> indexerCommand)
|
||||||
{
|
{
|
||||||
@@ -35,10 +57,29 @@ std::shared_ptr<IntermediateStorage> Indexer<T>::index(std::shared_ptr<IndexerCo
|
|||||||
LOG_ERROR("Trying to process " + indexerCommandTypeToString(indexerCommand->getIndexerCommandType()) +
|
LOG_ERROR("Trying to process " + indexerCommandTypeToString(indexerCommand->getIndexerCommandType()) +
|
||||||
" indexer command with indexer that supports \"" + indexerCommandTypeToString(getSupportedIndexerCommandType()) + "\".");
|
" indexer command with indexer that supports \"" + indexerCommandTypeToString(getSupportedIndexerCommandType()) + "\".");
|
||||||
|
|
||||||
return std::shared_ptr<IntermediateStorage>();
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return doIndex(castCommand);
|
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
|
||||||
|
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>(storage.get());
|
||||||
|
|
||||||
|
doIndex(castCommand, parserClient, m_indexerStateInfo);
|
||||||
|
|
||||||
|
if (parserClient->hasFatalErrors())
|
||||||
|
{
|
||||||
|
storage->setAllFilesIncomplete();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
storage->setFilesWithErrorsIncomplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_indexerStateInfo->indexingInterrupted)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // INDEXER_H
|
#endif // INDEXER_H
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class IndexerBase
|
|||||||
public:
|
public:
|
||||||
IndexerBase();
|
IndexerBase();
|
||||||
virtual ~IndexerBase() = default;
|
virtual ~IndexerBase() = default;
|
||||||
|
|
||||||
virtual IndexerCommandType getSupportedIndexerCommandType() const = 0;
|
virtual IndexerCommandType getSupportedIndexerCommandType() const = 0;
|
||||||
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommand> indexerCommand) = 0;
|
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommand> indexerCommand) = 0;
|
||||||
virtual void interrupt() = 0;
|
virtual void interrupt() = 0;
|
||||||
|
|||||||
@@ -14,11 +14,16 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::wstring NameHierarchy::serialize(const NameHierarchy& nameHierarchy)
|
std::wstring NameHierarchy::serialize(const NameHierarchy& nameHierarchy)
|
||||||
|
{
|
||||||
|
return serializeRange(nameHierarchy, 0, nameHierarchy.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring NameHierarchy::serializeRange(const NameHierarchy& nameHierarchy, size_t first, size_t last)
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
std::wstringstream ss;
|
||||||
ss << nameDelimiterTypeToString(nameHierarchy.getDelimiter());
|
ss << nameDelimiterTypeToString(nameHierarchy.getDelimiter());
|
||||||
ss << META_DELIMITER;
|
ss << META_DELIMITER;
|
||||||
for (size_t i = 0; i < nameHierarchy.size(); i++)
|
for (size_t i = first; i < last && i < nameHierarchy.size(); i++)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
@@ -102,10 +107,10 @@ NameHierarchy::NameHierarchy(const NameDelimiterType delimiter)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NameHierarchy::NameHierarchy(const std::wstring& name, const NameDelimiterType delimiter)
|
NameHierarchy::NameHierarchy(std::wstring name, const NameDelimiterType delimiter)
|
||||||
: m_delimiter(delimiter)
|
: m_delimiter(delimiter)
|
||||||
{
|
{
|
||||||
push(std::make_shared<NameElement>(name));
|
push(std::make_shared<NameElement>(std::move(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
NameHierarchy::NameHierarchy(const std::vector<std::wstring>& names, const NameDelimiterType delimiter)
|
NameHierarchy::NameHierarchy(const std::vector<std::wstring>& names, const NameDelimiterType delimiter)
|
||||||
@@ -138,6 +143,11 @@ void NameHierarchy::push(std::shared_ptr<NameElement> element)
|
|||||||
m_elements.push_back(element);
|
m_elements.push_back(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NameHierarchy::push(std::wstring name)
|
||||||
|
{
|
||||||
|
m_elements.push_back(std::make_shared<NameElement>(std::move(name)));
|
||||||
|
}
|
||||||
|
|
||||||
void NameHierarchy::pop()
|
void NameHierarchy::pop()
|
||||||
{
|
{
|
||||||
m_elements.pop_back();
|
m_elements.pop_back();
|
||||||
|
|||||||
@@ -12,11 +12,13 @@ class NameHierarchy
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::wstring serialize(const NameHierarchy& nameHierarchy);
|
static std::wstring serialize(const NameHierarchy& nameHierarchy);
|
||||||
|
static std::wstring serializeRange(const NameHierarchy& nameHierarchy, size_t first, size_t last);
|
||||||
static NameHierarchy deserialize(const std::wstring& serializedName);
|
static NameHierarchy deserialize(const std::wstring& serializedName);
|
||||||
|
|
||||||
NameHierarchy(const NameDelimiterType delimiter = NAME_DELIMITER_UNKNOWN);
|
NameHierarchy(const NameDelimiterType delimiter = NAME_DELIMITER_UNKNOWN);
|
||||||
NameHierarchy(const std::wstring& name, const NameDelimiterType delimiter);
|
|
||||||
NameHierarchy(const std::vector<std::wstring>& names, const NameDelimiterType delimiter);
|
NameHierarchy(const std::vector<std::wstring>& names, const NameDelimiterType delimiter);
|
||||||
|
NameHierarchy(std::wstring name, const NameDelimiterType delimiter);
|
||||||
|
|
||||||
NameHierarchy(const NameHierarchy& other);
|
NameHierarchy(const NameHierarchy& other);
|
||||||
NameHierarchy(NameHierarchy&& other);
|
NameHierarchy(NameHierarchy&& other);
|
||||||
~NameHierarchy();
|
~NameHierarchy();
|
||||||
@@ -25,6 +27,7 @@ public:
|
|||||||
void setDelimiter(const NameDelimiterType delimiter);
|
void setDelimiter(const NameDelimiterType delimiter);
|
||||||
|
|
||||||
void push(std::shared_ptr<NameElement> element);
|
void push(std::shared_ptr<NameElement> element);
|
||||||
|
void push(std::wstring name);
|
||||||
void pop();
|
void pop();
|
||||||
|
|
||||||
std::shared_ptr<NameElement> back() const;
|
std::shared_ptr<NameElement> back() const;
|
||||||
|
|||||||
@@ -2,32 +2,28 @@
|
|||||||
|
|
||||||
#include "Edge.h"
|
#include "Edge.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
#include "LocationType.h"
|
|
||||||
#include "ParseLocation.h"
|
#include "ParseLocation.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
ParserClientImpl::ParserClientImpl()
|
ParserClientImpl::ParserClientImpl(IntermediateStorage* const storage)
|
||||||
|
: m_storage(storage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserClientImpl::setStorage(std::shared_ptr<IntermediateStorage> storage)
|
|
||||||
{
|
|
||||||
m_storage = storage;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParserClientImpl::resetStorage()
|
|
||||||
{
|
|
||||||
m_storage.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
Id ParserClientImpl::recordSymbol(
|
Id ParserClientImpl::recordSymbol(
|
||||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||||
AccessKind access, DefinitionKind definitionKind
|
AccessKind access, DefinitionKind definitionKind
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Id nodeId = addNodeHierarchy(symbolName, symbolKindToNodeType(symbolKind));
|
Id nodeId = addNodeHierarchy(symbolName, symbolKindToNodeType(symbolKind));
|
||||||
addSymbol(nodeId, definitionKind);
|
if (definitionKind != DEFINITION_NONE)
|
||||||
addAccess(nodeId, access);
|
{
|
||||||
|
m_storage->addSymbol(StorageSymbol(nodeId, definitionKindToInt(definitionKind)));
|
||||||
|
}
|
||||||
|
if (access != ACCESS_NONE)
|
||||||
|
{
|
||||||
|
m_storage->addComponentAccess(StorageComponentAccess(nodeId, accessKindToInt(access)));
|
||||||
|
}
|
||||||
return nodeId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +34,7 @@ Id ParserClientImpl::recordSymbolWithLocation(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Id nodeId = recordSymbol(symbolName, symbolKind, access, definitionKind);
|
Id nodeId = recordSymbol(symbolName, symbolKind, access, definitionKind);
|
||||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
addSourceLocation(nodeId, location, LOCATION_TOKEN);
|
||||||
return nodeId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +45,7 @@ Id ParserClientImpl::recordSymbolWithLocationAndScope(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Id nodeId = recordSymbolWithLocation(symbolName, symbolKind, location, access, definitionKind);
|
Id nodeId = recordSymbolWithLocation(symbolName, symbolKind, location, access, definitionKind);
|
||||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
addSourceLocation(nodeId, scopeLocation, LOCATION_SCOPE);
|
||||||
return nodeId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +55,7 @@ Id ParserClientImpl::recordSymbolWithLocationAndScopeAndSignature(
|
|||||||
AccessKind access, DefinitionKind definitionKind)
|
AccessKind access, DefinitionKind definitionKind)
|
||||||
{
|
{
|
||||||
Id nodeId = recordSymbolWithLocationAndScope(symbolName, symbolKind, location, scopeLocation, access, definitionKind);
|
Id nodeId = recordSymbolWithLocationAndScope(symbolName, symbolKind, location, scopeLocation, access, definitionKind);
|
||||||
addSourceLocation(nodeId, signatureLocation, locationTypeToInt(LOCATION_SIGNATURE));
|
addSourceLocation(nodeId, signatureLocation, LOCATION_SIGNATURE);
|
||||||
return nodeId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,30 +66,36 @@ void ParserClientImpl::recordReference(
|
|||||||
Id contextNodeId = addNodeHierarchy(contextName);
|
Id contextNodeId = addNodeHierarchy(contextName);
|
||||||
Id referencedNodeId = addNodeHierarchy(referencedName);
|
Id referencedNodeId = addNodeHierarchy(referencedName);
|
||||||
Id edgeId = addEdge(referenceKindToEdgeType(referenceKind), contextNodeId, referencedNodeId);
|
Id edgeId = addEdge(referenceKindToEdgeType(referenceKind), contextNodeId, referencedNodeId);
|
||||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
addSourceLocation(edgeId, location, LOCATION_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserClientImpl::recordQualifierLocation(const NameHierarchy& qualifierName, const ParseLocation& location)
|
void ParserClientImpl::recordQualifierLocation(const NameHierarchy& qualifierName, const ParseLocation& location)
|
||||||
{
|
{
|
||||||
Id nodeId = addNodeHierarchy(qualifierName, NodeType::NODE_SYMBOL);
|
Id nodeId = addNodeHierarchy(qualifierName, NodeType::NODE_SYMBOL);
|
||||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_QUALIFIER));
|
addSourceLocation(nodeId, location, LOCATION_QUALIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserClientImpl::recordLocalSymbol(const std::wstring& name, const ParseLocation& location)
|
void ParserClientImpl::recordLocalSymbol(const std::wstring& name, const ParseLocation& location)
|
||||||
{
|
{
|
||||||
const Id localSymbolId = addLocalSymbol(name);
|
const Id localSymbolId = m_storage->addLocalSymbol(name);
|
||||||
addSourceLocation(localSymbolId, location, locationTypeToInt(LOCATION_LOCAL_SYMBOL));
|
addSourceLocation(localSymbolId, location, LOCATION_LOCAL_SYMBOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserClientImpl::recordFile(const FilePath& filePath, bool indexed)
|
void ParserClientImpl::recordFile(const FilePath& filePath, bool indexed)
|
||||||
{
|
{
|
||||||
const Id nodeId = addNodeHierarchy(NameHierarchy(filePath.wstr(), NAME_DELIMITER_FILE), NodeType::NODE_FILE);
|
const Id fileId = addFileName(filePath);
|
||||||
addFile(nodeId, filePath, indexed);
|
m_storage->addFile(StorageFile(fileId, filePath.wstr(), indexed, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserClientImpl::recordComment(const ParseLocation& location)
|
void ParserClientImpl::recordComment(const ParseLocation& location)
|
||||||
{
|
{
|
||||||
addCommentLocation(location);
|
m_storage->addCommentLocation(StorageCommentLocationData(
|
||||||
|
addFileName(location.filePath),
|
||||||
|
location.startLineNumber,
|
||||||
|
location.startColumnNumber,
|
||||||
|
location.endLineNumber,
|
||||||
|
location.endColumnNumber
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserClientImpl::doRecordError(
|
void ParserClientImpl::doRecordError(
|
||||||
@@ -101,7 +103,15 @@ void ParserClientImpl::doRecordError(
|
|||||||
{
|
{
|
||||||
if (location.isValid())
|
if (location.isValid())
|
||||||
{
|
{
|
||||||
addError(message, fatal, indexed, location, translationUnit);
|
m_storage->addError(StorageErrorData(
|
||||||
|
message,
|
||||||
|
location.filePath.wstr(),
|
||||||
|
location.startLineNumber,
|
||||||
|
location.startColumnNumber,
|
||||||
|
translationUnit.wstr(),
|
||||||
|
fatal,
|
||||||
|
indexed
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,31 +199,15 @@ Edge::EdgeType ParserClientImpl::referenceKindToEdgeType(ReferenceKind reference
|
|||||||
return Edge::EDGE_UNDEFINED;
|
return Edge::EDGE_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserClientImpl::addAccess(Id nodeId, AccessKind access)
|
|
||||||
{
|
|
||||||
if (access != ACCESS_NONE)
|
|
||||||
{
|
|
||||||
addComponentAccess(nodeId, accessKindToInt(access));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Id ParserClientImpl::addNodeHierarchy(const NameHierarchy& nameHierarchy, NodeType nodeType)
|
Id ParserClientImpl::addNodeHierarchy(const NameHierarchy& nameHierarchy, NodeType nodeType)
|
||||||
{
|
{
|
||||||
if (nameHierarchy.size() == 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Id parentNodeId = 0;
|
Id parentNodeId = 0;
|
||||||
NameHierarchy currentNameHierarchy(nameHierarchy.getDelimiter());
|
for (size_t i = 1; i <= nameHierarchy.size(); i++)
|
||||||
|
|
||||||
for (size_t i = 0; i < nameHierarchy.size(); i++)
|
|
||||||
{
|
{
|
||||||
currentNameHierarchy.push(nameHierarchy[i]);
|
const NodeType currentType = (i == nameHierarchy.size() ? nodeType : NodeType::NODE_SYMBOL); // TODO: rename to unknown!
|
||||||
const bool currentIsLastElement = (i == nameHierarchy.size() - 1);
|
|
||||||
const NodeType currentType = (currentIsLastElement ? nodeType : NodeType::NODE_SYMBOL); // TODO: rename to unknown!
|
|
||||||
|
|
||||||
Id nodeId = addNode(currentType, currentNameHierarchy);
|
Id nodeId = m_storage->addNode(StorageNodeData(
|
||||||
|
NodeType::typeToInt(currentType.getType()), NameHierarchy::serializeRange(nameHierarchy, 0, i)));
|
||||||
|
|
||||||
if (parentNodeId != 0)
|
if (parentNodeId != 0)
|
||||||
{
|
{
|
||||||
@@ -225,69 +219,32 @@ Id ParserClientImpl::addNodeHierarchy(const NameHierarchy& nameHierarchy, NodeTy
|
|||||||
return parentNodeId;
|
return parentNodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
Id ParserClientImpl::addNode(NodeType nodeType, const NameHierarchy& nameHierarchy)
|
Id ParserClientImpl::addFileName(const FilePath& filePath)
|
||||||
{
|
{
|
||||||
if (!m_storage)
|
const std::wstring file = filePath.wstr();
|
||||||
|
|
||||||
|
auto it = m_fileIdMap.find(file);
|
||||||
|
if (it != m_fileIdMap.end())
|
||||||
{
|
{
|
||||||
return 0;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_storage->addNode(StorageNodeData(NodeType::typeToInt(nodeType.getType()), NameHierarchy::serialize(nameHierarchy)));
|
const Id fileId = addNodeHierarchy(NameHierarchy(file, NAME_DELIMITER_FILE), NodeType::NODE_FILE);
|
||||||
}
|
m_fileIdMap.emplace(file, fileId);
|
||||||
|
return fileId;
|
||||||
void ParserClientImpl::addFile(Id id, const FilePath& filePath, bool indexed)
|
|
||||||
{
|
|
||||||
if (m_storage)
|
|
||||||
{
|
|
||||||
m_storage->addFile(StorageFile(id, filePath.wstr(), indexed, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParserClientImpl::addSymbol(Id id, DefinitionKind definitionKind)
|
|
||||||
{
|
|
||||||
if (!m_storage)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (definitionKind != DEFINITION_NONE)
|
|
||||||
{
|
|
||||||
m_storage->addSymbol(StorageSymbol(id, definitionKindToInt(definitionKind)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Id ParserClientImpl::addEdge(int type, Id sourceId, Id targetId)
|
Id ParserClientImpl::addEdge(int type, Id sourceId, Id targetId)
|
||||||
{
|
{
|
||||||
if (!m_storage)
|
if (sourceId && targetId)
|
||||||
{
|
{
|
||||||
return 0;
|
return m_storage->addEdge(StorageEdgeData(type, sourceId, targetId));
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
if (!sourceId || !targetId)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_storage->addEdge(StorageEdgeData(type, sourceId, targetId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Id ParserClientImpl::addLocalSymbol(const std::wstring& name)
|
void ParserClientImpl::addSourceLocation(Id elementId, const ParseLocation& location, LocationType type)
|
||||||
{
|
{
|
||||||
if (!m_storage)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_storage->addLocalSymbol(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParserClientImpl::addSourceLocation(Id elementId, const ParseLocation& location, int type)
|
|
||||||
{
|
|
||||||
if (!m_storage)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!location.isValid())
|
if (!location.isValid())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -300,12 +257,12 @@ void ParserClientImpl::addSourceLocation(Id elementId, const ParseLocation& loca
|
|||||||
}
|
}
|
||||||
|
|
||||||
Id sourceLocationId = m_storage->addSourceLocation(StorageSourceLocationData(
|
Id sourceLocationId = m_storage->addSourceLocation(StorageSourceLocationData(
|
||||||
addNodeHierarchy(NameHierarchy(location.filePath.wstr(), NAME_DELIMITER_FILE), NodeType::NODE_FILE),
|
addFileName(location.filePath),
|
||||||
location.startLineNumber,
|
location.startLineNumber,
|
||||||
location.startColumnNumber,
|
location.startColumnNumber,
|
||||||
location.endLineNumber,
|
location.endLineNumber,
|
||||||
location.endColumnNumber,
|
location.endColumnNumber,
|
||||||
type
|
locationTypeToInt(type)
|
||||||
));
|
));
|
||||||
|
|
||||||
m_storage->addOccurrence(StorageOccurrence(
|
m_storage->addOccurrence(StorageOccurrence(
|
||||||
@@ -313,42 +270,3 @@ void ParserClientImpl::addSourceLocation(Id elementId, const ParseLocation& loca
|
|||||||
sourceLocationId
|
sourceLocationId
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParserClientImpl::addComponentAccess(Id nodeId , int type)
|
|
||||||
{
|
|
||||||
if (!m_storage)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_storage->addComponentAccess(StorageComponentAccess(nodeId, type));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParserClientImpl::addCommentLocation(const ParseLocation& location)
|
|
||||||
{
|
|
||||||
if (!m_storage)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_storage->addCommentLocation(StorageCommentLocationData(
|
|
||||||
addNodeHierarchy(NameHierarchy(location.filePath.wstr(), NAME_DELIMITER_FILE), NodeType::NODE_FILE),
|
|
||||||
location.startLineNumber,
|
|
||||||
location.startColumnNumber,
|
|
||||||
location.endLineNumber,
|
|
||||||
location.endColumnNumber
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParserClientImpl::addError(
|
|
||||||
const std::wstring& message, bool fatal, bool indexed, const ParseLocation& location, const FilePath& translationUnit)
|
|
||||||
{
|
|
||||||
if (!m_storage)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_storage->addError(StorageErrorData(
|
|
||||||
message, location.filePath.wstr(), location.startLineNumber, location.startColumnNumber, translationUnit.wstr(), fatal, indexed
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,16 +6,14 @@
|
|||||||
#include "DefinitionKind.h"
|
#include "DefinitionKind.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
#include "IntermediateStorage.h"
|
#include "IntermediateStorage.h"
|
||||||
|
#include "LocationType.h"
|
||||||
#include "ParserClient.h"
|
#include "ParserClient.h"
|
||||||
|
|
||||||
class ParserClientImpl
|
class ParserClientImpl
|
||||||
: public ParserClient
|
: public ParserClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ParserClientImpl();
|
ParserClientImpl(IntermediateStorage* const storage);
|
||||||
|
|
||||||
void setStorage(std::shared_ptr<IntermediateStorage> storage);
|
|
||||||
void resetStorage();
|
|
||||||
|
|
||||||
Id recordSymbol(
|
Id recordSymbol(
|
||||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||||
@@ -54,20 +52,17 @@ private:
|
|||||||
NodeType symbolKindToNodeType(SymbolKind symbolType) const;
|
NodeType symbolKindToNodeType(SymbolKind symbolType) const;
|
||||||
Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const;
|
Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const;
|
||||||
void addAccess(Id nodeId, AccessKind access);
|
void addAccess(Id nodeId, AccessKind access);
|
||||||
Id addNodeHierarchy(const NameHierarchy& nameHierarchy, NodeType nodeType = NodeType::NODE_SYMBOL);
|
|
||||||
|
|
||||||
Id addNode(NodeType nodeType, const NameHierarchy& nameHierarchy);
|
Id addNodeHierarchy(const NameHierarchy& nameHierarchy, NodeType nodeType = NodeType::NODE_SYMBOL);
|
||||||
void addFile(Id id, const FilePath& filePath, bool indexed);
|
Id addFileName(const FilePath& filePath);
|
||||||
void addSymbol(Id id, DefinitionKind definitionKind);
|
|
||||||
Id addEdge(int type, Id sourceId, Id targetId);
|
Id addEdge(int type, Id sourceId, Id targetId);
|
||||||
Id addLocalSymbol(const std::wstring& name);
|
|
||||||
void addSourceLocation(Id elementId, const ParseLocation& location, int type);
|
void addSourceLocation(Id elementId, const ParseLocation& location, LocationType type);
|
||||||
void addComponentAccess(Id nodeId , int type);
|
|
||||||
void addCommentLocation(const ParseLocation& location);
|
|
||||||
void addError(const std::wstring& message, bool fatal, bool indexed,
|
void addError(const std::wstring& message, bool fatal, bool indexed,
|
||||||
const ParseLocation& location, const FilePath& sourceFilePath);
|
const ParseLocation& location, const FilePath& sourceFilePath);
|
||||||
|
|
||||||
std::shared_ptr<IntermediateStorage> m_storage;
|
IntermediateStorage* const m_storage;
|
||||||
|
std::map<std::wstring, Id> m_fileIdMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARSER_CLIENT_IMPL_H
|
#endif // PARSER_CLIENT_IMPL_H
|
||||||
|
|||||||
@@ -2,25 +2,13 @@
|
|||||||
|
|
||||||
#include "CxxParser.h"
|
#include "CxxParser.h"
|
||||||
#include "FileRegister.h"
|
#include "FileRegister.h"
|
||||||
#include "IndexerStateInfo.h"
|
|
||||||
#include "ParserClientImpl.h"
|
|
||||||
|
|
||||||
IndexerCxx::IndexerCxx()
|
void IndexerCxx::doIndex(
|
||||||
: m_indexerStateInfo(std::make_shared<IndexerStateInfo>())
|
std::shared_ptr<IndexerCommandCxx> indexerCommand,
|
||||||
{
|
std::shared_ptr<ParserClientImpl> parserClient,
|
||||||
m_indexerStateInfo->indexingInterrupted = false;
|
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo
|
||||||
}
|
){
|
||||||
|
CxxParser parser(
|
||||||
void IndexerCxx::interrupt()
|
|
||||||
{
|
|
||||||
m_indexerStateInfo->indexingInterrupted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<IntermediateStorage> IndexerCxx::doIndex(std::shared_ptr<IndexerCommandCxx> indexerCommand)
|
|
||||||
{
|
|
||||||
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
|
|
||||||
|
|
||||||
std::shared_ptr<CxxParser> parser = std::make_shared<CxxParser>(
|
|
||||||
parserClient,
|
parserClient,
|
||||||
std::make_shared<FileRegister>(
|
std::make_shared<FileRegister>(
|
||||||
indexerCommand->getSourceFilePath(), indexerCommand->getIndexedPaths(), indexerCommand->getExcludeFilters()
|
indexerCommand->getSourceFilePath(), indexerCommand->getIndexedPaths(), indexerCommand->getExcludeFilters()
|
||||||
@@ -28,26 +16,5 @@ std::shared_ptr<IntermediateStorage> IndexerCxx::doIndex(std::shared_ptr<Indexer
|
|||||||
m_indexerStateInfo
|
m_indexerStateInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
|
parser.buildIndex(indexerCommand);
|
||||||
parserClient->setStorage(storage);
|
|
||||||
|
|
||||||
parser->buildIndex(indexerCommand);
|
|
||||||
|
|
||||||
parserClient->resetStorage();
|
|
||||||
|
|
||||||
if (parserClient->hasFatalErrors())
|
|
||||||
{
|
|
||||||
storage->setAllFilesIncomplete();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
storage->setFilesWithErrorsIncomplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_indexerStateInfo->indexingInterrupted)
|
|
||||||
{
|
|
||||||
return std::shared_ptr<IntermediateStorage>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return storage;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,17 @@
|
|||||||
#ifndef INDEXER_CXX_H
|
#ifndef INDEXER_CXX_H
|
||||||
#define INDEXER_CXX_H
|
#define INDEXER_CXX_H
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include "Indexer.h"
|
#include "Indexer.h"
|
||||||
#include "IndexerCommandCxx.h"
|
#include "IndexerCommandCxx.h"
|
||||||
|
|
||||||
struct IndexerStateInfo;
|
class IndexerCxx
|
||||||
|
: public Indexer<IndexerCommandCxx>
|
||||||
class IndexerCxx: public Indexer<IndexerCommandCxx>
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
IndexerCxx();
|
|
||||||
void interrupt() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<IntermediateStorage> doIndex(std::shared_ptr<IndexerCommandCxx> indexerCommand) override;
|
void doIndex(
|
||||||
|
std::shared_ptr<IndexerCommandCxx> indexerCommand,
|
||||||
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo;
|
std::shared_ptr<ParserClientImpl> parserClient,
|
||||||
|
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INDEXER_CXX_H
|
#endif // INDEXER_CXX_H
|
||||||
|
|||||||
@@ -1,52 +1,16 @@
|
|||||||
#include "IndexerJava.h"
|
#include "IndexerJava.h"
|
||||||
|
|
||||||
#include "IndexerCommandJava.h"
|
|
||||||
#include "IndexerStateInfo.h"
|
|
||||||
#include "JavaParser.h"
|
#include "JavaParser.h"
|
||||||
#include "ParserClientImpl.h"
|
|
||||||
|
|
||||||
IndexerJava::IndexerJava()
|
|
||||||
: m_indexerStateInfo(std::make_shared<IndexerStateInfo>())
|
|
||||||
{
|
|
||||||
m_indexerStateInfo->indexingInterrupted = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IndexerJava::~IndexerJava()
|
IndexerJava::~IndexerJava()
|
||||||
{
|
{
|
||||||
JavaParser::clearCaches();
|
JavaParser::clearCaches();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IndexerJava::interrupt()
|
void IndexerJava::doIndex(
|
||||||
{
|
std::shared_ptr<IndexerCommandJava> indexerCommand,
|
||||||
m_indexerStateInfo->indexingInterrupted = true;
|
std::shared_ptr<ParserClientImpl> parserClient,
|
||||||
}
|
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo
|
||||||
|
){
|
||||||
std::shared_ptr<IntermediateStorage> IndexerJava::doIndex(std::shared_ptr<IndexerCommandJava> indexerCommand)
|
JavaParser(parserClient, m_indexerStateInfo).buildIndex(indexerCommand);
|
||||||
{
|
|
||||||
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
|
|
||||||
|
|
||||||
std::shared_ptr<JavaParser> parser = std::make_shared<JavaParser>(parserClient, m_indexerStateInfo);
|
|
||||||
|
|
||||||
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
|
|
||||||
parserClient->setStorage(storage);
|
|
||||||
|
|
||||||
parser->buildIndex(indexerCommand);
|
|
||||||
|
|
||||||
parserClient->resetStorage();
|
|
||||||
|
|
||||||
if (parserClient->hasFatalErrors())
|
|
||||||
{
|
|
||||||
storage->setAllFilesIncomplete();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
storage->setFilesWithErrorsIncomplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_indexerStateInfo->indexingInterrupted)
|
|
||||||
{
|
|
||||||
return std::shared_ptr<IntermediateStorage>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return storage;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
#ifndef INDEXER_JAVA_H
|
#ifndef INDEXER_JAVA_H
|
||||||
#define INDEXER_JAVA_H
|
#define INDEXER_JAVA_H
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "Indexer.h"
|
#include "Indexer.h"
|
||||||
#include "IndexerCommandJava.h"
|
#include "IndexerCommandJava.h"
|
||||||
|
|
||||||
struct IndexerStateInfo;
|
struct IndexerStateInfo;
|
||||||
|
|
||||||
class IndexerJava: public Indexer<IndexerCommandJava>
|
class IndexerJava
|
||||||
|
: public Indexer<IndexerCommandJava>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IndexerJava();
|
|
||||||
virtual ~IndexerJava();
|
virtual ~IndexerJava();
|
||||||
void interrupt() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<IntermediateStorage> doIndex(std::shared_ptr<IndexerCommandJava> indexerCommand) override;
|
void doIndex(
|
||||||
|
std::shared_ptr<IndexerCommandJava> indexerCommand,
|
||||||
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo;
|
std::shared_ptr<ParserClientImpl> parserClient,
|
||||||
|
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INDEXER_JAVA_H
|
#endif // INDEXER_JAVA_H
|
||||||
|
|||||||
Reference in New Issue
Block a user