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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
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