This is an automated email from the ASF dual-hosted git repository.

tmysik 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 83abd45982 Fix GotoDeclaration feature for `instanceof` interface #5371
     new 2b37e4c824 Merge pull request #5684 from 
junichi11/php-gh-5371-goto-instanceof-interface
83abd45982 is described below

commit 83abd45982bb3861ef148b51e0483df875547ec8
Author: Junichi Yamamoto <junich...@apache.org>
AuthorDate: Mon Mar 20 09:02:34 2023 +0900

    Fix GotoDeclaration feature for `instanceof` interface #5371
    
    - https://github.com/apache/netbeans/issues/5371
    - Also check interfaces
---
 .../php/editor/model/impl/OccurenceBuilder.java    |  2 +-
 .../testIssueGH5371/testIssueGH5371.php            | 42 ++++++++++++++++++
 .../testIssueGH5371/testIssueGH5371.php            | 42 ++++++++++++++++++
 ...IssueGH5371.php.testIssueGH5371_01a.occurrences |  3 ++
 ...IssueGH5371.php.testIssueGH5371_01b.occurrences |  3 ++
 ...IssueGH5371.php.testIssueGH5371_01c.occurrences |  3 ++
 ...IssueGH5371.php.testIssueGH5371_02a.occurrences |  3 ++
 ...IssueGH5371.php.testIssueGH5371_02b.occurrences |  3 ++
 ...IssueGH5371.php.testIssueGH5371_02c.occurrences |  3 ++
 .../php/editor/csl/GotoDeclarationGH5371Test.java  | 43 ++++++++++++++++++
 .../csl/OccurrencesFinderImplGH5371Test.java       | 51 ++++++++++++++++++++++
 11 files changed, 197 insertions(+), 1 deletion(-)

diff --git 
a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/OccurenceBuilder.java
 
b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/OccurenceBuilder.java
index dde98e49a9..f971b45c14 100644
--- 
a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/OccurenceBuilder.java
+++ 
b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/OccurenceBuilder.java
@@ -296,7 +296,7 @@ class OccurenceBuilder {
     }
 
     void prepare(final NamespaceName namespaceName, final Scope scope) {
-        Kind[] kinds = {Kind.CLASS, Kind.ENUM};
+        Kind[] kinds = {Kind.CLASS, Kind.IFACE, Kind.ENUM};
         prepare(kinds, namespaceName, scope);
     }
 
diff --git 
a/php/php.editor/test/unit/data/testfiles/gotodeclaration/testIssueGH5371/testIssueGH5371.php
 
b/php/php.editor/test/unit/data/testfiles/gotodeclaration/testIssueGH5371/testIssueGH5371.php
new file mode 100644
index 0000000000..37b678873d
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/gotodeclaration/testIssueGH5371/testIssueGH5371.php
@@ -0,0 +1,42 @@
+<?php
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+interface TestInterface {
+    public function test();
+}
+
+class TestClass implements TestInterface {
+
+    public function test() {
+        echo 1;
+    }
+
+}
+
+$a = new TestClass();
+
+if ($a instanceof TestClass) {
+    $a->test();
+}
+
+if ($a instanceof TestInterface) {
+    $a->test();
+}
diff --git 
a/php/php.editor/test/unit/data/testfiles/markoccurences/testIssueGH5371/testIssueGH5371.php
 
b/php/php.editor/test/unit/data/testfiles/markoccurences/testIssueGH5371/testIssueGH5371.php
new file mode 100644
index 0000000000..37b678873d
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/markoccurences/testIssueGH5371/testIssueGH5371.php
@@ -0,0 +1,42 @@
+<?php
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+interface TestInterface {
+    public function test();
+}
+
+class TestClass implements TestInterface {
+
+    public function test() {
+        echo 1;
+    }
+
+}
+
+$a = new TestClass();
+
+if ($a instanceof TestClass) {
+    $a->test();
+}
+
+if ($a instanceof TestInterface) {
+    $a->test();
+}
diff --git 
a/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_01a.occurrences
 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_01a.occurrences
new file mode 100644
index 0000000000..f76f8bcd0c
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_01a.occurrences
@@ -0,0 +1,3 @@
+interface |>MARK_OCCURRENCES:TestInterfa^ce<| {
+class TestClass implements |>MARK_OCCURRENCES:TestInterface<| {
+if ($a instanceof |>MARK_OCCURRENCES:TestInterface<|) {
diff --git 
a/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_01b.occurrences
 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_01b.occurrences
new file mode 100644
index 0000000000..a9bd279054
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_01b.occurrences
@@ -0,0 +1,3 @@
+interface |>MARK_OCCURRENCES:TestInterface<| {
+class TestClass implements |>MARK_OCCURRENCES:TestInt^erface<| {
+if ($a instanceof |>MARK_OCCURRENCES:TestInterface<|) {
diff --git 
a/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_01c.occurrences
 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_01c.occurrences
new file mode 100644
index 0000000000..3abe36b148
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_01c.occurrences
@@ -0,0 +1,3 @@
+interface |>MARK_OCCURRENCES:TestInterface<| {
+class TestClass implements |>MARK_OCCURRENCES:TestInterface<| {
+if ($a instanceof |>MARK_OCCURRENCES:TestInt^erface<|) {
diff --git 
a/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_02a.occurrences
 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_02a.occurrences
new file mode 100644
index 0000000000..fdecefc9b5
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_02a.occurrences
@@ -0,0 +1,3 @@
+class |>MARK_OCCURRENCES:Tes^tClass<| implements TestInterface {
+$a = new |>MARK_OCCURRENCES:TestClass<|();
+if ($a instanceof |>MARK_OCCURRENCES:TestClass<|) {
diff --git 
a/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_02b.occurrences
 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_02b.occurrences
new file mode 100644
index 0000000000..3ef6b5e13b
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_02b.occurrences
@@ -0,0 +1,3 @@
+class |>MARK_OCCURRENCES:TestClass<| implements TestInterface {
+$a = new |>MARK_OCCURRENCES:TestCla^ss<|();
+if ($a instanceof |>MARK_OCCURRENCES:TestClass<|) {
diff --git 
a/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_02c.occurrences
 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_02c.occurrences
new file mode 100644
index 0000000000..3d34689209
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/testIssueGH5371.php.testIssueGH5371_02c.occurrences
@@ -0,0 +1,3 @@
+class |>MARK_OCCURRENCES:TestClass<| implements TestInterface {
+$a = new |>MARK_OCCURRENCES:TestClass<|();
+if ($a instanceof |>MARK_OCCURRENCES:TestC^lass<|) {
diff --git 
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/GotoDeclarationGH5371Test.java
 
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/GotoDeclarationGH5371Test.java
new file mode 100644
index 0000000000..0efa7c40fb
--- /dev/null
+++ 
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/GotoDeclarationGH5371Test.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.php.editor.csl;
+
+public class GotoDeclarationGH5371Test extends GotoDeclarationTestBase {
+
+    public GotoDeclarationGH5371Test(String testName) {
+        super(testName);
+    }
+
+    public void testIssueGH5371_01a() throws Exception {
+        checkDeclaration(getTestPath(), "class TestClass implements 
TestI^nterface {", "interface ^TestInterface {");
+    }
+
+    public void testIssueGH5371_01b() throws Exception {
+        checkDeclaration(getTestPath(), "if ($a instanceof TestInt^erface) {", 
"interface ^TestInterface {");
+    }
+
+    public void testIssueGH5371_02a() throws Exception {
+        checkDeclaration(getTestPath(), "$a = new TestCla^ss();", "class 
^TestClass implements TestInterface {");
+    }
+
+    public void testIssueGH5371_02b() throws Exception {
+        checkDeclaration(getTestPath(), "if ($a instanceof Tes^tClass) {", 
"class ^TestClass implements TestInterface {");
+    }
+
+}
diff --git 
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/OccurrencesFinderImplGH5371Test.java
 
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/OccurrencesFinderImplGH5371Test.java
new file mode 100644
index 0000000000..3cc22fb117
--- /dev/null
+++ 
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/OccurrencesFinderImplGH5371Test.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.php.editor.csl;
+
+public class OccurrencesFinderImplGH5371Test extends 
OccurrencesFinderImplTestBase {
+
+    public OccurrencesFinderImplGH5371Test(String testName) {
+        super(testName);
+    }
+
+    public void testIssueGH5371_01a() throws Exception {
+        checkOccurrences(getTestPath(), "interface TestInterfa^ce {", true);
+    }
+
+    public void testIssueGH5371_01b() throws Exception {
+        checkOccurrences(getTestPath(), "class TestClass implements 
TestInt^erface {", true);
+    }
+
+    public void testIssueGH5371_01c() throws Exception {
+        checkOccurrences(getTestPath(), "if ($a instanceof TestInt^erface) {", 
true);
+    }
+
+    public void testIssueGH5371_02a() throws Exception {
+        checkOccurrences(getTestPath(), "class Tes^tClass implements 
TestInterface {", true);
+    }
+
+    public void testIssueGH5371_02b() throws Exception {
+        checkOccurrences(getTestPath(), "$a = new TestCla^ss();", true);
+    }
+
+    public void testIssueGH5371_02c() throws Exception {
+        checkOccurrences(getTestPath(), "if ($a instanceof TestC^lass) {", 
true);
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to