logic: add type information of variable decl to name hierarchy

* implemented this feature for both, CXX and Java
* adjusted tests to reflect these changes
* added NameElement and NameHierarchy to Java code
* created more specialized JavaDeclName classes: JavaFunctionDeclName and JavaVariableDeclName
* implemented recording static modifier for Java methods and variables

fortune cookie message = You will enjoy true success in whatever you do.
This commit is contained in:
malte_langkabel
2017-07-28 09:12:32 +02:00
parent 2e117c4b6d
commit 01b1e0d6f1
21 changed files with 526 additions and 135 deletions
@@ -4,6 +4,7 @@
#include <clang/AST/ASTContext.h>
#include "data/parser/cxx/name/CxxFunctionDeclName.h"
#include "data/parser/cxx/name/CxxVariableDeclName.h"
#include "data/parser/cxx/name_resolver/CxxSpecifierNameResolver.h"
#include "data/parser/cxx/name_resolver/CxxTemplateArgumentNameResolver.h"
#include "data/parser/cxx/name_resolver/CxxTypeNameResolver.h"
@@ -270,6 +271,14 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
}
return std::make_shared<CxxDeclName>(declNameString, templateParameters);
}
else if (clang::isa<clang::FieldDecl>(declaration))
{
const clang::FieldDecl* fieldDecl = clang::dyn_cast<clang::FieldDecl>(declaration);
CxxTypeNameResolver typenNameResolver(getIgnoredContextDecls());
typenNameResolver.ignoreContextDecl(fieldDecl);
std::shared_ptr<CxxTypeName> typeName = CxxTypeName::makeUnsolvedIfNull(typenNameResolver.getName(fieldDecl->getType()));
return std::make_shared<CxxVariableDeclName>(declNameString, std::vector<std::string>(), typeName, false);
}
else if (clang::isa<clang::NamespaceDecl>(declaration) && clang::dyn_cast<clang::NamespaceDecl>(declaration)->isAnonymousNamespace())
{
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
@@ -299,6 +308,28 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart());
return std::make_shared<CxxDeclName>(getNameForAnonymousSymbol("parameter", presumedBegin), std::vector<std::string>());
}
else if (clang::isa<clang::VarDecl>(declaration))
{
const clang::VarDecl* varDecl = clang::dyn_cast<clang::VarDecl>(declaration);
if (varDecl->getParentFunctionOrMethod() == NULL)
{
bool isStatic = false;
if (varDecl->getAccess() != clang::AS_none)
{
// var is declared inside a type and must be static (non-statics are stored as clang::FieldDecl)
isStatic = true;
}
else
{
// nothing todo, varDecl is global (and non-static)
}
CxxTypeNameResolver typenNameResolver(getIgnoredContextDecls());
typenNameResolver.ignoreContextDecl(varDecl);
std::shared_ptr<CxxTypeName> typeName = CxxTypeName::makeUnsolvedIfNull(typenNameResolver.getName(varDecl->getType()));
return std::make_shared<CxxVariableDeclName>(declNameString, std::vector<std::string>(), typeName, isStatic);
}
}
if (declNameString.size() > 0)
{