From c6e41226574c94a869ad0757b53027562ef189e1 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Mon, 17 Nov 2014 20:42:40 +0100 Subject: [PATCH] Bug 740218 - Full scope needed when making link inside cross-referenced section --- src/classdef.cpp | 3 ++- src/cmdmapper.cpp | 1 + src/cmdmapper.h | 3 ++- src/docparser.cpp | 11 +++++++++++ src/doctokenizer.h | 1 + src/doctokenizer.l | 13 +++++++++++++ src/doxygen.cpp | 6 +++--- src/filedef.cpp | 1 + src/groupdef.cpp | 1 + src/memberdef.cpp | 2 +- src/membergroup.cpp | 2 +- src/namespacedef.cpp | 3 ++- src/reflist.cpp | 8 ++++++++ src/reflist.h | 5 ++++- src/util.cpp | 3 ++- src/util.h | 2 +- 16 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/classdef.cpp b/src/classdef.cpp index 271634a0d7c..e6b90640b6e 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -3879,7 +3879,8 @@ void ClassDef::addListReferences() : theTranslator->trClass(TRUE,TRUE), getOutputFileBase(), displayName(), - 0 + 0, + this ); } if (m_impl->memberGroupSDict) diff --git a/src/cmdmapper.cpp b/src/cmdmapper.cpp index b0ca85f22d8..9b644010706 100644 --- a/src/cmdmapper.cpp +++ b/src/cmdmapper.cpp @@ -140,6 +140,7 @@ CommandMap cmdMap[] = { "diafile", CMD_DIAFILE }, { "--", CMD_NDASH }, { "---", CMD_MDASH }, + { "_setscope", CMD_SETSCOPE }, { 0, 0 }, }; diff --git a/src/cmdmapper.h b/src/cmdmapper.h index 75fd8ec7138..87a3e66e801 100644 --- a/src/cmdmapper.h +++ b/src/cmdmapper.h @@ -129,7 +129,8 @@ enum CommandType CMD_NDASH = 99, CMD_MDASH = 100, CMD_STARTUML = 101, - CMD_ENDUML = 102 + CMD_ENDUML = 102, + CMD_SETSCOPE = 103 }; enum HtmlTagType diff --git a/src/docparser.cpp b/src/docparser.cpp index 8c435fa6224..a788e13ae70 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -1410,6 +1410,17 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList &children doctokenizerYYsetStatePara(); } break; + case CMD_SETSCOPE: + { + QCString scope; + doctokenizerYYsetStateSetScope(); + doctokenizerYYlex(); + scope = g_token->name; + g_context = scope; + //printf("Found scope='%s'\n",scope.data()); + doctokenizerYYsetStatePara(); + } + break; default: return FALSE; } diff --git a/src/doctokenizer.h b/src/doctokenizer.h index c95230b7974..65f33269b83 100644 --- a/src/doctokenizer.h +++ b/src/doctokenizer.h @@ -161,5 +161,6 @@ void doctokenizerYYsetStateSnippet(); void doctokenizerYYstartAutoList(); void doctokenizerYYendAutoList(); void doctokenizerYYsetStatePlantUML(); +void doctokenizerYYsetStateSetScope(); #endif diff --git a/src/doctokenizer.l b/src/doctokenizer.l index 2de04a3cc98..aa8ef8d8454 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -436,6 +436,7 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{REFWORD4} %x St_SkipTitle %x St_Anchor %x St_Snippet +%x St_SetScope %x St_Sections %s St_SecLabel1 @@ -1012,6 +1013,13 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{REFWORD4} {BLANK}+"\"" { BEGIN(St_Ref2); } +{SCOPEMASK}{BLANK} { + g_token->name = yytext; + g_token->name = g_token->name.stripWhiteSpace(); + return TK_WORD; + } +{BLANK} { + } "&"{ID}";" { /* symbol */ g_token->name = yytext; return TK_SYMBOL; @@ -1411,6 +1419,11 @@ void doctokenizerYYsetStateSnippet() BEGIN(St_Snippet); } +void doctokenizerYYsetStateSetScope() +{ + BEGIN(St_SetScope); +} + void doctokenizerYYcleanup() { yy_delete_buffer( YY_CURRENT_BUFFER ); diff --git a/src/doxygen.cpp b/src/doxygen.cpp index df1f8531b48..821ebc5421a 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -5221,7 +5221,7 @@ static void addListReferences() addRefItem(xrefItems, name, theTranslator->trPage(TRUE,TRUE), - name,pd->title(),0); + name,pd->title(),0,0); } } @@ -5238,7 +5238,7 @@ static void addListReferences() addRefItem(xrefItems, name, theTranslator->trDir(TRUE,TRUE), - name,dd->displayName(),0); + name,dd->displayName(),0,0); } } @@ -8629,7 +8629,7 @@ static void buildPageList(EntryNav *rootNav) "page", name, title, - 0 + 0,0 ); rootNav->releaseEntry(); diff --git a/src/filedef.cpp b/src/filedef.cpp index 3ff69a4cf4e..42e3efc9f17 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -1409,6 +1409,7 @@ void FileDef::addListReferences() getOutputFileBase(), theTranslator->trFile(TRUE,TRUE), getOutputFileBase(),name(), + 0, 0 ); } diff --git a/src/groupdef.cpp b/src/groupdef.cpp index 65e59f33008..5993bb2653e 100644 --- a/src/groupdef.cpp +++ b/src/groupdef.cpp @@ -1534,6 +1534,7 @@ void GroupDef::addListReferences() getOutputFileBase(), theTranslator->trGroup(TRUE,TRUE), getOutputFileBase(),name(), + 0, 0 ); } diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 83528ef52c2..29595cf2287 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -3507,7 +3507,7 @@ void MemberDef::addListReference(Definition *) addRefItem(xrefItems, qualifiedName()+argsString(), // argsString is needed for overloaded functions (see bug 609624) memLabel, - getOutputFileBase()+"#"+anchor(),memName,memArgs); + getOutputFileBase()+"#"+anchor(),memName,memArgs,pd); } } diff --git a/src/membergroup.cpp b/src/membergroup.cpp index 51eb4a15cbe..aa0a36ee6c3 100644 --- a/src/membergroup.cpp +++ b/src/membergroup.cpp @@ -326,7 +326,7 @@ void MemberGroup::addListReferences(Definition *def) name, theTranslator->trGroup(TRUE,TRUE), name, - grpHeader,0); + grpHeader,0,def); } } diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 8580a2e72a6..6cf12b6ab41 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -832,7 +832,8 @@ void NamespaceDef::addListReferences() theTranslator->trModule(TRUE,TRUE) : theTranslator->trNamespace(TRUE,TRUE), getOutputFileBase(),displayName(), - 0 + 0, + this ); } MemberGroupSDict::Iterator mgli(*memberGroupSDict); diff --git a/src/reflist.cpp b/src/reflist.cpp index ee6ac916e39..3cc76947266 100644 --- a/src/reflist.cpp +++ b/src/reflist.cpp @@ -20,6 +20,7 @@ #include "reflist.h" #include "util.h" #include "ftextstream.h" +#include "definition.h" /*! Create a list of items that are cross referenced with documentation blocks * @param listName String representing the name of the list. @@ -144,6 +145,12 @@ void RefList::generatePage() doc += "\\anchor "; doc += item->listAnchor; doc += "\n"; + if (item->scope) + { + doc += "\\_setscope "; + doc += item->scope->name(); + doc += " "; + } doc += item->prefix; doc += " \\_internalref "; doc += item->name; @@ -166,6 +173,7 @@ void RefList::generatePage() doc += ""; } doc += "\n"; + //printf("generatePage('%s')\n",doc.data()); addRelatedPage(m_listName,m_pageTitle,doc,0,m_listName,1,0,0,0); } diff --git a/src/reflist.h b/src/reflist.h index 97b1420ca04..5b647ea0680 100644 --- a/src/reflist.h +++ b/src/reflist.h @@ -23,14 +23,17 @@ #include #include "sortdict.h" +class Definition; + /** This struct represents an item in the list of references. */ struct RefItem { - RefItem() /*: written(FALSE)*/ {} + RefItem() : scope(0) {} QCString text; //!< text of the item. QCString listAnchor; //!< anchor in the list QCString prefix; //!< type prefix for the name + Definition *scope; //!< scope to use for references. QCString name; //!< name of the entity containing the reference QCString title; //!< display name of the entity QCString args; //!< optional arguments for the entity (if function) diff --git a/src/util.cpp b/src/util.cpp index 101d6b391b4..acf0063d52a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -6364,7 +6364,7 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle, void addRefItem(const QList *sli, const char *key, - const char *prefix, const char *name,const char *title,const char *args) + const char *prefix, const char *name,const char *title,const char *args,Definition *scope) { //printf("addRefItem(sli=%p,key=%s,prefix=%s,name=%s,title=%s,args=%s)\n",sli,key,prefix,name,title,args); if (sli && key && key[0]!='@') // check for @ to skip anonymous stuff (see bug427012) @@ -6389,6 +6389,7 @@ void addRefItem(const QList *sli, ASSERT(item!=0); item->prefix = prefix; + item->scope = scope; item->name = name; item->title = title; item->args = args; diff --git a/src/util.h b/src/util.h index 07744ca1521..b3f99c03b69 100644 --- a/src/util.h +++ b/src/util.h @@ -316,7 +316,7 @@ int filterCRLF(char *buf,int len); void addRefItem(const QList *sli,const char *prefix, const char *key, - const char *name,const char *title,const char *args); + const char *name,const char *title,const char *args,Definition *scope); PageDef *addRelatedPage(const char *name,const QCString &ptitle, const QCString &doc,QList *anchors,