How to get Eclipse Console to hyperlink text to source code files?

前端 未结 7 1820
生来不讨喜
生来不讨喜 2020-12-09 10:37

In Code: System.out.println(\"myPackage.MyClass\");

In Eclipse Console: myPackage.MyClass.myMethod

I want to click on the output (myPackage.MyClass.myM

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 11:34

    Maybe this is clear to other people, but I found the other answers confusing, although correct. The eclipse console parses the pattern (FileName.java:lineNumber) to be a link to that line in that file:

    (MyFile.java:2)
    

    As the other answers point out, there are many ways to output this to the console. Location in the line does not matter, it is just a pattern match. As Colin Smith shows, log4j PatternLayout can use (%F:%L) to get the file name and line number. To get the file name and line number programmatically see this question.

    The question asks about linking to a method and I believe you could use the consolePatternMatchListeners method recommended by Tonny Madsen and described in more detail in this question.

提交回复
热议问题