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 2020/07/06 01:32:48 UTC
[netbeans] branch master updated: Fixing vanilla indexer to handle
based anonymous classes properly.
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/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new fa61687 Fixing vanilla indexer to handle based anonymous classes properly.
fa61687 is described below
commit fa61687d410f5b4e7ebdfe4c35ea4830e2a3ddad
Author: Jan Lahoda <jl...@netbeans.org>
AuthorDate: Thu Jun 18 06:25:35 2020 +0200
Fixing vanilla indexer to handle based anonymous classes properly.
---
.../java/source/indexing/VanillaCompileWorker.java | 6 ++++-
.../source/indexing/VanillaCompileWorkerTest.java | 27 ++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java b/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
index 6506ebd..34e5f1d 100644
--- a/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
+++ b/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
@@ -622,7 +622,11 @@ final class VanillaCompileWorker extends CompileWorker {
if (node.getClassBody() != null && !nc.clazz.type.hasTag(TypeTag.ERROR)) {
MethodSymbol constructor = (MethodSymbol) nc.constructor;
ListBuffer<JCExpression> args = new ListBuffer<>();
- for (VarSymbol param : constructor.params) {
+ int startIdx = 0;
+ if (node.getEnclosingExpression() != null) {
+ startIdx = 1;
+ }
+ for (VarSymbol param : constructor.params.subList(startIdx, constructor.params.size())) {
args.add(make.TypeCast(param.type, make.Literal(TypeTag.BOT, null).setType(syms.botType)));
}
nc.args = args.toList();
diff --git a/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java b/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
index 96b8558..7cae875 100644
--- a/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
+++ b/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
@@ -611,6 +611,33 @@ public class VanillaCompileWorkerTest extends CompileWorkerTestBase {
createdFiles);
}
+ public void testBasedAnonymous() throws Exception {
+ ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test.java",
+ "package test;\n" +
+ "public class Test {\n" +
+ " private int i;\n" +
+ " static void test(Test t) {\n" +
+ " t.new Inner() {};\n" +
+ " }\n" +
+ " class Inner {}\n" +
+ "}\n")),
+ Arrays.asList());
+
+ assertFalse(result.lowMemory);
+ assertTrue(result.success);
+
+ Set<String> createdFiles = new HashSet<String>();
+
+ for (File created : result.createdFiles) {
+ createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+ }
+
+ assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test.sig",
+ "cache/s1/java/15/classes/test/Test$Inner.sig",
+ "cache/s1/java/15/classes/test/Test$1.sig")),
+ createdFiles);
+ }
+
public static void noop() {}
@Override
---------------------------------------------------------------------
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