You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ju...@apache.org on 2023/02/17 13:16:10 UTC
[netbeans] branch master updated: - Changed the way to parse an array type by analogy with other types. - Fixed broken tests. - Fixed issue #5375 - New tests for fixed issue have been added - Fixed broken UnusableTypesHintError
This is an automated email from the ASF dual-hosted git repository.
junichi11 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 267e706157 - Changed the way to parse an array type by analogy with other types. - Fixed broken tests. - Fixed issue #5375 - New tests for fixed issue have been added - Fixed broken UnusableTypesHintError
new e8425feafc Merge pull request #5475 from troizet/parsing_array_type
267e706157 is described below
commit 267e706157028cbb644a5b07b7b73ec302b79e03
Author: Alexey Borokhvostov <tr...@gmail.com>
AuthorDate: Sun Feb 12 13:00:36 2023 +0700
- Changed the way to parse an array type by analogy with other types.
- Fixed broken tests.
- Fixed issue #5375
- New tests for fixed issue have been added
- Fixed broken UnusableTypesHintError
---
.../modules/php/editor/parser/ASTPHP5Parser.java | 13 ++++++------
.../modules/php/editor/parser/ASTPHP5Symbols.java | 2 +-
.../verification/UnusableTypesHintError.java | 15 ++++++--------
.../parser/php74/arrowFunctions_01.pass | 8 ++++++--
.../parser/php74/typedPropertiesClass.pass | 8 ++++++--
.../parser/php74/typedPropertiesTrait.pass | 8 ++++++--
.../parser/php80/namedArguments_01.pass | 4 +++-
.../parser/php81/readonlyProperties_01.pass | 16 +++++++++++----
.../ASTPHP5ParserTest/parser/returnTypes_02.pass | 4 +++-
.../ASTPHP5ParserTest/parser/shortArrays_02.pass | 4 +++-
.../completion/documentation/issueGH5375.php | 23 ++++++++++++++++++++++
.../issueGH5375.php.testIssueGH5375_01.html | 11 +++++++++++
.../issueGH5375.php.testIssueGH5375_02.html | 10 ++++++++++
.../editor/completion/PHPCCDocumentationTest.java | 8 ++++++++
php/php.editor/tools/ASTPHP5Parser.cup | 5 ++---
15 files changed, 106 insertions(+), 33 deletions(-)
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java
index 9a904c96ca..cd9afd516b 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java
@@ -19,7 +19,7 @@
//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
-// Tue Jan 17 01:59:15 JST 2023
+// Wed Feb 08 23:05:51 NOVT 2023
//----------------------------------------------------
package org.netbeans.modules.php.editor.parser;
@@ -30,7 +30,7 @@ import org.netbeans.modules.php.editor.parser.astnodes.*;
import org.openide.util.Pair;
/** CUP v0.11a beta 20060608 generated parser.
- * @version Tue Jan 17 01:59:15 JST 2023
+ * @version Wed Feb 08 23:05:51 NOVT 2023
*/
@org.netbeans.api.annotations.common.SuppressWarnings({"EI_EXPOSE_REP", "MS_PKGPROTECT", "BC_BAD_CAST_TO_CONCRETE_COLLECTION"})
public class ASTPHP5Parser extends java_cup.runtime.lr_parser {
@@ -7685,12 +7685,11 @@ switch (CUP$ASTPHP5Parser$act_num) {
case 287: // class_type_without_static ::= T_ARRAY
{
Expression RESULT =null;
- int arrayleft = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).left;
- int arrayright = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).right;
- String array = (String)((java_cup.runtime.Symbol) CUP$ASTPHP5Parser$stack.peek()).value;
+ int nameleft = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).left;
+ int nameright = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).right;
+ String name = (String)((java_cup.runtime.Symbol) CUP$ASTPHP5Parser$stack.peek()).value;
- Identifier classId = new Identifier(arrayleft, arrayright, "array");
- RESULT = classId;
+ RESULT = NamespaceName.create(nameleft, nameright, name);
CUP$ASTPHP5Parser$result = parser.getSymbolFactory().newSymbol("class_type_without_static",163, ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), RESULT);
}
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Symbols.java b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Symbols.java
index 06e07b87f9..e7ef52d870 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Symbols.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Symbols.java
@@ -19,7 +19,7 @@
//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
-// Tue Jan 17 01:59:15 JST 2023
+// Wed Feb 08 23:05:51 NOVT 2023
//----------------------------------------------------
package org.netbeans.modules.php.editor.parser;
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/UnusableTypesHintError.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/UnusableTypesHintError.java
index f5b41d603a..b777a168d6 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/UnusableTypesHintError.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/UnusableTypesHintError.java
@@ -532,12 +532,10 @@ public class UnusableTypesHintError extends HintErrorRule {
if (hasIterable) {
for (Expression type : unionType.getTypes()) {
- if (type instanceof Identifier) {
- if (isArrayType((Identifier) type)) {
+ if (type instanceof NamespaceName) {
+ if (isArrayType((NamespaceName) type)) {
hasArray = true;
- }
- } else if (type instanceof NamespaceName) {
- if (isTraversableType((NamespaceName) type)) {
+ } else if (isTraversableType((NamespaceName) type)) {
NamespaceName name = (NamespaceName) type;
QualifiedName qualifiedName = QualifiedName.create(name);
NamespaceScope namespaceScope = ModelUtils.getNamespaceScope(model.getFileScope(), type.getStartOffset());
@@ -577,10 +575,9 @@ public class UnusableTypesHintError extends HintErrorRule {
hints.add(new IterableRedundantTypeCombination(rule, fileObject, unionType.getStartOffset(), unionType.getEndOffset(), unionType, redundantType));
}
- private static boolean isArrayType(Identifier identifier) {
- return !identifier.isKeyword()
- && Type.ARRAY.equals(identifier.getName().toLowerCase(Locale.ENGLISH));
- }
+ private static boolean isArrayType(NamespaceName namespaceName) {
+ return Type.ARRAY.equals(CodeUtils.extractUnqualifiedName(namespaceName));
+ }
private static boolean isCallableType(Identifier identifier) {
return !identifier.isKeyword()
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/arrowFunctions_01.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/arrowFunctions_01.pass
index ed975d9894..f0621107c3 100644
--- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/arrowFunctions_01.pass
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/arrowFunctions_01.pass
@@ -1365,7 +1365,9 @@
<ArrowFunctionDeclaration start='1002' end='1021' isReference='false' isStatic='false'>
<FormalParameter start='1006' end='1014' isMandatory='true' isVariadic='false'>
<ParametrType>
- <Identifier start='1006' end='1011' name='array'/>
+ <NamespaceName start='1006' end='1011' isCurrent='false' isGlobal='false'>
+ <Identifier start='1006' end='1011' name='array'/>
+ </NamespaceName>
</ParametrType>
<ParametrName>
<Variable start='1012' end='1014' isDollared='true'>
@@ -1395,7 +1397,9 @@
<FormalParameter start='1078' end='1087' isMandatory='true' isVariadic='false'>
<ParametrType>
<NullableType start='1078' end='1084'>
- <Identifier start='1079' end='1084' name='array'/>
+ <NamespaceName start='1079' end='1084' isCurrent='false' isGlobal='false'>
+ <Identifier start='1079' end='1084' name='array'/>
+ </NamespaceName>
</NullableType>
</ParametrType>
<ParametrName>
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesClass.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesClass.pass
index 2600b4bf19..999bfb486c 100644
--- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesClass.pass
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesClass.pass
@@ -535,7 +535,9 @@
</FieldsDeclaration>
<FieldsDeclaration start='980' end='1001' modifier='private'>
<FieldType>
- <Identifier start='988' end='993' name='array'/>
+ <NamespaceName start='988' end='993' isCurrent='false' isGlobal='false'>
+ <Identifier start='988' end='993' name='array'/>
+ </NamespaceName>
</FieldType>
<VariableNames>
<Variable start='994' end='1000' isDollared='true'>
@@ -709,7 +711,9 @@
</FieldsDeclaration>
<FieldsDeclaration start='1426' end='1472' modifier='private static'>
<FieldType>
- <Identifier start='1441' end='1446' name='array'/>
+ <NamespaceName start='1441' end='1446' isCurrent='false' isGlobal='false'>
+ <Identifier start='1441' end='1446' name='array'/>
+ </NamespaceName>
</FieldType>
<VariableNames>
<Variable start='1447' end='1459' isDollared='true'>
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesTrait.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesTrait.pass
index 77159e54ee..e95897cae9 100644
--- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesTrait.pass
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesTrait.pass
@@ -531,7 +531,9 @@
</FieldsDeclaration>
<FieldsDeclaration start='980' end='1001' modifier='private'>
<FieldType>
- <Identifier start='988' end='993' name='array'/>
+ <NamespaceName start='988' end='993' isCurrent='false' isGlobal='false'>
+ <Identifier start='988' end='993' name='array'/>
+ </NamespaceName>
</FieldType>
<VariableNames>
<Variable start='994' end='1000' isDollared='true'>
@@ -705,7 +707,9 @@
</FieldsDeclaration>
<FieldsDeclaration start='1426' end='1472' modifier='private static'>
<FieldType>
- <Identifier start='1441' end='1446' name='array'/>
+ <NamespaceName start='1441' end='1446' isCurrent='false' isGlobal='false'>
+ <Identifier start='1441' end='1446' name='array'/>
+ </NamespaceName>
</FieldType>
<VariableNames>
<Variable start='1447' end='1459' isDollared='true'>
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php80/namedArguments_01.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php80/namedArguments_01.pass
index ffa19fcef1..3706727693 100644
--- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php80/namedArguments_01.pass
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php80/namedArguments_01.pass
@@ -1332,7 +1332,9 @@
<NamespaceName start='1873' end='1876' isCurrent='false' isGlobal='false'>
<Identifier start='1873' end='1876' name='int'/>
</NamespaceName>
- <Identifier start='1877' end='1882' name='array'/>
+ <NamespaceName start='1877' end='1882' isCurrent='false' isGlobal='false'>
+ <Identifier start='1877' end='1882' name='array'/>
+ </NamespaceName>
</UnionType>
</ParametrType>
<ParametrName>
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/readonlyProperties_01.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/readonlyProperties_01.pass
index 42167c4f01..9dc5e6f332 100644
--- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/readonlyProperties_01.pass
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/readonlyProperties_01.pass
@@ -822,7 +822,9 @@
</FormalParameter>
<FormalParameter start='1388' end='1440' modifier='private readonly' isMandatory='false' isVariadic='false'>
<ParametrType>
- <Identifier start='1405' end='1410' name='array'/>
+ <NamespaceName start='1405' end='1410' isCurrent='false' isGlobal='false'>
+ <Identifier start='1405' end='1410' name='array'/>
+ </NamespaceName>
</ParametrType>
<ParametrName>
<Variable start='1411' end='1435' isDollared='true'>
@@ -868,7 +870,9 @@
</FormalParameter>
<FormalParameter start='1579' end='1631' modifier='private readonly' isMandatory='false' isVariadic='false'>
<ParametrType>
- <Identifier start='1596' end='1601' name='array'/>
+ <NamespaceName start='1596' end='1601' isCurrent='false' isGlobal='false'>
+ <Identifier start='1596' end='1601' name='array'/>
+ </NamespaceName>
</ParametrType>
<ParametrName>
<Variable start='1602' end='1626' isDollared='true'>
@@ -1062,7 +1066,9 @@
</FormalParameter>
<FormalParameter start='2342' end='2394' modifier='private readonly' isMandatory='false' isVariadic='false'>
<ParametrType>
- <Identifier start='2359' end='2364' name='array'/>
+ <NamespaceName start='2359' end='2364' isCurrent='false' isGlobal='false'>
+ <Identifier start='2359' end='2364' name='array'/>
+ </NamespaceName>
</ParametrType>
<ParametrName>
<Variable start='2365' end='2389' isDollared='true'>
@@ -1108,7 +1114,9 @@
</FormalParameter>
<FormalParameter start='2533' end='2585' modifier='private readonly' isMandatory='false' isVariadic='false'>
<ParametrType>
- <Identifier start='2550' end='2555' name='array'/>
+ <NamespaceName start='2550' end='2555' isCurrent='false' isGlobal='false'>
+ <Identifier start='2550' end='2555' name='array'/>
+ </NamespaceName>
</ParametrType>
<ParametrName>
<Variable start='2556' end='2580' isDollared='true'>
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/returnTypes_02.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/returnTypes_02.pass
index 44dd8cec35..77a1e48e6e 100644
--- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/returnTypes_02.pass
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/returnTypes_02.pass
@@ -36,7 +36,9 @@
<Identifier start='16' end='19' name='foo'/>
<FormalParameters>
</FormalParameters>
- <Identifier start='23' end='28' name='array'/>
+ <NamespaceName start='23' end='28' isCurrent='false' isGlobal='false'>
+ <Identifier start='23' end='28' name='array'/>
+ </NamespaceName>
<Block start='29' end='32' isCurly='true'>
</Block>
</FunctionDeclaration>
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/shortArrays_02.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/shortArrays_02.pass
index c2a14d4684..1aedd7f3b5 100644
--- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/shortArrays_02.pass
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/shortArrays_02.pass
@@ -88,7 +88,9 @@
<FormalParameters>
<FormalParameter start='38' end='48' isMandatory='true' isVariadic='false'>
<ParametrType>
- <Identifier start='38' end='43' name='array'/>
+ <NamespaceName start='38' end='43' isCurrent='false' isGlobal='false'>
+ <Identifier start='38' end='43' name='array'/>
+ </NamespaceName>
</ParametrType>
<ParametrName>
<Variable start='44' end='48' isDollared='true'>
diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5375.php b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5375.php
new file mode 100644
index 0000000000..e74bd45bb6
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5375.php
@@ -0,0 +1,23 @@
+<?php
+
+class ClassName {
+
+ /**
+ * This text should be displayed here.
+ */
+ public array $test_without_var_tag;
+
+ /**
+ * This text should be displayed here.
+ * @var array
+ */
+ public array $test_with_var_tag;
+
+ public function test() {
+ $this->test_without_var_tag;
+ $this->test_with_var_tag;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5375.php.testIssueGH5375_01.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5375.php.testIssueGH5375_01.html
new file mode 100644
index 0000000000..9bfef00e59
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5375.php.testIssueGH5375_01.html
@@ -0,0 +1,11 @@
+<html><body>
+<pre>Code completion result for source line:
+$this->test_without_v|ar_tag;
+(QueryType=COMPLETION, prefixSearch=false, caseSensitive=true)
+VARIABLE array test_without_var_tag [PUBLIC] ClassName
+</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>$test_without_var_tag</b><br/><br/>
+This text should be displayed here.
+<br />
+<table>
+<tr><th align="left">Type:</th><td>array</td></tr></table>
+</body></html>
\ No newline at end of file
diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5375.php.testIssueGH5375_02.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5375.php.testIssueGH5375_02.html
new file mode 100644
index 0000000000..dc737f4d92
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/issueGH5375.php.testIssueGH5375_02.html
@@ -0,0 +1,10 @@
+<html><body>
+<pre>Code completion result for source line:
+$this->test_with_v|ar_tag;
+(QueryType=COMPLETION, prefixSearch=false, caseSensitive=true)
+VARIABLE array test_with_var_tag [PUBLIC] ClassName
+</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>$test_with_var_tag</b><br/><br/>
+This text should be displayed here.<br />
+<table>
+<tr><th align="left">Type:</th><td>array</td></tr></table>
+</body></html>
\ No newline at end of file
diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java
index 2d7675ada1..d00a80f955 100644
--- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java
+++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java
@@ -275,6 +275,14 @@ public class PHPCCDocumentationTest extends PHPCodeCompletionTestBase {
checkCompletionDocumentation("testfiles/completion/documentation/issueGH5427.php", "$this->test_with_v^ar_tag", false, "");
}
+ public void testIssueGH5375_01() throws Exception {
+ checkCompletionDocumentation("testfiles/completion/documentation/issueGH5375.php", "$this->test_without_v^ar_tag", false, "");
+ }
+
+ public void testIssueGH5375_02() throws Exception {
+ checkCompletionDocumentation("testfiles/completion/documentation/issueGH5375.php", "$this->test_with_v^ar_tag", false, "");
+ }
+
@Override
protected String alterDocumentationForTest(String documentation) {
int start = documentation.indexOf("file:");
diff --git a/php/php.editor/tools/ASTPHP5Parser.cup b/php/php.editor/tools/ASTPHP5Parser.cup
index f76b5ccf8a..999549a191 100644
--- a/php/php.editor/tools/ASTPHP5Parser.cup
+++ b/php/php.editor/tools/ASTPHP5Parser.cup
@@ -2625,10 +2625,9 @@ fully_qualified_class_name:className
RESULT = className;
:}
-| T_ARRAY:array
+| T_ARRAY:name
{:
- Identifier classId = new Identifier(arrayleft, arrayright, "array");
- RESULT = classId;
+ RESULT = NamespaceName.create(nameleft, nameright, name);
:}
| T_CALLABLE:callable
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists