我想在用户单击编辑器左侧垂直标尺上的标记时添加自定义操作
我设法通过添加来运行自定义操作plugin.xml
下面的代码:
<extension point="org.eclipse.ui.editorActions">
<editorContribution targetID="org.eclipse.cdt.ui.editor.CEditor"
id="org.eclipse.cdt.debug.ui.CEditor.MyRulerActions">
<action label="%Dummy.label"
class="com.example.MarkerClickAction"
actionID="RulerClick"
id="com.example.MarkerClickAction">
</action>
</editorContribution>
</extension>
我想调用一个自定义实现IQuickFixProcessor
,但是实现的方法getCorrections
需要一个IInvocationContext
and IProblemLocation[]
。
我怎样才能得到这些信息?
我想到的一个非常糟糕的实现是模拟Ctrl+1
按下快捷键,但如果插入符号未与单击的标记位于同一行,它将显示插入符号中的快速修复:
public class MarkerClickAction implements IEditorActionDelegate {
@Override
public void run(IAction action) {
Robot robot = null;
try {
robot = new Robot();
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_1);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_1);
}
@Override
public void selectionChanged(IAction action, ISelection selection) {
// TODO Auto-generated method stub
}
@Override
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
// TODO Auto-generated method stub
}
}
如果无法调用后面的方法Ctrl + 1
快捷方式,如何将插入符号定位到标记线?
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)