aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-03-11 03:21:40 (EDT)
committerzzhongwei2013-03-11 03:21:40 (EDT)
commitd0bba0b3a93a9621526e8c563ae0bf1cd7dea77a (patch)
treee5fc00cf1dfc515e9c4833224c4d508429bfc9fc
parent3469659296b1bd2574eeb293a38cf41eee7e2ef1 (diff)
downloadorg.eclipse.pdt-d0bba0b3a93a9621526e8c563ae0bf1cd7dea77a.zip
org.eclipse.pdt-d0bba0b3a93a9621526e8c563ae0bf1cd7dea77a.tar.gz
org.eclipse.pdt-d0bba0b3a93a9621526e8c563ae0bf1cd7dea77a.tar.bz2
401875: phpDocumentor @method with parameters produces wrong
autocomplete and outline https://bugs.eclipse.org/bugs/show_bug.cgi?id=401875
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/PHPSourceElementRequestor.java11
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/index/PhpIndexingVisitor.java4
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/util/MagicMemberUtil.java78
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/documentation/PHPDocumentationContentAccess.java5
4 files changed, 96 insertions, 2 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/PHPSourceElementRequestor.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/PHPSourceElementRequestor.java
index 5060306..97db52f 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/PHPSourceElementRequestor.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/PHPSourceElementRequestor.java
@@ -552,8 +552,15 @@ public class PHPSourceElementRequestor extends SourceElementRequestVisitor {
mi.isConstructor = false;
mi.returnType = split[0];
- MagicMethod magicMethod = MagicMemberUtil
- .getMagicMethod(docTag.getValue());
+ MagicMethod magicMethod;
+ if (mi.name != null && mi.name.indexOf('(') > 0) {
+ magicMethod = MagicMemberUtil
+ .getMagicMethod2(docTag.getValue());
+ mi.name = magicMethod.name;
+ } else {
+ magicMethod = MagicMemberUtil.getMagicMethod(docTag
+ .getValue());
+ }
if (magicMethod != null) {
mi.parameterNames = magicMethod.parameterNames;
mi.parameterTypes = magicMethod.parameterTypes;
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 5c433d5..cc4590e 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
@@ -480,6 +480,10 @@ public class PhpIndexingVisitor extends PhpIndexingVisitorExtension {
}
String name = removeParenthesis(split);
+ int index = name.indexOf('(');
+ if (index > 0) {
+ name = name.substring(0, index);
+ }
int offset = docTag.sourceStart();
int length = docTag.sourceStart() + 6;
modifyDeclaration(null, new DeclarationInfo(
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/util/MagicMemberUtil.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/util/MagicMemberUtil.java
index 4e1df6c..5ead96b 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/util/MagicMemberUtil.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/util/MagicMemberUtil.java
@@ -27,6 +27,16 @@ public class MagicMemberUtil {
: name;
}
+ public static String removeParenthesis2(final String[] split) {
+ String name = split[1];
+ int index = name.indexOf('(');
+ if (index > 0) {
+ name = name.substring(0, index);
+ }
+ return name.endsWith("()") ? name.substring(0, name.length() - 2)
+ : name;
+ }
+
public static MagicMethod getMagicMethod(String docValue) {
docValue = docValue.trim();
final String[] split = WHITESPACE_SEPERATOR.split(docValue);
@@ -92,6 +102,74 @@ public class MagicMemberUtil {
return mi;
}
+ /**
+ * for @method int setName(string $name,string $name1)
+ */
+ public static MagicMethod getMagicMethod2(String docValue) {
+ docValue = docValue.trim();
+ final String[] split = WHITESPACE_SEPERATOR.split(docValue);
+ if (split.length < 2) {
+ return null;
+ }
+ MagicMethod mi = new MagicMethod();
+ try {
+ mi.returnType = split[0];
+ mi.name = removeParenthesis2(split);
+ if (split.length > 1) {
+ for (int i = 0; i < 1; i++) {
+ docValue = docValue.substring(split[i].length()).trim();
+ }
+ if (docValue.startsWith(mi.name)) {
+ docValue = docValue.substring(mi.name.length()).trim();
+ if (docValue.startsWith("(") && docValue.indexOf(')') > 0) {
+ int endIndex = docValue.indexOf(')');
+ String paramsString = docValue.substring(1, endIndex);
+ String[] params = paramsString.split(",");
+ String[] paramType = new String[params.length];
+ String[] paramName = new String[params.length];
+ String[] paramValue = new String[params.length];
+ // List<String>
+ for (int i = 0; i < params.length; i++) {
+ String param = params[i];
+ String value = null;
+ int equalIndex = param.indexOf('=');
+ if (equalIndex > 0) {
+ value = param.substring(equalIndex + 1).trim();
+ param = param.substring(0, equalIndex).trim();
+ }
+ String[] paramPair = WHITESPACE_SEPERATOR
+ .split(param.trim());
+ if (paramPair.length == 1) {
+ paramName[i] = paramPair[0];
+ } else if (paramPair.length == 2) {
+ paramType[i] = paramPair[0];
+ paramName[i] = paramPair[1];
+ }
+ if (value != null) {
+ paramValue[i] = value;
+ }
+ }
+ mi.parameterNames = paramName;
+ mi.parameterTypes = paramType;
+ mi.parameterInitializers = paramValue;
+ if (docValue.length() > endIndex) {
+ mi.desc = docValue.substring(endIndex + 1);
+ }
+ } else {
+ mi.desc = docValue;
+ }
+ } else {
+ mi.desc = docValue;
+ }
+
+ }
+ } catch (Exception e) {
+ mi = null;
+ }
+
+ return mi;
+ }
+
public static MagicField getMagicField(String docValue) {
docValue = docValue.trim();
final String[] split = WHITESPACE_SEPERATOR.split(docValue);
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/documentation/PHPDocumentationContentAccess.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/documentation/PHPDocumentationContentAccess.java
index 4410980..419468d 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/documentation/PHPDocumentationContentAccess.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/documentation/PHPDocumentationContentAccess.java
@@ -700,6 +700,11 @@ public class PHPDocumentationContentAccess {
.equals(member.getElementName())) {
return MagicMemberUtil.getMagicMethod(docTag
.getValue());
+ } else if (MagicMemberUtil
+ .removeParenthesis2(split).equals(
+ member.getElementName())) {
+ return MagicMemberUtil.getMagicMethod2(docTag
+ .getValue());
}
}
}