Commit e835d4b2 authored by Sergio Oller's avatar Sergio Oller Committed by Dimitri van Heesch

Bug 707641 - `FILTER_SOURCE_FILES=YES` required to build CALL_GRAPHS

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.
parent 54f60c11
......@@ -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();
......
......@@ -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
......@@ -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);
}
......@@ -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);
}
......@@ -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);
}
......@@ -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);
}
......@@ -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);
}
......@@ -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);
}
......@@ -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>");
......@@ -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;
......
......@@ -870,7 +870,8 @@ void DBusXMLScanner::parseCode(CodeOutputInterface & /* codeOutIntf */,
bool /* inlineFragment */,
MemberDef * /* memberDef */,
bool /*showLineNumbers*/,
Definition * /* searchCtx */)
Definition * /* searchCtx */,
bool /*collectXRefs*/ )
{ }
void DBusXMLScanner::resetCodeParserState()
......
......@@ -51,7 +51,8 @@ public:
bool inlineFragment=FALSE,
MemberDef *memberDef=0,
bool showLineNumbers=TRUE,
Definition *searchCtx=0
Definition *searchCtx=0,
bool collectXRefs=TRUE
);
void resetCodeParserState();
......
......@@ -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())
{
......@@ -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();
}
......
......@@ -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();
......
......@@ -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
......@@ -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
//-------------------------------------------------------------------------------
/**
......@@ -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);
}
......@@ -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);
......@@ -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
......
......@@ -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);
......
......@@ -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)
......
......@@ -2347,7 +2347,8 @@ void MarkdownFileParser::parseCode(CodeOutputInterface &codeOutIntf,
bool inlineFragment,
MemberDef *memberDef,
bool showLineNumbers,
Definition *searchCtx
Definition *searchCtx,
bool collectXRefs
)
{
ParserInterface *pIntf = Doxygen::parserManager->getParser("*.cpp");
......@@ -2355,7 +2356,8 @@ void MarkdownFileParser::parseCode(CodeOutputInterface &codeOutIntf,
{
pIntf->parseCode(
codeOutIntf,scopeName,input,lang,isExampleBlock,exampleName,
fileDef,startLine,endLine,inlineFragment,memberDef,showLineNumbers,searchCtx);
fileDef,startLine,endLine,inlineFragment,memberDef,showLineNumbers,
searchCtx,collectXRefs);
}
}
......
......@@ -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);
......
......@@ -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,
......@@ -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.
......
......@@ -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
......@@ -62,6 +62,7 @@ static int g_inputPosition; //!< read offset during parsing
static const char * g_currentFontClass;
static bool g_needsTermination;
static Definition *g_searchCtx;
static bool g_collectXRefs;
static int g_inputLines; //!< number of line in the code fragment
static int g_yyLineNr; //!< current line number
static FileDef * g_sourceFileDef;
......@@ -493,35 +494,6 @@ static void codifyLines(char *text)
}
}
#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;
}
static void addDocCrossReference(MemberDef *src,MemberDef *dst)
{
static bool referencedByRelation = Config_getBool("REFERENCED_BY_RELATION");
static bool callerGraph = Config_getBool("CALLER_GRAPH");
static bool referencesRelation = Config_getBool("REFERENCES_RELATION");
static bool callGraph = Config_getBool("CALL_GRAPH");
if (dst->isTypedef() || dst->isEnumerate()) return; // don't add types
//printf("addDocCrossReference src=%s,dst=%s\n",src->name().data(),dst->name().data());
if ((referencedByRelation || callerGraph) && (src->isFunction() || src->isSlot()))
{
dst->addSourceReferencedBy(src,fileLocation());
}
if ((referencesRelation || callGraph) && (src->isFunction() || src->isSlot()))
{
src->addSourceReferences(dst,fileLocation());
}
}
#endif
static bool getLinkInScope(const QCString &c, // scope
const QCString &m, // member
......@@ -553,7 +525,7 @@ static bool getLinkInScope(const QCString &c, // scope
// g_currentDefinition,g_currentMemberDef);
if (g_currentDefinition && g_currentMemberDef &&
md!=g_currentMemberDef)
md!=g_currentMemberDef && g_collectXRefs)
{
addDocCrossReference(g_currentMemberDef,md);
}
......@@ -652,7 +624,8 @@ static void generateClassOrGlobalLink(CodeOutputInterface &ol,char *clName,
Definition *d = md->getOuterScope()==Doxygen::globalScope ?
md->getBodyDef() : 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);
}
......@@ -678,7 +651,8 @@ static void generateClassOrGlobalLink(CodeOutputInterface &ol,char *clName,
Definition *d = md->getOuterScope()==Doxygen::globalScope ?
md->getBodyDef() : 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);
}
......@@ -700,7 +674,8 @@ static void generateClassOrGlobalLink(CodeOutputInterface &ol,char *clName,
Definition *d = md->getOuterScope()==Doxygen::globalScope ?
md->getBodyDef() : 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);
}
......@@ -773,7 +748,7 @@ static bool findMemberLink(CodeOutputInterface &ol,Definition *sym,const char *s
ClassDef *thisCd = (ClassDef *)g_currentDefinition;
if (sym->definitionType()==Definition::TypeMember)
{
if (g_currentMemberDef)
if (g_currentMemberDef && g_collectXRefs)
{
addDocCrossReference(g_currentMemberDef,(MemberDef*)sym);
}
......@@ -1452,7 +1427,7 @@ static void adjustScopesAndSuites(unsigned indentLength)
void parsePythonCode(CodeOutputInterface &od,const char * /*className*/,
const QCString &s,bool exBlock, const char *exName,
FileDef *fd,int startLine,int endLine,bool /*inlineFragment*/,
MemberDef *,bool,Definition *searchCtx)
MemberDef *,bool,Definition *searchCtx,bool collectXRefs)
{
//printf("***parseCode()\n");
......@@ -1466,6 +1441,7 @@ void parsePythonCode(CodeOutputInterface &od,const char * /*className*/,
g_currentFontClass = 0;
g_needsTermination = FALSE;
g_searchCtx=searchCtx;
g_collectXRefs=collectXRefs;
if (endLine!=-1)
g_inputLines = endLine+1;
else
......
......@@ -55,7 +55,8 @@ class PythonLanguageScanner : 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);
......
......@@ -1709,12 +1709,13 @@ void PythonLanguageScanner::parseCode(CodeOutputInterface &codeOutIntf,
bool inlineFragment,
MemberDef *memberDef,
bool showLineNumbers,
Definition *searchCtx
Definition *searchCtx,
bool collectXRefs
)
{
::parsePythonCode(codeOutIntf,scopeName,input,isExampleBlock,exampleName,
fileDef,startLine,endLine,inlineFragment,memberDef,
showLineNumbers,searchCtx);
showLineNumbers,searchCtx,collectXRefs);
}
void PythonLanguageScanner::parsePrototype(const char *text)
......
......@@ -50,7 +50,8 @@ class CLanguageScanner : 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);
......
......@@ -6928,12 +6928,13 @@ void CLanguageScanner::parseCode(CodeOutputInterface & codeOutIntf,
bool inlineFragment,
MemberDef *memberDef,
bool showLineNumbers,
Definition *searchCtx
Definition *searchCtx,
bool collectXRefs
)
{
::parseCCode(codeOutIntf,scopeName,input,lang,isExampleBlock,exampleName,
fileDef,startLine,endLine,inlineFragment,memberDef,
showLineNumbers,searchCtx);
showLineNumbers,searchCtx,collectXRefs);
}
bool CLanguageScanner::needsPreprocessing(const QCString &extension)
......
......@@ -49,7 +49,8 @@ class TclLanguageScanner : 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);
......
......@@ -2569,7 +2569,8 @@ void TclLanguageScanner::parseCode(CodeOutputInterface & codeOutIntf,
bool inlineFragment,
MemberDef *memberDef,
bool showLineNumbers,
Definition *searchCtx
Definition *searchCtx,
bool collectXRefs
)
{
(void)scopeName;
......@@ -2579,6 +2580,7 @@ void TclLanguageScanner::parseCode(CodeOutputInterface & codeOutIntf,
(void)endLine;
(void)inlineFragment;
(void)searchCtx;
(void)collectXRefs;
if (input.length()<1) return;
tcl.input_string = input;
......
......@@ -8,7 +8,8 @@ class MemberDef;
void parseVhdlCode(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);
void resetVhdlCodeParserState();
void codeFreeVhdlScanner();
......
......@@ -1512,7 +1512,8 @@ void resetVhdlCodeParserState()
void parseVhdlCode(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);
if (s.isEmpty()) return;
......
......@@ -68,7 +68,8 @@ class VHDLLanguageScanner : 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);
......
......@@ -805,12 +805,13 @@ void VHDLLanguageScanner::parseCode(CodeOutputInterface &codeOutIntf,
bool inlineFragment,
MemberDef *memberDef,
bool showLineNumbers,
Definition *searchCtx
Definition *searchCtx,
bool collectXRefs
)
{
::parseVhdlCode(codeOutIntf,scopeName,input,isExampleBlock,exampleName,
fileDef,startLine,endLine,inlineFragment,memberDef,
showLineNumbers,searchCtx);
showLineNumbers,searchCtx,collectXRefs);
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment