ui: show when type is built-in (issue #2)
* renamed DefinitionType to DefinitionKind * passing DefinitionKind from Java to C++ instead of just a single bool * omitting to create a symbol for undefined types fortune cookie message = Happy news is on the way to you.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#include "data/DefinitionKind.h"
|
||||
|
||||
int definitionKindToInt(DefinitionKind definitionKind)
|
||||
{
|
||||
return definitionKind;
|
||||
}
|
||||
|
||||
DefinitionKind intToDefinitionKind(int definitionKind)
|
||||
{
|
||||
switch (definitionKind)
|
||||
{
|
||||
case 0:
|
||||
return DEFINITION_NONE;
|
||||
case 1:
|
||||
return DEFINITION_IMPLICIT;
|
||||
case 2:
|
||||
return DEFINITION_EXPLICIT;
|
||||
}
|
||||
return DEFINITION_NONE;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef DEFINITION_KIND_H
|
||||
#define DEFINITION_KIND_H
|
||||
|
||||
enum DefinitionKind
|
||||
{ // these values need to be the same as DefinitionKind in Java code
|
||||
DEFINITION_NONE = 0,
|
||||
DEFINITION_IMPLICIT = 1,
|
||||
DEFINITION_EXPLICIT = 2
|
||||
};
|
||||
|
||||
int definitionKindToInt(DefinitionKind definitionKind);
|
||||
DefinitionKind intToDefinitionKind(int definitionKind);
|
||||
|
||||
#endif // DEFINITION_TYPE_H
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "data/DefinitionType.h"
|
||||
|
||||
int definitionTypeToInt(DefinitionType definitionType)
|
||||
{
|
||||
return definitionType;
|
||||
}
|
||||
|
||||
DefinitionType intToDefinitionType(int definitionType)
|
||||
{
|
||||
switch (definitionType)
|
||||
{
|
||||
case 0:
|
||||
return DEFINITION_NONE;
|
||||
case 1:
|
||||
return DEFINITION_IMPLICIT;
|
||||
case 2:
|
||||
return DEFINITION_EXPLICIT;
|
||||
}
|
||||
return DEFINITION_NONE;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef DEFINITION_TYPE_H
|
||||
#define DEFINITION_TYPE_H
|
||||
|
||||
enum DefinitionType
|
||||
{
|
||||
DEFINITION_NONE = 0,
|
||||
DEFINITION_IMPLICIT = 1,
|
||||
DEFINITION_EXPLICIT = 2
|
||||
};
|
||||
|
||||
int definitionTypeToInt(DefinitionType definitionType);
|
||||
DefinitionType intToDefinitionType(int definitionType);
|
||||
|
||||
#endif // DEFINITION_TYPE_H
|
||||
@@ -65,9 +65,9 @@ void IntermediateStorage::addFile(const Id id, const std::string& filePath, cons
|
||||
m_files.push_back(StorageFile(id, filePath, modificationTime));
|
||||
}
|
||||
|
||||
void IntermediateStorage::addSymbol(const Id id, int definitionType)
|
||||
void IntermediateStorage::addSymbol(const Id id, int definitionKind)
|
||||
{
|
||||
m_symbols.push_back(StorageSymbol(id, definitionType));
|
||||
m_symbols.push_back(StorageSymbol(id, definitionKind));
|
||||
}
|
||||
|
||||
Id IntermediateStorage::addEdge(int type, Id sourceId, Id targetId)
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
virtual Id addNode(int type, const std::string& serializedName);
|
||||
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime);
|
||||
virtual void addSymbol(const Id id, int definitionType);
|
||||
virtual void addSymbol(const Id id, int definitionKind);
|
||||
virtual Id addEdge(int type, Id sourceId, Id targetId);
|
||||
virtual Id addLocalSymbol(const std::string& name);
|
||||
virtual Id addSourceLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
|
||||
|
||||
@@ -65,11 +65,11 @@ void PersistentStorage::addFile(const Id id, const std::string& filePath, const
|
||||
}
|
||||
}
|
||||
|
||||
void PersistentStorage::addSymbol(const Id id, int definitionType)
|
||||
void PersistentStorage::addSymbol(const Id id, int definitionKind)
|
||||
{
|
||||
if (m_sqliteStorage.getFirstById<StorageSymbol>(id).id == 0)
|
||||
{
|
||||
m_sqliteStorage.addSymbol(id, definitionType);
|
||||
m_sqliteStorage.addSymbol(id, definitionKind);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -607,8 +607,8 @@ std::set<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(const st
|
||||
match.typeName = Node::getTypeString(match.nodeType);
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
|
||||
if (storageSymbolMap.find(firstNode->id) == storageSymbolMap.end()
|
||||
&& match.nodeType != Node::NODE_UNDEFINED)
|
||||
if (storageSymbolMap.find(firstNode->id) == storageSymbolMap.end() &&
|
||||
match.nodeType != Node::NODE_UNDEFINED)
|
||||
{
|
||||
match.typeName = "undefined " + match.typeName;
|
||||
}
|
||||
@@ -722,7 +722,7 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForAll() const
|
||||
std::unordered_set<Id> explicitlyDefinedSymbolIds;
|
||||
for (StorageSymbol symbol: m_sqliteStorage.getAll<StorageSymbol>())
|
||||
{
|
||||
if (intToDefinitionType(symbol.definitionType) == DEFINITION_EXPLICIT)
|
||||
if (intToDefinitionKind(symbol.definitionKind) == DEFINITION_EXPLICIT)
|
||||
{
|
||||
explicitlyDefinedSymbolIds.insert(symbol.id);
|
||||
}
|
||||
@@ -822,7 +822,7 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForActiveTokenIds(const std::v
|
||||
{
|
||||
for (const StorageSymbol& symbol : m_sqliteStorage.getAllByIds<StorageSymbol>(ids))
|
||||
{
|
||||
if (symbol.id > 0 && (!isNamespace || intToDefinitionType(symbol.definitionType) != DEFINITION_IMPLICIT))
|
||||
if (symbol.id > 0 && (!isNamespace || intToDefinitionKind(symbol.definitionKind) != DEFINITION_IMPLICIT))
|
||||
{
|
||||
nodeIds.push_back(symbol.id);
|
||||
}
|
||||
@@ -912,7 +912,7 @@ std::vector<Id> PersistentStorage::getNodeIdsForLocationIds(const std::vector<Id
|
||||
StorageSymbol symbol = m_sqliteStorage.getFirstById<StorageSymbol>(elementId);
|
||||
if (symbol.id != 0) // here we test if location is a symbol
|
||||
{
|
||||
if (intToDefinitionType(symbol.definitionType) == DEFINITION_IMPLICIT)
|
||||
if (intToDefinitionKind(symbol.definitionKind) == DEFINITION_IMPLICIT)
|
||||
{
|
||||
implicitNodeIds.insert(elementId);
|
||||
}
|
||||
@@ -1472,25 +1472,25 @@ void PersistentStorage::addNodesToGraph(const std::vector<Id>& nodeIds, Graph* g
|
||||
{
|
||||
const NameHierarchy nameHierarchy = NameHierarchy::deserialize(storageNode.serializedName);
|
||||
|
||||
DefinitionType defType = DEFINITION_NONE;
|
||||
DefinitionKind defKind = DEFINITION_NONE;
|
||||
auto it = symbolMap.find(storageNode.id);
|
||||
if (it != symbolMap.end())
|
||||
{
|
||||
defType = intToDefinitionType(it->second.definitionType);
|
||||
defKind = intToDefinitionKind(it->second.definitionKind);
|
||||
}
|
||||
|
||||
Node* node = graph->createNode(
|
||||
storageNode.id,
|
||||
type,
|
||||
nameHierarchy,
|
||||
defType != DEFINITION_NONE
|
||||
defKind != DEFINITION_NONE
|
||||
);
|
||||
|
||||
if (defType == DEFINITION_IMPLICIT)
|
||||
if (defKind == DEFINITION_IMPLICIT)
|
||||
{
|
||||
node->setImplicit(true);
|
||||
}
|
||||
else if (defType == DEFINITION_EXPLICIT)
|
||||
else if (defKind == DEFINITION_EXPLICIT)
|
||||
{
|
||||
node->setExplicit(true);
|
||||
}
|
||||
@@ -1733,7 +1733,7 @@ void PersistentStorage::buildSearchIndex()
|
||||
else
|
||||
{
|
||||
auto it = symbolMap.find(node.id);
|
||||
if (it == symbolMap.end() || intToDefinitionType(it->second.definitionType) != DEFINITION_IMPLICIT)
|
||||
if (it == symbolMap.end() || intToDefinitionKind(it->second.definitionKind) != DEFINITION_IMPLICIT)
|
||||
{
|
||||
// we don't use the signature here, so elements with the same signature share the same node.
|
||||
m_symbolIndex.addNode(node.id, NameHierarchy::deserialize(node.serializedName).getQualifiedName());
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
virtual Id addNode(int type, const std::string& serializedName);
|
||||
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime);
|
||||
virtual void addSymbol(const Id id, int definitionType);
|
||||
virtual void addSymbol(const Id id, int definitionKind);
|
||||
virtual Id addEdge(int type, Id sourceId, Id targetId);
|
||||
virtual Id addLocalSymbol(const std::string& name);
|
||||
virtual Id addSourceLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/location/TokenLocation.h"
|
||||
#include "data/DefinitionType.h"
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
const size_t SqliteStorage::STORAGE_VERSION = 7;
|
||||
const size_t SqliteStorage::STORAGE_VERSION = 8;
|
||||
|
||||
SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
|
||||
: m_dbFilePath(dbFilePath)
|
||||
@@ -198,11 +197,11 @@ Id SqliteStorage::addNode(const int type, const std::string& serializedName)
|
||||
return id;
|
||||
}
|
||||
|
||||
void SqliteStorage::addSymbol(const int id, const int definitionType)
|
||||
void SqliteStorage::addSymbol(const int id, const int definitionKind)
|
||||
{
|
||||
executeStatement(
|
||||
"INSERT INTO symbol(id, definition_type) VALUES("
|
||||
+ std::to_string(id) + ", " + std::to_string(definitionType) + ");"
|
||||
"INSERT INTO symbol(id, definition_kind) VALUES("
|
||||
+ std::to_string(id) + ", " + std::to_string(definitionKind) + ");"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -587,13 +586,6 @@ void SqliteStorage::setNodeType(int type, Id nodeId)
|
||||
);
|
||||
}
|
||||
|
||||
void SqliteStorage::setSymbolDefinitionType(int definitionType, Id symbolId)
|
||||
{
|
||||
executeStatement(
|
||||
"UPDATE symbol SET definition_type = " + std::to_string(definitionType) + " WHERE id == " + std::to_string(symbolId) + ";"
|
||||
);
|
||||
}
|
||||
|
||||
StorageSourceLocation SqliteStorage::getSourceLocationByAll(const Id fileNodeId, const uint startLine, const uint startCol, const uint endLine, const uint endCol, const int type) const
|
||||
{
|
||||
return doGetFirst<StorageSourceLocation>(
|
||||
@@ -769,7 +761,7 @@ void SqliteStorage::setupTables()
|
||||
m_database.execDML(
|
||||
"CREATE TABLE IF NOT EXISTS symbol("
|
||||
"id INTEGER NOT NULL, "
|
||||
"definition_type INTEGER NOT NULL, "
|
||||
"definition_kind INTEGER NOT NULL, "
|
||||
"PRIMARY KEY(id), "
|
||||
"FOREIGN KEY(id) REFERENCES node(id) ON DELETE CASCADE);"
|
||||
);
|
||||
@@ -1057,18 +1049,18 @@ template <>
|
||||
std::vector<StorageSymbol> SqliteStorage::doGetAll<StorageSymbol>(const std::string& query) const
|
||||
{
|
||||
CppSQLite3Query q = executeQuery(
|
||||
"SELECT id, definition_type FROM symbol " + query + ";"
|
||||
"SELECT id, definition_kind FROM symbol " + query + ";"
|
||||
);
|
||||
|
||||
std::vector<StorageSymbol> symbols;
|
||||
while (!q.eof())
|
||||
{
|
||||
const Id id = q.getIntField(0, 0);
|
||||
const int definitionType = q.getIntField(1, 0);
|
||||
const int definitionKind = q.getIntField(1, 0);
|
||||
|
||||
if (id != 0)
|
||||
{
|
||||
symbols.push_back(StorageSymbol(id, definitionType));
|
||||
symbols.push_back(StorageSymbol(id, definitionKind));
|
||||
}
|
||||
|
||||
q.nextRow();
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
Id addEdge(int type, Id sourceNodeId, Id targetNodeId);
|
||||
|
||||
Id addNode(const int type, const std::string& serializedName);
|
||||
void addSymbol(const int id, int definitionType);
|
||||
void addSymbol(const int id, int definitionKind);
|
||||
void addFile(const int id, const std::string& filePath, const std::string& modificationTime);
|
||||
Id addLocalSymbol(const std::string& name);
|
||||
Id addSourceLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
|
||||
@@ -102,7 +102,6 @@ public:
|
||||
std::shared_ptr<TextAccess> getFileContentById(Id fileId) const;
|
||||
|
||||
void setNodeType(int type, Id nodeId);
|
||||
void setSymbolDefinitionType(int definitionType, Id symbolId);
|
||||
|
||||
StorageSourceLocation getSourceLocationByAll(const Id fileNodeId, const uint startLine, const uint startCol, const uint endLine, const uint endCol, const int type) const;
|
||||
std::shared_ptr<TokenLocationFile> getTokenLocationsForFile(const FilePath& filePath) const;
|
||||
|
||||
@@ -61,7 +61,7 @@ void Storage::inject(Storage* injected)
|
||||
}
|
||||
const Id ownId = it->second;
|
||||
|
||||
addSymbol(ownId, injectedData.definitionType);
|
||||
addSymbol(ownId, injectedData.definitionKind);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
virtual Id addNode(int type, const std::string& serializedName) = 0;
|
||||
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime) = 0;
|
||||
virtual void addSymbol(const Id id, int definitionType) = 0;
|
||||
virtual void addSymbol(const Id id, int definitionKind) = 0;
|
||||
virtual Id addEdge(int type, Id sourceId, Id targetId) = 0;
|
||||
virtual Id addLocalSymbol(const std::string& name) = 0;
|
||||
virtual Id addSourceLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type) = 0;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
#include "data/DefinitionType.h"
|
||||
#include "data/DefinitionKind.h"
|
||||
|
||||
struct StorageEdge
|
||||
{
|
||||
@@ -53,16 +53,16 @@ struct StorageSymbol
|
||||
{
|
||||
StorageSymbol()
|
||||
: id(0)
|
||||
, definitionType(definitionTypeToInt(DEFINITION_NONE))
|
||||
, definitionKind(definitionKindToInt(DEFINITION_NONE))
|
||||
{}
|
||||
|
||||
StorageSymbol(Id id, int definitionType)
|
||||
StorageSymbol(Id id, int definitionKind)
|
||||
: id(id)
|
||||
, definitionType(definitionType)
|
||||
, definitionKind(definitionKind)
|
||||
{}
|
||||
|
||||
Id id;
|
||||
int definitionType;
|
||||
int definitionKind;
|
||||
};
|
||||
|
||||
struct StorageFile
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define ACCESS_KIND_H
|
||||
|
||||
enum AccessKind
|
||||
{ // these values need to be the same as AccessType in Java code
|
||||
{ // these values need to be the same as AccessKind in Java code
|
||||
ACCESS_NONE = 0,
|
||||
ACCESS_PUBLIC = 1,
|
||||
ACCESS_PROTECTED = 2,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "data/parser/AccessKind.h"
|
||||
#include "data/parser/ReferenceKind.h"
|
||||
#include "data/parser/SymbolKind.h"
|
||||
#include "data/DefinitionType.h"
|
||||
#include "data/DefinitionKind.h"
|
||||
#include "utility/file/FileInfo.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
@@ -33,17 +33,17 @@ public:
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access, DefinitionType definitionType) = 0;
|
||||
AccessKind access, DefinitionKind definitionKind) = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, DefinitionType definitionType) = 0;
|
||||
AccessKind access, DefinitionKind definitionKind) = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, DefinitionType definitionType) = 0;
|
||||
AccessKind access, DefinitionKind definitionKind) = 0;
|
||||
|
||||
virtual void recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
|
||||
@@ -35,11 +35,11 @@ void ParserClientImpl::finishParsingFile()
|
||||
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access, DefinitionType definitionType
|
||||
AccessKind access, DefinitionKind definitionKind
|
||||
)
|
||||
{
|
||||
Id nodeId = addNodeHierarchy(symbolName, symbolKindToNodeType(symbolType));
|
||||
addSymbol(nodeId, definitionType);
|
||||
addSymbol(nodeId, definitionKind);
|
||||
addAccess(nodeId, access);
|
||||
return nodeId;
|
||||
}
|
||||
@@ -47,10 +47,10 @@ Id ParserClientImpl::recordSymbol(
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, DefinitionType definitionType
|
||||
AccessKind access, DefinitionKind definitionKind
|
||||
)
|
||||
{
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, access, definitionType);
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, access, definitionKind);
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
return nodeId;
|
||||
}
|
||||
@@ -58,10 +58,10 @@ Id ParserClientImpl::recordSymbol(
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, DefinitionType definitionType
|
||||
AccessKind access, DefinitionKind definitionKind
|
||||
)
|
||||
{
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, location, access, definitionType);
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, location, access, definitionKind);
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
return nodeId;
|
||||
}
|
||||
@@ -236,17 +236,20 @@ void ParserClientImpl::addFile(Id id, const FilePath& filePath, const std::strin
|
||||
return;
|
||||
}
|
||||
|
||||
return m_storage->addFile(id, filePath.str(), modificationTime);
|
||||
m_storage->addFile(id, filePath.str(), modificationTime);
|
||||
}
|
||||
|
||||
void ParserClientImpl::addSymbol(Id id, DefinitionType definitionType)
|
||||
void ParserClientImpl::addSymbol(Id id, DefinitionKind definitionKind)
|
||||
{
|
||||
if (!m_storage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return m_storage->addSymbol(id, definitionTypeToInt(definitionType));
|
||||
if (definitionKind != DEFINITION_NONE)
|
||||
{
|
||||
m_storage->addSymbol(id, definitionKindToInt(definitionKind));
|
||||
}
|
||||
}
|
||||
|
||||
Id ParserClientImpl::addEdge(int type, Id sourceId, Id targetId)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "data/IntermediateStorage.h"
|
||||
#include "data/graph/token_component/TokenComponentAccess.h"
|
||||
|
||||
#include "data/DefinitionType.h"
|
||||
#include "data/DefinitionKind.h"
|
||||
|
||||
class ParserClientImpl: public ParserClient
|
||||
{
|
||||
@@ -24,17 +24,17 @@ public:
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access, DefinitionType definitionType);
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, DefinitionType definitionType);
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, DefinitionType definitionType);
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
|
||||
virtual void recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
|
||||
Id addNode(Node::NodeType nodeType, NameHierarchy nameHierarchy);
|
||||
void addFile(Id id, const FilePath& filePath, const std::string& modificationTime);
|
||||
void addSymbol(Id id, DefinitionType definitionType);
|
||||
void addSymbol(Id id, DefinitionKind definitionKind);
|
||||
Id addEdge(int type, Id sourceId, Id targetId);
|
||||
Id addLocalSymbol(const std::string& name);
|
||||
void addSourceLocation(Id elementId, const ParseLocation& location, int type);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define SYMBOL_KIND_H
|
||||
|
||||
enum SymbolKind
|
||||
{ // these values need to be the same as SymbolType in Java code
|
||||
{ // these values need to be the same as SymbolKind in Java code
|
||||
SYMBOL_BUILTIN_TYPE = 1,
|
||||
SYMBOL_CLASS = 2,
|
||||
SYMBOL_ENUM = 3,
|
||||
|
||||
@@ -67,10 +67,10 @@ void CxxAstVisitorComponentIndexer::visitTagDecl(clang::TagDecl* d)
|
||||
{
|
||||
if (shouldVisitDecl(d))
|
||||
{
|
||||
DefinitionType definitionType = DEFINITION_NONE;
|
||||
DefinitionKind definitionKind = DEFINITION_NONE;
|
||||
if (d->isThisDeclarationADefinition())
|
||||
{
|
||||
definitionType = utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT;
|
||||
definitionKind = utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT;
|
||||
}
|
||||
|
||||
m_client->recordSymbol(
|
||||
@@ -79,7 +79,7 @@ void CxxAstVisitorComponentIndexer::visitTagDecl(clang::TagDecl* d)
|
||||
getParseLocation(d->getLocation()),
|
||||
getParseLocationOfTagDeclBody(d),
|
||||
utility::convertAccessSpecifier(d->getAccess()),
|
||||
definitionType
|
||||
definitionKind
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -377,6 +377,11 @@ void CxxAstVisitorComponentIndexer::visitTypeLoc(clang::TypeLoc tl)
|
||||
if ((shouldVisitReference(tl.getBeginLoc(), getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getTopmostContextDecl())) &&
|
||||
(!getAstVisitor()->checkIgnoresTypeLoc(tl)))
|
||||
{
|
||||
if (const clang::BuiltinType* builtinType = clang::dyn_cast_or_null<clang::BuiltinType>(tl.getTypePtr()))
|
||||
{
|
||||
m_client->recordSymbol(getAstVisitor()->getTypeNameCache()->getValue(tl.getTypePtr()), SYMBOL_BUILTIN_TYPE, ACCESS_NONE, DEFINITION_EXPLICIT);
|
||||
}
|
||||
|
||||
clang::SourceLocation loc;
|
||||
if (!tl.getAs<clang::DependentNameTypeLoc>().isNull())
|
||||
{
|
||||
|
||||
@@ -139,8 +139,10 @@ void JavaProject::fetchRootDirectories()
|
||||
m_projectSettings->getAbsoluteExcludePaths(),
|
||||
m_projectSettings->getSourceExtensions()
|
||||
);
|
||||
|
||||
FileManager::FileSets fileSets = fileManager.fetchFilePaths(std::vector<FileInfo>());
|
||||
std::shared_ptr<JavaEnvironment> javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment();
|
||||
|
||||
for (FilePath filePath: fileSets.addedFiles)
|
||||
{
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath.str());
|
||||
|
||||
@@ -133,35 +133,35 @@ void JavaParser::doLogError(jstring jError)
|
||||
|
||||
void JavaParser::doRecordSymbol(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint jAccess, jint jIsImplicit
|
||||
jint jAccess, jint jDefinitionKind
|
||||
)
|
||||
{
|
||||
AccessKind access = intToAccessKind(jAccess);
|
||||
bool isImplicit = jIsImplicit;
|
||||
DefinitionKind definitionKind = intToDefinitionKind(jDefinitionKind);
|
||||
|
||||
m_client->recordSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)),
|
||||
intToSymbolKind(jSymbolType),
|
||||
access,
|
||||
isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
definitionKind
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordSymbolWithLocation(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
jint jAccess, jint jDefinitionKind
|
||||
)
|
||||
{
|
||||
AccessKind access = intToAccessKind(jAccess);
|
||||
bool isImplicit = jIsImplicit;
|
||||
DefinitionKind definitionKind = intToDefinitionKind(jDefinitionKind);
|
||||
|
||||
m_client->recordSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)),
|
||||
intToSymbolKind(jSymbolType),
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
|
||||
access,
|
||||
isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
definitionKind
|
||||
);
|
||||
}
|
||||
|
||||
@@ -169,11 +169,11 @@ void JavaParser::doRecordSymbolWithLocationAndScope(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint scopeBeginLine, jint scopeBeginColumn, jint scopeEndLine, jint scopeEndColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
jint jAccess, jint jDefinitionKind
|
||||
)
|
||||
{
|
||||
AccessKind access = intToAccessKind(jAccess);
|
||||
bool isImplicit = jIsImplicit;
|
||||
DefinitionKind definitionKind = intToDefinitionKind(jDefinitionKind);
|
||||
|
||||
m_client->recordSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)),
|
||||
@@ -181,7 +181,7 @@ void JavaParser::doRecordSymbolWithLocationAndScope(
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
|
||||
ParseLocation(m_currentFilePath, scopeBeginLine, scopeBeginColumn, scopeEndLine, scopeEndColumn),
|
||||
access,
|
||||
isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
definitionKind
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,20 +147,20 @@ private:
|
||||
|
||||
void doRecordSymbol(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint jAccess, jint jIsImplicit
|
||||
jint jAccess, jint jDefinitionKind
|
||||
);
|
||||
|
||||
void doRecordSymbolWithLocation(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
jint jAccess, jint jDefinitionKind
|
||||
);
|
||||
|
||||
void doRecordSymbolWithLocationAndScope(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint scopeBeginLine, jint scopeBeginColumn, jint scopeEndLine, jint scopeEndColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
jint jAccess, jint jDefinitionKind
|
||||
);
|
||||
|
||||
void doRecordReference(jint jRefType, jstring jReferencedName, jstring jContextName, jint beginLine, jint beginColumn, jint endLine, jint endColumn);
|
||||
|
||||
@@ -1252,7 +1252,24 @@ public:
|
||||
));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// test implicit symbols
|
||||
|
||||
void test_cxx_parser_finds_builtin_types()
|
||||
{
|
||||
std::shared_ptr<TestParserClient> client = parseCode(
|
||||
"void t1(int v) {}\n"
|
||||
"void t2(float v) {}\n"
|
||||
"void t3(double v) {}\n"
|
||||
"void t4(bool v) {}\n"
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::string>(client->builtinTypes, "void"));
|
||||
TS_ASSERT(utility::containsElement<std::string>(client->builtinTypes, "int"));
|
||||
TS_ASSERT(utility::containsElement<std::string>(client->builtinTypes, "float"));
|
||||
TS_ASSERT(utility::containsElement<std::string>(client->builtinTypes, "double"));
|
||||
TS_ASSERT(utility::containsElement<std::string>(client->builtinTypes, "bool"));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// test finding usages of symbols
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access, DefinitionType definitionType)
|
||||
AccessKind access, DefinitionKind definitionKind)
|
||||
{
|
||||
std::vector<std::string>* bin = getBinForSymbolKind(symbolKind);
|
||||
if (bin != nullptr)
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, DefinitionType definitionType)
|
||||
AccessKind access, DefinitionKind definitionKind)
|
||||
{
|
||||
std::vector<std::string>* bin = getBinForSymbolKind(symbolKind);
|
||||
if (bin != nullptr)
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, DefinitionType definitionType)
|
||||
AccessKind access, DefinitionKind definitionKind)
|
||||
{
|
||||
std::vector<std::string>* bin = getBinForSymbolKind(symbolKind);
|
||||
if (bin != nullptr)
|
||||
@@ -134,6 +134,7 @@ public:
|
||||
|
||||
std::vector<std::string> packages;
|
||||
std::vector<std::string> typedefs;
|
||||
std::vector<std::string> builtinTypes;
|
||||
std::vector<std::string> classes;
|
||||
std::vector<std::string> interfaces;
|
||||
std::vector<std::string> enums;
|
||||
@@ -174,6 +175,8 @@ private:
|
||||
return &packages;
|
||||
case SYMBOL_TYPEDEF:
|
||||
return &typedefs;
|
||||
case SYMBOL_BUILTIN_TYPE:
|
||||
return &builtinTypes;
|
||||
case SYMBOL_CLASS:
|
||||
return &classes;
|
||||
case SYMBOL_INTERFACE:
|
||||
|
||||
Reference in New Issue
Block a user