aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-04-02 03:47:51 (EDT)
committerzzhongwei2013-04-02 03:47:51 (EDT)
commit4906dee36a3a4696e8b9d0680db3e0724cbb97ab (patch)
treec805576b4ebd25e6438e60847e2a3d3a1c2d2d78
parentc2794845722457ae042ade27ca7d76ffbf8c43ea (diff)
downloadorg.eclipse.pdt-4906dee36a3a4696e8b9d0680db3e0724cbb97ab.zip
org.eclipse.pdt-4906dee36a3a4696e8b9d0680db3e0724cbb97ab.tar.gz
org.eclipse.pdt-4906dee36a3a4696e8b9d0680db3e0724cbb97ab.tar.bz2
404699: Function's parameter hint tooltip doesn't provide information
about type https://bugs.eclipse.org/bugs/show_bug.cgi?id=404699
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/Constants.java7
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpElementResolver.java5
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java38
3 files changed, 48 insertions, 2 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/Constants.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/Constants.java
new file mode 100644
index 0000000..b88f910
--- /dev/null
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/Constants.java
@@ -0,0 +1,7 @@
+package org.eclipse.php.internal.core;
+
+public interface Constants {
+ char TYPE_SEPERATOR_CHAR = '|';
+ char DOT = '.';
+
+}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpElementResolver.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpElementResolver.java
index f9d0196..13dc052 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpElementResolver.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpElementResolver.java
@@ -22,6 +22,7 @@ import org.eclipse.dltk.core.SourceRange;
import org.eclipse.dltk.core.index2.IElementResolver;
import org.eclipse.dltk.internal.core.*;
import org.eclipse.php.core.compiler.IPHPModifiers;
+import org.eclipse.php.internal.core.Constants;
import org.eclipse.php.internal.core.Logger;
import org.eclipse.php.internal.core.model.IncludeField;
@@ -185,6 +186,10 @@ public class PhpElementResolver implements IElementResolver {
if (PhpIndexingVisitor.NULL_VALUE.equals(type)) {
type = null;
}
+ if (type != null) {
+ type = type.replace(Constants.DOT,
+ Constants.TYPE_SEPERATOR_CHAR);
+ }
String param = values[1];
String defaultValue = values[2];
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java
index cc4590e..b4de7f9 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java
@@ -39,11 +39,13 @@ import org.eclipse.dltk.core.index2.IIndexingRequestor.DeclarationInfo;
import org.eclipse.dltk.core.index2.IIndexingRequestor.ReferenceInfo;
import org.eclipse.php.core.compiler.IPHPModifiers;
import org.eclipse.php.core.index.PhpIndexingVisitorExtension;
+import org.eclipse.php.internal.core.Constants;
import org.eclipse.php.internal.core.Logger;
import org.eclipse.php.internal.core.PHPCoreConstants;
import org.eclipse.php.internal.core.PHPCorePlugin;
import org.eclipse.php.internal.core.compiler.ast.nodes.*;
import org.eclipse.php.internal.core.compiler.ast.parser.ASTUtils;
+import org.eclipse.php.internal.core.typeinference.evaluators.phpdoc.PHPDocClassVariableEvaluator;
/**
* PHP indexing visitor for H2 database
@@ -218,7 +220,11 @@ public class PhpIndexingVisitor extends PhpIndexingVisitorExtension {
public boolean visit(MethodDeclaration method) throws Exception {
fNodes.push(method);
methodGlobalVars.add(new HashSet<String>());
-
+ PHPDocBlock doc = null;
+ if (method instanceof IPHPDocAwareDeclaration) {
+ IPHPDocAwareDeclaration declaration = (IPHPDocAwareDeclaration) method;
+ doc = declaration.getPHPDoc();
+ }
Declaration parentDeclaration = null;
if (!declarations.empty()) {
parentDeclaration = declarations.peek();
@@ -272,7 +278,9 @@ public class PhpIndexingVisitor extends PhpIndexingVisitorExtension {
type = fp.getParameterType().getName();
}
}
-
+ }
+ if (type == NULL_VALUE && doc != null) {
+ type = getParamType(doc, arg.getName(), type);
}
metadata.append(type);
@@ -313,6 +321,32 @@ public class PhpIndexingVisitor extends PhpIndexingVisitorExtension {
return visitGeneral(method);
}
+ private String getParamType(PHPDocBlock docBlock, String paramName,
+ String defaultType) {
+ String result = defaultType;
+ if (docBlock != null) {
+ for (PHPDocTag tag : docBlock.getTags()) {
+ if (tag.getTagKind() == PHPDocTag.PARAM) {
+ SimpleReference[] references = tag.getReferences();
+ if (references.length == 2) {
+ if (references[0].getName().equals(paramName)) {
+ String typeName = references[1].getName();
+ if (typeName
+ .endsWith(PHPDocClassVariableEvaluator.BRACKETS)) {
+ typeName = typeName.substring(0,
+ typeName.length() - 2);
+ }
+ result = typeName.replace(
+ Constants.TYPE_SEPERATOR_CHAR,
+ Constants.DOT);
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
public boolean visit(TypeDeclaration type) throws Exception {
boolean isNamespace = false;
if (type instanceof NamespaceDeclaration) {