diff options
Diffstat (limited to 'src/docparser.cpp')
-rw-r--r-- | src/docparser.cpp | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/src/docparser.cpp b/src/docparser.cpp index aff7411..1c8479b 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -112,6 +112,8 @@ static QCString g_includeFileName; static QCString g_includeFileText; static uint g_includeFileOffset; static uint g_includeFileLength; +static uint g_includeFileLine; +static bool g_includeFileShowLineNo; /** Parser's context to store all global variables. @@ -143,6 +145,8 @@ struct DocParserContext QCString includeFileText; uint includeFileOffset; uint includeFileLength; + uint includeFileLine; + bool includeFileLineNo; TokenInfo *token; }; @@ -190,6 +194,8 @@ static void docParserPushContext(bool saveParamInfo=TRUE) ctx->includeFileText = g_includeFileText; ctx->includeFileOffset = g_includeFileOffset; ctx->includeFileLength = g_includeFileLength; + ctx->includeFileLine = g_includeFileLine; + ctx->includeFileLineNo = g_includeFileShowLineNo; ctx->token = g_token; g_token = new TokenInfo; @@ -228,6 +234,8 @@ static void docParserPopContext(bool keepParamInfo=FALSE) g_includeFileText = ctx->includeFileText; g_includeFileOffset = ctx->includeFileOffset; g_includeFileLength = ctx->includeFileLength; + g_includeFileLine = ctx->includeFileLine; + g_includeFileShowLineNo = ctx->includeFileLineNo; delete g_token; g_token = ctx->token; @@ -1157,7 +1165,7 @@ static void handleLinkedWord(DocNode *parent,QList<DocNode> &children,bool ignor } else if (compound->definitionType()==Definition::TypeGroup) { - name=((GroupDef*)compound)->groupTitle(); + name=(dynamic_cast<GroupDef*>(compound))->groupTitle(); } children.append(new DocLinkedWord(parent,name, @@ -1169,7 +1177,7 @@ static void handleLinkedWord(DocNode *parent,QList<DocNode> &children,bool ignor ); } else if (compound->definitionType()==Definition::TypeFile && - ((FileDef*)compound)->generateSourceFile() + (dynamic_cast<FileDef*>(compound))->generateSourceFile() ) // undocumented file that has source code we can link to { children.append(new @@ -2004,6 +2012,8 @@ void DocInclude::parse() DBG(("DocInclude::parse(file=%s,text=%s)\n",qPrint(m_file),qPrint(m_text))); switch(m_type) { + case DontIncWithLines: + // fall through case IncWithLines: // fall through case Include: @@ -2014,6 +2024,8 @@ void DocInclude::parse() g_includeFileText = m_text; g_includeFileOffset = 0; g_includeFileLength = m_text.length(); + g_includeFileLine = 0; + g_includeFileShowLineNo = (m_type == DontIncWithLines || m_type == IncWithLines); //printf("g_includeFile=<<%s>>\n",g_includeFileText.data()); break; case VerbInclude: @@ -2048,10 +2060,18 @@ void DocInclude::parse() void DocIncOperator::parse() { + if (g_includeFileName.isEmpty()) + { + warn_doc_error(g_fileName,doctokenizerYYlineno, + "No previous '\\include' or \\dontinclude' command for '\\%s' present", + typeAsString()); + } + m_includeFileName = g_includeFileName; const char *p = g_includeFileText; uint l = g_includeFileLength; uint o = g_includeFileOffset; + uint il = g_includeFileLine; DBG(("DocIncOperator::parse() text=%s off=%d len=%d\n",qPrint(p),o,l)); uint so = o,bo; bool nonEmpty = FALSE; @@ -2063,6 +2083,7 @@ void DocIncOperator::parse() char c = p[o]; if (c=='\n') { + g_includeFileLine++; if (nonEmpty) break; // we have a pattern to match so=o+1; // no pattern, skip empty line } @@ -2074,10 +2095,12 @@ void DocIncOperator::parse() } if (g_includeFileText.mid(so,o-so).find(m_pattern)!=-1) { + m_line = il; m_text = g_includeFileText.mid(so,o-so); DBG(("DocIncOperator::parse() Line: %s\n",qPrint(m_text))); } g_includeFileOffset = QMIN(l,o+1); // set pointer to start of new line + m_showLineNo = g_includeFileShowLineNo; break; case SkipLine: while (o<l) @@ -2088,6 +2111,7 @@ void DocIncOperator::parse() char c = p[o]; if (c=='\n') { + g_includeFileLine++; if (nonEmpty) break; // we have a pattern to match so=o+1; // no pattern, skip empty line } @@ -2099,6 +2123,7 @@ void DocIncOperator::parse() } if (g_includeFileText.mid(so,o-so).find(m_pattern)!=-1) { + m_line = il; m_text = g_includeFileText.mid(so,o-so); DBG(("DocIncOperator::parse() SkipLine: %s\n",qPrint(m_text))); break; @@ -2106,6 +2131,7 @@ void DocIncOperator::parse() o++; // skip new line } g_includeFileOffset = QMIN(l,o+1); // set pointer to start of new line + m_showLineNo = g_includeFileShowLineNo; break; case Skip: while (o<l) @@ -2116,6 +2142,7 @@ void DocIncOperator::parse() char c = p[o]; if (c=='\n') { + g_includeFileLine++; if (nonEmpty) break; // we have a pattern to match so=o+1; // no pattern, skip empty line } @@ -2132,6 +2159,7 @@ void DocIncOperator::parse() o++; // skip new line } g_includeFileOffset = so; // set pointer to start of new line + m_showLineNo = g_includeFileShowLineNo; break; case Until: bo=o; @@ -2143,6 +2171,7 @@ void DocIncOperator::parse() char c = p[o]; if (c=='\n') { + g_includeFileLine++; if (nonEmpty) break; // we have a pattern to match so=o+1; // no pattern, skip empty line } @@ -2154,6 +2183,7 @@ void DocIncOperator::parse() } if (g_includeFileText.mid(so,o-so).find(m_pattern)!=-1) { + m_line = il; m_text = g_includeFileText.mid(bo,o-bo); DBG(("DocIncOperator::parse() Until: %s\n",qPrint(m_text))); break; @@ -2161,6 +2191,7 @@ void DocIncOperator::parse() o++; // skip new line } g_includeFileOffset = QMIN(l,o+1); // set pointer to start of new line + m_showLineNo = g_includeFileShowLineNo; break; } } @@ -2569,16 +2600,16 @@ DocRef::DocRef(DocNode *parent,const QCString &target,const QCString &context) : { if (anchor.isEmpty() && /* compound link */ compound->definitionType()==Definition::TypeGroup && /* is group */ - ((GroupDef *)compound)->groupTitle() /* with title */ + (dynamic_cast<GroupDef *>(compound))->groupTitle() /* with title */ ) { - m_text=((GroupDef *)compound)->groupTitle(); // use group's title as link + m_text=(dynamic_cast<GroupDef *>(compound))->groupTitle(); // use group's title as link } else if (compound->definitionType()==Definition::TypeMember && - ((MemberDef*)compound)->isObjCMethod()) + (dynamic_cast<MemberDef*>(compound))->isObjCMethod()) { // Objective C Method - MemberDef *member = (MemberDef*)compound; + MemberDef *member = dynamic_cast<MemberDef*>(compound); bool localLink = g_memberDef ? member->getClassDef()==g_memberDef->getClassDef() : FALSE; m_text = member->objCMethodName(localLink,g_inSeeBlock); } @@ -2590,7 +2621,7 @@ DocRef::DocRef(DocNode *parent,const QCString &target,const QCString &context) : return; } else if (compound && compound->definitionType()==Definition::TypeFile && - ((FileDef*)compound)->generateSourceFile() + (dynamic_cast<FileDef*>(compound))->generateSourceFile() ) // undocumented file that has source code we can link to { m_file = compound->getSourceFileBase(); @@ -2729,8 +2760,8 @@ DocLink::DocLink(DocNode *parent,const QCString &target) m_file = compound->getOutputFileBase(); m_ref = compound->getReference(); } - else if (compound && compound->definitionType()==Definition::TypeFile && - ((FileDef*)compound)->generateSourceFile() + else if (compound && compound->definitionType()==Definition::TypeFile && + (dynamic_cast<FileDef*>(compound))->generateSourceFile() ) // undocumented file that has source code we can link to { m_file = compound->getSourceFileBase(); @@ -5269,6 +5300,10 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t) { t = DocInclude::SnipWithLines; } + else if (t==DocInclude::DontInclude && optList.contains("lineno")) + { + t = DocInclude::DontIncWithLines; + } else if (t==DocInclude::Include && optList.contains("doc")) { t = DocInclude::IncludeDoc; @@ -7546,12 +7581,12 @@ DocRoot *validatingParseDoc(const char *fileName,int startLine, } else if (ctx && ctx->definitionType()==Definition::TypePage) { - Definition *scope = ((PageDef*)ctx)->getPageScope(); + Definition *scope = (dynamic_cast<PageDef*>(ctx))->getPageScope(); if (scope && scope!=Doxygen::globalScope) g_context = scope->name(); } else if (ctx && ctx->definitionType()==Definition::TypeGroup) { - Definition *scope = ((GroupDef*)ctx)->getGroupScope(); + Definition *scope = (dynamic_cast<GroupDef*>(ctx))->getGroupScope(); if (scope && scope!=Doxygen::globalScope) g_context = scope->name(); } else |