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

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
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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();

+13 −9
Original line number Diff line number Diff line
@@ -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);
	      }
@@ -3539,7 +3541,8 @@ 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)
		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;
+2 −1
Original line number Diff line number Diff line
@@ -870,7 +870,8 @@ void DBusXMLScanner::parseCode(CodeOutputInterface & /* codeOutIntf */,
                               bool /* inlineFragment */,
                               MemberDef * /* memberDef */,
                               bool /*showLineNumbers*/,
                               Definition * /* searchCtx */)
                               Definition * /* searchCtx */,
                               bool /*collectXRefs*/ )
{ }

void DBusXMLScanner::resetCodeParserState()
+2 −1
Original line number Diff line number Diff line
@@ -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();
+26 −2
Original line number Diff line number Diff line
@@ -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,11 +879,34 @@ void FileDef::writeSource(OutputList &ol,bool sameTu,QStrList &filesInSameTu)
    ParserInterface *pIntf = Doxygen::parserManager->getParser(getDefFileExtension());
    pIntf->resetCodeParserState();
    ol.startCodeFragment();
    pIntf->parseCode(ol,0,
        fileToString(absFilePath(),filterSourceFiles,TRUE),
    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(),      // lang
        FALSE,              // isExampleBlock
        0,                  // exampleName
        this,               // fileDef
        -1,                 // startLine
        -1,                 // endLine
        FALSE,              // inlineFragment
        0,                  // memberDef
        TRUE,               // showLineNumbers
        0,                  // searchCtx
        !needs2PassParsing  // collectXRefs
        );
    ol.endCodeFragment();
  }
  ol.endContents();
Loading