KDevVarLengthArray<Declaration*> DeclarationId::getDeclarations(const TopDUContext* top) const { KDevVarLengthArray<Declaration*> ret; if(m_isDirect == false) { //Find the declaration by its qualified identifier and additionalIdentity QualifiedIdentifier id(m_indirectData.identifier); if(top) { //Do filtering PersistentSymbolTable::FilteredDeclarationIterator filter = PersistentSymbolTable::self().getFilteredDeclarations(id, top->recursiveImportIndices()); for(; filter; ++filter) { Declaration* decl = filter->data(); if(decl && m_indirectData.additionalIdentity == decl->additionalIdentity()) { //Hit ret.append(decl); } } }else{ //Just accept anything PersistentSymbolTable::Declarations decls = PersistentSymbolTable::self().getDeclarations(id); PersistentSymbolTable::Declarations::Iterator decl = decls.iterator(); for(; decl; ++decl) { const IndexedDeclaration& iDecl(*decl); ///@todo think this over once we don't pull in all imported top-context any more //Don't trigger loading of top-contexts from here, it will create a lot of problems if((!DUChain::self()->isInMemory(iDecl.topContextIndex()))) continue; if(!top) { Declaration* decl = iDecl.data(); if(decl && m_indirectData.additionalIdentity == decl->additionalIdentity()) { //Hit ret.append(decl); } } } } }else{ Declaration* decl = m_directData.declaration(); if(decl) ret.append(decl); } if(!ret.isEmpty() && m_specialization.index()) { KDevVarLengthArray<Declaration*> newRet; foreach (Declaration* decl, ret) { Declaration* specialized = decl->specialize(m_specialization, top ? top : decl->topContext()); if(specialized) newRet.append(specialized); }
uint pp_skip_identifier::operator()(Stream& input) { KDevVarLengthArray<char, 100> identifier; KDevelop::IndexedString::RunningHash hash; while (!input.atEnd()) { if(!isCharacter(input.current())) { //Do a more complex merge, where also tokenized identifiers can be merged KDevelop::IndexedString ret; if(!identifier.isEmpty()) ret = KDevelop::IndexedString(identifier.constData(), identifier.size(), hash.hash); while (!input.atEnd()) { uint current = input.current(); if (!isLetterOrNumber(current) && input != '_' && isCharacter(current)) break; if(ret.isEmpty()) ret = KDevelop::IndexedString::fromIndex(current); //The most common fast path else ///@todo Be better to build up a complete buffer and then append it all, so we don't get he intermediate strings into the repository ret = KDevelop::IndexedString(ret.byteArray() + KDevelop::IndexedString::fromIndex(input.current()).byteArray()); ++input; } return ret.index(); } //Collect characters and connect them to an IndexedString if (!isLetterOrNumber(input.current()) && input != '_') break; char c = characterFromIndex(input); hash.append(c); identifier.append(c); ++input; } return KDevelop::IndexedString(identifier.constData(), identifier.size(), hash.hash).index(); }