From 0fc0de19ba79068ff7b6bad1e161393adcd865b8 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Fri, 20 Dec 2019 10:35:14 +0100 Subject: issue #7446: C#: parameter named `extends` is broken in the documentation --- src/classdef.cpp | 2 +- src/classlist.cpp | 4 ++-- src/defargs.h | 4 +++- src/defargs.l | 17 +++++++++++++---- src/defgen.cpp | 2 +- src/doxygen.cpp | 8 ++++---- src/memberdef.cpp | 6 +++--- src/pre.l | 2 +- src/scanner.l | 8 ++++---- src/tagreader.cpp | 2 +- src/util.cpp | 10 +++++----- 11 files changed, 38 insertions(+), 27 deletions(-) diff --git a/src/classdef.cpp b/src/classdef.cpp index bba962e..61ae528 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -4274,7 +4274,7 @@ void ClassDefImpl::addMembersToTemplateInstance(const ClassDef *cd,const char *t for (mnii.toFirst();(mi=mnii.current());++mnii) { ArgumentList actualArguments; - stringToArgumentList(templSpec,actualArguments); + stringToArgumentList(getLanguage(),templSpec,actualArguments); MemberDef *md = mi->memberDef; MemberDef *imd = md->createTemplateInstanceMember( cd->templateArguments(),actualArguments); diff --git a/src/classlist.cpp b/src/classlist.cpp index 2b284b1..f06f744 100644 --- a/src/classlist.cpp +++ b/src/classlist.cpp @@ -167,7 +167,7 @@ void GenericsSDict::insert(const QCString &key,ClassDef *cd) int i=key.find('<'); if (i==-1) return; ArgumentList argList; - stringToArgumentList(key.mid(i),argList); + stringToArgumentList(SrcLangExt_CSharp, key.mid(i),argList); int c = argList.size(); if (c==0) return; GenericsCollection *collection = m_dict.find(key.left(i)); @@ -200,7 +200,7 @@ ClassDef *GenericsSDict::find(const QCString &key) if (collection) { ArgumentList argList; - stringToArgumentList(key.mid(i),argList); + stringToArgumentList(SrcLangExt_CSharp,key.mid(i),argList); int c = argList.size(); return collection->find(c); } diff --git a/src/defargs.h b/src/defargs.h index 1b08671..4a38723 100644 --- a/src/defargs.h +++ b/src/defargs.h @@ -18,10 +18,12 @@ #ifndef DEFARGS_H #define DEFARGS_H +#include "types.h" + class ArgumentList; class QCString; -extern void stringToArgumentList(const char *argsString,ArgumentList& argList, +extern void stringToArgumentList(SrcLangExt lang, const char *argsString,ArgumentList& argList, QCString *extraTypeChars=0); #endif diff --git a/src/defargs.l b/src/defargs.l index eb454ce..9745f44 100644 --- a/src/defargs.l +++ b/src/defargs.l @@ -86,6 +86,7 @@ static int g_lastDocContext; static int g_lastDocChar; static int g_lastExtendsContext; static QCString g_delimiter; +static SrcLangExt g_lang; static const char *stateToString(int state); /* ----------------------------------------------------------------- @@ -481,9 +482,16 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" } } "extends" { - g_curTypeConstraint.resize(0); - g_lastExtendsContext=YY_START; - BEGIN(ReadTypeConstraint); + if (g_lang!=SrcLangExt_Java) + { + REJECT; + } + else + { + g_curTypeConstraint.resize(0); + g_lastExtendsContext=YY_START; + BEGIN(ReadTypeConstraint); + } } "$"?{ID} { QCString name=yytext; //resolveDefines(yytext); @@ -601,7 +609,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" * for complex types are written to */ -void stringToArgumentList(const char *argsString,ArgumentList& al,QCString *extraTypeChars) +void stringToArgumentList(SrcLangExt lang, const char *argsString,ArgumentList& al,QCString *extraTypeChars) { if (argsString==0) return; printlex(yy_flex_debug, TRUE, __FILE__, NULL); @@ -623,6 +631,7 @@ void stringToArgumentList(const char *argsString,ArgumentList& al,QCString *extr g_curArgDefValue.resize(0); g_curArgName.resize(0); g_argList = &al; + g_lang = lang; defargsYYrestart( defargsYYin ); BEGIN( Start ); defargsYYlex(); diff --git a/src/defgen.cpp b/src/defgen.cpp index f5e12aa..7590a7e 100644 --- a/src/defgen.cpp +++ b/src/defgen.cpp @@ -146,7 +146,7 @@ void generateDEFForMember(MemberDef *md, { const ArgumentList &defAl = md->argumentList(); ArgumentList declAl; - stringToArgumentList(md->argsString(),declAl); + stringToArgumentList(md->getLanguage(),md->argsString(),declAl); QCString fcnPrefix = " " + memPrefix + "param-"; auto defIt = defAl.begin(); diff --git a/src/doxygen.cpp b/src/doxygen.cpp index cc1526f..52f9ceb 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -1060,7 +1060,7 @@ static void addClassToContext(const Entry *root) { // a Java/C# generic class looks like a C++ specialization, so we need to split the // name and template arguments here - stringToArgumentList(fullName.mid(i),tArgList); + stringToArgumentList(root->lang,fullName.mid(i),tArgList); fullName=fullName.left(i); } else @@ -3388,7 +3388,7 @@ static void buildFunctionList(const Entry *root) if (md->documentation().isEmpty() && !root->doc.isEmpty()) { ArgumentList argList; - stringToArgumentList(root->args,argList); + stringToArgumentList(root->lang,root->args,argList); if (root->proto) { //printf("setDeclArgumentList to %p\n",argList); @@ -4211,7 +4211,7 @@ static bool findTemplateInstanceRelation(const Entry *root, Debug::print(Debug::Classes,0," template root found %s templSpec=%s!\n", qPrint(templateRoot->name),qPrint(templSpec)); ArgumentList templArgs; - stringToArgumentList(templSpec,templArgs); + stringToArgumentList(root->lang,templSpec,templArgs); findBaseClassesForClass(templateRoot,context,templateClass,instanceClass, TemplateInstances,isArtificial,templArgs,templateNames); @@ -4825,7 +4825,7 @@ static void computeTemplateClassRelations() Debug::print(Debug::Classes,0," Template instance %s : \n",qPrint(tcd->name())); QCString templSpec = tdi.currentKey(); ArgumentList templArgs; - stringToArgumentList(templSpec,templArgs); + stringToArgumentList(tcd->getLanguage(),templSpec,templArgs); for (const BaseInfo &bi : root->extends) { // check if the base class is a template argument diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 4a9048a..239d614 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -1503,7 +1503,7 @@ void MemberDefImpl::IMPL::init(Definition *def, // convert function declaration arguments (if any) if (!args.isEmpty()) { - stringToArgumentList(args,declArgList,&extraTypeChars); + stringToArgumentList(def->getLanguage(),args,declArgList,&extraTypeChars); //printf("setDeclArgList %s to %s const=%d\n",args.data(), // argListToString(declArgList).data(),declArgList->constSpecifier); } @@ -6010,7 +6010,7 @@ void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef) if (mdefAl.hasParameters()) { ArgumentList mdefAlComb; - stringToArgumentList(mdef->argsString(),mdefAlComb); + stringToArgumentList(mdef->getLanguage(),mdef->argsString(),mdefAlComb); transferArgumentDocumentation(mdefAl,mdefAlComb); mdec->setArgumentList(mdefAlComb); } @@ -6023,7 +6023,7 @@ void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef) if (mdecAl.hasParameters()) { ArgumentList mdecAlComb; - stringToArgumentList(mdec->argsString(),mdecAlComb); + stringToArgumentList(mdec->getLanguage(),mdec->argsString(),mdecAlComb); transferArgumentDocumentation(mdecAl,mdecAlComb); mdef->setDeclArgumentList(mdecAlComb); } diff --git a/src/pre.l b/src/pre.l index 1ac9cf8..b6420e7 100644 --- a/src/pre.l +++ b/src/pre.l @@ -2795,7 +2795,7 @@ static void addDefine(yyscan_t yyscanner) { ArgumentList argList; //printf("addDefine() state->defName='%s' state->defArgsStr='%s'\n",state->defName.data(),state->defArgsStr.data()); - stringToArgumentList(state->defArgsStr,argList); + stringToArgumentList(SrcLangExt_Cpp, state->defArgsStr,argList); md->setArgumentList(argList); } //printf("Setting initializer for '%s' to '%s'\n",state->defName.data(),state->defText.data()); diff --git a/src/scanner.l b/src/scanner.l index c1718dc..6ad0860 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -4160,7 +4160,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) ")" { *yyextra->copyArgString+=*yytext; yyextra->fullArgString+=*yytext; - stringToArgumentList(yyextra->fullArgString,yyextra->current->argList); + stringToArgumentList(yyextra->language, yyextra->fullArgString,yyextra->current->argList); if (yyextra->insideJS) { fixArgumentListForJavaScript(yyextra->current->argList); @@ -4187,7 +4187,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { unput(yytext[i]); } - stringToArgumentList(yyextra->fullArgString,yyextra->current->argList); + stringToArgumentList(yyextra->language, yyextra->fullArgString,yyextra->current->argList); handleParametersCommentBlocks(yyscanner,yyextra->current->argList); BEGIN( yyextra->currentArgumentContext ); } @@ -4240,7 +4240,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } *yyextra->copyArgString+=*yytext; yyextra->fullArgString+=*yytext; - stringToArgumentList(yyextra->fullArgString,yyextra->current->argList); + stringToArgumentList(yyextra->language, yyextra->fullArgString,yyextra->current->argList); handleParametersCommentBlocks(yyscanner,yyextra->current->argList); BEGIN( yyextra->currentArgumentContext ); } @@ -4321,7 +4321,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) *yyextra->copyArgString+=*yytext; yyextra->fullArgString+=*yytext; //printf("end template list '%s'\n",yyextra->copyArgString->data()); - stringToArgumentList(yyextra->fullArgString,*yyextra->currentArgumentList); + stringToArgumentList(yyextra->language, yyextra->fullArgString,*yyextra->currentArgumentList); BEGIN( yyextra->currentArgumentContext ); } "(" { diff --git a/src/tagreader.cpp b/src/tagreader.cpp index 4b99f0d..3f9a7a1 100644 --- a/src/tagreader.cpp +++ b/src/tagreader.cpp @@ -1190,7 +1190,7 @@ void TagFileParser::buildMemberList(const std::shared_ptr &ce,QListargs = tmi->arglist; if (!me->args.isEmpty()) { - stringToArgumentList(me->args,me->argList); + stringToArgumentList(SrcLangExt_Cpp,me->args,me->argList); } if (tmi->enumValues.count()>0) { diff --git a/src/util.cpp b/src/util.cpp index 55dcc19..aac0d4f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1397,7 +1397,7 @@ static const ClassDef *getResolvedClassRec(const Definition *scope, ArgumentList actTemplParams; if (!strippedTemplateParams.isEmpty()) // template part that was stripped { - stringToArgumentList(strippedTemplateParams,actTemplParams); + stringToArgumentList(scope->getLanguage(),strippedTemplateParams,actTemplParams); } int qualifierIndex = computeQualifiedIndex(name); @@ -3874,7 +3874,7 @@ static void findMembersWithSpecificName(MemberName *mn, { const ArgumentList &mdAl = md->argumentList(); ArgumentList argList; - stringToArgumentList(args,argList); + stringToArgumentList(md->getLanguage(),args,argList); match=matchArguments2( md->getOuterScope(),fd,mdAl, Doxygen::globalScope,fd,argList, @@ -4005,7 +4005,7 @@ bool getDefs(const QCString &scName, ArgumentList argList; if (args) { - stringToArgumentList(args,argList); + stringToArgumentList(fcd->getLanguage(),args,argList); } for (mmli.toFirst();(mmd=mmli.current());++mmli) { @@ -4124,7 +4124,7 @@ bool getDefs(const QCString &scName, if (args) { - stringToArgumentList(args, argList); + stringToArgumentList(SrcLangExt_Cpp, args, argList); } for (mmli.toFirst(); (mmd = mmli.current()); ++mmli) @@ -4227,7 +4227,7 @@ bool getDefs(const QCString &scName, if (args && qstrcmp(args,"()")!=0) { const ArgumentList &mmdAl = mmd->argumentList(); - stringToArgumentList(args,argList); + stringToArgumentList(mmd->getLanguage(),args,argList); match=matchArguments2( mmd->getOuterScope(),mmd->getFileDef(),mmdAl, fnd,mmd->getFileDef(),argList, -- cgit v0.12