[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdev-php] completion: Improve completion: don't filter abstract methods
From: Niko Sams <niko.sams () gmail ! com>
Date: 2013-11-17 13:14:42
Message-ID: E1Vi2BW-0003I1-3G () scm ! kde ! org
[Download RAW message or body]
Git commit 7f9caec4d88c2f6fb3bf29f8d777b1e9c1f44d13 by Niko Sams.
Committed on 17/11/2013 at 12:55.
Pushed by nsams into branch 'master'.
Improve completion: don't filter abstract methods
It makes sense in theory to filter them because they can't be called, but in pratice
abstract methods are overridden in a class and the base methods can call those.
Fixes completion for methods that have an interface as @return typehint.
M +0 -8 completion/context.cpp
M +18 -2 completion/tests/test_completion.cpp
M +1 -0 completion/tests/test_completion.h
http://commits.kde.org/kdev-php/7f9caec4d88c2f6fb3bf29f8d777b1e9c1f44d13
diff --git a/completion/context.cpp b/completion/context.cpp
index da088ba..435428a 100644
--- a/completion/context.cpp
+++ b/completion/context.cpp
@@ -1408,14 +1408,6 @@ QList<CompletionTreeItemPointer> \
CodeCompletionContext::completionItems(bool& ab }
}
- // filter abstract methods
- if (filterAbstract) {
- ClassFunctionDeclaration* method = \
dynamic_cast<ClassFunctionDeclaration*>(decl.first);
- if (method && method->isAbstract()) {
- continue;
- }
- }
-
if (!decl.first->identifier().isEmpty())
items << CompletionTreeItemPointer(
new NormalDeclarationCompletionItem(
diff --git a/completion/tests/test_completion.cpp \
b/completion/tests/test_completion.cpp index 2dcb8d5..6e4a816 100644
--- a/completion/tests/test_completion.cpp
+++ b/completion/tests/test_completion.cpp
@@ -626,7 +626,7 @@ void TestCompletion::abstractMethods()
DUContext* funContext = \
top->childContexts().first()->localDeclarations().last()->internalContext(); \
PhpCompletionTester tester(funContext, "$this->");
- QCOMPARE(tester.names, QStringList() << "bar");
+ QCOMPARE(tester.names, QStringList() << "foo" << "bar");
}
void TestCompletion::interfaceMethods()
@@ -641,8 +641,24 @@ void TestCompletion::interfaceMethods()
DUContext* funContext = \
top->childContexts().last()->localDeclarations().first()->internalContext(); \
PhpCompletionTester tester(funContext, "$this->");
- QCOMPARE(tester.names, QStringList() << "bar");
+ QCOMPARE(tester.names, QStringList() << "bar" << "foo");
}
+
+void TestCompletion::interfaceMethods2()
+{
+ // 0 1 2 3 4 5 6 \
7 + // \
01234567890123456789012345678901234567890123456789012345678901234567890123456789 + \
QByteArray method("<? interface A { function foo(); } /** @var A **/ $a = x(); "); +
+ TopDUContext* top = parse(method, DumpNone);
+ DUChainReleaser releaseTop(top);
+ DUChainWriteLocker lock(DUChain::lock());
+
+ DUContext* funContext = top;
+ PhpCompletionTester tester(funContext, "$a->");
+ QCOMPARE(tester.names, QStringList() << "foo");
+}
+
void TestCompletion::implementMethods()
{
// 0 1 2 3 4 5 6 \
7
diff --git a/completion/tests/test_completion.h b/completion/tests/test_completion.h
index b0d29ef..56fe20a 100644
--- a/completion/tests/test_completion.h
+++ b/completion/tests/test_completion.h
@@ -65,6 +65,7 @@ private slots:
void exceptionOtherFile();
void abstractMethods();
void interfaceMethods();
+ void interfaceMethods2();
void overrideMethods();
void implementMethods();
void inArray();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic