Beispiel #1
0
void ClangParser::linkIdentifier(CodeOutputInterface &ol,FileDef *fd,
    uint &line,uint &column,const char *text,int tokenIndex)
{
  CXCursor c = p->cursors[tokenIndex];
  CXCursor r = clang_getCursorReferenced(c);
  if (!clang_equalCursors(r, c))
  {
    c=r; // link to referenced location
  }
  CXCursor t = clang_getSpecializedCursorTemplate(c);
  if (!clang_Cursor_isNull(t) && !clang_equalCursors(t,c))
  {
    c=t; // link to template 
  }
  CXString usr = clang_getCursorUSR(c);
  const char *usrStr = clang_getCString(usr);

  Definition *d = usrStr ? Doxygen::clangUsrMap->find(usrStr) : 0;
  //CXCursorKind kind = clang_getCursorKind(c);
  //if (d==0)
  //{
  //  printf("didn't find definition for '%s' usr='******' kind=%d\n",
  //      text,usrStr,kind);
  //}
  //else
  //{
  //  printf("found definition for '%s' usr='******' name='%s'\n",
  //      text,usrStr,d->name().data());
  //}
  if (d && d->isLinkable())
  {
    if (g_insideBody &&
        g_currentMemberDef && d->definitionType()==Definition::TypeMember && 
        (g_currentMemberDef!=d || g_currentLine<line)) // avoid self-reference
    {
      addDocCrossReference(g_currentMemberDef,(MemberDef*)d);
    }
    writeMultiLineCodeLink(ol,fd,line,column,d,text);
  }
  else
  {
    codifyLines(ol,fd,text,line,column);
  }
  clang_disposeString(usr);
}
Beispiel #2
0
void TooltipManager::writeTooltips(CodeOutputInterface &ol)
{
  QDictIterator<Definition> di(p->tooltipInfo);
  Definition *d;
  for (di.toFirst();(d=di.current());++di)
  {
    DocLinkInfo docInfo;
    docInfo.name   = d->qualifiedName();
    docInfo.ref    = d->getReference();
    docInfo.url    = d->getOutputFileBase();
    docInfo.anchor = d->anchor();
    SourceLinkInfo defInfo;
    if (d->getBodyDef() && d->getStartBodyLine()!=-1)
    {
      defInfo.file    = d->getBodyDef()->name();
      defInfo.line    = d->getStartBodyLine();
      defInfo.url     = d->getSourceFileBase();
      defInfo.anchor  = d->getSourceAnchor();
    }
    SourceLinkInfo declInfo; // TODO: fill in...
    QCString decl;
    if (d->definitionType()==Definition::TypeMember)
    {
      MemberDef *md = (MemberDef*)d;
      decl = md->declaration();
      if (!decl.isEmpty() && decl.at(0)=='@') // hide enum values
      {
        decl.resize(0);
      }
    }
    ol.writeTooltip(di.currentKey(),                 // id
                    docInfo,                         // symName
                    decl,                            // decl
                    d->briefDescriptionAsTooltip(),  // desc
                    defInfo,
                    declInfo
                   );
  }
}
Beispiel #3
0
 // here we are presented with the symbols found by the code parser
 void linkableSymbol(int l, const char *sym,Definition *symDef,Definition *context) 
 {
   QCString ctx;
   if (context) // the context of the symbol is known
   {
     if (context->definitionType()==Definition::TypeMember) // it is inside a member
     {
       Definition *parentContext = context->getOuterScope();
       if (parentContext && parentContext->definitionType()==Definition::TypeClass)
          // it is inside a member of a class
       {
         ctx.sprintf("inside %s %s of %s %s",
           ((MemberDef *)context)->memberTypeName().data(),
           context->name().data(),
           ((ClassDef*)parentContext)->compoundTypeString().data(),
           parentContext->name().data());
       }
       else if (parentContext==Doxygen::globalScope) // it is inside a global member
       {
         ctx.sprintf("inside %s %s",
           ((MemberDef *)context)->memberTypeName().data(),
           context->name().data());
       }
     }
     if (ctx.isEmpty()) // it is something else (class, or namespace member, ...)
     {
       ctx.sprintf("in %s",context->name().data());
     }
   }
   printf("Found symbol %s at line %d of %s %s\n",
       sym,l,m_fd->getDefFileName().data(),ctx.data());
   if (symDef && context) // in this case the definition of the symbol is
     // known to doxygen.
   {
     printf("-> defined at line %d of %s\n",
         symDef->getDefLine(),symDef->getDefFileName().data());
   }
 }