eclipsehyperlinkconsole

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


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

In Eclipse Console: myPackage.MyClass.myMethod

I want to click on the output (myPackage.MyClass.myMethod) in Console and it directly shows the corresponding method, similar to what happens for exception stack traces. Any Idea?


Solution

  • The hyperlinking for exception stack traces is based on the file name and line number given at the end of the line. E.g.

    Stack trace:
    
    org.eclipse.jface.internal.databinding.provisional.BindingException: string property does not have a read method.
    at org.eclipse.jface.internal.databinding.internal.beans.JavaBeanObservableValue.doGetValue(JavaBeanObservableValue.java:102)
    at org.eclipse.jface.internal.databinding.internal.beans.JavaBeanObservableValue.setValue(JavaBeanObservableValue.java:83)
    

    For the first stack trace, it is at line 102 in the file JavaBeanObservableValue.java. The file is searched after in the current class path so if you have multiple classes with the same name, the first is always found...

    With other words, if you want to add extended hyperlinking based on your example, you need to extend the console view a bit...

    ...which can be done with the org.eclipse.ui.console.consolePatternMatchListeners extension point. It is pretty easy to use this extension point and by looking at the example from JDT, you should be able to get your example to work without too much work...