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

Summary: Patch for: Open file from within string literals - plugin available
Product: java Reporter: markiewb
Component: EditorAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: normal CC: markiewb
Priority: P4 Keywords: PATCH_AVAILABLE
Version: 8.0   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Proposed patch
Patch in action

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