You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "mbien (via GitHub)" <gi...@apache.org> on 2023/12/14 08:11:08 UTC

[PR] Stacktrace analyzer window fixes [netbeans]

mbien opened a new pull request, #6841:
URL: https://github.com/apache/netbeans/pull/6841

    - update matcher to be more forgiving when traces are pasted from ANSI decorated sources (some loggers use colors for exception elements)
    - properly escape angle brackets in cell renderer and some indentation fixes
    - avoid using deprecated methods
   
   
   example: this trace isn't parsed properly NB 20 (note: the space before '('):
   ```
   java.util.zip.ZipException: zip file is empty
       at java.util.zip.ZipFile$Source.zerror (ZipFile.java:1769)
       at java.util.zip.ZipFile$Source.findEND (ZipFile.java:1565)
       at java.util.zip.ZipFile$Source.initCEN (ZipFile.java:1659)
       at java.util.zip.ZipFile$Source.<init> (ZipFile.java:1463)
       at java.util.zip.ZipFile$Source.get (ZipFile.java:1426)
       at java.util.zip.ZipFile$CleanableResource.<init> (ZipFile.java:742)
       at java.util.zip.ZipFile$CleanableResource.get (ZipFile.java:859)
       at java.util.zip.ZipFile.<init> (ZipFile.java:257)
       at java.util.zip.ZipFile.<init> (ZipFile.java:186)
       at java.util.zip.ZipFile.<init> (ZipFile.java:200)
   ```
   ![image](https://github.com/apache/netbeans/assets/114367/fb1f934b-b454-4aa9-a38f-83380be39f80)
   
   with this PR applied:
   ![image](https://github.com/apache/netbeans/assets/114367/ae2448d6-9e23-4e35-bbc0-ab547cefd339)
   
   
   unfortunately I don't know which logger is causing this, when run in console the exception was decorated with ANSI symbols for coloring.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1429059008


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########
@@ -57,11 +55,12 @@ class StackLineAnalyser {
     private static final String IDENTIFIER =
         "\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*";    // NOI18N
     private static final Pattern LINE_PATTERN = Pattern.compile(
-        "at\\s" +                                       //  initial at // NOI18N
+        "at\\s+" +                                       //  initial at // NOI18N
         "("+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" + // optional module name // NOI18N
         "(("+IDENTIFIER+"(\\."+IDENTIFIER+")*)\\.)?("+IDENTIFIER+")" + // class name // NOI18N
-        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" +IDENTIFIER+"\\.?("+IDENTIFIER+ // method and file name // NOI18N
-        ")\\:([0-9]*)\\)");                              // line number // NOI18N
+        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\s*"+ // method name
+        "\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?"+IDENTIFIER+"(\\.(?:\\p{javaJavaIdentifierPart}+))?"+ // '(File.java' // NOI18N
+        "\\:([0-9]*)\\)");                              // ':123)' // NOI18N

Review Comment:
   the original goal was to add a few optional `\\s*` but this does also include a fix for https://github.com/apache/netbeans/pull/6640/files#r1377502665, since this didn't work before as pointed out by @dbalek in the linked review.
   
   The file extension group is now optional `(\\.(?:\\p{javaJavaIdentifierPart}+))?`. Tests cover this now too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien merged PR #6841:
URL: https://github.com/apache/netbeans/pull/6841


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1429059008


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########
@@ -57,11 +55,12 @@ class StackLineAnalyser {
     private static final String IDENTIFIER =
         "\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*";    // NOI18N
     private static final Pattern LINE_PATTERN = Pattern.compile(
-        "at\\s" +                                       //  initial at // NOI18N
+        "at\\s+" +                                       //  initial at // NOI18N
         "("+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" + // optional module name // NOI18N
         "(("+IDENTIFIER+"(\\."+IDENTIFIER+")*)\\.)?("+IDENTIFIER+")" + // class name // NOI18N
-        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" +IDENTIFIER+"\\.?("+IDENTIFIER+ // method and file name // NOI18N
-        ")\\:([0-9]*)\\)");                              // line number // NOI18N
+        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\s*"+ // method name
+        "\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?"+IDENTIFIER+"(\\.(?:\\p{javaJavaIdentifierPart}+))?"+ // '(File.java' // NOI18N
+        "\\:([0-9]*)\\)");                              // ':123)' // NOI18N

Review Comment:
   the original goal was to add a few optional `\\s*` but this does also include a fix for https://github.com/apache/netbeans/pull/6640/files#r1377502665, since this didn't work before as pointed out in the linked review. Tests cover this now too now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1429059008


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########
@@ -57,11 +55,12 @@ class StackLineAnalyser {
     private static final String IDENTIFIER =
         "\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*";    // NOI18N
     private static final Pattern LINE_PATTERN = Pattern.compile(
-        "at\\s" +                                       //  initial at // NOI18N
+        "at\\s+" +                                       //  initial at // NOI18N
         "("+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" + // optional module name // NOI18N
         "(("+IDENTIFIER+"(\\."+IDENTIFIER+")*)\\.)?("+IDENTIFIER+")" + // class name // NOI18N
-        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" +IDENTIFIER+"\\.?("+IDENTIFIER+ // method and file name // NOI18N
-        ")\\:([0-9]*)\\)");                              // line number // NOI18N
+        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\s*"+ // method name
+        "\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?"+IDENTIFIER+"(\\.(?:\\p{javaJavaIdentifierPart}+))?"+ // '(File.java' // NOI18N
+        "\\:([0-9]*)\\)");                              // ':123)' // NOI18N

Review Comment:
   the original goal was to add a few optional `\\s*` but this does also include a fix for https://github.com/apache/netbeans/pull/6640/files#r1377502665, since this didn't work before as pointed out by @dbalek in the linked review.
   
   The file extension group is now optional `(\\.(?:\\p{javaJavaIdentifierPart}+))?` and matches more character types since extensions aren't real java identifiers. Tests cover this now too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1426378590


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########


Review Comment:
   recommend to enable ignore whitespace changes for reviewing this one



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#issuecomment-1855443077

   there you go, found the evil logger:
   https://github.com/apache/maven/blob/eee9514d3db6b876723366745d8220fc50af7d22/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenSimpleLogger.java#L86-L88
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1426378590


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########


Review Comment:
   recommend to enable ignore whitespace changes for reviewing this one - sorry about this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1429212059


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########
@@ -144,75 +143,68 @@ void show () {
                 resources.add(name + ".java"); //NOI18N
                 idx = name.lastIndexOf('$');
             }
-            final ProgressHandle handle = ProgressHandleFactory.createHandle(
+            final ProgressHandle handle = ProgressHandle.createHandle(
                 NbBundle.getMessage(StackLineAnalyser.class, "TXT_OpeningSource", resources.get(0)));
             handle.start();
-            RP.execute(
-                new Runnable() {
-                    @Override
-                    public void run() {
-                        DataObject dobj = null;
-                        try {
-                            final ClassPath classPath = ClassPathSupport.createClassPath(
+            RP.execute(() -> {
+                DataObject dobj = null;
+                try {
+                    final ClassPath classPath = ClassPathSupport.createClassPath(
                             GlobalPathRegistry.getDefault().getSourceRoots().toArray(new FileObject[0]));
-                            for (String resource : resources) {
-                                dobj = findDataObject(classPath.findResource(resource));
-                                if (dobj != null)
-                                    break;
+                    for (String resource : resources) {
+                        dobj = findDataObject(classPath.findResource(resource));
+                        if (dobj != null)
+                            break;
+                    }
+                } finally {
+                    final DataObject dataObject = dobj;
+                    Mutex.EVENT.readAccess(() -> {
+                        try {
+                            if (dataObject == null) {
+                                StatusDisplayer.getDefault().setStatusText(
+                                        NbBundle.getMessage(StackLineAnalyser.class,
+                                                "AnalyzeStackTopComponent.sourceNotFound",
+                                                new Object[]{resources.get(0)}));
+                                return;
                             }
-                        } finally {
-                            final DataObject dataObject = dobj;
-                            Mutex.EVENT.readAccess(new Runnable() {
-                                @Override
-                                public void run() {
-                                    try {
-                                        if (dataObject == null) {
-                                            StatusDisplayer.getDefault().setStatusText(
-                                            NbBundle.getMessage(StackLineAnalyser.class,
-                                            "AnalyzeStackTopComponent.sourceNotFound",
-                                            new Object[]{resources.get(0)}));
-                                            return;
-                                        }
-                                        try {
-                                            EditorCookie editorCookie = (EditorCookie) dataObject.getCookie(EditorCookie.class);
-                                            LineCookie lineCookie = (LineCookie) dataObject.getCookie(LineCookie.class);
-                                            if (editorCookie != null && lineCookie != null && lineNumber != -1) {
-                                                StyledDocument doc = editorCookie.openDocument();
-                                                if (doc != null) {
-                                                    if (lineNumber != -1) {
-                                                        try {
-                                                            Line l = lineCookie.getLineSet().getCurrent(lineNumber - 1);
-
-                                                            if (l != null) {
-                                                                l.show(Line.SHOW_GOTO);
-                                                                return;
-                                                            }
-                                                        } catch (IndexOutOfBoundsException oob) {
-                                                            //line number is no more valid, do not report as an error
-                                                            StatusDisplayer.getDefault().setStatusText(
-                                                            NbBundle.getMessage(StackLineAnalyser.class,
-                                                            "AnalyzeStackTopComponent.lineNotFound",
-                                                            new Object[]{lineNumber}));
-                                                        }
-                                                    }
+                            try {
+                                EditorCookie editorCookie = (EditorCookie) dataObject.getLookup().lookup(EditorCookie.class);

Review Comment:
   The cast `(EditorCookie)` could be removed now.



##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########
@@ -144,75 +143,68 @@ void show () {
                 resources.add(name + ".java"); //NOI18N
                 idx = name.lastIndexOf('$');
             }
-            final ProgressHandle handle = ProgressHandleFactory.createHandle(
+            final ProgressHandle handle = ProgressHandle.createHandle(
                 NbBundle.getMessage(StackLineAnalyser.class, "TXT_OpeningSource", resources.get(0)));
             handle.start();
-            RP.execute(
-                new Runnable() {
-                    @Override
-                    public void run() {
-                        DataObject dobj = null;
-                        try {
-                            final ClassPath classPath = ClassPathSupport.createClassPath(
+            RP.execute(() -> {
+                DataObject dobj = null;
+                try {
+                    final ClassPath classPath = ClassPathSupport.createClassPath(
                             GlobalPathRegistry.getDefault().getSourceRoots().toArray(new FileObject[0]));
-                            for (String resource : resources) {
-                                dobj = findDataObject(classPath.findResource(resource));
-                                if (dobj != null)
-                                    break;
+                    for (String resource : resources) {
+                        dobj = findDataObject(classPath.findResource(resource));
+                        if (dobj != null)
+                            break;
+                    }
+                } finally {
+                    final DataObject dataObject = dobj;
+                    Mutex.EVENT.readAccess(() -> {
+                        try {
+                            if (dataObject == null) {
+                                StatusDisplayer.getDefault().setStatusText(
+                                        NbBundle.getMessage(StackLineAnalyser.class,
+                                                "AnalyzeStackTopComponent.sourceNotFound",
+                                                new Object[]{resources.get(0)}));
+                                return;
                             }
-                        } finally {
-                            final DataObject dataObject = dobj;
-                            Mutex.EVENT.readAccess(new Runnable() {
-                                @Override
-                                public void run() {
-                                    try {
-                                        if (dataObject == null) {
-                                            StatusDisplayer.getDefault().setStatusText(
-                                            NbBundle.getMessage(StackLineAnalyser.class,
-                                            "AnalyzeStackTopComponent.sourceNotFound",
-                                            new Object[]{resources.get(0)}));
-                                            return;
-                                        }
-                                        try {
-                                            EditorCookie editorCookie = (EditorCookie) dataObject.getCookie(EditorCookie.class);
-                                            LineCookie lineCookie = (LineCookie) dataObject.getCookie(LineCookie.class);
-                                            if (editorCookie != null && lineCookie != null && lineNumber != -1) {
-                                                StyledDocument doc = editorCookie.openDocument();
-                                                if (doc != null) {
-                                                    if (lineNumber != -1) {
-                                                        try {
-                                                            Line l = lineCookie.getLineSet().getCurrent(lineNumber - 1);
-
-                                                            if (l != null) {
-                                                                l.show(Line.SHOW_GOTO);
-                                                                return;
-                                                            }
-                                                        } catch (IndexOutOfBoundsException oob) {
-                                                            //line number is no more valid, do not report as an error
-                                                            StatusDisplayer.getDefault().setStatusText(
-                                                            NbBundle.getMessage(StackLineAnalyser.class,
-                                                            "AnalyzeStackTopComponent.lineNotFound",
-                                                            new Object[]{lineNumber}));
-                                                        }
-                                                    }
+                            try {
+                                EditorCookie editorCookie = (EditorCookie) dataObject.getLookup().lookup(EditorCookie.class);
+                                LineCookie lineCookie = (LineCookie) dataObject.getLookup().lookup(LineCookie.class);

Review Comment:
   Cast here is also unnecessary now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1429059008


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########
@@ -57,11 +55,12 @@ class StackLineAnalyser {
     private static final String IDENTIFIER =
         "\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*";    // NOI18N
     private static final Pattern LINE_PATTERN = Pattern.compile(
-        "at\\s" +                                       //  initial at // NOI18N
+        "at\\s+" +                                       //  initial at // NOI18N
         "("+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" + // optional module name // NOI18N
         "(("+IDENTIFIER+"(\\."+IDENTIFIER+")*)\\.)?("+IDENTIFIER+")" + // class name // NOI18N
-        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" +IDENTIFIER+"\\.?("+IDENTIFIER+ // method and file name // NOI18N
-        ")\\:([0-9]*)\\)");                              // line number // NOI18N
+        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\s*"+ // method name
+        "\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?"+IDENTIFIER+"(\\.(?:\\p{javaJavaIdentifierPart}+))?"+ // '(File.java' // NOI18N
+        "\\:([0-9]*)\\)");                              // ':123)' // NOI18N

Review Comment:
   the original goal was to add a few optional `\\s*` but this does also include a fix for https://github.com/apache/netbeans/pull/6640/files#r1377502665, since this didn't work before as pointed out by @dbalek in the linked review.
   
   The file extension group is now optional `(\\.(?:\\p{javaJavaIdentifierPart}+))?` and matches more characters. Tests cover this now too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1429218221


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########
@@ -144,75 +143,68 @@ void show () {
                 resources.add(name + ".java"); //NOI18N
                 idx = name.lastIndexOf('$');
             }
-            final ProgressHandle handle = ProgressHandleFactory.createHandle(
+            final ProgressHandle handle = ProgressHandle.createHandle(
                 NbBundle.getMessage(StackLineAnalyser.class, "TXT_OpeningSource", resources.get(0)));
             handle.start();
-            RP.execute(
-                new Runnable() {
-                    @Override
-                    public void run() {
-                        DataObject dobj = null;
-                        try {
-                            final ClassPath classPath = ClassPathSupport.createClassPath(
+            RP.execute(() -> {
+                DataObject dobj = null;
+                try {
+                    final ClassPath classPath = ClassPathSupport.createClassPath(
                             GlobalPathRegistry.getDefault().getSourceRoots().toArray(new FileObject[0]));
-                            for (String resource : resources) {
-                                dobj = findDataObject(classPath.findResource(resource));
-                                if (dobj != null)
-                                    break;
+                    for (String resource : resources) {
+                        dobj = findDataObject(classPath.findResource(resource));
+                        if (dobj != null)
+                            break;
+                    }
+                } finally {
+                    final DataObject dataObject = dobj;
+                    Mutex.EVENT.readAccess(() -> {
+                        try {
+                            if (dataObject == null) {
+                                StatusDisplayer.getDefault().setStatusText(
+                                        NbBundle.getMessage(StackLineAnalyser.class,
+                                                "AnalyzeStackTopComponent.sourceNotFound",
+                                                new Object[]{resources.get(0)}));
+                                return;
                             }
-                        } finally {
-                            final DataObject dataObject = dobj;
-                            Mutex.EVENT.readAccess(new Runnable() {
-                                @Override
-                                public void run() {
-                                    try {
-                                        if (dataObject == null) {
-                                            StatusDisplayer.getDefault().setStatusText(
-                                            NbBundle.getMessage(StackLineAnalyser.class,
-                                            "AnalyzeStackTopComponent.sourceNotFound",
-                                            new Object[]{resources.get(0)}));
-                                            return;
-                                        }
-                                        try {
-                                            EditorCookie editorCookie = (EditorCookie) dataObject.getCookie(EditorCookie.class);
-                                            LineCookie lineCookie = (LineCookie) dataObject.getCookie(LineCookie.class);
-                                            if (editorCookie != null && lineCookie != null && lineNumber != -1) {
-                                                StyledDocument doc = editorCookie.openDocument();
-                                                if (doc != null) {
-                                                    if (lineNumber != -1) {
-                                                        try {
-                                                            Line l = lineCookie.getLineSet().getCurrent(lineNumber - 1);
-
-                                                            if (l != null) {
-                                                                l.show(Line.SHOW_GOTO);
-                                                                return;
-                                                            }
-                                                        } catch (IndexOutOfBoundsException oob) {
-                                                            //line number is no more valid, do not report as an error
-                                                            StatusDisplayer.getDefault().setStatusText(
-                                                            NbBundle.getMessage(StackLineAnalyser.class,
-                                                            "AnalyzeStackTopComponent.lineNotFound",
-                                                            new Object[]{lineNumber}));
-                                                        }
-                                                    }
+                            try {
+                                EditorCookie editorCookie = (EditorCookie) dataObject.getLookup().lookup(EditorCookie.class);

Review Comment:
   good catch! I have the "redundant cast" hint enabled but it looks like the NB project settings are overwriting this (nbbuild/misc/hints-settings.xml), I enabled it now for me locally.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1429059008


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########
@@ -57,11 +55,12 @@ class StackLineAnalyser {
     private static final String IDENTIFIER =
         "\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*";    // NOI18N
     private static final Pattern LINE_PATTERN = Pattern.compile(
-        "at\\s" +                                       //  initial at // NOI18N
+        "at\\s+" +                                       //  initial at // NOI18N
         "("+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" + // optional module name // NOI18N
         "(("+IDENTIFIER+"(\\."+IDENTIFIER+")*)\\.)?("+IDENTIFIER+")" + // class name // NOI18N
-        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" +IDENTIFIER+"\\.?("+IDENTIFIER+ // method and file name // NOI18N
-        ")\\:([0-9]*)\\)");                              // line number // NOI18N
+        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\s*"+ // method name
+        "\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?"+IDENTIFIER+"(\\.(?:\\p{javaJavaIdentifierPart}+))?"+ // '(File.java' // NOI18N
+        "\\:([0-9]*)\\)");                              // ':123)' // NOI18N

Review Comment:
   the original goal was to add a few optional `\\s*` but this does also include a fix for https://github.com/apache/netbeans/pull/6640/files#r1377502665, since this didn't work before as pointed out in the linked review.
   
   The file extension group is now optional `(\\.(?:\\p{javaJavaIdentifierPart}+))?`. Tests cover this now too now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Stacktrace analyzer window fixes [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6841:
URL: https://github.com/apache/netbeans/pull/6841#discussion_r1429059008


##########
java/java.navigation/src/org/netbeans/modules/java/stackanalyzer/StackLineAnalyser.java:
##########
@@ -57,11 +55,12 @@ class StackLineAnalyser {
     private static final String IDENTIFIER =
         "\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*";    // NOI18N
     private static final Pattern LINE_PATTERN = Pattern.compile(
-        "at\\s" +                                       //  initial at // NOI18N
+        "at\\s+" +                                       //  initial at // NOI18N
         "("+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" + // optional module name // NOI18N
         "(("+IDENTIFIER+"(\\."+IDENTIFIER+")*)\\.)?("+IDENTIFIER+")" + // class name // NOI18N
-        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?" +IDENTIFIER+"\\.?("+IDENTIFIER+ // method and file name // NOI18N
-        ")\\:([0-9]*)\\)");                              // line number // NOI18N
+        "\\.("+IDENTIFIER+"|\\<init\\>|\\<clinit\\>)\\s*"+ // method name
+        "\\((?:"+IDENTIFIER+"(?:\\."+IDENTIFIER+")*/)?"+IDENTIFIER+"(\\.(?:\\p{javaJavaIdentifierPart}+))?"+ // '(File.java' // NOI18N
+        "\\:([0-9]*)\\)");                              // ':123)' // NOI18N

Review Comment:
   the original goal was to add a few optional `\\s*` but this does also include a fix for https://github.com/apache/netbeans/pull/6640/files#r1377502665, since this didn't work before as pointed out in the linked review.
   
   The file extension group is now optional `(\\.(?:\\p{javaJavaIdentifierPart}+))?`. Tests cover this now too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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