dtrebbien closed pull request #363: Work around an AssertionError
URL: https://github.com/apache/incubator-netbeans/pull/363
 
 
   

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/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
 
b/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
index 14adc771a..4391d4ccc 100644
--- 
a/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
+++ 
b/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
@@ -469,7 +469,19 @@ public void exportToClipboard(JComponent comp, Clipboard 
clip, int action) throw
                                 private void handleDeclaration() {
                                     int s = (int) 
parameter.getTrees().getSourcePositions().getStartPosition(parameter.getCompilationUnit(),
 getCurrentPath().getLeaf());
                                     int e = (int) 
parameter.getTrees().getSourcePositions().getEndPosition(parameter.getCompilationUnit(),
 getCurrentPath().getLeaf());
-                                    javax.lang.model.element.Element el = 
parameter.getTrees().getElement(getCurrentPath());
+                                    javax.lang.model.element.Element el = null;
+                                    try {
+                                        el = 
parameter.getTrees().getElement(getCurrentPath());
+                                    } catch (AssertionError ignored) {
+                                        // Probably related to the Java - 
source issue
+                                        // reported in NETBEANS-267, selecting 
the entire
+                                        // contents of the report's Test.java 
file and
+                                        // copying causes an AssertionError 
deep within
+                                        // the com.sun.tools.javac package 
from the
+                                        // getElement() call.
+                                        // As a temporary work-around, catch 
the
+                                        // AssertionError and ignore it.
+                                    }
 
                                     if (el != null && ((start <= s && s <= 
end) || (start <= e && e <= end))) {
                                         
simple2ImportFQN.remove(el.getSimpleName().toString());


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
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

Reply via email to