void Parser::addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol *symbol) { if (item.isNull() || !symbol) return; // easy solution - lets add any scoped symbol and // any symbol which does not contain :: in the name // if (symbol->isDeclaration()) // return; //! \todo collect statistics and reorder to optimize if (symbol->isForwardClassDeclaration() || symbol->isExtern() || symbol->isFriend() || symbol->isGenerated() || symbol->isUsingNamespaceDirective() || symbol->isUsingDeclaration() ) return; // skip static local functions // if ((!symbol->scope() || symbol->scope()->isClass()) // && symbol->isStatic() && symbol->isFunction()) // return; const CPlusPlus::Name *symbolName = symbol->name(); if (symbolName && symbolName->isQualifiedNameId()) return; QString name = d->overview.prettyName(symbol->name()).trimmed(); QString type = d->overview.prettyType(symbol->type()).trimmed(); int iconType = CPlusPlus::Icons::iconTypeForSymbol(symbol); SymbolInformation information(name, type, iconType); ParserTreeItem::Ptr itemAdd; // If next line will be removed, 5% speed up for the initial parsing. // But there might be a problem for some files ??? // Better to improve qHash timing itemAdd = item->child(information); if (itemAdd.isNull()) itemAdd = ParserTreeItem::Ptr(new ParserTreeItem()); // locations are 1-based in Symbol, start with 0 for the editor SymbolLocation location(QString::fromUtf8(symbol->fileName() , symbol->fileNameLength()), symbol->line(), symbol->column() - 1); itemAdd->addSymbolLocation(location); // prevent showing a content of the functions if (!symbol->isFunction()) { const CPlusPlus::Scope *scope = symbol->asScope(); if (scope) { CPlusPlus::Scope::iterator cur = scope->firstMember(); while (cur != scope->lastMember()) { const CPlusPlus::Symbol *curSymbol = *cur; ++cur; if (!curSymbol) continue; // if (!symbol->isClass() && curSymbol->isStatic() && curSymbol->isFunction()) // return; addSymbol(itemAdd, curSymbol); } } } bool appendChild = true; // if item is empty and has not to be added if (symbol->isNamespace() && itemAdd->childCount() == 0) appendChild = false; if (appendChild) item->appendChild(itemAdd, information); }