You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2019/03/07 05:08:22 UTC

[incubator-netbeans] branch master updated: [NETBEANS-326] adding local variables in autocomplete list inside lambda expression

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

lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new b006f5b  [NETBEANS-326] adding local variables in autocomplete list inside lambda expression
b006f5b is described below

commit b006f5bc838ca33860053dca218db0b28de28de7
Author: sarveshkesharwani <sa...@oracle.com>
AuthorDate: Wed Mar 6 03:46:24 2019 -0800

    [NETBEANS-326] adding local variables in autocomplete list inside lambda expression
---
 .../java/completion/JavaCompletionTask.java        |   1 +
 .../1.8/lambdaOutsideMethodBodyContent.pass        | 142 ++++++++++++++++++++
 .../10/lambdaOutsideMethodBodyContent.pass         | 148 +++++++++++++++++++++
 .../11/lambdaOutsideMethodBodyContent.pass         | 148 +++++++++++++++++++++
 .../data/LambdaExpressionOutsideMethodBody.java    |  32 +++++
 .../JavaCompletionTask18FeaturesTest.java          |   4 +
 6 files changed, 475 insertions(+)

diff --git a/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java b/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
index afa4cb2..aa0b898 100644
--- a/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
+++ b/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
@@ -3210,6 +3210,7 @@ public final class JavaCompletionTask<T> extends BaseTask {
                                     env.getController().getSourceVersion().compareTo(SourceVersion.RELEASE_8) >= 0 && eu.isEffectivelyFinal((VariableElement)e)
                                 || (method == null && (e.getEnclosingElement().getKind() == INSTANCE_INIT
                                 || e.getEnclosingElement().getKind() == STATIC_INIT
+                                || e.getEnclosingElement().getKind() == CONSTRUCTOR
                                 || e.getEnclosingElement().getKind() == METHOD && e.getEnclosingElement().getEnclosingElement().getKind() == FIELD)))
                                 && (!illegalForwardRefs.containsKey(e.getSimpleName()) || illegalForwardRefs.get(e.getSimpleName()).getEnclosingElement() != e.getEnclosingElement());
                     case FIELD:
diff --git a/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/lambdaOutsideMethodBodyContent.pass b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/lambdaOutsideMethodBodyContent.pass
new file mode 100644
index 0000000..eb9a49f
--- /dev/null
+++ b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/lambdaOutsideMethodBodyContent.pass
@@ -0,0 +1,142 @@
+String s
+int t
+protected native Object clone()
+public boolean equals(Object arg0)
+protected void finalize()
+public final native Class<?> getClass()
+public native int hashCode()
+public final native void notify()
+public final native void notifyAll()
+public String toString()
+public final void wait()
+public final native void wait(long arg0)
+public final void wait(long arg0, int arg1)
+assert
+boolean
+byte
+char
+class
+do
+double
+final
+float
+for
+if
+int
+long
+new
+return
+short
+strictfp
+super
+switch
+synchronized
+this
+throw
+try
+void
+while
+AbstractMethodError
+Appendable
+ArithmeticException
+ArrayIndexOutOfBoundsException
+ArrayStoreException
+AssertionError
+AutoCloseable
+Boolean
+BootstrapMethodError
+Byte
+CharSequence
+Character
+Class
+ClassCastException
+ClassCircularityError
+ClassFormatError
+ClassLoader
+ClassNotFoundException
+ClassValue
+CloneNotSupportedException
+Cloneable
+Comparable
+Compiler
+Deprecated
+Double
+Enum
+EnumConstantNotPresentException
+Error
+Exception
+ExceptionInInitializerError
+Float
+Foo
+FunctionalInterface
+IllegalAccessError
+IllegalAccessException
+IllegalArgumentException
+IllegalMonitorStateException
+IllegalStateException
+IllegalThreadStateException
+IncompatibleClassChangeError
+IndexOutOfBoundsException
+InheritableThreadLocal
+InstantiationError
+InstantiationException
+Integer
+InternalError
+InterruptedException
+Iterable
+LinkageError
+Long
+Math
+NegativeArraySizeException
+NoClassDefFoundError
+NoSuchFieldError
+NoSuchFieldException
+NoSuchMethodError
+NoSuchMethodException
+NullPointerException
+Number
+NumberFormatException
+Object
+OutOfMemoryError
+Override
+Package
+Process
+ProcessBuilder
+Readable
+ReflectiveOperationException
+Runnable
+Runtime
+RuntimeException
+RuntimePermission
+SafeVarargs
+SecurityException
+SecurityManager
+Short
+StackOverflowError
+StackTraceElement
+StrictMath
+String
+StringBuffer
+StringBuilder
+StringIndexOutOfBoundsException
+SuppressWarnings
+System
+Test
+Thread
+ThreadDeath
+ThreadGroup
+ThreadLocal
+Throwable
+TypeNotPresentException
+UnknownError
+UnsatisfiedLinkError
+UnsupportedClassVersionError
+UnsupportedOperationException
+VerifyError
+VirtualMachineError
+Void
+com
+java
+javax
+org
+sun
diff --git a/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/10/lambdaOutsideMethodBodyContent.pass b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/10/lambdaOutsideMethodBodyContent.pass
new file mode 100644
index 0000000..6b4e1ee
--- /dev/null
+++ b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/10/lambdaOutsideMethodBodyContent.pass
@@ -0,0 +1,148 @@
+String s
+int t
+protected native Object clone()
+public boolean equals(Object arg0)
+protected void finalize()
+public final native Class<?> getClass()
+public native int hashCode()
+public final native void notify()
+public final native void notifyAll()
+public String toString()
+public final void wait()
+public final native void wait(long arg0)
+public final void wait(long arg0, int arg1)
+assert
+boolean
+byte
+char
+class
+do
+double
+final
+float
+for
+if
+int
+long
+new
+return
+short
+strictfp
+super
+switch
+synchronized
+this
+throw
+try
+void
+while
+AbstractMethodError
+Appendable
+ArithmeticException
+ArrayIndexOutOfBoundsException
+ArrayStoreException
+AssertionError
+AutoCloseable
+Boolean
+BootstrapMethodError
+Byte
+CharSequence
+Character
+Class
+ClassCastException
+ClassCircularityError
+ClassFormatError
+ClassLoader
+ClassNotFoundException
+ClassValue
+CloneNotSupportedException
+Cloneable
+Comparable
+Compiler
+Deprecated
+Double
+Enum
+EnumConstantNotPresentException
+Error
+Exception
+ExceptionInInitializerError
+Float
+Foo
+FunctionalInterface
+IllegalAccessError
+IllegalAccessException
+IllegalArgumentException
+IllegalCallerException
+IllegalMonitorStateException
+IllegalStateException
+IllegalThreadStateException
+IncompatibleClassChangeError
+IndexOutOfBoundsException
+InheritableThreadLocal
+InstantiationError
+InstantiationException
+Integer
+InternalError
+InterruptedException
+Iterable
+LayerInstantiationException
+LinkageError
+Long
+Math
+Module
+ModuleLayer
+NegativeArraySizeException
+NoClassDefFoundError
+NoSuchFieldError
+NoSuchFieldException
+NoSuchMethodError
+NoSuchMethodException
+NullPointerException
+Number
+NumberFormatException
+Object
+OutOfMemoryError
+Override
+Package
+Process
+ProcessBuilder
+ProcessHandle
+Readable
+ReflectiveOperationException
+Runnable
+Runtime
+RuntimeException
+RuntimePermission
+SafeVarargs
+SecurityException
+SecurityManager
+Short
+StackOverflowError
+StackTraceElement
+StackWalker
+StrictMath
+String
+StringBuffer
+StringBuilder
+StringIndexOutOfBoundsException
+SuppressWarnings
+System
+Test
+Thread
+ThreadDeath
+ThreadGroup
+ThreadLocal
+Throwable
+TypeNotPresentException
+UnknownError
+UnsatisfiedLinkError
+UnsupportedClassVersionError
+UnsupportedOperationException
+VerifyError
+VirtualMachineError
+Void
+com
+java
+javax
+org
+sun
diff --git a/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/11/lambdaOutsideMethodBodyContent.pass b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/11/lambdaOutsideMethodBodyContent.pass
new file mode 100644
index 0000000..6b4e1ee
--- /dev/null
+++ b/java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/11/lambdaOutsideMethodBodyContent.pass
@@ -0,0 +1,148 @@
+String s
+int t
+protected native Object clone()
+public boolean equals(Object arg0)
+protected void finalize()
+public final native Class<?> getClass()
+public native int hashCode()
+public final native void notify()
+public final native void notifyAll()
+public String toString()
+public final void wait()
+public final native void wait(long arg0)
+public final void wait(long arg0, int arg1)
+assert
+boolean
+byte
+char
+class
+do
+double
+final
+float
+for
+if
+int
+long
+new
+return
+short
+strictfp
+super
+switch
+synchronized
+this
+throw
+try
+void
+while
+AbstractMethodError
+Appendable
+ArithmeticException
+ArrayIndexOutOfBoundsException
+ArrayStoreException
+AssertionError
+AutoCloseable
+Boolean
+BootstrapMethodError
+Byte
+CharSequence
+Character
+Class
+ClassCastException
+ClassCircularityError
+ClassFormatError
+ClassLoader
+ClassNotFoundException
+ClassValue
+CloneNotSupportedException
+Cloneable
+Comparable
+Compiler
+Deprecated
+Double
+Enum
+EnumConstantNotPresentException
+Error
+Exception
+ExceptionInInitializerError
+Float
+Foo
+FunctionalInterface
+IllegalAccessError
+IllegalAccessException
+IllegalArgumentException
+IllegalCallerException
+IllegalMonitorStateException
+IllegalStateException
+IllegalThreadStateException
+IncompatibleClassChangeError
+IndexOutOfBoundsException
+InheritableThreadLocal
+InstantiationError
+InstantiationException
+Integer
+InternalError
+InterruptedException
+Iterable
+LayerInstantiationException
+LinkageError
+Long
+Math
+Module
+ModuleLayer
+NegativeArraySizeException
+NoClassDefFoundError
+NoSuchFieldError
+NoSuchFieldException
+NoSuchMethodError
+NoSuchMethodException
+NullPointerException
+Number
+NumberFormatException
+Object
+OutOfMemoryError
+Override
+Package
+Process
+ProcessBuilder
+ProcessHandle
+Readable
+ReflectiveOperationException
+Runnable
+Runtime
+RuntimeException
+RuntimePermission
+SafeVarargs
+SecurityException
+SecurityManager
+Short
+StackOverflowError
+StackTraceElement
+StackWalker
+StrictMath
+String
+StringBuffer
+StringBuilder
+StringIndexOutOfBoundsException
+SuppressWarnings
+System
+Test
+Thread
+ThreadDeath
+ThreadGroup
+ThreadLocal
+Throwable
+TypeNotPresentException
+UnknownError
+UnsatisfiedLinkError
+UnsupportedClassVersionError
+UnsupportedOperationException
+VerifyError
+VirtualMachineError
+Void
+com
+java
+javax
+org
+sun
diff --git a/java/java.completion/test/unit/data/org/netbeans/modules/java/completion/data/LambdaExpressionOutsideMethodBody.java b/java/java.completion/test/unit/data/org/netbeans/modules/java/completion/data/LambdaExpressionOutsideMethodBody.java
new file mode 100644
index 0000000..fad2517
--- /dev/null
+++ b/java/java.completion/test/unit/data/org/netbeans/modules/java/completion/data/LambdaExpressionOutsideMethodBody.java
@@ -0,0 +1,32 @@
+/*
+ * 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 test;
+
+public class Test {
+    
+    interface Foo {
+        int op (String s);
+    }
+    
+    Foo foo = (String s) -> {
+        int t = 5;
+        return s.length(); 
+    };
+    
+}
diff --git a/java/java.completion/test/unit/src/org/netbeans/modules/java/completion/JavaCompletionTask18FeaturesTest.java b/java/java.completion/test/unit/src/org/netbeans/modules/java/completion/JavaCompletionTask18FeaturesTest.java
index 42a8456..98f5b18 100644
--- a/java/java.completion/test/unit/src/org/netbeans/modules/java/completion/JavaCompletionTask18FeaturesTest.java
+++ b/java/java.completion/test/unit/src/org/netbeans/modules/java/completion/JavaCompletionTask18FeaturesTest.java
@@ -334,6 +334,10 @@ public class JavaCompletionTask18FeaturesTest extends CompletionTestBase {
         performTest("LambdaExpression", 1159, null, "lambdaSmartInt2.pass", "1.8");
     }
     
+    public void testLambdaExpressionOutsideMethodBody() throws Exception {
+        performTest("LambdaExpressionOutsideMethodBody", 959, null, "lambdaOutsideMethodBodyContent.pass", "1.8");
+    }
+    
     static {
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
     }


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

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