This is an automated email from the ASF dual-hosted git repository. jtulach 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 ab9c997 [NETBEANS-6218] An infinite loop may occur when parsing Groovy sources new 5486169 Merge pull request #3325 from ppisl/NETBEANS-6218 ab9c997 is described below commit ab9c9977595cecdbfaeb09d9a30bc8664fadada8 Author: Petr Pisl <petr.p...@oracle.com> AuthorDate: Thu Nov 18 18:51:40 2021 +0100 [NETBEANS-6218] An infinite loop may occur when parsing Groovy sources The fix and test. --- .../groovy/editor/compiler/CompilationUnit.java | 10 ++-- .../issueNETBEANS6218/my/pkg/MainClass.groovy | 10 ++++ ...ainClass.groovy.testCompletionInMain.completion | 5 ++ .../issueNETBEANS6218/my/pkg/app/ClassA.groovy | 10 ++++ ...ClassA.groovy.testCompletionInClassA.completion | 5 ++ .../issueNETBEANS6218/my/pkg/impl/ClassB.groovy | 9 ++++ ...ClassB.groovy.testCompletionInClassB.completion | 5 ++ .../editor/api/completion/IssueNETBEANS6218.java | 55 ++++++++++++++++++++++ 8 files changed, 102 insertions(+), 7 deletions(-) diff --git a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/compiler/CompilationUnit.java b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/compiler/CompilationUnit.java index dd91bf3..5e79a9c 100644 --- a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/compiler/CompilationUnit.java +++ b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/compiler/CompilationUnit.java @@ -127,10 +127,6 @@ public class CompilationUnit extends org.codehaus.groovy.control.CompilationUnit if (parser.isCancelled()) { throw new CancellationException(); } - - if (cache.isNonExistent(name)) { - return null; - } ClassNode classNode = cache.get(name); if (classNode != null) { @@ -152,9 +148,9 @@ public class CompilationUnit extends org.codehaus.groovy.control.CompilationUnit cache.put(name, classNode); return classNode; } - classNode = super.getClass(name); - if (classNode != null) { - return classNode; + + if (cache.isNonExistent(name)) { + return null; } // The following code is legacy and ClassNodes it creates are not fully populated with properties, fields and methods. diff --git a/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/MainClass.groovy b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/MainClass.groovy new file mode 100644 index 0000000..c5b3e60 --- /dev/null +++ b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/MainClass.groovy @@ -0,0 +1,10 @@ +package my.pkg + +import my.pkg.app.ClassA + +class MainClass { + static void main(String[] arg) { + ClassA.execute() + } +} + diff --git a/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/MainClass.groovy.testCompletionInMain.completion b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/MainClass.groovy.testCompletionInMain.completion new file mode 100644 index 0000000..a984707 --- /dev/null +++ b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/MainClass.groovy.testCompletionInMain.completion @@ -0,0 +1,5 @@ +Code completion result for source line: +ClassA.ex|ecute() +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +------------------------------------ +METHOD execute() [STATIC, void diff --git a/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/app/ClassA.groovy b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/app/ClassA.groovy new file mode 100644 index 0000000..cb6c6b1 --- /dev/null +++ b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/app/ClassA.groovy @@ -0,0 +1,10 @@ +package my.pkg.app + +import my.pkg.impl.ClassB + +class ClassA { + static void execute() { + ClassB.execute2(); + } +} + diff --git a/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/app/ClassA.groovy.testCompletionInClassA.completion b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/app/ClassA.groovy.testCompletionInClassA.completion new file mode 100644 index 0000000..8d80f72 --- /dev/null +++ b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/app/ClassA.groovy.testCompletionInClassA.completion @@ -0,0 +1,5 @@ +Code completion result for source line: +ClassB.ex|ecute2(); +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +------------------------------------ +METHOD execute2() [STATIC, void diff --git a/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/impl/ClassB.groovy b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/impl/ClassB.groovy new file mode 100644 index 0000000..19596f3 --- /dev/null +++ b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/impl/ClassB.groovy @@ -0,0 +1,9 @@ +package my.pkg.impl + +import my.pkg.app.ClassA + +class ClassB { + static void execute2() { + ClassA.execute(); + } +} diff --git a/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/impl/ClassB.groovy.testCompletionInClassB.completion b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/impl/ClassB.groovy.testCompletionInClassB.completion new file mode 100644 index 0000000..b35d993 --- /dev/null +++ b/groovy/groovy.editor/test/unit/data/testfiles/completion/issueNETBEANS6218/my/pkg/impl/ClassB.groovy.testCompletionInClassB.completion @@ -0,0 +1,5 @@ +Code completion result for source line: +ClassA.ex|ecute(); +(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) +------------------------------------ +METHOD execute() [STATIC, void diff --git a/groovy/groovy.editor/test/unit/src/org/netbeans/modules/groovy/editor/api/completion/IssueNETBEANS6218.java b/groovy/groovy.editor/test/unit/src/org/netbeans/modules/groovy/editor/api/completion/IssueNETBEANS6218.java new file mode 100644 index 0000000..e7f3936 --- /dev/null +++ b/groovy/groovy.editor/test/unit/src/org/netbeans/modules/groovy/editor/api/completion/IssueNETBEANS6218.java @@ -0,0 +1,55 @@ +/* + * 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.groovy.editor.api.completion; + +import java.util.Collections; +import java.util.Set; + +/** + * + * @author Petr Pisl + */ +public class IssueNETBEANS6218 extends GroovyCCTestBase { + + public IssueNETBEANS6218(String testName) { + super(testName); + } + + @Override + protected Set<String> additionalSourceClassPath() { + return Collections.singleton("/testfiles/completion/"+ getTestType()); + } + + @Override + protected String getTestType() { + return "issueNETBEANS6218"; + } + + public void testCompletionInMain() throws Exception { + checkCompletion(getBasicSourcePath() + "/my/pkg/MainClass.groovy", "ClassA.ex^ecute()", false); + } + + public void testCompletionInClassA() throws Exception { + checkCompletion(getBasicSourcePath() + "/my/pkg/app/ClassA.groovy", "ClassB.ex^", false); + } + + public void testCompletionInClassB() throws Exception { + checkCompletion(getBasicSourcePath() + "/my/pkg/impl/ClassB.groovy", "ClassA.ex^", false); + } +} --------------------------------------------------------------------- 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