logic: indexer fixes
* forward declarations are recorded as undefined types now * fixed minor issue with dependent template argument names
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "data/parser/AccessKind.h"
|
||||
#include "data/parser/ReferenceKind.h"
|
||||
#include "data/parser/SymbolKind.h"
|
||||
#include "data/DefinitionType.h"
|
||||
#include "utility/file/FileInfo.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
@@ -32,17 +33,17 @@ public:
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false) = 0;
|
||||
AccessKind access, DefinitionType definitionType) = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false) = 0;
|
||||
AccessKind access, DefinitionType definitionType) = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false) = 0;
|
||||
AccessKind access, DefinitionType definitionType) = 0;
|
||||
|
||||
virtual void recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
|
||||
@@ -35,10 +35,10 @@ void ParserClientImpl::finishParsingFile()
|
||||
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access, bool isImplicit
|
||||
AccessKind access, DefinitionType definitionType
|
||||
)
|
||||
{
|
||||
Id nodeId = addNodeHierarchy(symbolKindToNodeType(symbolType), symbolName, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
Id nodeId = addNodeHierarchy(symbolKindToNodeType(symbolType), symbolName, definitionType);
|
||||
addAccess(nodeId, access);
|
||||
return nodeId;
|
||||
}
|
||||
@@ -46,10 +46,10 @@ Id ParserClientImpl::recordSymbol(
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, bool isImplicit
|
||||
AccessKind access, DefinitionType definitionType
|
||||
)
|
||||
{
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, access, isImplicit);
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, access, definitionType);
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
return nodeId;
|
||||
}
|
||||
@@ -57,10 +57,10 @@ Id ParserClientImpl::recordSymbol(
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, bool isImplicit
|
||||
AccessKind access, DefinitionType definitionType
|
||||
)
|
||||
{
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, location, access, isImplicit);
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, location, access, definitionType);
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
@@ -24,17 +24,17 @@ public:
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false);
|
||||
AccessKind access, DefinitionType definitionType);
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false);
|
||||
AccessKind access, DefinitionType definitionType);
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false);
|
||||
AccessKind access, DefinitionType definitionType);
|
||||
|
||||
virtual void recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
|
||||
@@ -67,13 +67,19 @@ void CxxAstVisitorComponentIndexer::visitTagDecl(clang::TagDecl* d)
|
||||
{
|
||||
if (shouldVisitDecl(d))
|
||||
{
|
||||
DefinitionType definitionType = DEFINITION_NONE;
|
||||
if (d->isThisDeclarationADefinition())
|
||||
{
|
||||
definitionType = utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT;
|
||||
}
|
||||
|
||||
m_client->recordSymbol(
|
||||
getAstVisitor()->getDeclNameCache()->getValue(d),
|
||||
utility::convertTagKind(d->getTagKind()),
|
||||
getParseLocation(d->getLocation()),
|
||||
getParseLocationOfTagDeclBody(d),
|
||||
utility::convertAccessSpecifier(d->getAccess()),
|
||||
utility::isImplicit(d)
|
||||
definitionType
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -128,7 +134,7 @@ void CxxAstVisitorComponentIndexer::visitVarDecl(clang::VarDecl* d)
|
||||
symbolKind,
|
||||
getParseLocation(d->getLocation()),
|
||||
utility::convertAccessSpecifier(d->getAccess()),
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -143,7 +149,7 @@ void CxxAstVisitorComponentIndexer::visitFieldDecl(clang::FieldDecl* d)
|
||||
SYMBOL_FIELD,
|
||||
getParseLocation(d->getLocation()),
|
||||
utility::convertAccessSpecifier(d->getAccess()),
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +164,7 @@ void CxxAstVisitorComponentIndexer::visitFunctionDecl(clang::FunctionDecl* d)
|
||||
getParseLocation(d->getLocation()),
|
||||
getParseLocationOfFunctionBody(d),
|
||||
utility::convertAccessSpecifier(d->getAccess()),
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
|
||||
if (d->isFunctionTemplateSpecialization())
|
||||
@@ -215,7 +221,7 @@ void CxxAstVisitorComponentIndexer::visitEnumConstantDecl(clang::EnumConstantDec
|
||||
SYMBOL_ENUM_CONSTANT,
|
||||
getParseLocation(d->getLocation()),
|
||||
ACCESS_NONE,
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -230,7 +236,7 @@ void CxxAstVisitorComponentIndexer::visitNamespaceDecl(clang::NamespaceDecl* d)
|
||||
d->isAnonymousNamespace() ? ParseLocation() : getParseLocation(d->getLocation()),
|
||||
getParseLocation(d->getSourceRange()),
|
||||
utility::convertAccessSpecifier(d->getAccess()),
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -244,7 +250,7 @@ void CxxAstVisitorComponentIndexer::visitNamespaceAliasDecl(clang::NamespaceAlia
|
||||
SYMBOL_NAMESPACE,
|
||||
getParseLocation(d->getLocation()),
|
||||
utility::convertAccessSpecifier(d->getAccess()),
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
|
||||
m_client->recordReference(
|
||||
@@ -265,7 +271,7 @@ void CxxAstVisitorComponentIndexer::visitTypedefDecl(clang::TypedefDecl* d)
|
||||
SYMBOL_TYPEDEF,
|
||||
getParseLocation(d->getLocation()),
|
||||
utility::convertAccessSpecifier(d->getAccess()),
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -279,7 +285,7 @@ void CxxAstVisitorComponentIndexer::visitTypeAliasDecl(clang::TypeAliasDecl* d)
|
||||
SYMBOL_TYPEDEF,
|
||||
getParseLocation(d->getLocation()),
|
||||
utility::convertAccessSpecifier(d->getAccess()),
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -321,7 +327,7 @@ void CxxAstVisitorComponentIndexer::visitNonTypeTemplateParmDecl(clang::NonTypeT
|
||||
SYMBOL_TEMPLATE_PARAMETER,
|
||||
getParseLocation(d->getLocation()),
|
||||
ACCESS_TEMPLATE_PARAMETER,
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -335,7 +341,7 @@ void CxxAstVisitorComponentIndexer::visitTemplateTypeParmDecl(clang::TemplateTyp
|
||||
SYMBOL_TEMPLATE_PARAMETER,
|
||||
getParseLocation(d->getLocation()),
|
||||
ACCESS_TEMPLATE_PARAMETER,
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -349,7 +355,7 @@ void CxxAstVisitorComponentIndexer::visitTemplateTemplateParmDecl(clang::Templat
|
||||
SYMBOL_TEMPLATE_PARAMETER,
|
||||
getParseLocation(d->getLocation()),
|
||||
ACCESS_TEMPLATE_PARAMETER,
|
||||
utility::isImplicit(d)
|
||||
utility::isImplicit(d) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -486,7 +492,7 @@ void CxxAstVisitorComponentIndexer::visitLambdaExpr(clang::LambdaExpr* s)
|
||||
getParseLocation(s->getLocStart()),
|
||||
getParseLocationOfFunctionBody(methodDecl),
|
||||
ACCESS_NONE, // TODO: introduce AccessLambda
|
||||
utility::isImplicit(methodDecl)
|
||||
utility::isImplicit(methodDecl) ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,9 @@ void PreprocessorCallbacks::MacroDefined(const clang::Token& macroNameToken, con
|
||||
nameHierarchy,
|
||||
SYMBOL_MACRO,
|
||||
getParseLocation(macroNameToken),
|
||||
getParseLocation(macroDirective->getMacroInfo())
|
||||
getParseLocation(macroDirective->getMacroInfo()),
|
||||
ACCESS_NONE,
|
||||
DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ CxxNameResolver::~CxxNameResolver()
|
||||
|
||||
void CxxNameResolver::ignoreContextDecl(const clang::Decl* decl)
|
||||
{
|
||||
m_ignoredContextDecls.push_back(decl);
|
||||
if (decl)
|
||||
{
|
||||
m_ignoredContextDecls.push_back(decl);
|
||||
}
|
||||
}
|
||||
|
||||
bool CxxNameResolver::ignoresContext(const clang::DeclContext* declContext)
|
||||
|
||||
@@ -159,6 +159,7 @@ std::shared_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
|
||||
{
|
||||
std::vector<std::string> templateArguments;
|
||||
CxxTemplateArgumentNameResolver resolver(getIgnoredContextDecls());
|
||||
resolver.ignoreContextDecl(templateSpecializationType->getTemplateName().getAsTemplateDecl()->getTemplatedDecl());
|
||||
for (size_t i = 0; i < templateSpecializationType->getNumArgs(); i++)
|
||||
{
|
||||
templateArguments.push_back(resolver.getTemplateArgumentName(templateSpecializationType->getArg(i)));
|
||||
|
||||
@@ -143,7 +143,7 @@ void JavaParser::doRecordSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)),
|
||||
intToSymbolKind(jSymbolType),
|
||||
access,
|
||||
isImplicit
|
||||
isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void JavaParser::doRecordSymbolWithLocation(
|
||||
intToSymbolKind(jSymbolType),
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
|
||||
access,
|
||||
isImplicit
|
||||
isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ void JavaParser::doRecordSymbolWithLocationAndScope(
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
|
||||
ParseLocation(m_currentFilePath, scopeBeginLine, scopeBeginColumn, scopeEndLine, scopeEndColumn),
|
||||
access,
|
||||
isImplicit
|
||||
isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2036,10 +2036,10 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::string>(
|
||||
client->typeUses, "Foo<Foo<typename T>::T> & Foo<typename T>::operator=(const Foo<Foo<typename T>::T> &) -> Foo<Foo<typename T>::T> <4:2 4:4>"
|
||||
client->typeUses, "Foo<T> & Foo<typename T>::operator=(const Foo<T> &) -> Foo<T> <4:2 4:4>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::string>(
|
||||
client->typeUses, "Foo<Foo<typename T>::T> & Foo<typename T>::operator=(const Foo<Foo<typename T>::T> &) -> Foo<Foo<typename T>::T> <4:23 4:25>"
|
||||
client->typeUses, "Foo<T> & Foo<typename T>::operator=(const Foo<T> &) -> Foo<T> <4:23 4:25>"
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false)
|
||||
AccessKind access, DefinitionType definitionType)
|
||||
{
|
||||
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 = ACCESS_NONE, bool isImplicit = false)
|
||||
AccessKind access, DefinitionType definitionType)
|
||||
{
|
||||
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 = ACCESS_NONE, bool isImplicit = false)
|
||||
AccessKind access, DefinitionType definitionType)
|
||||
{
|
||||
std::vector<std::string>* bin = getBinForSymbolKind(symbolKind);
|
||||
if (bin != nullptr)
|
||||
|
||||
Reference in New Issue
Block a user