This is an automated email from the ASF dual-hosted git repository.
skygo pushed a commit to branch delivery
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/delivery by this push:
new b40953b Get elements resolved before working with types.
new 8886ee9 Merge pull request #3139 from sdedic/bugfix/javacompiler-phase
b40953b is described below
commit b40953bfee2904b47d09933cbc68a730ec2cbfd5
Author: Svata Dedic <[email protected]>
AuthorDate: Tue Aug 31 14:48:19 2021 +0200
Get elements resolved before working with types.
---
.../org/netbeans/modules/groovy/editor/compiler/CompilationUnit.java | 1 +
.../netbeans/modules/groovy/editor/completion/MethodCompletion.java | 4 ++--
.../netbeans/modules/groovy/editor/completion/TypesCompletion.java | 4 ++--
.../modules/groovy/editor/completion/provider/JavaElementHandler.java | 4 ++--
.../org/netbeans/modules/groovy/editor/java/JavaElementHandle.java | 1 +
5 files changed, 8 insertions(+), 6 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 4465f4c..2974456 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
@@ -164,6 +164,7 @@ public final class CompilationUnit extends
org.codehaus.groovy.control.Compilati
Task<CompilationController> task = new
Task<CompilationController>() {
@Override
public void run(CompilationController controller) throws
Exception {
+ controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
Elements elements = controller.getElements();
TypeElement typeElement =
ElementSearch.getClass(elements, name);
if (typeElement != null) {
diff --git
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/MethodCompletion.java
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/MethodCompletion.java
index 71a5274..d3948e8 100644
---
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/MethodCompletion.java
+++
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/MethodCompletion.java
@@ -158,8 +158,8 @@ public class MethodCompletion extends BaseCompletion {
try {
javaSource.runUserActionTask(new Task<CompilationController>()
{
@Override
- public void run(CompilationController info) {
-
+ public void run(CompilationController info) throws
IOException {
+ info.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
List<Element> typelist = new ArrayList<>();
for (String importName : getAllImports()) {
typelist.addAll(getElementListFor(info.getElements(), importName));
diff --git
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/TypesCompletion.java
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/TypesCompletion.java
index acc9f98..0071487 100644
---
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/TypesCompletion.java
+++
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/TypesCompletion.java
@@ -345,9 +345,9 @@ public class TypesCompletion extends BaseCompletion {
try {
javaSource.runUserActionTask(new Task<CompilationController>()
{
@Override
- public void run(CompilationController info) {
+ public void run(CompilationController info) throws
IOException {
Elements elements = info.getElements();
-
+ info.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
addPackageElements(elements.getPackageElement(pkg));
addTypeElements(elements.getTypeElement(pkg));
}
diff --git
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/provider/JavaElementHandler.java
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/provider/JavaElementHandler.java
index 4a5e73e..83f18ab 100644
---
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/provider/JavaElementHandler.java
+++
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/provider/JavaElementHandler.java
@@ -215,7 +215,7 @@ public final class JavaElementHandler {
return false;
}
};
-
+ info.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
TypeElement te = elements.getTypeElement(className);
if (te != null) {
for (ExecutableElement element :
ElementFilter.methodsIn(te.getEnclosedElements())) {
@@ -383,7 +383,7 @@ public final class JavaElementHandler {
return false;
}
};
-
+ info.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
TypeElement te = elements.getTypeElement(className);
if (te != null) {
for (VariableElement element :
ElementFilter.fieldsIn(te.getEnclosedElements())) {
diff --git
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/java/JavaElementHandle.java
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/java/JavaElementHandle.java
index 8a765c9..e4bb0a1 100644
---
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/java/JavaElementHandle.java
+++
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/java/JavaElementHandle.java
@@ -213,6 +213,7 @@ public final class JavaElementHandle implements
ElementHandle {
@Override
public void run(CompilationController parameter) throws Exception {
try {
+ parameter.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
result = resolver.apply(parameter, toElement(parameter));
} catch (Exception ex) {
thrown = ex;
---------------------------------------------------------------------
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