1
votes

I am looking for a built-in feature or plugin for Eclipse to do the following:

  • Open Resource + Jump to Line (in one step)

Ideal would be to do this:

  • Open Resource (Ctrl+Shift+R)
  • Type: FileName:LineNumber (eg. test.html:50)

I know i can do it in 2 steps, but when copying "File:Line" from somewhere i need to paste it in "Open Resource", copy or memorize and delete the line-number, open the file and then invoke "Go to line" (Ctrl+L) and paste or type the line number and confirm. This is very complicated.

It would be great if the "Open resource" dialog could combine these steps.

Is there a built-in feature or plugin for Eclipse that can do this?

If not could anybody write such a plugin?

2

2 Answers

1
votes

You can use eclipse's 'Open from clipboard' navigation option. In Mac, the keyboard shortcut is Command+Shift+V. To use this option copy the java file and line number as it appears in the stackframe and press Command+Shift+V. The file should open at the specified line. You can change the keybinding in eclipse preferences

Read eclipse's documentation for navigation menu actions Open from clipboard :

Open from clipboard Tries to open the matching Java element in the editor if the clipboard contains a single line. Otherwise it opens the contents in the Java Stack Trace Console. Examples:

  • java.lang.String
  • String
  • String#getBytes
  • String.getBytes
  • java.lang.String.getBytes(String)
  • String.java:123
  • at java.lang.String.matches(String.java:1550)
  • java.lang.String.valueOf(char) line: 1456
  • currentTimeMillis()
1
votes

The Open Resource dialog does not have such feature. If you think this is a generally useful feature you should open an enhancement request

Writing an external plug-in that provides this feature would be hard as the Open Resource dialog isn't meant to be extended.

In the meanwhile you'd have to hit two more keys:

Ctrl+Shift+R test.html Return Ctrl+L 50 Return