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 3f73d67 [NETBEANS-3108] PHP: Some features(e.g. Go to declaration) do
not work after "new"
new 5a97c54 Merge pull request #1516 from
junichi11/netbeans-3108-gotodeclaration-after-new
3f73d67 is described below
commit 3f73d6746bd326ea1e6c93e75484940c013067a8
Author: Junichi Yamamoto <[email protected]>
AuthorDate: Wed Sep 18 22:20:15 2019 +0900
[NETBEANS-3108] PHP: Some features(e.g. Go to declaration) do not work
after "new"
---
.../php/editor/model/impl/ModelVisitor.java | 4 +-
.../gotodeclaration/testNb3108/testNb3108.php | 37 ++++++++++++++
.../markoccurences/testNb3108/testNb3108.php | 37 ++++++++++++++
.../testNb3108.php.testNb3108_01a.occurrences | 2 +
.../testNb3108.php.testNb3108_01b.occurrences | 2 +
.../testNb3108.php.testNb3108_02a.occurrences | 2 +
.../testNb3108.php.testNb3108_02b.occurrences | 2 +
.../testNb3108.php.testNb3108_03a.occurrences | 3 ++
.../testNb3108.php.testNb3108_03b.occurrences | 3 ++
.../testNb3108.php.testNb3108_03c.occurrences | 2 +
.../php/editor/csl/GotoDeclarationNb3108Test.java | 43 +++++++++++++++++
.../csl/OccurrencesFinderImplNb3108Test.java | 56 ++++++++++++++++++++++
12 files changed, 192 insertions(+), 1 deletion(-)
diff --git
a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelVisitor.java
b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelVisitor.java
index c9e38ae..ae278d4 100644
---
a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelVisitor.java
+++
b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelVisitor.java
@@ -575,7 +575,9 @@ public final class ModelVisitor extends
DefaultTreePathVisitor {
}
} else {
Expression name = node.getClassName().getName();
- if (name instanceof Variable) {
+ if (name instanceof Variable
+ || name instanceof StaticFieldAccess // NETBEANS-3108 e.g.
new self::staticProperty[self::getIndex()];
+ || name instanceof FieldAccess) { // NETBEANS-3108 e.g.
new $this->property[$this->getIndex()];
scan(name);
} else {
ScopeImpl currentScope = modelBuilder.getCurrentScope();
diff --git
a/php/php.editor/test/unit/data/testfiles/gotodeclaration/testNb3108/testNb3108.php
b/php/php.editor/test/unit/data/testfiles/gotodeclaration/testNb3108/testNb3108.php
new file mode 100644
index 0000000..2e3be7f
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/gotodeclaration/testNb3108/testNb3108.php
@@ -0,0 +1,37 @@
+<?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.
+ */
+class Class3108 {
+
+ private $property = [
+ Class3108::class,
+ ];
+ private static $staticProperty = [
+ Class3108::class,
+ ];
+
+ private static function getIndex() {
+ return 0;
+ }
+
+ public static function test() {
+ $instance1 = new self::$staticProperty[self::getIndex()];
+ $instance2 = new $this->property[$this->getIndex()];
+ }
+}
diff --git
a/php/php.editor/test/unit/data/testfiles/markoccurences/testNb3108/testNb3108.php
b/php/php.editor/test/unit/data/testfiles/markoccurences/testNb3108/testNb3108.php
new file mode 100644
index 0000000..2e3be7f
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/markoccurences/testNb3108/testNb3108.php
@@ -0,0 +1,37 @@
+<?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.
+ */
+class Class3108 {
+
+ private $property = [
+ Class3108::class,
+ ];
+ private static $staticProperty = [
+ Class3108::class,
+ ];
+
+ private static function getIndex() {
+ return 0;
+ }
+
+ public static function test() {
+ $instance1 = new self::$staticProperty[self::getIndex()];
+ $instance2 = new $this->property[$this->getIndex()];
+ }
+}
diff --git
a/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_01a.occurrences
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_01a.occurrences
new file mode 100644
index 0000000..eefcb80
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_01a.occurrences
@@ -0,0 +1,2 @@
+ private $|>MARK_OCCURRENCES:pro^perty<| = [
+ $instance2 = new
$this->|>MARK_OCCURRENCES:property<|[$this->getIndex()];
diff --git
a/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_01b.occurrences
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_01b.occurrences
new file mode 100644
index 0000000..591ea3c
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_01b.occurrences
@@ -0,0 +1,2 @@
+ private $|>MARK_OCCURRENCES:property<| = [
+ $instance2 = new
$this->|>MARK_OCCURRENCES:pr^operty<|[$this->getIndex()];
diff --git
a/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_02a.occurrences
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_02a.occurrences
new file mode 100644
index 0000000..54ba4dd
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_02a.occurrences
@@ -0,0 +1,2 @@
+ private static $^|>MARK_OCCURRENCES:staticProperty<| = [
+ $instance1 = new
self::$|>MARK_OCCURRENCES:staticProperty<|[self::getIndex()];
diff --git
a/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_02b.occurrences
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_02b.occurrences
new file mode 100644
index 0000000..466e2a1
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_02b.occurrences
@@ -0,0 +1,2 @@
+ private static $|>MARK_OCCURRENCES:staticProperty<| = [
+ $instance1 = new
self::$|>MARK_OCCURRENCES:stati^cProperty<|[self::getIndex()];
diff --git
a/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_03a.occurrences
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_03a.occurrences
new file mode 100644
index 0000000..035f2cf
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_03a.occurrences
@@ -0,0 +1,3 @@
+ private static function |>MARK_OCCURRENCES:ge^tIndex<|() {
+ $instance1 = new
self::$staticProperty[self::|>MARK_OCCURRENCES:getIndex<|()];
+ $instance2 = new
$this->property[$this->|>MARK_OCCURRENCES:getIndex<|()];
diff --git
a/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_03b.occurrences
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_03b.occurrences
new file mode 100644
index 0000000..0f8211f
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_03b.occurrences
@@ -0,0 +1,3 @@
+ private static function |>MARK_OCCURRENCES:getIndex<|() {
+ $instance1 = new
self::$staticProperty[self::|>MARK_OCCURRENCES:get^Index<|()];
+ $instance2 = new
$this->property[$this->|>MARK_OCCURRENCES:getIndex<|()];
diff --git
a/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_03c.occurrences
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_03c.occurrences
new file mode 100644
index 0000000..9d3a227
--- /dev/null
+++
b/php/php.editor/test/unit/data/testfiles/testNb3108.php.testNb3108_03c.occurrences
@@ -0,0 +1,2 @@
+ private static function |>MARK_OCCURRENCES:getIndex<|() {
+ $instance2 = new
$this->property[$this->|>MARK_OCCURRENCES:getI^ndex<|()];
diff --git
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/GotoDeclarationNb3108Test.java
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/GotoDeclarationNb3108Test.java
new file mode 100644
index 0000000..eedd97d
--- /dev/null
+++
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/GotoDeclarationNb3108Test.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 GotoDeclarationNb3108Test extends GotoDeclarationTestBase {
+
+ public GotoDeclarationNb3108Test(String testName) {
+ super(testName);
+ }
+
+ public void testNb3108_01() throws Exception {
+ checkDeclaration(getTestPath(), " $instance1 = new
self::$static^Property[self::getIndex()];", " private static
$^staticProperty = [");
+ }
+
+ public void testNb3108_02() throws Exception {
+ checkDeclaration(getTestPath(), " $instance2 = new
$this->pr^operty[$this->getIndex()];", " private $^property = [");
+ }
+
+ public void testNb3108_03a() throws Exception {
+ checkDeclaration(getTestPath(), " $instance1 = new
self::$staticProperty[self::getIn^dex()];", " private static function
^getIndex() {");
+ }
+
+ public void testNb3108_03b() throws Exception {
+ checkDeclaration(getTestPath(), " $instance2 = new
$this->property[$this->g^etIndex()];", " private static function ^getIndex()
{");
+ }
+}
diff --git
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/OccurrencesFinderImplNb3108Test.java
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/OccurrencesFinderImplNb3108Test.java
new file mode 100644
index 0000000..fc95573
--- /dev/null
+++
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/OccurrencesFinderImplNb3108Test.java
@@ -0,0 +1,56 @@
+/*
+ * 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 OccurrencesFinderImplNb3108Test extends
OccurrencesFinderImplTestBase {
+
+ public OccurrencesFinderImplNb3108Test(String testName) {
+ super(testName);
+ }
+
+ public void testNb3108_01a() throws Exception {
+ checkOccurrences(getTestPath(), " private $pro^perty = [", true);
+ }
+
+ public void testNb3108_01b() throws Exception {
+ checkOccurrences(getTestPath(), " $instance2 = new
$this->pr^operty[$this->getIndex()];", true);
+ }
+
+ public void testNb3108_02a() throws Exception {
+ checkOccurrences(getTestPath(), " private static $^staticProperty =
[", true);
+ }
+
+ public void testNb3108_02b() throws Exception {
+ checkOccurrences(getTestPath(), " $instance1 = new
self::$stati^cProperty[self::getIndex()];", true);
+ }
+
+ public void testNb3108_03a() throws Exception {
+ checkOccurrences(getTestPath(), " private static function
ge^tIndex() {", true);
+ }
+
+ public void testNb3108_03b() throws Exception {
+ checkOccurrences(getTestPath(), " $instance1 = new
self::$staticProperty[self::get^Index()];", true);
+ }
+
+ public void testNb3108_03c() throws Exception {
+ checkOccurrences(getTestPath(), " $instance2 = new
$this->property[$this->getI^ndex()];", true);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists