aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek Pospychala2012-10-09 08:26:27 (EDT)
committerJacek Pospychala2012-10-09 08:26:27 (EDT)
commit8970773d6b160a4df46bab40bf8d90ad3c22b8dc (patch)
tree83b0921ce01e6fa11b04c3d751bfafd51b70845f
parenta31d347ee34126b11f427724d6c2daaa6e319193 (diff)
downloadorg.eclipse.pdt-8970773d6b160a4df46bab40bf8d90ad3c22b8dc.zip
org.eclipse.pdt-8970773d6b160a4df46bab40bf8d90ad3c22b8dc.tar.gz
org.eclipse.pdt-8970773d6b160a4df46bab40bf8d90ad3c22b8dc.tar.bz2
Bug 391359 - Add support for {inheritdoc}
-rw-r--r--plugins/org.eclipse.php.core/Resources/parserTools/parser/phpdoc/documentor_compiler_ast_scanner.flex2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTagKinds.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java68
3 files changed, 57 insertions, 15 deletions
diff --git a/plugins/org.eclipse.php.core/Resources/parserTools/parser/phpdoc/documentor_compiler_ast_scanner.flex b/plugins/org.eclipse.php.core/Resources/parserTools/parser/phpdoc/documentor_compiler_ast_scanner.flex
index 06c88be..7d114aa 100644
--- a/plugins/org.eclipse.php.core/Resources/parserTools/parser/phpdoc/documentor_compiler_ast_scanner.flex
+++ b/plugins/org.eclipse.php.core/Resources/parserTools/parser/phpdoc/documentor_compiler_ast_scanner.flex
@@ -347,6 +347,7 @@ EMPTYLINE=({LINESTART}{TABS_AND_SPACES}{NEWLINE})
<ST_IN_SHORT_DESC,ST_IN_LONG_DESC>^{LINESTART}("@property-read") {startTagsState(PHPDocTagKinds.PROPERTY_READ);}
<ST_IN_SHORT_DESC,ST_IN_LONG_DESC>^{LINESTART}("@property-write") {startTagsState(PHPDocTagKinds.PROPERTY_WRITE);}
<ST_IN_SHORT_DESC,ST_IN_LONG_DESC>^{LINESTART}("@version") {startTagsState(PHPDocTagKinds.VERSION);}
+<ST_IN_SHORT_DESC,ST_IN_LONG_DESC>^{LINESTART}("{@inheritdoc}") {startTagsState(PHPDocTagKinds.INHERITDOC);}
<ST_IN_SHORT_DESC,ST_IN_LONG_DESC,ST_IN_TAGS>^{LINESTART} {updateStartPos();}
@@ -392,6 +393,7 @@ EMPTYLINE=({LINESTART}{TABS_AND_SPACES}{NEWLINE})
<ST_IN_TAGS>^{LINESTART}("@property-write") {setNewTag(PHPDocTagKinds.PROPERTY_WRITE);}
<ST_IN_TAGS>^{LINESTART}("@var") {setNewTag(PHPDocTagKinds.VAR);}
<ST_IN_TAGS>^{LINESTART}("@version") {setNewTag(PHPDocTagKinds.VERSION);}
+<ST_IN_TAGS>^{LINESTART}("{@inheritDoc}") {setNewTag(PHPDocTagKinds.INHERITDOC);}
<ST_IN_TAGS>{TABS_AND_SPACES}("*/") {handleDocEnd_inTags();return -1;}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTagKinds.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTagKinds.java
index 30d73eb..c301943 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTagKinds.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTagKinds.java
@@ -83,4 +83,6 @@ public interface PHPDocTagKinds {
public static final int NAMESPACE = 34;
+ public static final int INHERITDOC = 35;
+
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java
index 5d6e62a..78bb326 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java
@@ -27,6 +27,7 @@ import org.eclipse.dltk.evaluation.types.MultiTypeType;
import org.eclipse.dltk.ti.GoalState;
import org.eclipse.dltk.ti.goals.IGoal;
import org.eclipse.dltk.ti.types.IEvaluatedType;
+import org.eclipse.php.internal.core.PHPCorePlugin;
import org.eclipse.php.internal.core.compiler.ast.nodes.*;
import org.eclipse.php.internal.core.index.IPHPDocAwareElement;
import org.eclipse.php.internal.core.typeinference.PHPClassType;
@@ -68,7 +69,57 @@ public class PHPDocMethodReturnTypeEvaluator extends
super(goal);
}
+ private void evaluateReturnType(List<String> returnTypeList,
+ PHPDocBlock docBlock, IMethod method) {
+
+ PHPDocTag[] tags = docBlock.getTags(PHPDocTagKinds.RETURN);
+ PHPDocTag[] inherit = docBlock.getTags(PHPDocTagKinds.INHERITDOC);
+
+ if (inherit != null && inherit.length == 1) {
+ IType type = method.getDeclaringType();
+
+ if (type != null) {
+ try {
+ IType[] superClasses = PHPModelUtils.getSuperClasses(type,
+ null);
+
+ for (IType superClass : superClasses) {
+ IMethod superClassMethod = superClass.getMethod(method
+ .getElementName());
+
+ if (superClassMethod != null) {
+ PHPDocBlock superDocBlock = PHPModelUtils
+ .getDocBlock(superClassMethod);
+ if (superDocBlock == null) {
+ continue;
+ }
+ evaluateReturnType(returnTypeList, superDocBlock,
+ superClassMethod);
+ }
+ }
+ } catch (ModelException e) {
+ PHPCorePlugin.getDefault().log(e);
+ }
+ }
+ }
+
+ if (tags != null && tags.length > 0) {
+ for (PHPDocTag phpDocTag : tags) {
+ if (phpDocTag.getReferences() != null
+ && phpDocTag.getReferences().length > 0) {
+ for (SimpleReference ref : phpDocTag.getReferences()) {
+ String type = ref.getName();
+ if (type != null) {
+ returnTypeList.add(type);
+ }
+ }
+ }
+ }
+ }
+ }
+
public IGoal[] init() {
+
for (IMethod method : getMethods()) {
IType currentNamespace = PHPModelUtils.getCurrentNamespace(method);
String[] typeNames = null;
@@ -80,21 +131,8 @@ public class PHPDocMethodReturnTypeEvaluator extends
if (docBlock == null) {
return IGoal.NO_GOALS;
}
- PHPDocTag[] tags = docBlock.getTags(PHPDocTagKinds.RETURN);
- if (tags != null && tags.length > 0) {
- for (PHPDocTag phpDocTag : tags) {
- if (phpDocTag.getReferences() != null
- && phpDocTag.getReferences().length > 0) {
- for (SimpleReference ref : phpDocTag
- .getReferences()) {
- String type = ref.getName();
- if (type != null) {
- returnTypeList.add(type);
- }
- }
- }
- }
- }
+
+ evaluateReturnType(returnTypeList, docBlock, method);
typeNames = returnTypeList.toArray(new String[returnTypeList
.size()]);
}