This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 237902 - Patch for: Open file from within string literals - plugin available
Summary: Patch for: Open file from within string literals - plugin available
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P4 normal (vote)
Assignee: Dusan Balek
URL:
Keywords: PATCH_AVAILABLE
Depends on:
Blocks:
 
Reported: 2013-11-01 18:47 UTC by markiewb
Modified: 2016-07-16 10:13 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Proposed patch (14.76 KB, patch)
2013-11-01 19:49 UTC, markiewb
Details | Diff
Patch in action (23.60 KB, image/png)
2013-11-01 19:55 UTC, markiewb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description markiewb 2013-11-01 18:47:55 UTC
Usecase: Allow to open a file which is encoded within a string literal. Consider this example:

package com.toy.anagrams.lib;

public class NewMain {

    public static void main(String[] args) {
        System.out.println("filename = " + "com/toy/anagrams/lib/WordLibrary.java");
    }
}
When I (CTRL-)hover above the literal "com/..." and the file path defined by the literal exists then allow me to open that file in the editor.

Note: I have seen this feature in Intellij IDEA and there is also an eclipse plugin [1], which provides this feature.



[1] http://andrei.gmxhome.de/anyedit/ (Eclipse plugin)
Comment 1 markiewb 2013-11-01 19:49:37 UTC
Created attachment 141787 [details]
Proposed patch

@Dusan: I like to propose a patch for this RFE. Please review.

The patch contains a "simple" hyperlink provider which is responsible to get the path out of a string literal and to open the respective file. When there are no matching files (File.exists) then no hyperlink is produced. When there are multiple matches a dialog pops up which asks the user to choose a file to open.

Some open issues
* cache the results for the same path, because checking for existence is an IO-operation
* replace the popup dialog with floating listbox like "Open implementations"
Comment 2 markiewb 2013-11-01 19:55:14 UTC
Created attachment 141788 [details]
Patch in action
Comment 3 markiewb 2013-11-01 21:00:44 UTC
(In reply to markiewb from comment #1)
> 
> Some open issues
* i had to add a dependency to org.netbeans.modules.java.project to get access the constants for the source root query
Comment 4 markiewb 2013-12-18 23:43:56 UTC
FYI: I created a separate plugin to provide this feature

http://plugins.netbeans.org/plugin/52349/?show=true
Comment 5 markiewb 2014-07-06 00:05:52 UTC
Lowering the prio to P4, because my plugin works as expected