浏览该文件的文档.
16 #include <unordered_map>
62 [&](
const AccessElem &e) { return e.scope==scope && e.fileScope==fileScope && e.item==item; });
68 [&](
const AccessElem &e) { return e.scope==scope && e.fileScope==fileScope && e.item==item && e.expScope==expScope; });
128 const std::unique_ptr<ArgumentList> &actTemplParams,
142 const std::unique_ptr<ArgumentList> &actTemplParams = std::unique_ptr<ArgumentList>()
152 const QCString &explicitScopePart=
"");
155 const QCString &explicitScopePart=
""
181 &strippedTemplateParams);
182 std::unique_ptr<ArgumentList> actTemplParams;
183 if (!strippedTemplateParams.
isEmpty())
190 if (qualifierIndex!=-1)
193 explicitScopePart=name.
left(qualifierIndex);
196 name=name.
mid(qualifierIndex+2);
209 if (range.first==range.second)
212 if (range.first==range.second)
220 bool hasUsingStatements =
232 int nameLen = name.
length()+1;
233 int explicitPartLen = explicitScopePart.
length();
238 QCString key(scopeNameLen+nameLen+explicitPartLen+fileScopeLen+1);
251 if (hasUsingStatements)
271 if (pTemplSpec) *pTemplSpec=pval->
templSpec;
272 if (pTypeDef) *pTypeDef=pval->
typeDef;
291 int minDistance=10000;
293 for (
auto it=range.first ; it!=range.second; ++it)
297 minDistance,bestMatch,bestTypedef,bestTemplSpec,bestResolvedType);
302 *pTypeDef = bestTypedef;
306 *pTemplSpec = bestTemplSpec;
310 *pResolvedType = bestResolvedType;
335 const std::unique_ptr<ArgumentList> &actTemplParams,
370 if (distance<minDistance)
372 minDistance=distance;
378 else if (distance==minDistance &&
379 m_fileScope && bestMatch &&
380 !m_fileScope->getUsedNamespaces().empty() &&
393 minDistance=distance;
420 if (distance<minDistance)
424 minDistance=distance;
426 const ClassDef *cd = newResolveTypedef(scope,md,&enumType,&spec,&type,actTemplParams);
432 bestTemplSpec = spec;
433 bestResolvedType = type;
439 bestTypedef = enumType;
447 bestTemplSpec = spec;
448 bestResolvedType = type;
455 bestResolvedType.
resize(0);
471 if (distance<minDistance)
473 minDistance=distance;
496 const std::unique_ptr<ArgumentList> &actTemplParams)
514 if (m_resolvedTypedefs.find(qname.
str())!=m_resolvedTypedefs.end())
519 auto typedef_it = m_resolvedTypedefs.
insert({qname.
str(),md}).first;
524 actTemplParams && !actTemplParams->empty())
532 while (ip>=0 && (type.
at(ip)==
'*' || type.
at(ip)==
'&' || type.
at(ip)==
' '))
536 type=type.
left(ip+1);
543 while (sp<tl && type.
at(sp)==
' ') sp++;
546 &memTypeDef,0,pResolvedType);
548 if (memTypeDef && memTypeDef->
isTypedef())
550 result=newResolveTypedef(m_fileScope,memTypeDef,pMemType,pTemplSpec,0);
553 else if (memTypeDef && memTypeDef->
isEnumerate() && pMemType)
555 *pMemType = memTypeDef;
563 int i=type.
find(
'<');
566 if (pTemplSpec) *pTemplSpec = type.
mid(i);
567 result = getResolvedClassRec(md->
getOuterScope(),type.
left(i),0,0,pResolvedType);
580 if (pTemplSpec) *pTemplSpec = type.
mid(i);
596 if (sp>0) pResolvedType->
prepend(typedefValue.
left(sp));
597 if (ip<tl-1) pResolvedType->
append(typedefValue.
right(tl-ip-1));
601 *pResolvedType = typedefValue;
617 pTemplSpec ? *pTemplSpec :
QCString(),
618 pResolvedType ? *pResolvedType :
QCString()
623 m_resolvedTypedefs.erase(typedef_it);
635 if (explicitScopePart.
isEmpty())
641 if (accessStack.
find(scope,m_fileScope,item,explicitScopePart))
645 accessStack.
push(scope,m_fileScope,item,explicitScopePart);
652 const Definition *newScope = followPath(scope,explicitScopePart);
662 if (itemScope==newScope)
666 else if (itemScope && newScope &&
689 visitedNamespaces.insert({newScope->
name().str(),newScope});
705 if (visitedNamespaces.find(nd->name().str())==visitedNamespaces.end())
723 result = (i==-1) ? -1 : i+2;
733 if (accessibleViaUsingNamespace(visited,nscope->
getUsedNamespaces(),item,explicitScopePart))
744 if (accessibleViaUsingNamespace(visited,m_fileScope->getUsedNamespaces(),item,explicitScopePart))
757 result= (i==-1) ? -1 : i+2;
779 QCString qualScopePart = substTypedef(current,path.
mid(is,l),&memTypeDef);
783 const ClassDef *type = newResolveTypedef(m_fileScope,memTypeDef,0,0,0);
800 next = endOfPathIsUsedClass(
805 next = endOfPathIsUsedClass(
806 (
toFileDef(current))->getUsedClasses(),qualScopePart);
809 if (current==0)
break;
825 for (
const auto &cd : cl)
827 if (cd->localName()==localName)
840 for (
const auto &und : nl)
844 const Definition *sc = explicitScopePart.
isEmpty() ? und : followPath(und,explicitScopePart);
853 if (!und->getUsedNamespaces().empty() && visited.find(key.
str())==visited.end())
857 if (accessibleViaUsingNamespace(visited,und->getUsedNamespaces(),item,explicitScopePart))
863 visited.erase(key.
str());
876 for (
const auto &ucd : cl)
879 const Definition *sc = explicitScopePart.
isEmpty() ? ucd : followPath(ucd,explicitScopePart);
880 if (sc && sc==item)
return true;
893 if (accessStack.
find(scope,m_fileScope,item))
897 accessStack.
push(scope,m_fileScope,item);
903 bool memberAccessibleFromScope =
909 bool nestedClassInsideBaseClass =
916 if (itemScope==scope || memberAccessibleFromScope || nestedClassInsideBaseClass)
919 if (nestedClassInsideBaseClass) result++;
927 if (accessibleViaUsingClass(m_fileScope->getUsedClasses(),item))
933 if (accessibleViaUsingNamespace(visited,m_fileScope->getUsedNamespaces(),item))
964 result= (i==-1) ? -1 : i+2;
976 if (name.
isEmpty())
return result;
979 if (range.first==range.second)
983 int minDistance=10000;
985 for (
auto it = range.first; it!=range.second; ++it)
999 if (distance!=-1 && distance<minDistance)
1002 minDistance=distance;
1012 if (pTypeDef) *pTypeDef=bestMatch;
1024 :
p(std::make_unique<
Private>(fileScope))
1035 bool mayBeUnlinkable,
1061 result =
p->getResolvedClassRec(scope,name,&
p->typeDef,&
p->templateSpec,&
p->resolvedType);
1069 if (!mayBeUnlinkable && result && !result->
isLinkable())
1071 if (!mayBeHidden || !result->
isHidden())
1086 return p->isAccessibleFrom(accessStack,scope,item);
1095 return p->isAccessibleFromWithExpScope(visitedNamespaces,accessStack,scope,item,explicitScopePart);
1100 p->setFileScope(fileScope);
1110 return p->templateSpec;
1115 return p->resolvedType;
Helper class representing the stack of items considered while resolving the scope.
virtual bool isTypedef() const =0
const ClassDef * getResolvedClassRec(const Definition *scope, const QCString &n, const MemberDef **pTypeDef, QCString *pTemplSpec, QCString *pResolvedType)
QCString getTemplateSpec() const
In case a call to resolveClass() points to a template specialization, the template part is return via...
void setFileScope(const FileDef *fd)
Sets or updates the file scope using when resolving symbols.
virtual LinkedRefMap< const NamespaceDef > getUsedNamespaces() const =0
MemberDefMutable * toMemberDefMutable(Definition *d)
char * rawData()
Returns a writable pointer to the data.
virtual QCString argsString() const =0
The common base class of all entity definitions found in the sources.
An abstract interface of a namespace symbol.
QCString substTypedef(const Definition *scope, const QCString &name, const MemberDef **pTypeDef=0)
virtual void cacheTypedefVal(const ClassDef *val, const QCString &templSpec, const QCString &resolvedType)=0
const Definition * followPath(const Definition *start, const QCString &path)
QCString substituteTemplateArgumentsInString(const QCString &nm, const ArgumentList &formalArgs, const std::unique_ptr< ArgumentList > &actualArgs)
int 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.
uint length() const
Returns the length of the string, not counting the 0-terminator.
int findRev(char c, int index=-1, bool cs=TRUE) const
bool isEmpty() const
Returns TRUE iff the string is empty
virtual const Definition * findInnerCompound(const QCString &name) const =0
int isAccessibleFrom(AccessStack &accessStack, const Definition *scope, const Definition *item)
char * qstrcpy(char *dst, const char *src)
void push(const Definition *scope, const FileDef *fileScope, const Definition *item, const QCString &expScope)
MemberDef * toMemberDef(Definition *d)
virtual LinkedRefMap< const ClassDef > getUsedClasses() const =0
static NamespaceDefMutable * globalScope
QCString stripTemplateSpecifiersFromScope(const QCString &fullName, bool parentOnly, QCString *pLastScopeStripped)
const Definition * endOfPathIsUsedClass(LinkedRefMap< const ClassDef > cl, const QCString &localName)
virtual bool isHidden() const =0
int isAccessibleFromWithExpScope(VisitedNamespaces &visitedNamespaces, AccessStack &accessStack, const Definition *scope, const Definition *item, const QCString &explicitScopePart)
const MemberDef * typeDef
char & at(size_t i)
Returns a reference to the character at index i.
std::unordered_map< std::string, const Definition * > VisitedNamespaces
int find(char c, int index=0, bool cs=TRUE) const
ClassDef * getClass(const QCString &n)
const ClassDef * newResolveTypedef(const Definition *scope, const MemberDef *md, const MemberDef **pMemType, QCString *pTemplSpec, QCString *pResolvedType, const std::unique_ptr< ArgumentList > &actTemplParams=std::unique_ptr< ArgumentList >())
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
static SymbolMap< Definition > * symbolMap
virtual LinkedRefMap< const NamespaceDef > getUsedNamespaces() const =0
std::pair< const_iterator, const_iterator > find(const QCString &name) const
Find the list of symbols stored under key name Returns a pair of iterators pointing to the start and ...
std::unordered_set< std::string > StringUnorderedSet
virtual bool isTypedefValCached() const =0
AccessElem(const Definition *d, const FileDef *f, const Definition *i, QCString e=QCString())
virtual QCString qualifiedName() const =0
virtual LinkedRefMap< const ClassDef > getUsedClasses() const =0
A model of a class/file/namespace member symbol.
SymbolResolver(const FileDef *fileScope=0)
A abstract class representing of a compound symbol.
virtual const ClassDef * getCachedTypedefVal() const =0
QCString left(size_t len) const
QCString & insert(size_t index, const QCString &s)
std::unique_ptr< Private > p
void push(const Definition *scope, const FileDef *fileScope, const Definition *item)
virtual bool isReference() const =0
QCString removeRedundantWhiteSpace(const QCString &s)
V * insert(const K &key, V &&value)
Inserts value under key in the cache
int isAccessibleFrom(const Definition *scope, const Definition *item)
Checks if symbol item is accessible from within scope.
virtual QCString name() const =0
virtual const ClassDef * getClassDef() const =0
int computeQualifiedIndex(const QCString &name)
const MemberDef * getTypedef() const
In case a call to resolveClass() resolves to a type member (e.g.
ClassDef * toClassDef(Definition *d)
QCString getResolvedType() const
In case a call to resolveClass() points to a typedef or using declaration.
void setFileScope(const FileDef *fileScope)
virtual DefType definitionType() const =0
const MemberDef * typeDef
virtual QCString qualifiedName() const =0
const FileDef * fileScope
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
virtual QCString getCachedResolvedTypedef() const =0
#define Config_getBool(name)
QCString & append(char c)
NamespaceDef * toNamespaceDef(Definition *d)
virtual bool isEnumerate() const =0
virtual Definition * getOuterScope() const =0
bool find(const Definition *scope, const FileDef *fileScope, const Definition *item, const QCString &expScope)
virtual QCString absFilePath() const =0
virtual QCString getDefFileName() const =0
V * find(const K &key)
Finds a value in the cache given the corresponding key.
void getResolvedSymbol(const Definition *scope, const Definition *d, const QCString &explicitScopePart, const std::unique_ptr< ArgumentList > &actTemplParams, int &minDistance, const ClassDef *&bestMatch, const MemberDef *&bestTypedef, QCString &bestTemplSpec, QCString &bestResolvedType)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
Private(const FileDef *f)
static Cache< std::string, LookupInfo > * lookupCache
const ClassDef * classDef
A model of a file symbol.
FileDef * toFileDef(Definition *d)
bool accessibleViaUsingNamespace(StringUnorderedSet &visited, const LinkedRefMap< const NamespaceDef > &nl, const Definition *item, const QCString &explicitScopePart="")
static std::recursive_mutex g_cacheTypedefMutex
virtual bool isTemplateArgument() const =0
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.
std::unordered_map< std::string, const MemberDef * > m_resolvedTypedefs
bool find(const Definition *scope, const FileDef *fileScope, const Definition *item)
int getScopeFragment(const QCString &s, int p, int *l)
A bunch of utility functions.
void replaceNamespaceAliases(QCString &scope, int i)
virtual QCString typeString() const =0
virtual bool isLinkable() const =0
return TRUE iff a link to this class is possible (either within this project, or as a cross-reference...
std::unique_ptr< ArgumentList > stringToArgumentList(SrcLangExt lang, const QCString &argsString, QCString *extraTypeChars=0)
bool stripPrefix(const QCString &prefix)
QCString right(size_t len) const
QCString & prepend(const char *s)
bool resize(size_t newlen)
Resizes the string to hold newlen characters (this value should also count the 0-terminator).
static std::mutex g_cacheMutex
std::vector< AccessElem > m_elements
virtual const ArgumentList & templateArguments() const =0
Returns the template arguments of this class
bool accessibleViaUsingClass(const LinkedRefMap< const ClassDef > &cl, const Definition *item, const QCString &explicitScopePart="")
virtual bool isTemplate() const =0
Returns TRUE if this class is a template
const FileDef * m_fileScope
virtual QCString getCachedTypedefTemplSpec() const =0
This is an alternative implementation of QCString.