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 53a462c  [NETBEANS-5849] Fix CC in a use declaration after a group use 
declaration
     new 500e70b  Merge pull request #3111 from 
junichi11/netbeans-5849-cc-for-use
53a462c is described below

commit 53a462c7025d7de1a627ddd5e7e69453f7114a07
Author: Junichi Yamamoto <junich...@apache.org>
AuthorDate: Tue Aug 17 20:30:07 2021 +0900

    [NETBEANS-5849] Fix CC in a use declaration after a group use declaration
    
    https://issues.apache.org/jira/browse/NETBEANS-5849
    
    Before
    ```php
    
    use NS1\{
        Test1,
        Test2
    };
    use tes; // context: GROUP_USE_KEYWORD
    
    ```
    
    After
    ```php
    
    use NS1\{
        Test1,
        Test2
    };
    use tes; // context: USE_KEYWORD
    
    ```
---
 .../editor/completion/CompletionContextFinder.java |  4 ++
 .../testfiles/completion/lib/nb5849/NS1/Test1.php  | 22 ++++++++++
 .../testfiles/completion/lib/nb5849/NS1/Test2.php  | 22 ++++++++++
 .../testfiles/completion/lib/nb5849/NS2/Test3.php  | 22 ++++++++++
 .../testfiles/completion/lib/nb5849/nb5849.php     | 25 +++++++++++
 .../lib/nb5849/nb5849.php.testNb5849_01.completion |  7 +++
 .../completion/PHPCodeCompletionNb5849Test.java    | 50 ++++++++++++++++++++++
 7 files changed, 152 insertions(+)

diff --git 
a/php/php.editor/src/org/netbeans/modules/php/editor/completion/CompletionContextFinder.java
 
b/php/php.editor/src/org/netbeans/modules/php/editor/completion/CompletionContextFinder.java
index bfcdf0b..405bb65 100644
--- 
a/php/php.editor/src/org/netbeans/modules/php/editor/completion/CompletionContextFinder.java
+++ 
b/php/php.editor/src/org/netbeans/modules/php/editor/completion/CompletionContextFinder.java
@@ -600,6 +600,10 @@ final class CompletionContextFinder {
 
         boolean hasCurlyOpen = false;
         do {
+            // NETBEANS-5849
+            if (tokenSequence.token().id() == PHPTokenId.PHP_USE) {
+                return false;
+            }
             if (tokenSequence.token().id() == PHPTokenId.PHP_CURLY_OPEN) {
                 hasCurlyOpen = true;
             }
diff --git 
a/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/NS1/Test1.php 
b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/NS1/Test1.php
new file mode 100644
index 0000000..3599ba7
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/NS1/Test1.php
@@ -0,0 +1,22 @@
+<?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.
+ */
+namespace NS1;
+
+class Test1{}
diff --git 
a/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/NS1/Test2.php 
b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/NS1/Test2.php
new file mode 100644
index 0000000..ace337f
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/NS1/Test2.php
@@ -0,0 +1,22 @@
+<?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.
+ */
+namespace NS1;
+
+class Test2{}
diff --git 
a/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/NS2/Test3.php 
b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/NS2/Test3.php
new file mode 100644
index 0000000..0c18f3c
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/NS2/Test3.php
@@ -0,0 +1,22 @@
+<?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.
+ */
+namespace NS2;
+
+class Test3{}
diff --git 
a/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/nb5849.php 
b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/nb5849.php
new file mode 100644
index 0000000..d9ad106
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/nb5849.php
@@ -0,0 +1,25 @@
+<?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.
+ */
+
+use NS1\{
+    Test1,
+    Test2
+};
+use tes;
diff --git 
a/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/nb5849.php.testNb5849_01.completion
 
b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/nb5849.php.testNb5849_01.completion
new file mode 100644
index 0000000..e7f1719
--- /dev/null
+++ 
b/php/php.editor/test/unit/data/testfiles/completion/lib/nb5849/nb5849.php.testNb5849_01.completion
@@ -0,0 +1,7 @@
+Code completion result for source line:
+use tes|;
+(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true)
+------------------------------------
+CLASS      Test1                           [PUBLIC]   NS1
+CLASS      Test2                           [PUBLIC]   NS1
+CLASS      Test3                           [PUBLIC]   NS2
diff --git 
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionNb5849Test.java
 
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionNb5849Test.java
new file mode 100644
index 0000000..bd935ef
--- /dev/null
+++ 
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionNb5849Test.java
@@ -0,0 +1,50 @@
+/*
+ * 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.completion;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Map;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.modules.php.project.api.PhpSourcePath;
+import org.netbeans.spi.java.classpath.support.ClassPathSupport;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+
+public class PHPCodeCompletionNb5849Test extends PHPCodeCompletionTestBase {
+
+    public PHPCodeCompletionNb5849Test(String testName) {
+        super(testName);
+    }
+
+    public void testNb5849_01() throws Exception {
+        checkCompletion("testfiles/completion/lib/nb5849/nb5849.php", "use 
tes^;", false);
+    }
+
+    @Override
+    protected Map<String, ClassPath> createClassPathsForTest() {
+        return Collections.singletonMap(
+            PhpSourcePath.SOURCE_CP,
+            ClassPathSupport.createClassPath(new FileObject[] {
+                FileUtil.toFileObject(new File(getDataDir(), 
"/testfiles/completion/lib/nb5849"))
+            })
+        );
+    }
+}

---------------------------------------------------------------------
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