diff --git a/php.editor/src/org/netbeans/modules/php/editor/model/impl/FunctionScopeImpl.java b/php.editor/src/org/netbeans/modules/php/editor/model/impl/FunctionScopeImpl.java --- a/php.editor/src/org/netbeans/modules/php/editor/model/impl/FunctionScopeImpl.java +++ b/php.editor/src/org/netbeans/modules/php/editor/model/impl/FunctionScopeImpl.java @@ -207,36 +207,41 @@ private ReturnTypesDescriptor getReturnTypesDescriptor(String types, boolean resolveSemiTypes) { ReturnTypesDescriptor result = ReturnTypesDescriptor.NONE; if (StringUtils.hasText(types)) { - String[] typeNames = types.split(TYPE_SEPARATOR_REGEXP); - if (containsCallerDependentType(typeNames)) { - result = new CallerDependentTypesDescriptor(); - } else if (getInScope() instanceof ClassScope && containsSelfDependentType(typeNames)) { - result = new CommonTypesDescriptor(Collections.singleton((TypeScope) getInScope())); - } else { - Collection retval = new HashSet<>(); - for (String typeName : typeNames) { - if (typeName.trim().length() > 0) { - boolean added = false; - try { - added = recursionDetection.add(typeName); - if (added && recursionDetection.size() < 15) { - if (resolveSemiTypes && VariousUtils.isSemiType(typeName)) { - retval.addAll(VariousUtils.getType(this, typeName, getLastValidMethodOffset(), false)); - } else { - String modifiedTypeName = typeName; - if (typeName.indexOf("[") != -1) { //NOI18N - modifiedTypeName = typeName.replaceAll("\\[.*\\]", ""); //NOI18N - } - retval.addAll(IndexScopeImpl.getTypes(QualifiedName.create(modifiedTypeName), this)); + final String[] typeNames = types.split(TYPE_SEPARATOR_REGEXP); + Collection retval = new HashSet<>(); + for (String typeName : typeNames) { + if (isSpecialTypeName(typeName)) { + continue; + } + if (typeName.trim().length() > 0) { + boolean added = false; + try { + added = recursionDetection.add(typeName); + if (added && recursionDetection.size() < 15) { + if (resolveSemiTypes && VariousUtils.isSemiType(typeName)) { + retval.addAll(VariousUtils.getType(this, typeName, getLastValidMethodOffset(), false)); + } else { + String modifiedTypeName = typeName; + if (typeName.indexOf("[") != -1) { //NOI18N + modifiedTypeName = typeName.replaceAll("\\[.*\\]", ""); //NOI18N } + retval.addAll(IndexScopeImpl.getTypes(QualifiedName.create(modifiedTypeName), this)); } - } finally { - if (added) { - recursionDetection.remove(typeName); - } + } + } finally { + if (added) { + recursionDetection.remove(typeName); } } } + } + if (getInScope() instanceof ClassScope && containsSelfDependentType(typeNames)) { + retval.add(((TypeScope) getInScope())); + } + + if (containsCallerDependentType(typeNames)) { + result = new CallerDependentTypesDescriptor(retval); + } else { result = new CommonTypesDescriptor(retval); } } @@ -279,6 +284,13 @@ return (Arrays.binarySearch(typeNames, "\\self") >= 0) || (Arrays.binarySearch(typeNames, Type.OBJECT) >= 0); //NOI18N } + private static boolean isSpecialTypeName(String typeName) { + return typeName.equals("\\this") //NOI18N + || typeName.equals("\\static") //NOI18N + || typeName.equals("\\self") //NOI18N + || typeName.equals(Type.OBJECT); + } + private void updateReturnTypes(String oldTypes, Collection resolvedReturnTypes) { if (VariousUtils.isSemiType(oldTypes)) { updateSemiReturnTypes(oldTypes, resolvedReturnTypes); @@ -443,10 +455,19 @@ private static final class CallerDependentTypesDescriptor implements ReturnTypesDescriptor { + private final Collection rawTypes; + + public CallerDependentTypesDescriptor(Collection rawTypes) { + assert rawTypes != null; + this.rawTypes = rawTypes; + } + @Override public Collection getModifiedResult(Collection callerTypes) { assert callerTypes != null; - return callerTypes; + HashSet types = new HashSet<>(rawTypes); + types.addAll(callerTypes); + return types; } } diff --git a/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelVisitor.java b/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelVisitor.java --- a/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelVisitor.java +++ b/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelVisitor.java @@ -302,16 +302,21 @@ } else if (expression instanceof VariableBase) { typeName = VariousUtils.extractTypeFroVariableBase((VariableBase) expression); if (typeName != null) { - Collection allVariables = VariousUtils.getAllVariables(functionScope, typeName); - Map var2Type = new HashMap<>(); - for (VariableName variable : allVariables) { - String name = variable.getName(); - String type = resolveVariableType(name, functionScope, node); - String qualifiedType = VariousUtils.qualifyTypeNames(type, node.getStartOffset(), currentScope); - var2Type.put(name, qualifiedType); - } - if (!var2Type.isEmpty()) { - typeName = VariousUtils.replaceVarNames(typeName, var2Type); + if (typeName.equals(VariousUtils.PRE_OPERATION_TYPE_DELIMITER + VariousUtils.VAR_TYPE_PREFIX + "$this")) { //NO18N + // #239987 just "return $this;" + typeName = "\\this"; //NOI18N + } else { + Collection allVariables = VariousUtils.getAllVariables(functionScope, typeName); + Map var2Type = new HashMap<>(); + for (VariableName variable : allVariables) { + String name = variable.getName(); + String type = resolveVariableType(name, functionScope, node); + String qualifiedType = VariousUtils.qualifyTypeNames(type, node.getStartOffset(), currentScope); + var2Type.put(name, qualifiedType); + } + if (!var2Type.isEmpty()) { + typeName = VariousUtils.replaceVarNames(typeName, var2Type); + } } } } else if (expression instanceof Scalar) { diff --git a/php.editor/src/org/netbeans/modules/php/editor/model/impl/VariousUtils.java b/php.editor/src/org/netbeans/modules/php/editor/model/impl/VariousUtils.java --- a/php.editor/src/org/netbeans/modules/php/editor/model/impl/VariousUtils.java +++ b/php.editor/src/org/netbeans/modules/php/editor/model/impl/VariousUtils.java @@ -491,7 +491,7 @@ for (TypeScope tScope : oldRecentTypes) { Collection inheritedMethods = IndexScopeImpl.getMethods(tScope, frag, varScope, PhpModifiers.ALL_FLAGS); for (MethodScope meth : inheritedMethods) { - newRecentTypes.addAll(meth.getReturnTypes(true, recentTypes)); + newRecentTypes.addAll(meth.getReturnTypes(true, Collections.singleton(tScope))); } } recentTypes = filterSuperTypes(newRecentTypes); @@ -1644,17 +1644,20 @@ if (!typeNames.matches(SPACES_AND_TYPE_DELIMITERS)) { //NOI18N for (String typeName : typeNames.split("\\" + typeSeparator)) { //NOI18N String typeRawPart = typeName; - String typeArrayPart = ""; + String typeArrayPart = ""; //NOI18N int indexOfArrayDelim = typeName.indexOf('['); if (indexOfArrayDelim != -1) { typeRawPart = typeName.substring(0, indexOfArrayDelim); typeArrayPart = typeName.substring(indexOfArrayDelim, typeName.length()); } - if (!typeRawPart.startsWith(NamespaceDeclarationInfo.NAMESPACE_SEPARATOR) && !Type.isPrimitive(typeRawPart)) { + if ("$this".equals(typeName)) { //NOI18N + // #239987 + retval.append("\\this").append(typeSeparator); //NOI18N + } else if (!typeRawPart.startsWith(NamespaceDeclarationInfo.NAMESPACE_SEPARATOR) && !Type.isPrimitive(typeRawPart)) { QualifiedName fullyQualifiedName = VariousUtils.getFullyQualifiedName(QualifiedName.create(typeRawPart), offset, inScope); retval.append(fullyQualifiedName.toString().startsWith(NamespaceDeclarationInfo.NAMESPACE_SEPARATOR) - ? "" - : NamespaceDeclarationInfo.NAMESPACE_SEPARATOR); //NOI18N + ? "" //NOI18N + : NamespaceDeclarationInfo.NAMESPACE_SEPARATOR); retval.append(fullyQualifiedName.toString()).append(typeArrayPart).append(typeSeparator); } else { retval.append(typeRawPart).append(typeArrayPart).append(typeSeparator); diff --git a/php.editor/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGenerator.java b/php.editor/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGenerator.java --- a/php.editor/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGenerator.java +++ b/php.editor/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGenerator.java @@ -58,6 +58,7 @@ import org.netbeans.modules.parsing.api.Source; import org.netbeans.modules.parsing.api.UserTask; import org.netbeans.modules.parsing.spi.ParseException; +import org.netbeans.modules.php.api.util.StringUtils; import org.netbeans.modules.php.editor.CodeUtils; import org.netbeans.modules.php.editor.api.AliasedName; import org.netbeans.modules.php.editor.api.NameKind; @@ -150,9 +151,10 @@ toAdd.append(" * "); toAdd.append(text); - if (type != null && !type.isEmpty()) { + String returnType = convertThisReturnType(type); + if (returnType != null && !returnType.isEmpty()) { toAdd.append(" "); - toAdd.append(type); + toAdd.append(returnType); } else { toAdd.append(" "); toAdd.append(TYPE_PLACEHOLDER); @@ -163,6 +165,33 @@ } } + /** + * Convert \this to $this. + * @param returnTypes return types separated by "|" + * @return converted return types + */ + private static String convertThisReturnType(String returnTypes) { + if (StringUtils.isEmpty(returnTypes)) { + return ""; //NOI18N + } + final String typeSeparator = "|"; //NOI18N + StringBuilder sb = new StringBuilder(returnTypes.length()); + boolean first = true; + for (String typeName : returnTypes.split("\\" + typeSeparator)) { //NOI18N + if (first) { + first = false; + } else { + sb.append(typeSeparator); + } + if (typeName.equals("\\this")) { //NOI18N + sb.append("$this"); //NOI18N + } else { + sb.append(typeName); + } + } + return sb.toString(); + } + private static void generateGlobalVariableDoc(BaseDocument doc, int offset, int indent, String indexName, String type) throws BadLocationException { StringBuilder toAdd = new StringBuilder(); diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php @@ -0,0 +1,163 @@ +baseClass = $baseClass; + } + + public function publicDelegateMethod() { + out("publicDelegateMethod"); + return $this; + } + + private function privateDelegateMethod() { + out("privateDelegateMethod"); + return $this; + } + + protected function protectedDelegateMethod() { + out("protectedDelegateMethod"); + return $this; + } +} + +class BaseClass +{ + private $delegate = false; + + public function setDelegate($delegate) { + out("setDelegate"); + $this->delegate = $delegate; + } + + /** + * Multiple return types. + */ + public function multipleReturnStatements() { + out("multipleReturnStatements"); + if ($this->delegate) { + return new Delegate($this); + } + return $this; + } + + /** + * Multiple return types (only return tag). + * + * @return $this|Delegate + */ + public function multipleReturnTags() { + } + + /** + * Multiple return types (both return tag and statement). + * + * @return $this|Delegate + */ + public function multipleReturnTagsAndStatements() { + out("multipleReturnTagsAndStatements"); + if ($this->delegate) { + return new Delegate($this); + } + return $this; + } + + /** + * @return \this + */ + public function returnTagWithOldThis() { + out("returnTagWithOldThis"); + } + + /** + * @return $this + */ + public function publicBaseMethod() { + out("publicBaseMethod"); + return $this; + } + + private function privateBaseMethod() { + out("privateBaseMethod"); + return $this; + } + + protected function protectedBaseMethod() { + out("protectedBaseMethod"); + return $this; + } + + public function publicBaseVoidMethod() { + out("publicBaseVoidMethod"); + } +} + +class ExClass extends BaseClass +{ + public function test() { + $this->setDelegate(false); + $this->multipleReturnStatements()->privateExMethod()->multipleReturnStatements(); // test + $this->setDelegate(true); + $this->multipleReturnTagsAndStatements()->publicDelegateMethod()->publicDelegateMethod(); // test + out("test"); + } + + public function publicExMethod() { + out("publicExMethod"); + return $this; + } + + private function privateExMethod() { + out("privateExMethod"); + return $this->protectedBaseMethod(); + } + + protected function protectedExMethod() { + out("protectedExMethod"); + return $this; + } + + public function publicExVoidMethod() { + out("publicExVoidMethod"); + } + +} + +$base = new BaseClass(); +echo PHP_EOL . "[\$base->publicBaseMethod()->multipleReturnStatements()->publicDelegateMethod()->publicDelegateMethod()]" . PHP_EOL; +$base->setDelegate(true); +$base->publicBaseMethod()->multipleReturnStatements()->publicDelegateMethod()->publicDelegateMethod(); // test + +echo PHP_EOL . "[\$base->multipleReturnTagsAndStatements()->publicBaseVoidMethod()]" . PHP_EOL; +$base->setDelegate(false); +$base->multipleReturnTagsAndStatements()->publicBaseVoidMethod(); // test + +$exClass = new ExClass(); +echo PHP_EOL . "[\$exClass->test()]" . PHP_EOL; +$exClass->test(); + +echo PHP_EOL . "[\$exClass->publicBaseMethod()->publicExClassMethod()->multipleReturnStatements()->publicDelegateMethod()->publicDelegateMethod()]" . PHP_EOL; +$exClass->setDelegate(true); +$exClass->publicBaseMethod()->publicExMethod()->multipleReturnStatements()->publicDelegateMethod()->publicDelegateMethod(); // test + +echo PHP_EOL . "[\$exClass->publicExMethod()->publicBaseMethod()->multipleReturnStatements()->publicExMethod()->publicBaseMethod()]" . PHP_EOL; +$exClass->setDelegate(false); +$exClass->publicExMethod()->publicBaseMethod()->multipleReturnStatements()->publicExMethod()->publicBaseMethod(); + +// cannot run actually because it is not returned anything (only @return tag) +echo PHP_EOL . "[\$base->multipleReturnTags()->multipleReturnStatements()]" . PHP_EOL; +$base->multipleReturnTags()->multipleReturnStatements(); // test +$base->returnTagWithOldThis()->multipleReturnStatements(); // test +$exClass->multipleReturnTags()->multipleReturnStatements(); //test diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes.completion @@ -0,0 +1,13 @@ +Code completion result for source line: +$exClass->publicBaseMethod()->|publicExMethod()->multipleReturnStatements()->publicDelegateMethod()->publicDelegateMethod(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicExMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD publicExVoidMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD test() [PUBLIC] \Foo\Bar\Baz\ExClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_02.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_02.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_02.completion @@ -0,0 +1,14 @@ +Code completion result for source line: +$exClass->publicBaseMethod()->publicExMethod()->multipleReturnStatements()->|publicDelegateMethod()->publicDelegateMethod(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicDelegateMethod() [PUBLIC] \Foo\Bar\Baz\Delegate +METHOD publicExMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD publicExVoidMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD test() [PUBLIC] \Foo\Bar\Baz\ExClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_03.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_03.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_03.completion @@ -0,0 +1,4 @@ +Code completion result for source line: +$exClass->publicBaseMethod()->publicExMethod()->multipleReturnStatements()->publicDelegateMethod()->|publicDelegateMethod(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD publicDelegateMethod() [PUBLIC] \Foo\Bar\Baz\Delegate diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_04.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_04.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_04.completion @@ -0,0 +1,17 @@ +Code completion result for source line: +$this->multipleReturnStatements()->|privateExMethod()->multipleReturnStatements(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD privateExMethod() [PRIVATE] \Foo\Bar\Baz\ExClass +METHOD protectedBaseMethod() [PROTECTE \Foo\Bar\Baz\BaseClass +METHOD protectedExMethod() [PROTECTE \Foo\Bar\Baz\ExClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicDelegateMethod() [PUBLIC] \Foo\Bar\Baz\Delegate +METHOD publicExMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD publicExVoidMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD test() [PUBLIC] \Foo\Bar\Baz\ExClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_05.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_05.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_05.completion @@ -0,0 +1,17 @@ +Code completion result for source line: +$this->multipleReturnTagsAndStatements()->|publicDelegateMethod()->publicDelegateMethod(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD privateExMethod() [PRIVATE] \Foo\Bar\Baz\ExClass +METHOD protectedBaseMethod() [PROTECTE \Foo\Bar\Baz\BaseClass +METHOD protectedExMethod() [PROTECTE \Foo\Bar\Baz\ExClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicDelegateMethod() [PUBLIC] \Foo\Bar\Baz\Delegate +METHOD publicExMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD publicExVoidMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD test() [PUBLIC] \Foo\Bar\Baz\ExClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_06.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_06.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_06.completion @@ -0,0 +1,4 @@ +Code completion result for source line: +$this->multipleReturnTagsAndStatements()->publicDelegateMethod()->|publicDelegateMethod(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD publicDelegateMethod() [PUBLIC] \Foo\Bar\Baz\Delegate diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_07.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_07.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testCallerDependentTypes_07.completion @@ -0,0 +1,14 @@ +Code completion result for source line: +$exClass->multipleReturnTags()->|multipleReturnStatements(); //test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicDelegateMethod() [PUBLIC] \Foo\Bar\Baz\Delegate +METHOD publicExMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD publicExVoidMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD test() [PUBLIC] \Foo\Bar\Baz\ExClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testMethodInvocationReturnType.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testMethodInvocationReturnType.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testMethodInvocationReturnType.completion @@ -0,0 +1,16 @@ +Code completion result for source line: +$this->multipleReturnStatements()->privateExMethod()->|multipleReturnStatements(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD privateExMethod() [PRIVATE] \Foo\Bar\Baz\ExClass +METHOD protectedBaseMethod() [PROTECTE \Foo\Bar\Baz\BaseClass +METHOD protectedExMethod() [PROTECTE \Foo\Bar\Baz\ExClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicExMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD publicExVoidMethod() [PUBLIC] \Foo\Bar\Baz\ExClass +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD test() [PUBLIC] \Foo\Bar\Baz\ExClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testOnlyReturnStatements.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testOnlyReturnStatements.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testOnlyReturnStatements.completion @@ -0,0 +1,11 @@ +Code completion result for source line: +$base->publicBaseMethod()->multipleReturnStatements()->|publicDelegateMethod()->publicDelegateMethod(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicDelegateMethod() [PUBLIC] \Foo\Bar\Baz\Delegate +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testOnlyReturnTags.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testOnlyReturnTags.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testOnlyReturnTags.completion @@ -0,0 +1,11 @@ +Code completion result for source line: +$base->multipleReturnTags()->|multipleReturnStatements(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicDelegateMethod() [PUBLIC] \Foo\Bar\Baz\Delegate +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testReturnTagAndStatement.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testReturnTagAndStatement.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testReturnTagAndStatement.completion @@ -0,0 +1,10 @@ +Code completion result for source line: +$base->publicBaseMethod()->|multipleReturnStatements()->publicDelegateMethod()->publicDelegateMethod(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testReturnTagWithOldThis.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testReturnTagWithOldThis.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testReturnTagWithOldThis.completion @@ -0,0 +1,10 @@ +Code completion result for source line: +$base->returnTagWithOldThis()->|multipleReturnStatements(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass diff --git a/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testReturnTagsAndStatements.completion b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testReturnTagsAndStatements.completion new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/testfiles/completion/lib/tests239987/issue239987.php.testReturnTagsAndStatements.completion @@ -0,0 +1,11 @@ +Code completion result for source line: +$base->multipleReturnTagsAndStatements()->|publicBaseVoidMethod(); // test +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +METHOD multipleReturnStatements() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTags() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD multipleReturnTagsAndStatement [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicBaseVoidMethod() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD publicDelegateMethod() [PUBLIC] \Foo\Bar\Baz\Delegate +METHOD returnTagWithOldThis() [PUBLIC] \Foo\Bar\Baz\BaseClass +METHOD setDelegate($delegate) [PUBLIC] \Foo\Bar\Baz\BaseClass diff --git a/php.editor/test/unit/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGeneratorTest.java b/php.editor/test/unit/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGeneratorTest.java --- a/php.editor/test/unit/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGeneratorTest.java +++ b/php.editor/test/unit/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGeneratorTest.java @@ -203,7 +203,7 @@ "class Prdel {\n" + " /**\n" + " * \n" + - " * @return \\Prdel^\n" + + " * @return $this^\n" + " */\n" + " function functionName() {\n" + " return $this;\n" +