From 04fe3c5dffa6d5fb530311d5763a1310dd1260cc Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Tue, 22 Dec 2020 16:05:08 +0100 Subject: Fixed scope resolution problem for nested Java generics --- src/classdef.cpp | 4 ++-- src/dotclassgraph.cpp | 2 +- src/doxygen.cpp | 21 +++++++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/classdef.cpp b/src/classdef.cpp index 315f3f6..aa3b4c1 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -4044,11 +4044,11 @@ ClassDef *ClassDefImpl::insertTemplateInstance(const QCString &fileName, ClassDefMutable *templateClass=toClassDefMutable(m_impl->templateInstances->find(templSpec)); if (templateClass==0) { - Debug::print(Debug::Classes,0," New template instance class '%s''%s'\n",qPrint(name()),qPrint(templSpec)); QCString tcname = removeRedundantWhiteSpace(localName()+templSpec); + Debug::print(Debug::Classes,0," New template instance class '%s''%s' inside '%s' hidden=%d\n",qPrint(name()),qPrint(templSpec),qPrint(name()),isHidden()); templateClass = toClassDefMutable( - Doxygen::classLinkedMap->add(tcname, + Doxygen::hiddenClassLinkedMap->add(tcname, std::unique_ptr( new ClassDefImpl(fileName,startLine,startColumn,tcname,ClassDef::Class)))); templateClass->setTemplateMaster(this); diff --git a/src/dotclassgraph.cpp b/src/dotclassgraph.cpp index 4077d5b..be318e4 100644 --- a/src/dotclassgraph.cpp +++ b/src/dotclassgraph.cpp @@ -38,7 +38,7 @@ void DotClassGraph::addClass(const ClassDef *cd,DotNode *n,int prot, } else if (templSpec) // name has a template part { - className=insertTemplateSpecifierInScope(cd->name(),templSpec); + className=insertTemplateSpecifierInScope(cd->displayName(),templSpec); } else // just a normal name { diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 64e5ac3..4cf1e8b 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -977,8 +977,8 @@ static void addClassToContext(const Entry *root) // see if we already found the class before ClassDefMutable *cd = getClassMutable(qualifiedName); - //Debug::print(Debug::Classes,0, " Found class with name %s (qualifiedName=%s -> cd=%p)\n", - // cd ? qPrint(cd->name()) : qPrint(root->name), qPrint(qualifiedName),cd); + Debug::print(Debug::Classes,0, " Found class with name %s (qualifiedName=%s -> cd=%p)\n", + cd ? qPrint(cd->name()) : qPrint(root->name), qPrint(qualifiedName),cd); if (cd) { @@ -1046,7 +1046,7 @@ static void addClassToContext(const Entry *root) } } std::unique_ptr tArgList; - if ((root->lang==SrcLangExt_CSharp || root->lang==SrcLangExt_Java) && (i=fullName.find('<'))!=-1) + if ((root->lang==SrcLangExt_CSharp || root->lang==SrcLangExt_Java) && (i=fullName.findRev('<'))!=-1) { // a Java/C# generic class looks like a C++ specialization, so we need to split the // name and template arguments here @@ -1064,8 +1064,8 @@ static void addClassToContext(const Entry *root) std::unique_ptr( createClassDef(tagInfo?tagName:root->fileName,root->startLine,root->startColumn, fullName,sec,tagName,refFileName,TRUE,root->spec&Entry::Enum) ))); - Debug::print(Debug::Classes,0," New class '%s' (sec=0x%08x)! #tArgLists=%d tagInfo=%p\n", - qPrint(fullName),sec,root->tArgLists.size(), tagInfo); + Debug::print(Debug::Classes,0," New class '%s' (sec=0x%08x)! #tArgLists=%d tagInfo=%p hidden=%d artificial=%d isGeneric=%d\n", + qPrint(fullName),sec,root->tArgLists.size(), tagInfo,root->hidden,root->artificial,cd->isGeneric()); cd->setDocumentation(root->doc,root->docFile,root->docLine); // copy docs to definition cd->setBriefDescription(root->brief,root->briefFile,root->briefLine); cd->setLanguage(root->lang); @@ -1855,7 +1855,7 @@ static void findUsingDeclarations(const Entry *root) Debug::print(Debug::Classes,0," New using class '%s' (sec=0x%08x)! #tArgLists=%d\n", qPrint(name),root->section,root->tArgLists.size()); usingCd = toClassDefMutable( - Doxygen::hiddenClassLinkedMap->add(root->name, + Doxygen::hiddenClassLinkedMap->add(name, std::unique_ptr( createClassDef( "",1,1, name, ClassDef::Class)))); usingCd->setArtificial(TRUE); @@ -3841,20 +3841,24 @@ static ClassDef *findClassWithinClassContext(Definition *context,ClassDef *cd,co { result = const_cast(resolver.resolveClass(context,name,true,true)); } + //printf("1. result=%p\n",result); if (result==0) { result = const_cast(resolver.resolveClass(cd,name,true,true)); } + //printf("2. result=%p\n",result); if (result==0) // try direct class, needed for namespaced classes imported via tag files (see bug624095) { result = getClass(name); } + //printf("3. result=%p\n",result); if (result==0 && (cd->getLanguage()==SrcLangExt_CSharp || cd->getLanguage()==SrcLangExt_Java) && name.find('<')!=-1) { result = Doxygen::genericsDict->find(name); } + //printf("4. result=%p\n",result); //printf("** Trying to find %s within context %s class %s result=%s lookup=%p\n", // name.data(), // context ? context->name().data() : "", @@ -4316,7 +4320,7 @@ static bool findClassRelation( qPrint(templSpec) ); - int i=baseClassName.find('<'); + int i=baseClassName.findRev('<'); int si=baseClassName.findRev("::",i==-1 ? baseClassName.length() : i); if (si==-1) si=0; if (baseClass==0 && (root->lang==SrcLangExt_CSharp || root->lang==SrcLangExt_Java)) @@ -4396,6 +4400,7 @@ static bool findClassRelation( found = baseClass!=0 && baseClass!=cd; } + //printf("3. found=%d\n",found); if (!found) { // for PHP the "use A\B as C" construct map class C to A::B, so we lookup @@ -4412,7 +4417,7 @@ static bool findClassRelation( // warning: the following line doesn't work for Mixin classes (see bug 560623) // templSpec = getCanonicalTemplateSpec(cd, cd->getFileDef(), templSpec); - //printf("3. found=%d\n",found); + //printf("4. found=%d\n",found); if (found) { Debug::print(Debug::Classes,0," Documented base class '%s' templSpec=%s\n",qPrint(biName),qPrint(templSpec)); -- cgit v0.12