aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2013-12-04 12:45:30 (EST)
committerDawid Pakuła2013-12-04 12:45:30 (EST)
commit1e7d685893197de727f4ad7e1d05a29d13c5d087 (patch)
treebc2225f45bf41b6774c8328ebec0b7a1a29890ba
parent0d5a2066fc7bc267ffc40f021c3bdf3d5f9108cb (diff)
downloadorg.eclipse.pdt-1e7d685893197de727f4ad7e1d05a29d13c5d087.zip
org.eclipse.pdt-1e7d685893197de727f4ad7e1d05a29d13c5d087.tar.gz
org.eclipse.pdt-1e7d685893197de727f4ad7e1d05a29d13c5d087.tar.bz2
Bug 422306 - Completion interfaces inside PHPDocrefs/changes/22/19322/1
Support for @param and @var Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=422306 Change-Id: I6ceecb647c2d41ee6d8b7a76b935c4c67ab35f11 Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java7
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocParamVariableStrategy.java16
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/codeassist/php5/testPHPDoc11.pdtt15
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/codeassist/php5/testPHPDoc12.pdtt17
4 files changed, 48 insertions, 7 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java
index 437edff..8705e50 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Zend Technologies
@@ -19,6 +19,7 @@ import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.dltk.ast.Modifiers;
import org.eclipse.php.core.codeassist.ICompletionContext;
import org.eclipse.php.core.codeassist.ICompletionContextResolver;
import org.eclipse.php.core.codeassist.ICompletionStrategy;
@@ -100,8 +101,8 @@ public class CompletionStrategyFactory implements ICompletionStrategyFactory {
return new ICompletionStrategy[] { new PHPDocTagStrategy(context) };
}
if (contextClass == PHPDocVarStartContext.class) {
- return new ICompletionStrategy[] { new GlobalClassesStrategy(
- context) {
+ return new ICompletionStrategy[] { new GlobalTypesStrategy(context,
+ 0, Modifiers.AccNameSpace) {
@Override
protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocParamVariableStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocParamVariableStrategy.java
index 0eeceb8..206ea79 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocParamVariableStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocParamVariableStrategy.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Zend Technologies
@@ -19,11 +19,13 @@ import org.eclipse.php.internal.core.codeassist.contexts.PHPDocTagContext;
/**
* This strategy completes variable names in 'param' PHPDoc tag
+ *
* @author michael
*/
public class PHPDocParamVariableStrategy extends FunctionArgumentsStrategy {
-
- public PHPDocParamVariableStrategy(ICompletionContext context, IElementFilter elementFilter) {
+
+ public PHPDocParamVariableStrategy(ICompletionContext context,
+ IElementFilter elementFilter) {
super(context, elementFilter);
}
@@ -37,10 +39,16 @@ public class PHPDocParamVariableStrategy extends FunctionArgumentsStrategy {
return;
}
PHPDocTagContext tagContext = (PHPDocTagContext) context;
-
+
String prefix = tagContext.getPrefix();
+ String prev = tagContext.getPreviousWord();
if (prefix.startsWith("$")) { //$NON-NLS-1$
super.apply(reporter);
+ } else if (prev.equalsIgnoreCase("param")) { //$NON-NLS-1$
+ final PHPDocReturnTypeStrategy returnStrategy = new PHPDocReturnTypeStrategy(
+ context);
+ returnStrategy.apply(reporter);
+
}
}
diff --git a/tests/org.eclipse.php.core.tests/workspace/codeassist/php5/testPHPDoc11.pdtt b/tests/org.eclipse.php.core.tests/workspace/codeassist/php5/testPHPDoc11.pdtt
new file mode 100644
index 0000000..2d7ca50
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/codeassist/php5/testPHPDoc11.pdtt
@@ -0,0 +1,15 @@
+--TEST--
+Test PHPDoc @var type
+--FILE--
+<?php
+interface TestInterface1 {
+}
+class T1 {
+ /**
+ * @var Test|
+ */
+ private $param;
+}
+?>
+--EXPECT--
+type(TestInterface1)
diff --git a/tests/org.eclipse.php.core.tests/workspace/codeassist/php5/testPHPDoc12.pdtt b/tests/org.eclipse.php.core.tests/workspace/codeassist/php5/testPHPDoc12.pdtt
new file mode 100644
index 0000000..5987778
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/codeassist/php5/testPHPDoc12.pdtt
@@ -0,0 +1,17 @@
+--TEST--
+Test PHPDoc @param type
+--FILE--
+<?php
+interface TestType1 {}
+interface TestType2 {}
+class TestType3{}
+/**
+ * @param TestT|
+ */
+function f1($param1, $param2) { }
+
+?>
+--EXPECT--
+type(TestType1)
+type(TestType2)
+type(TestType3)