Changeset View
Changeset View
Standalone View
Standalone View
duchain/expressionvisitor.cpp
Show All 37 Lines | |||||
38 | 38 | | |||
39 | using namespace KDevelop; | 39 | using namespace KDevelop; | ||
40 | 40 | | |||
41 | namespace Php | 41 | namespace Php | ||
42 | { | 42 | { | ||
43 | 43 | | |||
44 | ExpressionVisitor::ExpressionVisitor(EditorIntegrator* editor) | 44 | ExpressionVisitor::ExpressionVisitor(EditorIntegrator* editor) | ||
45 | : m_editor(editor), m_createProblems(false), | 45 | : m_editor(editor), m_createProblems(false), | ||
46 | m_offset(CursorInRevision::invalid()), m_currentContext(0), | 46 | m_offset(CursorInRevision::invalid()), m_currentContext(nullptr), | ||
47 | m_isAssignmentExpressionEqual(false), | 47 | m_isAssignmentExpressionEqual(false), | ||
48 | m_inDefine(false) | 48 | m_inDefine(false) | ||
49 | { | 49 | { | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | DeclarationPointer ExpressionVisitor::processVariable(VariableIdentifierAst* variable) | 52 | DeclarationPointer ExpressionVisitor::processVariable(VariableIdentifierAst* variable) | ||
53 | { | 53 | { | ||
54 | Q_ASSERT(m_currentContext); | 54 | Q_ASSERT(m_currentContext); | ||
▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Line(s) | 368 | } else { | |||
369 | m_result.setHadUnresolvedIdentifiers(true); | 369 | m_result.setHadUnresolvedIdentifiers(true); | ||
370 | } | 370 | } | ||
371 | } | 371 | } | ||
372 | } | 372 | } | ||
373 | } | 373 | } | ||
374 | ///TODO: DUContext pointer? | 374 | ///TODO: DUContext pointer? | ||
375 | DUContext* ExpressionVisitor::findClassContext(IdentifierAst* className) | 375 | DUContext* ExpressionVisitor::findClassContext(IdentifierAst* className) | ||
376 | { | 376 | { | ||
377 | DUContext* context = 0; | 377 | DUContext* context = nullptr; | ||
378 | DeclarationPointer declaration = findDeclarationImport(ClassDeclarationType, className); | 378 | DeclarationPointer declaration = findDeclarationImport(ClassDeclarationType, className); | ||
379 | usingDeclaration(className, declaration); | 379 | usingDeclaration(className, declaration); | ||
380 | if (declaration) { | 380 | if (declaration) { | ||
381 | DUChainReadLocker lock(DUChain::lock()); | 381 | DUChainReadLocker lock(DUChain::lock()); | ||
382 | context = declaration->internalContext(); | 382 | context = declaration->internalContext(); | ||
383 | if (!context && m_currentContext->parentContext() && m_currentContext->parentContext()->localScopeIdentifier() == declaration->qualifiedIdentifier()) { | 383 | if (!context && m_currentContext->parentContext() && m_currentContext->parentContext()->localScopeIdentifier() == declaration->qualifiedIdentifier()) { | ||
384 | //className is currentClass (internalContext is not yet set) | 384 | //className is currentClass (internalContext is not yet set) | ||
385 | context = m_currentContext->parentContext(); | 385 | context = m_currentContext->parentContext(); | ||
386 | } | 386 | } | ||
387 | } | 387 | } | ||
388 | return context; | 388 | return context; | ||
389 | } | 389 | } | ||
390 | ///TODO: DUContext pointer? | 390 | ///TODO: DUContext pointer? | ||
391 | DUContext* ExpressionVisitor::findClassContext(NamespacedIdentifierAst* className) | 391 | DUContext* ExpressionVisitor::findClassContext(NamespacedIdentifierAst* className) | ||
392 | { | 392 | { | ||
393 | DUContext* context = 0; | 393 | DUContext* context = nullptr; | ||
394 | const QualifiedIdentifier id = identifierForNamespace(className, m_editor); | 394 | const QualifiedIdentifier id = identifierForNamespace(className, m_editor); | ||
395 | DeclarationPointer declaration = findDeclarationImport(ClassDeclarationType, id); | 395 | DeclarationPointer declaration = findDeclarationImport(ClassDeclarationType, id); | ||
396 | usingDeclaration(className->namespaceNameSequence->back()->element, declaration); | 396 | usingDeclaration(className->namespaceNameSequence->back()->element, declaration); | ||
397 | buildNamespaceUses(className, id); | 397 | buildNamespaceUses(className, id); | ||
398 | if (declaration) { | 398 | if (declaration) { | ||
399 | DUChainReadLocker lock(DUChain::lock()); | 399 | DUChainReadLocker lock(DUChain::lock()); | ||
400 | context = declaration->internalContext(); | 400 | context = declaration->internalContext(); | ||
401 | if (!context && m_currentContext->parentContext() && m_currentContext->parentContext()->localScopeIdentifier() == declaration->qualifiedIdentifier()) { | 401 | if (!context && m_currentContext->parentContext() && m_currentContext->parentContext()->localScopeIdentifier() == declaration->qualifiedIdentifier()) { | ||
▲ Show 20 Lines • Show All 398 Lines • ▼ Show 20 Line(s) | |||||
800 | { | 800 | { | ||
801 | return findDeclarationImportHelper(m_currentContext, identifier, declarationType); | 801 | return findDeclarationImportHelper(m_currentContext, identifier, declarationType); | ||
802 | } | 802 | } | ||
803 | 803 | | |||
804 | Declaration* ExpressionVisitor::findVariableDeclaration(DUContext* context, Identifier identifier, | 804 | Declaration* ExpressionVisitor::findVariableDeclaration(DUContext* context, Identifier identifier, | ||
805 | CursorInRevision position, DUContext::SearchFlag flag) | 805 | CursorInRevision position, DUContext::SearchFlag flag) | ||
806 | { | 806 | { | ||
807 | QList<Declaration*> decls = context->findDeclarations(identifier, position, | 807 | QList<Declaration*> decls = context->findDeclarations(identifier, position, | ||
808 | 0, flag); | 808 | nullptr, flag); | ||
809 | for (int i = decls.count() - 1; i >= 0; i--) { | 809 | for (int i = decls.count() - 1; i >= 0; i--) { | ||
810 | Declaration *dec = decls.at(i); | 810 | Declaration *dec = decls.at(i); | ||
811 | if (dec->kind() == Declaration::Instance && dynamic_cast<VariableDeclaration*>(dec)) { | 811 | if (dec->kind() == Declaration::Instance && dynamic_cast<VariableDeclaration*>(dec)) { | ||
812 | return dec; | 812 | return dec; | ||
813 | } | 813 | } | ||
814 | } | 814 | } | ||
815 | 815 | | |||
816 | return NULL; | 816 | return nullptr; | ||
817 | } | 817 | } | ||
818 | 818 | | |||
819 | } | 819 | } |