Skip to content

Commit

Permalink
Bug 707641 - FILTER_SOURCE_FILES=YES required to build CALL_GRAPHS
Browse files Browse the repository at this point in the history
https://bugzilla.gnome.org/show_bug.cgi?id=707641

Add references if the file is filtered, as the parser
does not know whether we are insideBody or not.
  • Loading branch information
zeehio authored and Dimitri van Heesch committed Sep 28, 2013
1 parent 54f60c1 commit e835d4b
Show file tree
Hide file tree
Showing 24 changed files with 104 additions and 103 deletions.
3 changes: 2 additions & 1 deletion src/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class Definition;
void parseCCode(CodeOutputInterface &,const char *,const QCString &,
SrcLangExt lang, bool isExample, const char *exName,FileDef *fd,
int startLine,int endLine,bool inlineFragment,
MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx);
MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx,
bool collectXRefs);
void resetCCodeParserState();
void codeFreeScanner();

Expand Down
22 changes: 13 additions & 9 deletions src/code.l
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ static bool g_lexInit = FALSE;
static QStack<int> g_classScopeLengthStack;

static Definition *g_searchCtx;
static bool g_collectXRefs;

// context for an Objective-C method call
struct ObjCCallCtx
Expand Down Expand Up @@ -885,7 +886,7 @@ static bool getLinkInScope(const QCString &c, // scope
// g_currentDefinition,g_currentMemberDef,g_insideBody);

if (g_currentDefinition && g_currentMemberDef &&
md!=g_currentMemberDef && g_insideBody)
md!=g_currentMemberDef && g_insideBody && g_collectXRefs)
{
addDocCrossReference(g_currentMemberDef,md);
}
Expand Down Expand Up @@ -1018,7 +1019,8 @@ static void generateClassOrGlobalLink(CodeOutputInterface &ol,const char *clName
Definition *d = md->getOuterScope()==Doxygen::globalScope ?
md->getFileDef() : md->getOuterScope();
if (md->getGroupDef()) d = md->getGroupDef();
if (d && d->isLinkable() && md->isLinkable() && g_currentMemberDef)
if (d && d->isLinkable() && md->isLinkable() &&
g_currentMemberDef && g_collectXRefs)
{
addDocCrossReference(g_currentMemberDef,md);
}
Expand Down Expand Up @@ -1071,7 +1073,7 @@ static void generateClassOrGlobalLink(CodeOutputInterface &ol,const char *clName
}
writeMultiLineCodeLink(ol,md,text);
addToSearchIndex(clName);
if (g_currentMemberDef)
if (g_currentMemberDef && g_collectXRefs)
{
addDocCrossReference(g_currentMemberDef,md);
}
Expand Down Expand Up @@ -1127,7 +1129,7 @@ static bool generateClassMemberLink(CodeOutputInterface &ol,MemberDef *xmd,const
{
// add usage reference
if (g_currentDefinition && g_currentMemberDef &&
/*xmd!=g_currentMemberDef &&*/ g_insideBody)
/*xmd!=g_currentMemberDef &&*/ g_insideBody && g_collectXRefs)
{
addDocCrossReference(g_currentMemberDef,xmd);
}
Expand Down Expand Up @@ -1504,7 +1506,7 @@ static void writeObjCMethodCall(ObjCCallCtx *ctx)
if (ctx->method && ctx->method->isLinkable())
{
writeMultiLineCodeLink(*g_code,ctx->method,pName->data());
if (g_currentMemberDef)
if (g_currentMemberDef && g_collectXRefs)
{
addDocCrossReference(g_currentMemberDef,ctx->method);
}
Expand Down Expand Up @@ -1583,7 +1585,7 @@ static void writeObjCMethodCall(ObjCCallCtx *ctx)
else if (ctx->objectVar && ctx->objectVar->isLinkable()) // object is class variable
{
writeMultiLineCodeLink(*g_code,ctx->objectVar,pObject->data());
if (g_currentMemberDef)
if (g_currentMemberDef && g_collectXRefs)
{
addDocCrossReference(g_currentMemberDef,ctx->objectVar);
}
Expand Down Expand Up @@ -3537,9 +3539,10 @@ void resetCCodeParserState()
}

void parseCCode(CodeOutputInterface &od,const char *className,const QCString &s,
SrcLangExt lang,bool exBlock, const char *exName,FileDef *fd,
int startLine,int endLine,bool inlineFragment,
MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx)
SrcLangExt lang,bool exBlock, const char *exName,FileDef *fd,
int startLine,int endLine,bool inlineFragment,
MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx,
bool collectXRefs)
{
//printf("***parseCode() exBlock=%d exName=%s fd=%p className=%s searchCtx=%s\n",
// exBlock,exName,fd,className,searchCtx?searchCtx->name().data():"<none>");
Expand All @@ -3555,6 +3558,7 @@ void parseCCode(CodeOutputInterface &od,const char *className,const QCString &s,
g_currentFontClass = 0;
g_needsTermination = FALSE;
g_searchCtx = searchCtx;
g_collectXRefs = collectXRefs;
g_inFunctionTryBlock = FALSE;
if (endLine!=-1)
g_inputLines = endLine+1;
Expand Down
3 changes: 2 additions & 1 deletion src/dbusxmlscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,8 @@ void DBusXMLScanner::parseCode(CodeOutputInterface & /* codeOutIntf */,
bool /* inlineFragment */,
MemberDef * /* memberDef */,
bool /*showLineNumbers*/,
Definition * /* searchCtx */)
Definition * /* searchCtx */,
bool /*collectXRefs*/ )
{ }

void DBusXMLScanner::resetCodeParserState()
Expand Down
3 changes: 2 additions & 1 deletion src/dbusxmlscanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class DBusXMLScanner : public ParserInterface
bool inlineFragment=FALSE,
MemberDef *memberDef=0,
bool showLineNumbers=TRUE,
Definition *searchCtx=0
Definition *searchCtx=0,
bool collectXRefs=TRUE
);

void resetCodeParserState();
Expand Down
28 changes: 26 additions & 2 deletions src/filedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ void FileDef::writeSource(OutputList &ol,bool sameTu,QStrList &filesInSameTu)
static bool generateTreeView = Config_getBool("GENERATE_TREEVIEW");
static bool filterSourceFiles = Config_getBool("FILTER_SOURCE_FILES");
static bool latexSourceCode = Config_getBool("LATEX_SOURCE_CODE");
DevNullCodeDocInterface devNullIntf;
QCString title = m_docname;
if (!m_fileVersion.isEmpty())
{
Expand Down Expand Up @@ -878,10 +879,33 @@ void FileDef::writeSource(OutputList &ol,bool sameTu,QStrList &filesInSameTu)
ParserInterface *pIntf = Doxygen::parserManager->getParser(getDefFileExtension());
pIntf->resetCodeParserState();
ol.startCodeFragment();
bool needs2PassParsing =
Doxygen::parseSourcesNeeded && // we need to parse (filtered) sources for cross-references
!filterSourceFiles && // but user wants to show sources as-is
!getFileFilter(absFilePath(),TRUE).isEmpty(); // and there is a filter used while parsing

if (needs2PassParsing)
{
// parse code for cross-references only (see bug707641)
pIntf->parseCode(devNullIntf,0,
fileToString(absFilePath(),TRUE,TRUE),
getLanguage(),
FALSE,0,this
);
}
pIntf->parseCode(ol,0,
fileToString(absFilePath(),filterSourceFiles,TRUE),
getLanguage(),
FALSE,0,this
getLanguage(), // lang
FALSE, // isExampleBlock
0, // exampleName
this, // fileDef
-1, // startLine
-1, // endLine
FALSE, // inlineFragment
0, // memberDef
TRUE, // showLineNumbers
0, // searchCtx
!needs2PassParsing // collectXRefs
);
ol.endCodeFragment();
}
Expand Down
3 changes: 2 additions & 1 deletion src/fortrancode.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class Definition;
void parseFortranCode(CodeOutputInterface &,const char *,const QCString &,
bool ,const char *,FileDef *fd,
int startLine,int endLine,bool inlineFragment,
MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx);
MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx,
bool collectRefs);
void resetFortranCodeParserState();
void codeFreeScanner();

Expand Down
38 changes: 6 additions & 32 deletions src/fortrancode.l
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ static int g_inputLines; //!< number of line in the code fragment
static int g_yyLineNr; //!< current line number
static bool g_needsTermination;
static Definition *g_searchCtx;
static bool g_collectXRefs;
static bool g_isFixedForm;

static bool g_insideBody; //!< inside subprog/program body? => create links
Expand Down Expand Up @@ -378,36 +379,6 @@ static void writeMultiLineCodeLink(CodeOutputInterface &ol,
}
}

#if 0
static QCString fileLocation()
{
QCString result = g_sourceFileDef?g_sourceFileDef->absFilePath():QCString("[unknown]");
result+=":"+QCString().setNum(g_yyLineNr);
result+=":"+QCString().setNum(1);
return result;
}


/**
generates dictionay entries that are used if REFERENCED_BY_RELATION ... options are set
(e.g. the "referenced by ..." list after the function documentation)
*/

static void addDocCrossReference(MemberDef *src, MemberDef *dst)
{
if (dst->isTypedef() || dst->isEnumerate()) return; // don't add types
//printf("======= addDocCrossReference src=%s,dst=%s\n",src->name().data(),dst->name().data());
if ((Config_getBool("REFERENCED_BY_RELATION") || Config_getBool("CALLER_GRAPH")) &&
(src->isFunction()))
{
dst->addSourceReferencedBy(src,fileLocation());
}
if ((Config_getBool("REFERENCES_RELATION") || Config_getBool("CALL_GRAPH")) && (src->isFunction()))
{
src->addSourceReferences(dst,fileLocation());
}
}
#endif

//-------------------------------------------------------------------------------
/**
Expand Down Expand Up @@ -565,7 +536,8 @@ static bool getLink(UseSDict *usedict, // dictonary with used modules
if (md->getGroupDef()) d = md->getGroupDef();
if (d && d->isLinkable())
{
if (g_currentDefinition && g_currentMemberDef && md!=g_currentMemberDef && g_insideBody)
if (g_currentDefinition && g_currentMemberDef &&
md!=g_currentMemberDef && g_insideBody && g_collectXRefs)
{
addDocCrossReference(g_currentMemberDef,md);
}
Expand Down Expand Up @@ -1133,7 +1105,8 @@ void resetFortranCodeParserState() {}
void parseFortranCode(CodeOutputInterface &od,const char *className,const QCString &s,
bool exBlock, const char *exName,FileDef *fd,
int startLine,int endLine,bool inlineFragment,
MemberDef *memberDef,bool,Definition *searchCtx)
MemberDef *memberDef,bool,Definition *searchCtx,
bool collectXRefs)
{
//printf("***parseCode() exBlock=%d exName=%s fd=%p\n",exBlock,exName,fd);

Expand All @@ -1150,6 +1123,7 @@ void parseFortranCode(CodeOutputInterface &od,const char *className,const QCStri
g_currentFontClass = 0;
g_needsTermination = FALSE;
g_searchCtx = searchCtx;
g_collectXRefs = collectXRefs;
if (endLine!=-1)
g_inputLines = endLine+1;
else
Expand Down
3 changes: 2 additions & 1 deletion src/fortranscanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class FortranLanguageScanner : public ParserInterface
bool inlineFragment=FALSE,
MemberDef *memberDef=0,
bool showLineNumbers=TRUE,
Definition *searchCtx=0
Definition *searchCtx=0,
bool collectXRefs=TRUE
);
void resetCodeParserState();
void parsePrototype(const char *text);
Expand Down
5 changes: 3 additions & 2 deletions src/fortranscanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -2354,12 +2354,13 @@ void FortranLanguageScanner::parseCode(CodeOutputInterface & codeOutIntf,
bool inlineFragment,
MemberDef *memberDef,
bool showLineNumbers,
Definition *searchCtx
Definition *searchCtx,
bool collectXRefs
)
{
::parseFortranCode(codeOutIntf,scopeName,input,isExampleBlock,exampleName,
fileDef,startLine,endLine,inlineFragment,memberDef,
showLineNumbers,searchCtx);
showLineNumbers,searchCtx,collectXRefs);
}

bool FortranLanguageScanner::needsPreprocessing(const QCString &extension)
Expand Down
6 changes: 4 additions & 2 deletions src/markdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2347,15 +2347,17 @@ void MarkdownFileParser::parseCode(CodeOutputInterface &codeOutIntf,
bool inlineFragment,
MemberDef *memberDef,
bool showLineNumbers,
Definition *searchCtx
Definition *searchCtx,
bool collectXRefs
)
{
ParserInterface *pIntf = Doxygen::parserManager->getParser("*.cpp");
if (pIntf!=this)
{
pIntf->parseCode(
codeOutIntf,scopeName,input,lang,isExampleBlock,exampleName,
fileDef,startLine,endLine,inlineFragment,memberDef,showLineNumbers,searchCtx);
fileDef,startLine,endLine,inlineFragment,memberDef,showLineNumbers,
searchCtx,collectXRefs);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/markdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class MarkdownFileParser : public ParserInterface
bool inlineFragment=FALSE,
MemberDef *memberDef=0,
bool showLineNumbers=TRUE,
Definition *searchCtx=0
Definition *searchCtx=0,
bool collectXRefs=TRUE
);
void resetCodeParserState();
void parsePrototype(const char *text);
Expand Down
4 changes: 3 additions & 1 deletion src/parserintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class ParserInterface
* @param[in] showLineNumbers if set to TRUE and also fileDef is not 0,
* line numbers will be added to the source fragement
* @param[in] searchCtx context under which search data has to be stored.
* @param[in] collectXRefs collect cross-reference relations.
*/
virtual void parseCode(CodeOutputInterface &codeOutIntf,
const char *scopeName,
Expand All @@ -111,7 +112,8 @@ class ParserInterface
bool inlineFragment=FALSE,
MemberDef *memberDef=0,
bool showLineNumbers=TRUE,
Definition *searchCtx=0
Definition *searchCtx=0,
bool collectXRefs=TRUE
) = 0;

/** Resets the state of the code parser.
Expand Down
3 changes: 2 additions & 1 deletion src/pycode.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class Definition;
extern void parsePythonCode(CodeOutputInterface &,const char *,const QCString &,
bool ,const char *,FileDef *fd,
int startLine,int endLine,bool inlineFragment,
MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx);
MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx,
bool collectXRefs);
extern void resetPythonCodeParserState();

#endif
Loading

0 comments on commit e835d4b

Please sign in to comment.