Skip to main content

The SymbolResolver Class Reference

Declaration

class SymbolResolver { ... }

Included Headers

Public Constructors Index

SymbolResolver (const FileDef *fileScope=nullptr)

Public Destructor Index

~SymbolResolver ()

Public Member Functions Index

const ClassDef *resolveClass (const Definition *scope, const QCString &name, bool maybeUnlinkable=false, bool mayBeHidden=false)

Find the class definition matching name within the scope set. More...

ClassDefMutable *resolveClassMutable (const Definition *scope, const QCString &name, bool mayBeUnlinkable=false, bool mayBeHidden=false)

Wrapper around resolveClass that returns a mutable interface to the class object or a nullptr if the symbol is immutable. More...

const Definition *resolveSymbol (const Definition *scope, const QCString &name, const QCString &args=QCString(), bool checkCV=false, bool insideCode=false, bool onlyLinkable=false)

Find the symbool definition matching name within the scope set. More...

intisAccessibleFrom (const Definition *scope, const Definition *item)

Checks if symbol item is accessible from within scope. More...

intisAccessibleFromWithExpScope (const Definition *scope, const Definition *item, const QCString &explicitScopePart)

Check if symbol item is accessible from within scope, where it has to match the explicitScopePart. More...

voidsetFileScope (const FileDef *fd)

Sets or updates the file scope using when resolving symbols. More...

const MemberDef *getTypedef () const

In case a call to resolveClass() resolves to a type member (e.g. More...

QCStringgetTemplateSpec () const

In case a call to resolveClass() points to a template specialization, the template part is return via this method. More...

QCStringgetResolvedType () const

In case a call to resolveClass() points to a typedef or using declaration. More...

Private Member Attributes Index

std::unique_ptr< Private >p

Description

Helper class to find a class definition or check if A symbol is accessible in a given scope.

Definition at line 31 of file symbolresolver.h.

Public Constructors

SymbolResolver()

SymbolResolver::SymbolResolver (const FileDef * fileScope=nullptr)
explicit

Declaration at line 34 of file symbolresolver.h, definition at line 1606 of file symbolresolver.cpp.

1607 : p(std::make_unique<Private>(fileScope))
1608{
1609}

Reference p.

Public Destructor

~SymbolResolver()

SymbolResolver::~SymbolResolver ()

Declaration at line 35 of file symbolresolver.h, definition at line 1611 of file symbolresolver.cpp.

Public Member Functions

getResolvedType()

QCString SymbolResolver::getResolvedType ()

In case a call to resolveClass() points to a typedef or using declaration.

The type name it resolved to is returned via this method.

Declaration at line 116 of file symbolresolver.h, definition at line 1726 of file symbolresolver.cpp.

1727{
1728 return p->resolvedType;
1729}

Reference p.

Referenced by getCanonicalTypeForIdentifier and SymbolResolver::Private::getResolvedTypeRec.

getTemplateSpec()

QCString SymbolResolver::getTemplateSpec ()

In case a call to resolveClass() points to a template specialization, the template part is return via this method.

Declaration at line 111 of file symbolresolver.h, definition at line 1721 of file symbolresolver.cpp.

1722{
1723 return p->templateSpec;
1724}

Reference p.

Referenced by findClassRelation and getCanonicalTypeForIdentifier.

getTypedef()

const MemberDef * SymbolResolver::getTypedef ()

In case a call to resolveClass() resolves to a type member (e.g.

an enum) this method will return it.

Declaration at line 106 of file symbolresolver.h, definition at line 1716 of file symbolresolver.cpp.

1717{
1718 return p->typeDef;
1719}

Reference p.

Referenced by findClassRelation, getCanonicalTypeForIdentifier, getDefsOld and linkifyText.

isAccessibleFrom()

int SymbolResolver::isAccessibleFrom (const Definition * scope, const Definition * item)

Checks if symbol item is accessible from within scope.

Returns

-1 if item is not accessible or a number indicating how many scope levels up the nearest match was found.

Declaration at line 85 of file symbolresolver.h, definition at line 1685 of file symbolresolver.cpp.

1686{
1687 AUTO_TRACE("scope={} item={}",
1688 scope?scope->name():QCString(), item?item->name():QCString());
1689 p->reset();
1690 VisitedKeys visitedKeys;
1691 AccessStack accessStack;
1692 int result = p->isAccessibleFrom(visitedKeys,accessStack,scope,item);
1693 AUTO_TRACE_EXIT("result={}",result);
1694 return result;
1695}

References AUTO_TRACE, AUTO_TRACE_EXIT, Definition::name and p.

Referenced by SymbolResolver::Private::isAccessibleFrom, SymbolResolver::Private::isAccessibleFromWithExpScope and resolveTypeDef.

isAccessibleFromWithExpScope()

int SymbolResolver::isAccessibleFromWithExpScope (const Definition * scope, const Definition * item, const QCString & explicitScopePart)

Check if symbol item is accessible from within scope, where it has to match the explicitScopePart.

Returns

-1 if item is not accessible or a number indicating how many scope levels up the nearest match was found.

Declaration at line 93 of file symbolresolver.h, definition at line 1697 of file symbolresolver.cpp.

1698 const QCString &explicitScopePart)
1699{
1700 AUTO_TRACE("scope={} item={} explicitScopePart={}",
1701 scope?scope->name():QCString(), item?item->name():QCString(), explicitScopePart);
1702 p->reset();
1703 VisitedKeys visitedKeys;
1704 VisitedNamespaces visitedNamespaces;
1705 AccessStack accessStack;
1706 int result = p->isAccessibleFromWithExpScope(visitedKeys,visitedNamespaces,accessStack,scope,item,explicitScopePart);
1707 AUTO_TRACE_EXIT("result={}",result);
1708 return result;
1709}

References AUTO_TRACE, AUTO_TRACE_EXIT, Definition::name and p.

Referenced by getMemberFromSymbol, SymbolResolver::Private::getResolvedSymbol, SymbolResolver::Private::getResolvedType, SymbolResolver::Private::isAccessibleFromWithExpScope and SymbolResolver::Private::substTypedef.

resolveClass()

const ClassDef * SymbolResolver::resolveClass (const Definition * scope, const QCString & name, bool maybeUnlinkable=false, bool mayBeHidden=false)

Find the class definition matching name within the scope set.

Parameters
scope

The scope to search from.

name

The name of the symbol.

maybeUnlinkable

include unlinkable symbols in the search.

mayBeHidden

include hidden symbols in the search.

info

As a result of this call the getters getTypedef(), getTemplateSpec(), and getResolvedType() are set as well.

Declaration at line 49 of file symbolresolver.h, definition at line 1616 of file symbolresolver.cpp.

1617 const QCString &name,
1618 bool mayBeUnlinkable,
1619 bool mayBeHidden)
1620{
1621 AUTO_TRACE("scope={} name={} mayBeUnlinkable={} mayBeHidden={}",
1622 scope?scope->name():QCString(), name, mayBeUnlinkable, mayBeHidden);
1623 p->reset();
1624
1625 auto lang = scope ? scope->getLanguage() : SrcLangExt::Cpp;
1626
1627 if (scope==nullptr ||
1630 ) ||
1631 (name.stripWhiteSpace().startsWith("::")) ||
1632 ((lang==SrcLangExt::Java || lang==SrcLangExt::CSharp) && QCString(name).find("::")!=-1)
1633 )
1634 {
1636 }
1637 const ClassDef *result=nullptr;
1638 if (Config_getBool(OPTIMIZE_OUTPUT_VHDL))
1639 {
1640 result = getClass(name);
1641 }
1642 else
1643 {
1644 VisitedKeys visitedKeys;
1645 QCString lookupName = lang==SrcLangExt::CSharp ? mangleCSharpGenericName(name) : name;
1646 AUTO_TRACE_ADD("lookup={}",lookupName);
1647 result = p->getResolvedTypeRec(visitedKeys,scope,lookupName,&p->typeDef,&p->templateSpec,&p->resolvedType);
1648 if (result==nullptr) // for nested classes imported via tag files, the scope may not
1649 // present, so we check the class name directly as well.
1650 // See also bug701314
1651 {
1652 result = getClass(lookupName);
1653 }
1654 }
1655 if (!mayBeUnlinkable && result && !result->isLinkable())
1656 {
1657 if (!mayBeHidden || !result->isHidden())
1658 {
1659 AUTO_TRACE_ADD("hiding symbol {}",result->name());
1660 result=nullptr; // don't link to artificial/hidden classes unless explicitly allowed
1661 }
1662 }
1663 AUTO_TRACE_EXIT("result={}",result?result->name():QCString());
1664 return result;
1665}

References AUTO_TRACE, AUTO_TRACE_ADD, AUTO_TRACE_EXIT, Config_getBool, Definition::definitionType, getClass, Definition::getLanguage, Doxygen::globalScope, Definition::isHidden, Definition::isLinkable, mangleCSharpGenericName, Definition::name, p, QCString::startsWith, QCString::stripWhiteSpace, Definition::TypeClass and Definition::TypeNamespace.

Referenced by findClassDefinition, findClassWithinClassContext, findUsingDeclImports, getCanonicalTypeForIdentifier, getDefsOld, isVarWithConstructor, linkifyText, normalizeNonTemplateArgumentsInString and resolveClassMutable.

resolveClassMutable()

ClassDefMutable * SymbolResolver::resolveClassMutable (const Definition * scope, const QCString & name, bool mayBeUnlinkable=false, bool mayBeHidden=false)
inline

Wrapper around resolveClass that returns a mutable interface to the class object or a nullptr if the symbol is immutable.

Definition at line 57 of file symbolresolver.h.

58 const QCString &name,
59 bool mayBeUnlinkable=false,
60 bool mayBeHidden=false)
61 {
62 return toClassDefMutable(const_cast<ClassDef*>(resolveClass(scope,name,mayBeUnlinkable,mayBeHidden)));
63 }

References resolveClass and toClassDefMutable.

Referenced by ClassDefImpl::addTypeConstraint, findClassRelation, findUsedClassesForClass and resolveTemplateInstanceInType.

resolveSymbol()

const Definition * SymbolResolver::resolveSymbol (const Definition * scope, const QCString & name, const QCString & args=QCString(), bool checkCV=false, bool insideCode=false, bool onlyLinkable=false)

Find the symbool definition matching name within the scope set.

Parameters
scope

The scope to search from.

name

The name of the symbol.

args

Argument list associated with the symbol (for functions)

checkCV

Check const/volatile qualifiers (for methods)

insideCode

Is the symbol found in a code fragment

onlyLinkable

Only search linkable definitions

Declaration at line 73 of file symbolresolver.h, definition at line 1667 of file symbolresolver.cpp.

1668 const QCString &name,
1669 const QCString &args,
1670 bool checkCV,
1671 bool insideCode,
1672 bool onlyLinkable)
1673{
1674 AUTO_TRACE("scope={} name={} args={} checkCV={} insideCode={}",
1675 scope?scope->name():QCString(), name, args, checkCV, insideCode);
1676 p->reset();
1677 if (scope==nullptr) scope=Doxygen::globalScope;
1678 VisitedKeys visitedKeys;
1679 const Definition *result = p->getResolvedSymbolRec(visitedKeys,scope,name,args,checkCV,insideCode,onlyLinkable,&p->typeDef,&p->templateSpec,&p->resolvedType);
1680 AUTO_TRACE_EXIT("result={}{}", qPrint(result?result->qualifiedName():QCString()),
1681 qPrint(result && result->definitionType()==Definition::TypeMember ? toMemberDef(result)->argsString() : QCString()));
1682 return result;
1683}

References AUTO_TRACE, AUTO_TRACE_EXIT, Definition::definitionType, Doxygen::globalScope, Definition::name, p, qPrint, Definition::qualifiedName, toMemberDef and Definition::TypeMember.

Referenced by findUsingDeclarations, findUsingDeclImports and getDefsNew.

setFileScope()

void SymbolResolver::setFileScope (const FileDef * fd)

Sets or updates the file scope using when resolving symbols.

Declaration at line 99 of file symbolresolver.h, definition at line 1711 of file symbolresolver.cpp.

1712{
1713 p->setFileScope(fileScope);
1714}

Reference p.

Referenced by getDefsNew.

Private Member Attributes

p

std::unique_ptr<Private> SymbolResolver::p

The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus by Doxygen 1.14.0.