[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/devtools/kdevelop4-extra-plugins/php/duchain
From: Nikolaus Sams <niko.sams () gmail ! com>
Date: 2008-09-12 20:33:08
Message-ID: 1221251588.105131.22886.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 860375 by nsams:
Build more uses: static member function call, static member variable
M +6 -0 expressionvisitor.cpp
M +42 -2 tests/test_uses.cpp
M +2 -0 tests/test_uses.h
--- trunk/playground/devtools/kdevelop4-extra-plugins/php/duchain/expressionvisitor.cpp \
#860374:860375 @@ -108,7 +108,9 @@
}
ident += \
m_editor->parseSession()->symbol(node->stringFunctionName->string);
m_result.setDeclarations(m_currentContext->findDeclarations(QualifiedIdentifier(ident)));
+ lock.unlock();
if (!m_result.allDeclarations().isEmpty()) {
+ usingDeclaration(node->stringFunctionName, \
m_result.allDeclarations().last());
FunctionType::Ptr function = \
m_result.allDeclarations().last()->type<FunctionType>(); if (function) {
m_result.setType(function->returnType());
@@ -203,15 +205,19 @@
QList<Declaration*> declarations = \
m_currentContext->findDeclarations(identifierForNode(node->className)); if \
(!declarations.isEmpty()) { context = declarations.first()->internalContext();
+ lock.unlock();
if (!context && \
m_currentContext->parentContext()->localScopeIdentifier() == \
declarations.first()->qualifiedIdentifier()) {
//className is currentClass (internalContext is not yet set)
context = m_currentContext->parentContext();
}
+ usingDeclaration(node->className, declarations.last());
}
}
if (context) {
DUChainReadLocker lock(DUChain::lock());
m_result.setDeclarations(context->findDeclarations(identifierForNode(node->variable->variable->variable)));
+ lock.unlock();
+ usingDeclaration(node->variable->variable->variable, \
m_result.allDeclarations().last()); } else {
m_result.setType(AbstractType::Ptr());
}
--- trunk/playground/devtools/kdevelop4-extra-plugins/php/duchain/tests/test_uses.cpp \
#860374:860375 @@ -241,10 +241,50 @@
release(top);
}
+void TestUses::staticMemberFunctionCall()
+{
+ // 0 1 2 3 4 5 6 \
7 + // \
01234567890123456789012345678901234567890123456789012345678901234567890123456789 + \
QByteArray method("<? class A { public static function foo() {} } A::foo(); "); + \
TopDUContext* top = parse(method, DumpAll); + DUChainWriteLocker \
lock(DUChain::lock()); +
+ Declaration* cls = top->localDeclarations().first();
+ QCOMPARE(cls->uses().keys().count(), 1);
+ QCOMPARE(cls->uses().values().count(), 1);
+ QCOMPARE(cls->uses().values().first().count(), 1);
+ QCOMPARE(cls->uses().values().first().first(), SimpleRange(0, 47, 0, 48));
+
+ Declaration* fun = top->childContexts().first()->localDeclarations().first();
+ QCOMPARE(fun->uses().keys().count(), 1);
+ QCOMPARE(fun->uses().values().count(), 1);
+ QCOMPARE(fun->uses().values().first().count(), 1);
+ QCOMPARE(fun->uses().values().first().first(), SimpleRange(0, 50, 0, 53));
+ release(top);
+}
+void TestUses::staticMemberVariable()
+{
+ // 0 1 2 3 4 5 6 \
7 + // \
01234567890123456789012345678901234567890123456789012345678901234567890123456789 + \
QByteArray method("<? class A { public static $foo; } A::$foo; "); + TopDUContext* \
top = parse(method, DumpAll); + DUChainWriteLocker lock(DUChain::lock());
+
+ Declaration* cls = top->localDeclarations().first();
+ QCOMPARE(cls->uses().keys().count(), 1);
+ QCOMPARE(cls->uses().values().count(), 1);
+ QCOMPARE(cls->uses().values().first().count(), 1);
+ QCOMPARE(cls->uses().values().first().first(), SimpleRange(0, 35, 0, 36));
+
+ Declaration* var = top->childContexts().first()->localDeclarations().first();
+ QCOMPARE(var->uses().keys().count(), 1);
+ QCOMPARE(var->uses().values().count(), 1);
+ QCOMPARE(var->uses().values().first().count(), 1);
+ QCOMPARE(var->uses().values().first().first(), SimpleRange(0, 38, 0, 42));
+ release(top);
+}
/*
TODO:
-- static function call
-- static member variable
- constant
- parent::?
- self::
--- trunk/playground/devtools/kdevelop4-extra-plugins/php/duchain/tests/test_uses.h \
#860374:860375 @@ -42,6 +42,8 @@
void classImplementsMultiple();
void interfaceExtends();
void interfaceExtendsMultiple();
+ void staticMemberFunctionCall();
+ void staticMemberVariable();
};
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic