问题
So, I am developing an Eclipse plugin and trying to build a View similiar to the Variables View. Now, to get the selected StackFrame from the Debug View, I have registered an IDebugContextListener, which ultimately calls the method listed below in case of a selection. The problem is that I ma unable to get a IStackFrame object from IStructuredSelection.getFirstElement(). I also tried to get an adapter for the IStackframe class. That too didn't work. I would really appreciate if someone can point me the method of getting a IStackFrame object from a selection.
private void contextActivated(ISelection context) {
if (context instanceof StructuredSelection) {
System.out.println("a");
Object data = ((StructuredSelection) context).getFirstElement();
if (data instanceof IStackFrame) {
System.out.println("yes");
} else {
System.out.println("no" + data.getClass().getName());
}
}
}
The issue with this is that it always execute the else part (even when the selection is a StackFrame in the debug view). Also, the adapter approach didn't work.
来源:https://stackoverflow.com/questions/36615273/eclipse-plugin-dev-extracting-istackframe-object-from-selection-in-debug-view