~ubuntu-branches/ubuntu/utopic/kdevelop-php/utopic

« back to all changes in this revision

Viewing changes to duchain/helper.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-12-20 14:59:02 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20101220145902-a6cmovse1qmue52p
Tags: 1.1.80-0ubuntu1
* New upstream release
* Build-dep on kdevplatform >= 1.1.80
* Get rid of l10n packages, not relevant in Ubuntu, put locale files into main package

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
    return false;
79
79
}
80
80
 
81
 
Declaration* findDeclarationImportHelper(DUContext* currentContext, QualifiedIdentifier id,
 
81
DeclarationPointer findDeclarationImportHelper(DUContext* currentContext, QualifiedIdentifier id,
82
82
        DeclarationType declarationType, AstNode* node, EditorIntegrator* editor)
83
83
{
84
84
    /// Qualified identifier for 'self'
90
90
    if (declarationType == ClassDeclarationType && id == selfQId) {
91
91
        DUChainReadLocker lock(DUChain::lock());
92
92
        if (currentContext->type() == DUContext::Class) {
93
 
            return currentContext->owner();
 
93
            return DeclarationPointer(currentContext->owner());
94
94
        } else if (currentContext->parentContext() && currentContext->parentContext()->type() == DUContext::Class) {
95
 
            return currentContext->parentContext()->owner();
 
95
            return DeclarationPointer(currentContext->parentContext()->owner());
96
96
        } else {
97
 
            return 0;
 
97
            return DeclarationPointer();
98
98
        }
99
99
    } else if (declarationType == ClassDeclarationType && id == parentQId) {
100
100
        //there can be just one Class-Context imported
108
108
        if (classCtx) {
109
109
            foreach(const DUContext::Import &i, classCtx->importedParentContexts()) {
110
110
                if (i.context(classCtx->topContext())->type() == DUContext::Class) {
111
 
                    return i.context(classCtx->topContext())->owner();
 
111
                    return DeclarationPointer(i.context(classCtx->topContext())->owner());
112
112
                }
113
113
            }
114
114
        }
115
 
        return 0;
 
115
        return DeclarationPointer();
116
116
    } else {
117
 
        QList<Declaration*> foundDeclarations;
118
117
        DUChainReadLocker lock(DUChain::lock());
119
 
        foundDeclarations = currentContext->topContext()->findDeclarations(id);
 
118
        QList<Declaration*> foundDeclarations = currentContext->topContext()->findDeclarations(id);
120
119
        foreach(Declaration *declaration, foundDeclarations) {
121
120
            if (isMatch(declaration, declarationType)) {
122
 
                return declaration;
 
121
                return DeclarationPointer(declaration);
123
122
            }
124
123
        }
125
124
        if ( currentContext->url() == internalFunctionFile() ) {
126
125
            // when compiling php internal functions, we don't need to ask the persistent symbol table for anything
127
 
            return 0;
 
126
            return DeclarationPointer();
128
127
        }
129
128
        if (declarationType != GlobalVariableDeclarationType) {
130
129
            ifDebug(kDebug() << "No declarations found with findDeclarations, trying through PersistentSymbolTable" << id.toString();)
174
173
                currentContext->topContext()->parsingEnvironmentFile()
175
174
                ->addModificationRevisions(top->parsingEnvironmentFile()->allModificationRevisions());
176
175
                ifDebug(kDebug() << "using" << declarations[i].declaration()->toString() << top->url().str();)
177
 
                return declarations[i].declaration();
 
176
                return DeclarationPointer(declarations[i].declaration());
178
177
            }
179
178
        }
180
179
    }
181
180
 
182
181
    ifDebug(kDebug() << "returning 0";)
183
 
    return 0;
 
182
    return DeclarationPointer();
184
183
}
185
184
 
186
185
QByteArray formatComment(AstNode* node, EditorIntegrator* editor)
297
296
            if ( str == "." || str == ".." || str.endsWith('/') ) {
298
297
                return IndexedString();
299
298
            }
300
 
            return findIncludeFileUrl(str, editor->currentUrl().toUrl());
 
299
            return findIncludeFileUrl(str, editor->parseSession()->currentDocument().toUrl());
301
300
        }
302
301
    }
303
302