Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/declarationbuilder.cpp
Show First 20 Lines • Show All 925 Lines • ▼ Show 20 Line(s) | 921 | { | |||
---|---|---|---|---|---|
926 | } | 926 | } | ||
927 | DeclarationBuilderBase::visitVariable(node); | 927 | DeclarationBuilderBase::visitVariable(node); | ||
928 | } | 928 | } | ||
929 | 929 | | |||
930 | void DeclarationBuilder::declareVariable(DUContext* parentCtx, AbstractType::Ptr type, | 930 | void DeclarationBuilder::declareVariable(DUContext* parentCtx, AbstractType::Ptr type, | ||
931 | const QualifiedIdentifier& identifier, | 931 | const QualifiedIdentifier& identifier, | ||
932 | AstNode* node) | 932 | AstNode* node) | ||
933 | { | 933 | { | ||
934 | DUChainWriteLocker lock(DUChain::lock()); | ||||
935 | | ||||
934 | // we must not re-assign $this in a class context | 936 | // we must not re-assign $this in a class context | ||
935 | /// Qualified identifier for 'this' | 937 | /// Qualified identifier for 'this' | ||
936 | static const QualifiedIdentifier thisQId(QStringLiteral("this")); | 938 | static const QualifiedIdentifier thisQId(QStringLiteral("this")); | ||
937 | if ( identifier == thisQId | 939 | if ( identifier == thisQId | ||
938 | && currentContext()->parentContext() | 940 | && currentContext()->parentContext() | ||
939 | && currentContext()->parentContext()->type() == DUContext::Class ) { | 941 | && currentContext()->parentContext()->type() == DUContext::Class ) { | ||
940 | 942 | | |||
941 | // checks if imports \ArrayAccess | 943 | // checks if imports \ArrayAccess | ||
Show All 39 Lines | 963 | { | |||
981 | 983 | | |||
982 | return; | 984 | return; | ||
983 | } | 985 | } | ||
984 | 986 | | |||
985 | reportError(i18n("Cannot re-assign $this."), QList<AstNode*>() << node); | 987 | reportError(i18n("Cannot re-assign $this."), QList<AstNode*>() << node); | ||
986 | return; | 988 | return; | ||
987 | } | 989 | } | ||
988 | 990 | | |||
989 | DUChainWriteLocker lock(DUChain::lock()); | | |||
990 | | ||||
991 | const RangeInRevision newRange = editorFindRange(node, node); | 991 | const RangeInRevision newRange = editorFindRange(node, node); | ||
992 | 992 | | |||
993 | // check if this variable is already declared | 993 | // check if this variable is already declared | ||
994 | { | 994 | { | ||
995 | QList< Declaration* > decs = parentCtx->findDeclarations(identifier.first(), startPos(node), 0, DUContext::DontSearchInParent); | 995 | QList< Declaration* > decs = parentCtx->findDeclarations(identifier.first(), startPos(node), 0, DUContext::DontSearchInParent); | ||
996 | if ( !decs.isEmpty() ) { | 996 | if ( !decs.isEmpty() ) { | ||
997 | QList< Declaration* >::const_iterator it = decs.constEnd() - 1; | 997 | QList< Declaration* >::const_iterator it = decs.constEnd() - 1; | ||
998 | while ( true ) { | 998 | while ( true ) { | ||
▲ Show 20 Lines • Show All 507 Lines • Show Last 20 Lines |