You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/01/18 20:45:13 UTC

[GitHub] matthiasblaesing closed pull request #364: [NETBEANS-252] Fix CG adding methods to enum constant bodies

matthiasblaesing closed pull request #364: [NETBEANS-252] Fix CG adding methods to enum constant bodies
URL: https://github.com/apache/incubator-netbeans/pull/364
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonClass.pass2 b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonClass.pass2
new file mode 100644
index 000000000..0fe4f4e07
--- /dev/null
+++ b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonClass.pass2
@@ -0,0 +1,34 @@
+/*
+ * 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 {
+    public Object o = new Object() {
+        @Override
+        public String toString() {
+            return super.toString();
+        }
+    };
+
+    public Object test() {
+        return new Object() {
+        };
+    }
+}
diff --git a/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonClass2.pass2 b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonClass2.pass2
new file mode 100644
index 000000000..d13eec27a
--- /dev/null
+++ b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonClass2.pass2
@@ -0,0 +1,34 @@
+/*
+ * 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 {
+    public Object o = new Object() {
+    };
+
+    public Object test() {
+        return new Object() {
+            @Override
+            public String toString() {
+                return super.toString();
+            }
+        };
+    }
+}
diff --git a/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonInterfaceImpl.pass2 b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonInterfaceImpl.pass2
new file mode 100644
index 000000000..093d1e76a
--- /dev/null
+++ b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonInterfaceImpl.pass2
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+public class Test {
+    public Serializable o = new Serializable() {
+        @Override
+        public String toString() {
+            return super.toString();
+        }
+    };
+
+    public Serializable test() {
+        return new Serializable() {
+        };
+    }
+}
diff --git a/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonInterfaceImpl2.pass2 b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonInterfaceImpl2.pass2
new file mode 100644
index 000000000..b4706e732
--- /dev/null
+++ b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInAnonInterfaceImpl2.pass2
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+public class Test {
+    public Serializable o = new Serializable() {
+    };
+
+    public Serializable test() {
+        return new Serializable() {
+            @Override
+            public String toString() {
+                return super.toString();
+            }
+        };
+    }
+}
diff --git a/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInEnumConstantBody.pass2 b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInEnumConstantBody.pass2
new file mode 100644
index 000000000..86d952985
--- /dev/null
+++ b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInEnumConstantBody.pass2
@@ -0,0 +1,43 @@
+/*
+ * 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 {
+    public enum E {
+        A(new Object() { })
+        {
+            @Override
+            public String toString() {
+                return super.toString();
+            }
+        },
+
+        B()
+        {
+        },
+
+        C
+        {
+        };
+
+        private E() { }
+        private E(Object o) { }
+    }
+}
diff --git a/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInEnumConstantBody2.pass2 b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInEnumConstantBody2.pass2
new file mode 100644
index 000000000..7d12923cc
--- /dev/null
+++ b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInEnumConstantBody2.pass2
@@ -0,0 +1,43 @@
+/*
+ * 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 {
+    public enum E {
+        A(new Object() { })
+        {
+        },
+
+        B()
+        {
+            @Override
+            public String toString() {
+                return super.toString();
+            }
+        },
+
+        C
+        {
+        };
+
+        private E() { }
+        private E(Object o) { }
+    }
+}
diff --git a/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInEnumConstantBody3.pass2 b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInEnumConstantBody3.pass2
new file mode 100644
index 000000000..1f82e64be
--- /dev/null
+++ b/java.editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/completion/JavaCompletionProviderTest/1.8/OverrideInEnumConstantBody3.pass2
@@ -0,0 +1,43 @@
+/*
+ * 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 {
+    public enum E {
+        A(new Object() { })
+        {
+        },
+
+        B()
+        {
+        },
+
+        C
+        {
+            @Override
+            public String toString() {
+                return super.toString();
+            }
+        };
+
+        private E() { }
+        private E(Object o) { }
+    }
+}
diff --git a/java.editor/test/unit/data/org/netbeans/modules/java/editor/completion/data/OverrideInAnonClass.java b/java.editor/test/unit/data/org/netbeans/modules/java/editor/completion/data/OverrideInAnonClass.java
new file mode 100644
index 000000000..d42d976ea
--- /dev/null
+++ b/java.editor/test/unit/data/org/netbeans/modules/java/editor/completion/data/OverrideInAnonClass.java
@@ -0,0 +1,30 @@
+/*
+ * 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 {
+    public Object o = new Object() {
+    };
+
+    public Object test() {
+        return new Object() {
+        };
+    }
+}
diff --git a/java.editor/test/unit/data/org/netbeans/modules/java/editor/completion/data/OverrideInAnonInterfaceImpl.java b/java.editor/test/unit/data/org/netbeans/modules/java/editor/completion/data/OverrideInAnonInterfaceImpl.java
new file mode 100644
index 000000000..603d11cc3
--- /dev/null
+++ b/java.editor/test/unit/data/org/netbeans/modules/java/editor/completion/data/OverrideInAnonInterfaceImpl.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;
+
+import java.io.Serializable;
+
+public class Test {
+    public Serializable o = new Serializable() {
+    };
+
+    public Serializable test() {
+        return new Serializable() {
+        };
+    }
+}
diff --git a/java.editor/test/unit/data/org/netbeans/modules/java/editor/completion/data/OverrideInEnumConstantBody.java b/java.editor/test/unit/data/org/netbeans/modules/java/editor/completion/data/OverrideInEnumConstantBody.java
new file mode 100644
index 000000000..db64557e5
--- /dev/null
+++ b/java.editor/test/unit/data/org/netbeans/modules/java/editor/completion/data/OverrideInEnumConstantBody.java
@@ -0,0 +1,39 @@
+/*
+ * 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 {
+    public enum E {
+        A(new Object() { })
+        {
+        },
+
+        B()
+        {
+        },
+
+        C
+        {
+        };
+
+        private E() { }
+        private E(Object o) { }
+    }
+}
diff --git a/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/JavaCompletionItemElementCreatingTest.java b/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/JavaCompletionItemElementCreatingTest.java
index 82b5ee03c..0c42d74b9 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/JavaCompletionItemElementCreatingTest.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/JavaCompletionItemElementCreatingTest.java
@@ -64,4 +64,31 @@ public void testOverrideTypedException2() throws Exception {
     public void testOverrideInInnerClass() throws Exception {
         performTest("OverrideInInnerClass", 185, "pai", "paint\\(.*override", "OverrideInInnerClass.pass2");
     }
+
+    public void testOverrideInAnonClass() throws Exception {
+        performTest("OverrideInAnonClass", 880, null, "toString\\(\\).*override", "OverrideInAnonClass.pass2");
+    }
+
+    public void testOverrideInAnonClass2() throws Exception {
+        performTest("OverrideInAnonClass", 945, null, "toString\\(\\).*override", "OverrideInAnonClass2.pass2");
+    }
+
+    public void testOverrideInAnonInterfaceImpl() throws Exception {
+        performTest("OverrideInAnonInterfaceImpl", 922, null, "toString\\(\\).*override", "OverrideInAnonInterfaceImpl.pass2");
+    }
+
+    public void testOverrideInAnonInterfaceImpl2() throws Exception {
+        performTest("OverrideInAnonInterfaceImpl", 999, null, "toString\\(\\).*override", "OverrideInAnonInterfaceImpl2.pass2");
+    }
+
+    // Tests the fix for NETBEANS-252 / #271633
+    public void testOverrideInEnumConstantBody() throws Exception {
+        performTest("OverrideInEnumConstantBody", 901, null, "toString\\(\\).*override", "OverrideInEnumConstantBody.pass2");
+    }
+    public void testOverrideInEnumBody2() throws Exception {
+        performTest("OverrideInEnumConstantBody", 935, null, "toString\\(\\).*override", "OverrideInEnumConstantBody2.pass2");
+    }
+    public void testOverrideInEnumBody3() throws Exception {
+        performTest("OverrideInEnumConstantBody", 967, null, "toString\\(\\).*override", "OverrideInEnumConstantBody3.pass2");
+    }
 }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java b/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
index 71f87b6a1..e3f235622 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
@@ -184,7 +184,7 @@
     private final Names names;
     private static final Logger LOG = Logger.getLogger(CasualDiff.class.getName());
 
-    private Map<Integer, String> diffInfo = new HashMap<Integer, String>();
+    private Map<Integer, String> diffInfo = new HashMap<>();
     private final Map<Tree, ?> tree2Tag;
     private final Map<Object, int[]> tag2Span;
     private final Set<Tree> oldTrees;
@@ -200,7 +200,7 @@
      * on how guarded blocks (or other divisor of the source) is mapped into the changed text and not generate diffs across
      * such a boundary.
      */
-    private Map<Integer, Integer>   blockSequenceMap = new LinkedHashMap<Integer, Integer>();
+    private Map<Integer, Integer> blockSequenceMap = new LinkedHashMap<>();
 
     private Iterator<Integer>    boundaries;
     private int nextBlockBoundary = -1;
@@ -222,10 +222,6 @@ protected CasualDiff(Context context, DiffContext diffContext, TreeUtilities tre
         this.oldTrees = oldTrees;
     }
 
-    private Collection<Diff> getDiffs() {
-        return diffs;
-    }
-
     public static Collection<Diff> diff(Context context,
             DiffContext diffContext,
             TreeUtilities treeUtilities,
@@ -347,7 +343,7 @@ protected CasualDiff(Context context, DiffContext diffContext, TreeUtilities tre
         String resultSrc = td.printer.toString().substring(start - lineStart);
         if (!td.printer.reindentRegions.isEmpty()) {
             // must add region boundaries to tag2span, since the text may be reformatted.
-            List<SectKey> keys = new ArrayList<SectKey>(td.blockSequenceMap.size());
+            List<SectKey> keys = new ArrayList<>(td.blockSequenceMap.size());
             for (Map.Entry<Integer, Integer> e : td.blockSequenceMap.entrySet()) {
                 int x = e.getValue();
                 SectKey k = new SectKey(x);
@@ -498,8 +494,8 @@ protected CasualDiff(Context context, DiffContext diffContext, TreeUtilities tre
         }
         //XXX: no-javac-patch end
 
-        List<JCImport> originalJC = new LinkedList<JCImport>();
-        List<JCImport> nueJC = new LinkedList<JCImport>();
+        List<JCImport> originalJC = new LinkedList<>();
+        List<JCImport> nueJC = new LinkedList<>();
 
         for (ImportTree i : original) {
             originalJC.add((JCImport) i);
@@ -1048,7 +1044,7 @@ protected int diffClassDef(JCClassDecl oldT, JCClassDecl newT, int[] bounds) {
         tokenSequence.moveNext();
         insertHint = moveBackToToken(tokenSequence, insertHint, JavaTokenId.LBRACE) + 1;
         } else {
-            insertHint = moveFwdToToken(tokenSequence, getOldPos(oldT), JavaTokenId.LBRACE);
+            insertHint = moveFwdToToken(tokenSequence, oldT.getKind() == Kind.ENUM ? localPointer : getOldPos(oldT), JavaTokenId.LBRACE);
             tokenSequence.moveNext();
             insertHint = tokenSequence.offset();
         }
@@ -2161,9 +2157,26 @@ protected int diffNewClass(JCNewClass oldT, JCNewClass newT, int[] bounds) {
         // let diffClassDef() method notified that anonymous class is printed.
         if (oldT.def != newT.def) {
             if (oldT.def != null && newT.def != null) {
-                copyTo(localPointer, getOldPos(oldT.def));
+                int[] defBounds = getBounds(oldT.def);
+                // getBounds(oldT.def)[0] (which is getOldPos(oldT.def)) for
+                // classes and interfaces is the position of the LBRACE of the
+                // class/interface body. For enums, it is the start position of
+                // the enum constant, so we need to move forward to the LBRACE.
+                if (enumConstantPrint) {
+                    // Move to the end of the arguments if there were any before
+                    // looking for the LBRACE so that we don't stop on an LBRACE
+                    // involved in one of the arguments.
+                    if (!oldTFilteredArgs.isEmpty()) {
+                        defBounds[0] = endPos(oldTFilteredArgs);
+                    }
+                    if (defBounds[0] != -1) {
+                        moveFwdToToken(tokenSequence, defBounds[0], JavaTokenId.LBRACE);
+                        defBounds[0] = tokenSequence.offset();
+                    }
+                }
+                copyTo(localPointer, defBounds[0]);
                 anonClass = true;
-                localPointer = diffTree(oldT.def, newT.def, getBounds(oldT.def));
+                localPointer = diffTree(oldT.def, newT.def, defBounds);
                 anonClass = false;
             } else if (newT.def == null) {
                 if (endPos(oldTFilteredArgs) > localPointer) {
@@ -2352,7 +2365,7 @@ protected int diffBinary(JCBinary oldT, JCBinary newT, int[] bounds) {
         if (oldT.getTag() != newT.getTag()) {
             copyTo(localPointer, oldT.pos);
             printer.print(operatorName(newT.getTag()));
-            localPointer = oldT.pos + operatorName(oldT.getTag()).toString().length();
+            localPointer = oldT.pos + operatorName(oldT.getTag()).length();
         }
         int[] rhsBounds = getCommentCorrectedBounds(oldT.rhs);
         rhsBounds[0] = copyUpTo(localPointer, rhsBounds[0]);
@@ -2695,7 +2708,7 @@ protected int diffModifiers(JCModifiers oldT, JCModifiers newT, JCTree parent, i
             //first modifiers, then annotations:
             if (oldT.flags != newT.flags) {
                 copyTo(localPointer, startPos);
-                printer.printFlags(newT.flags & ~Flags.INTERFACE, oldT.getFlags().isEmpty() ? true : false);
+                printer.printFlags(newT.flags & ~Flags.INTERFACE, oldT.getFlags().isEmpty());
                 tokenSequence.move(firstAnnotationPos);
                 moveToSrcRelevant(tokenSequence, Direction.BACKWARD);
                 tokenSequence.moveNext();
@@ -2718,7 +2731,7 @@ protected int diffModifiers(JCModifiers oldT, JCModifiers newT, JCTree parent, i
             if (localPointer == startPos) {
                 // no annotation printed, do modifiers print immediately
                 if ((newT.flags & ~Flags.INTERFACE) != 0) {
-                    printer.printFlags(newT.flags & ~Flags.INTERFACE, oldT.getFlags().isEmpty() ? true : false);
+                    printer.printFlags(newT.flags & ~Flags.INTERFACE, oldT.getFlags().isEmpty());
                     localPointer = endOffset > 0 ? endOffset : localPointer;
                 } else {
                     if (endOffset > 0) {
@@ -3337,7 +3350,7 @@ private int diffParameterList(
                 moveFwdToToken(tokenSequence, endPos, makeAround[1]);
                 tokenSequence.moveNext();
                 endPos = tokenSequence.offset();
-                if (!nonRelevant.contains(tokenSequence.token()))
+                if (!nonRelevant.contains(tokenSequence.token().id()))
                     printer.print(" "); // use options, if mods should be at new line
             }
             return endPos;
@@ -3513,7 +3526,7 @@ private int diffVarGroup(
                 moveFwdToToken(tokenSequence, endPos, makeAround[1]);
                 tokenSequence.moveNext();
                 endPos = tokenSequence.offset();
-                if (!nonRelevant.contains(tokenSequence.token()))
+                if (!nonRelevant.contains(tokenSequence.token().id()))
                     printer.print(" "); // use options, if mods should be at new line
             }
             return endPos;
@@ -3694,9 +3707,9 @@ private boolean commaNeeded(ResultItem[] arr, ResultItem item) {
     }
     
     public static List<JCTree> filterHidden(DiffContext diffContext, List<? extends JCTree> list) {
-        LinkedList<JCTree> result = new LinkedList<JCTree>(); // todo (#pf): capacity?
-        List<JCVariableDecl> fieldGroup = new ArrayList<JCVariableDecl>();
-        List<JCVariableDecl> enumConstants = new ArrayList<JCVariableDecl>();
+        LinkedList<JCTree> result = new LinkedList<>(); // todo (#pf): capacity?
+        List<JCVariableDecl> fieldGroup = new ArrayList<>();
+        List<JCVariableDecl> enumConstants = new ArrayList<>();
         for (JCTree tree : list) {
             if (tree.pos == (-1)) continue;
             if (diffContext.syntheticTrees.contains(tree)) continue;
@@ -3787,7 +3800,7 @@ private int diffList(
         if (!matcher.match()) {
             return localPointer;
         }
-        Queue<JCTree> deletedItems = new LinkedList<JCTree>(); // deleted items
+        Queue<JCTree> deletedItems = new LinkedList<>(); // deleted items
         JCTree lastdel = null; // last deleted element
         ResultItem<JCTree>[] result = matcher.getResult();
 
@@ -3842,7 +3855,7 @@ private int diffList(
             int group = -1;
             if (importGroups != null) {
                 Name name = printer.fullName(((JCImport)item.element).qualid);
-                group = importGroups != null && name != null ? importGroups.getGroupId(name.toString(), ((JCImport)item.element).staticImport) : -1;
+                group = (name != null ? importGroups.getGroupId(name.toString(), ((JCImport)item.element).staticImport) : -1);
             }
             switch (item.operation) {
                 case MODIFY: {
@@ -5085,7 +5098,8 @@ public Void scan(Tree node, Void p) {
                 max = Math.max(getPosAfterCommentEnd((JCTree)node, -1), max);
                 return super.scan(node, p);
             }
-        };
+        }
+
         Scn scn = new Scn();
         scn.scan(t, null);
         return Math.max(scn.max, end);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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