From a292601d5d06cf5993247f2f7a6bc7306997da23 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Fri, 27 Nov 2020 21:41:30 +0100 Subject: Issue #8206: Incorrect XHTML results Changes: - Change TooltipManager back into a singleton - Give the OutputList object a unique output id - Increment the id at each startFile() atomically - Pass the id to the HTML code generator - Store tooltips per output id. - Keep track of tooltips that are already written for a given id - for output formats other than HTML the output id is 0 and tooltips are not collected and written --- src/clangparser.cpp | 2 +- src/code.l | 5 +-- src/docbookgen.cpp | 4 +- src/docbookgen.h | 4 +- src/fortrancode.l | 5 +-- src/htmlgen.cpp | 6 ++- src/htmlgen.h | 7 +++- src/latexgen.cpp | 4 +- src/latexgen.h | 4 +- src/mangen.cpp | 4 +- src/mangen.h | 4 +- src/outputgen.cpp | 1 + src/outputgen.h | 7 +++- src/outputlist.cpp | 18 +++++++-- src/outputlist.h | 10 ++++- src/pycode.l | 5 +-- src/rtfgen.cpp | 6 +-- src/rtfgen.h | 4 +- src/tooltip.cpp | 105 ++++++++++++++++++++++++++++++++++++---------------- src/tooltip.h | 5 ++- src/vhdlcode.l | 5 +-- 21 files changed, 140 insertions(+), 75 deletions(-) diff --git a/src/clangparser.cpp b/src/clangparser.cpp index 7e97473..76ee426 100644 --- a/src/clangparser.cpp +++ b/src/clangparser.cpp @@ -573,7 +573,7 @@ void ClangTUParser::writeMultiLineCodeLink(CodeOutputInterface &ol, const char *text) { static bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS); - p->tooltipManager.addTooltip(d); + p->tooltipManager.addTooltip(ol,d); QCString ref = d->getReference(); QCString file = d->getOutputFileBase(); QCString anchor = d->anchor(); diff --git a/src/code.l b/src/code.l index d37b939..1b6cf42 100644 --- a/src/code.l +++ b/src/code.l @@ -175,7 +175,6 @@ struct codeYY_state VariableContext theVarContext; CallContext theCallContext; - TooltipManager tooltipManager; SymbolResolver symbolResolver; }; @@ -2469,7 +2468,7 @@ static void writeMultiLineCodeLink(yyscan_t yyscanner,CodeOutputInterface &ol, { struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS); - yyextra->tooltipManager.addTooltip(d); + TooltipManager::instance().addTooltip(ol,d); QCString ref = d->getReference(); QCString file = d->getOutputFileBase(); QCString anchor = d->anchor(); @@ -3886,7 +3885,7 @@ void CCodeParser::parseCode(CodeOutputInterface &od,const char *className,const yyextra->sourceFileDef=0; } // write the tooltips - yyextra->tooltipManager.writeTooltips(od); + TooltipManager::instance().writeTooltips(od); printlex(yy_flex_debug, FALSE, __FILE__, fd ? fd->fileName().data(): NULL); return; diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index b25a43c..db11c67 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -296,7 +296,7 @@ void DocbookGenerator::init() createSubDirs(d); } -void DocbookGenerator::startFile(const char *name,const char *,const char *) +void DocbookGenerator::startFile(const char *name,const char *,const char *,int) { DB_GEN_C QCString fileName=name; @@ -654,7 +654,7 @@ DB_GEN_C } } -void DocbookGenerator::writeDoc(DocNode *n,const Definition *,const MemberDef *) +void DocbookGenerator::writeDoc(DocNode *n,const Definition *,const MemberDef *,int) { DB_GEN_C DocbookDocVisitor *visitor = diff --git a/src/docbookgen.h b/src/docbookgen.h index 112d0a0..214ec97 100644 --- a/src/docbookgen.h +++ b/src/docbookgen.h @@ -136,13 +136,13 @@ class DocbookGenerator : public OutputGenerator { m_codeGen.endCodeFragment(style); } // --------------------------- - void writeDoc(DocNode *,const Definition *ctx,const MemberDef *md); + void writeDoc(DocNode *,const Definition *ctx,const MemberDef *md,int id); /////////////////////////////////////////////////////////////// // structural output interface /////////////////////////////////////////////////////////////// void startFile(const char *name,const char *manName, - const char *title); + const char *title,int id); void writeSearchInfo(){DB_GEN_EMPTY}; void writeFooter(const char *){DB_GEN_NEW}; void endFile(); diff --git a/src/fortrancode.l b/src/fortrancode.l index 0de7b84..a3795e4 100644 --- a/src/fortrancode.l +++ b/src/fortrancode.l @@ -172,7 +172,6 @@ struct fortrancodeYY_state int inTypeDecl = 0; bool endComment = false; - TooltipManager tooltipManager; }; #if USE_STATE2STRING @@ -1017,7 +1016,7 @@ static void writeMultiLineCodeLink(yyscan_t yyscanner,CodeOutputInterface &ol, { struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; static bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS); - yyextra->tooltipManager.addTooltip(d); + TooltipManager::instance().addTooltip(ol,d); QCString ref = d->getReference(); QCString file = d->getOutputFileBase(); QCString anchor = d->anchor(); @@ -1521,7 +1520,7 @@ void FortranCodeParser::parseCode(CodeOutputInterface & codeOutIntf, yyextra->hasContLine = NULL; // write the tooltips - yyextra->tooltipManager.writeTooltips(codeOutIntf); + TooltipManager::instance().writeTooltips(codeOutIntf); printlex(yy_flex_debug, FALSE, __FILE__, fileDef ? fileDef->fileName().data(): NULL); } diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index e1358a7..3a92020 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -1130,7 +1130,7 @@ void HtmlGenerator::writeFooterFile(QFile &file) static std::mutex g_indexLock; void HtmlGenerator::startFile(const char *name,const char *, - const char *title) + const char *title,int id) { //printf("HtmlGenerator::startFile(%s)\n",name); m_relPath = relativePathToRoot(name); @@ -1138,6 +1138,7 @@ void HtmlGenerator::startFile(const char *name,const char *, m_lastTitle=title; startPlainFile(fileName); + m_codeGen.setId(id); m_codeGen.setTextStream(t); m_codeGen.setRelativePath(m_relPath); { @@ -2238,8 +2239,9 @@ void HtmlGenerator::endParamList() t << ""; } -void HtmlGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *) +void HtmlGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *,int id) { + m_codeGen.setId(id); HtmlDocVisitor *visitor = new HtmlDocVisitor(t,m_codeGen,ctx); n->accept(visitor); delete visitor; diff --git a/src/htmlgen.h b/src/htmlgen.h index 45899a6..659a69e 100644 --- a/src/htmlgen.h +++ b/src/htmlgen.h @@ -26,6 +26,8 @@ class HtmlCodeGenerator : public CodeOutputInterface public: HtmlCodeGenerator(FTextStream &t,const QCString &relPath); HtmlCodeGenerator(); + int id() const { return m_id; } + void setId(int id) { m_id = id; } void setTextStream(FTextStream &t); void setRelativePath(const QCString &path); void codify(const char *text); @@ -61,6 +63,7 @@ class HtmlCodeGenerator : public CodeOutputInterface int m_col = 0; QCString m_relPath; bool m_lineOpen = false; + int m_id = 0; }; /** Generator for HTML output */ @@ -117,9 +120,9 @@ class HtmlGenerator : public OutputGenerator void setCurrentDoc(const Definition *context,const char *anchor,bool isSourceFile); void addWord(const char *word,bool hiPriority); - void writeDoc(DocNode *,const Definition *,const MemberDef *); + void writeDoc(DocNode *,const Definition *,const MemberDef *,int id); - void startFile(const char *name,const char *manName,const char *title); + void startFile(const char *name,const char *manName,const char *title,int id); void writeFooter(const char *navPath); void endFile(); void clearBuffer(); diff --git a/src/latexgen.cpp b/src/latexgen.cpp index 668a8fa..e9f8fd7 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -902,7 +902,7 @@ void LatexGenerator::writeStyleSheetFile(QFile &f) writeDefaultStyleSheet(t); } -void LatexGenerator::startFile(const char *name,const char *,const char *) +void LatexGenerator::startFile(const char *name,const char *,const char *,int) { #if 0 setEncoding(Config_getString(LATEX_OUTPUT_ENCODING)); @@ -2230,7 +2230,7 @@ void LatexGenerator::exceptionEntry(const char* prefix,bool closeBracket) t << " "; } -void LatexGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *) +void LatexGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *,int) { LatexDocVisitor *visitor = new LatexDocVisitor(t,m_codeGen,ctx?ctx->getDefFileExtension():QCString(""),m_insideTabbing); diff --git a/src/latexgen.h b/src/latexgen.h index 4c793fa..6be5de7 100644 --- a/src/latexgen.h +++ b/src/latexgen.h @@ -123,9 +123,9 @@ class LatexGenerator : public OutputGenerator // --------------------------- - void writeDoc(DocNode *,const Definition *ctx,const MemberDef *); + void writeDoc(DocNode *,const Definition *ctx,const MemberDef *,int id); - void startFile(const char *name,const char *manName,const char *title); + void startFile(const char *name,const char *manName,const char *title,int id); void writeSearchInfo() {} void writeFooter(const char *) {} void endFile(); diff --git a/src/mangen.cpp b/src/mangen.cpp index 4b01904..e58aa6e 100644 --- a/src/mangen.cpp +++ b/src/mangen.cpp @@ -155,7 +155,7 @@ static QCString buildFileName(const char *name) return fileName; } -void ManGenerator::startFile(const char *,const char *manName,const char *) +void ManGenerator::startFile(const char *,const char *manName,const char *,int) { startPlainFile( buildFileName( manName ) ); m_firstCol=TRUE; @@ -696,7 +696,7 @@ void ManGenerator::endParamList() { } -void ManGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *) +void ManGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *,int) { ManDocVisitor *visitor = new ManDocVisitor(t,*this,ctx?ctx->getDefFileExtension():QCString("")); n->accept(visitor); diff --git a/src/mangen.h b/src/mangen.h index 8a8def7..052c5ee 100644 --- a/src/mangen.h +++ b/src/mangen.h @@ -34,10 +34,10 @@ class ManGenerator : public OutputGenerator OutputType type() const { return Man; } - void writeDoc(DocNode *,const Definition *,const MemberDef *); + void writeDoc(DocNode *,const Definition *,const MemberDef *,int); static void init(); - void startFile(const char *name,const char *manName,const char *title); + void startFile(const char *name,const char *manName,const char *title,int); void writeSearchInfo() {} void writeFooter(const char *) {} void endFile(); diff --git a/src/outputgen.cpp b/src/outputgen.cpp index 2c3bf46..5be6817 100644 --- a/src/outputgen.cpp +++ b/src/outputgen.cpp @@ -21,6 +21,7 @@ #include +#include "doxygen.h" #include "outputgen.h" #include "message.h" #include "portable.h" diff --git a/src/outputgen.h b/src/outputgen.h index ba9f2f4..0d64833 100644 --- a/src/outputgen.h +++ b/src/outputgen.h @@ -62,6 +62,9 @@ class CodeOutputInterface public: virtual ~CodeOutputInterface() {} + /** Identifier for the output file */ + virtual int id() const { return 0; } + /*! Writes an code fragment to the output. This function should keep * spaces visible, should break lines at a newline and should convert * tabs to the right number of spaces. @@ -351,13 +354,13 @@ class OutputGenerator : public BaseOutputDocInterface //void setEncoding(const QCString &enc) { encoding = enc; } //virtual void postProcess(QByteArray &) { } - virtual void writeDoc(DocNode *,const Definition *ctx,const MemberDef *md) = 0; + virtual void writeDoc(DocNode *,const Definition *ctx,const MemberDef *md,int id) = 0; /////////////////////////////////////////////////////////////// // structural output interface /////////////////////////////////////////////////////////////// virtual void startFile(const char *name,const char *manName, - const char *title) = 0; + const char *title,int id=0) = 0; virtual void writeSearchInfo() = 0; virtual void writeFooter(const char *navPath) = 0; virtual void endFile() = 0; diff --git a/src/outputlist.cpp b/src/outputlist.cpp index 3e05dac..f968c8b 100644 --- a/src/outputlist.cpp +++ b/src/outputlist.cpp @@ -29,15 +29,19 @@ #include "definition.h" #include "docparser.h" #include "vhdldocgen.h" +#include "doxygen.h" +static AtomicInt g_outId; OutputList::OutputList() { + newId(); //printf("OutputList::OutputList()\n"); } OutputList::OutputList(const OutputList &ol) { + m_id = ol.m_id; for (const auto &og : ol.m_outputs) { m_outputs.emplace_back(og->clone()); @@ -48,6 +52,7 @@ OutputList &OutputList::operator=(const OutputList &ol) { if (this!=&ol) { + m_id = ol.m_id; for (const auto &og : ol.m_outputs) { m_outputs.emplace_back(og->clone()); @@ -61,6 +66,11 @@ OutputList::~OutputList() //printf("OutputList::~OutputList()\n"); } +void OutputList::newId() +{ + m_id = ++g_outId; +} + void OutputList::disableAllBut(OutputGenerator::OutputType o) { for (const auto &og : m_outputs) @@ -150,17 +160,17 @@ void OutputList::generateDoc(const char *fileName,int startLine, root = validatingParseDoc(fileName,startLine, ctx,md,docStr,indexWords,isExample,exampleName, singleLine,linkFromIndex,markdownSupport); - if (count>0) writeDoc(root,ctx,md); + if (count>0) writeDoc(root,ctx,md,m_id); delete root; } -void OutputList::writeDoc(DocRoot *root,const Definition *ctx,const MemberDef *md) +void OutputList::writeDoc(DocRoot *root,const Definition *ctx,const MemberDef *md,int) { for (const auto &og : m_outputs) { //printf("og->printDoc(extension=%s)\n", // ctx?ctx->getDefFileExtension().data():""); - if (og->isEnabled()) og->writeDoc(root,ctx,md); + if (og->isEnabled()) og->writeDoc(root,ctx,md,m_id); } VhdlDocGen::setFlowMember(0); } @@ -183,7 +193,7 @@ void OutputList::parseText(const QCString &textStr) { for (const auto &og : m_outputs) { - if (og->isEnabled()) og->writeDoc(root,0,0); + if (og->isEnabled()) og->writeDoc(root,0,0,m_id); } } diff --git a/src/outputlist.h b/src/outputlist.h index 2d06598..7baef7a 100644 --- a/src/outputlist.h +++ b/src/outputlist.h @@ -49,6 +49,7 @@ class OutputList : public OutputDocInterface } size_t size() const { return m_outputs.size(); } + int id() const { return m_id; } void disableAllBut(OutputGenerator::OutputType o); void enableAll(); @@ -69,7 +70,7 @@ class OutputList : public OutputDocInterface bool indexWords,bool isExample,const char *exampleName /*=0*/, bool singleLine /*=FALSE*/,bool linkFromIndex /*=FALSE*/, bool markdownSupport /*=FALSE*/); - void writeDoc(DocRoot *root,const Definition *ctx,const MemberDef *md); + void writeDoc(DocRoot *root,const Definition *ctx,const MemberDef *md,int id=0); void parseText(const QCString &textStr); void startIndexSection(IndexSections is) @@ -85,7 +86,10 @@ class OutputList : public OutputDocInterface void writeStyleInfo(int part) { forall(&OutputGenerator::writeStyleInfo,part); } void startFile(const char *name,const char *manName,const char *title) - { forall(&OutputGenerator::startFile,name,manName,title); } + { + newId(); + forall(&OutputGenerator::startFile,name,manName,title,m_id); + } void writeSearchInfo() { forall(&OutputGenerator::writeSearchInfo); } void writeFooter(const char *navPath) @@ -486,6 +490,7 @@ class OutputList : public OutputDocInterface private: void debug(); void clear(); + void newId(); // For each output format that is enabled (OutputGenerator::isEnabled()) we forward // the method call. @@ -501,6 +506,7 @@ class OutputList : public OutputDocInterface } std::vector< std::unique_ptr > m_outputs; + int m_id; }; diff --git a/src/pycode.l b/src/pycode.l index e136e91..970ac91 100644 --- a/src/pycode.l +++ b/src/pycode.l @@ -107,7 +107,6 @@ struct pycodeYY_state bool endComment = FALSE; VariableContext theVarContext; CallContext theCallContext; - TooltipManager tooltipManager; SymbolResolver symbolResolver; }; @@ -1097,7 +1096,7 @@ static void writeMultiLineCodeLink(yyscan_t yyscanner, { struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS); - yyextra->tooltipManager.addTooltip(d); + TooltipManager::instance().addTooltip(ol,d); QCString ref = d->getReference(); QCString file = d->getOutputFileBase(); QCString anchor = d->anchor(); @@ -1627,7 +1626,7 @@ void PythonCodeParser::parseCode(CodeOutputInterface &codeOutIntf, yyextra->sourceFileDef=0; } // write the tooltips - yyextra->tooltipManager.writeTooltips(codeOutIntf); + TooltipManager::instance().writeTooltips(codeOutIntf); printlex(yy_flex_debug, FALSE, __FILE__, fileDef ? fileDef->fileName().data(): NULL); } diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index 7acd14f..2665d38 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -372,7 +372,7 @@ void RTFGenerator::beginRTFSection() t << rtf_Style["Heading2"]->reference() << "\n"; } -void RTFGenerator::startFile(const char *name,const char *,const char *) +void RTFGenerator::startFile(const char *name,const char *,const char *,int) { //setEncoding(QCString().sprintf("CP%s",theTranslator->trRTFansicp())); QCString fileName=name; @@ -628,7 +628,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { DocText *root = validatingParseText(projectName); t << "{\\field\\fldedit {\\*\\fldinst TITLE \\\\*MERGEFORMAT}{\\fldrslt "; - writeDoc(root,0,0); + writeDoc(root,0,0,0); t << "}}\\par" << endl; } @@ -2796,7 +2796,7 @@ void RTFGenerator::exceptionEntry(const char* prefix,bool closeBracket) t << " "; } -void RTFGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *) +void RTFGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *,int) { RTFDocVisitor *visitor = new RTFDocVisitor(t,*this,ctx?ctx->getDefFileExtension():QCString("")); n->accept(visitor); diff --git a/src/rtfgen.h b/src/rtfgen.h index 8a2c3fe..0aebd15 100644 --- a/src/rtfgen.h +++ b/src/rtfgen.h @@ -41,9 +41,9 @@ class RTFGenerator : public OutputGenerator void setRelativePath(const QCString &path); void setSourceFileName(const QCString &sourceFileName); - void writeDoc(DocNode *,const Definition *,const MemberDef *); + void writeDoc(DocNode *,const Definition *,const MemberDef *,int); - void startFile(const char *name,const char *manName,const char *title); + void startFile(const char *name,const char *manName,const char *title,int id); void writeSearchInfo() {} void writeFooter(const char *) {} void endFile(); diff --git a/src/tooltip.cpp b/src/tooltip.cpp index 3c2f0e1..f8222d7 100644 --- a/src/tooltip.cpp +++ b/src/tooltip.cpp @@ -14,7 +14,10 @@ */ #include +#include +#include #include +#include #include "tooltip.h" #include "definition.h" @@ -24,12 +27,27 @@ #include "doxygen.h" #include "config.h" +static std::mutex g_tooltipLock; + +struct TooltipData +{ + std::map tooltipInfo; + std::set tooltipWritten; +}; + class TooltipManager::Private { public: - std::map tooltipInfo; + std::unordered_map > tooltips; + std::unique_ptr &getTooltipData(int id); }; +TooltipManager &TooltipManager::instance() +{ + static TooltipManager s_instance; + return s_instance; +} + TooltipManager::TooltipManager() : p(std::make_unique()) { } @@ -50,10 +68,22 @@ static QCString escapeId(const char *s) return res; } -void TooltipManager::addTooltip(const Definition *d) +std::unique_ptr &TooltipManager::Private::getTooltipData(int id) +{ + std::lock_guard lock(g_tooltipLock); + auto it = tooltips.insert(std::make_pair(id,std::make_unique())).first; + return it->second; +} + +void TooltipManager::addTooltip(CodeOutputInterface &ol,const Definition *d) { bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS); if (!sourceTooltips) return; + int outputId = ol.id(); + if (outputId==0) return; + + auto &ttd = p->getTooltipData(outputId); + QCString id = d->getOutputFileBase(); int i=id.findRev('/'); if (i!=-1) @@ -67,44 +97,57 @@ void TooltipManager::addTooltip(const Definition *d) id+="_"+anc; } id = "a" + id; - p->tooltipInfo.insert({id.str(),d}); + ttd->tooltipInfo.insert(std::make_pair(id.str(),d)); + //printf("%p: addTooltip(%s) ol=%d\n",this,id.data(),ol.id()); } void TooltipManager::writeTooltips(CodeOutputInterface &ol) { - for (const auto &kv : p->tooltipInfo) + int outputId = ol.id(); // get unique identifier per output file + if (outputId==0) return; // not set => no HTML output + auto it = p->tooltips.find(outputId); // see if we have tooltips for this file + if (it!=p->tooltips.end()) { - const Definition *d = kv.second; - DocLinkInfo docInfo; - docInfo.name = d->qualifiedName(); - docInfo.ref = d->getReference(); - docInfo.url = d->getOutputFileBase(); - docInfo.anchor = d->anchor(); - SourceLinkInfo defInfo; - if (d->getBodyDef() && d->getStartBodyLine()!=-1) - { - defInfo.file = d->getBodyDef()->name(); - defInfo.line = d->getStartBodyLine(); - defInfo.url = d->getSourceFileBase(); - defInfo.anchor = d->getSourceAnchor(); - } - SourceLinkInfo declInfo; // TODO: fill in... - QCString decl; - if (d->definitionType()==Definition::TypeMember) + auto &ttd = it->second; + for (const auto &kv : ttd->tooltipInfo) { - const MemberDef *md = toMemberDef(d); - if (!md->isAnonymous()) + if (ttd->tooltipWritten.find(kv.first)==ttd->tooltipWritten.end()) // only write tooltips once { - decl = md->declaration(); + //printf("%p: writeTooltips(%s) ol=%d\n",this,kv.first.c_str(),ol.id()); + const Definition *d = kv.second; + DocLinkInfo docInfo; + docInfo.name = d->qualifiedName(); + docInfo.ref = d->getReference(); + docInfo.url = d->getOutputFileBase(); + docInfo.anchor = d->anchor(); + SourceLinkInfo defInfo; + if (d->getBodyDef() && d->getStartBodyLine()!=-1) + { + defInfo.file = d->getBodyDef()->name(); + defInfo.line = d->getStartBodyLine(); + defInfo.url = d->getSourceFileBase(); + defInfo.anchor = d->getSourceAnchor(); + } + SourceLinkInfo declInfo; // TODO: fill in... + QCString decl; + if (d->definitionType()==Definition::TypeMember) + { + const MemberDef *md = toMemberDef(d); + if (!md->isAnonymous()) + { + decl = md->declaration(); + } + } + ol.writeTooltip(kv.first.c_str(), // id + docInfo, // symName + decl, // decl + d->briefDescriptionAsTooltip(), // desc + defInfo, + declInfo + ); + ttd->tooltipWritten.insert(kv.first); } } - ol.writeTooltip(kv.first.c_str(), // id - docInfo, // symName - decl, // decl - d->briefDescriptionAsTooltip(), // desc - defInfo, - declInfo - ); } } diff --git a/src/tooltip.h b/src/tooltip.h index 3517b5d..acdacb4 100644 --- a/src/tooltip.h +++ b/src/tooltip.h @@ -24,16 +24,17 @@ class CodeOutputInterface; class TooltipManager { public: - TooltipManager(); + static TooltipManager &instance(); ~TooltipManager(); /** add a tooltip for a given symbol definition */ - void addTooltip(const Definition *d); + void addTooltip(CodeOutputInterface &ol,const Definition *d); /** write the list of all collected tooltip to the given outputs */ void writeTooltips(CodeOutputInterface &ol); private: + TooltipManager(); class Private; std::unique_ptr p; }; diff --git a/src/vhdlcode.l b/src/vhdlcode.l index dfabe5b..480e2e2 100644 --- a/src/vhdlcode.l +++ b/src/vhdlcode.l @@ -109,7 +109,6 @@ struct vhdlcodeYY_state bool lexInit = false; int braceCount = 0; - TooltipManager tooltipManager; }; @@ -1230,7 +1229,7 @@ static void writeMultiLineCodeLink(yyscan_t yyscanner,CodeOutputInterface &ol, { struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; static bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS); - yyextra->tooltipManager.addTooltip(d); + TooltipManager::instance().addTooltip(ol,d); QCString ref = d->getReference(); QCString file = d->getOutputFileBase(); QCString anchor = d->anchor(); @@ -1659,7 +1658,7 @@ void VHDLCodeParser::parseCode(CodeOutputInterface &od, yyextra->startCode=false; // write the tooltips - yyextra->tooltipManager.writeTooltips(od); + TooltipManager::instance().writeTooltips(od); printlex(yy_flex_debug, false, __FILE__, fd ? fd->fileName().data(): NULL); } -- cgit v0.12