简体   繁体   English

Eclipse插件:如何在“调试”视图中激活终止按钮

[英]Eclipse plug-in: how to activate terminate button in Debug view

I am writing a plug-in to extend Eclipse for a custom programming language. 我正在编写一个插件来扩展Eclipse以使用自定义编程语言。 I have all the launch configuration working and any program in the custom language launches correctly but I cannot seem to activate the Terminate button in the Debug view. 我已经完成所有启动配置,并且使用自定义语言的任何程序都可以正确启动,但是似乎无法激活“调试”视图中的“终止”按钮。

From what I have researched, I know that implementing the Debugger framework provides for the Terminate action but say, I do not want to implement the framework at this stage and would just like to have the option of terminating the program instead of having to cancel via the Task Manager. 根据我的研究,我知道实现Debugger框架可以提供Terminate操作,但是我不想在此阶段实现该框架,而是希望选择终止程序,而不必通过任务管理器。 Is that possible to do? 那有可能吗? Or is the Debugger Framework the only way to do this? 还是调试器框架是执行此操作的唯一方法?

Here is the code from the LaunchConfigurationDelegate class, 这是LaunchConfigurationDelegate类的代码,

public void launch(ILaunchConfiguration configuration, String mode,
        ILaunch launch, IProgressMonitor monitor) throws CoreException {

    // getting the resource from the workspace
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();

    List<String> filenames = configuration.getAttribute(RELATIVE_PATH,
            Collections.EMPTY_LIST);
    List<String> rawPaths = configuration.getAttribute(RAW_PATH,
            Collections.EMPTY_LIST);
    List<String> projPaths = configuration.getAttribute(PROJECT_PATH,
            Collections.EMPTY_LIST);

    //CustomRunner is the interface to manage the custom language execution
    CustomRunner runner = null;
    try {
        CustomOutputHandler outHand = new CustomOutputHandler();
        runner = new CustomRunner(new File(projPaths.get(0)));
        runner.setOutputHandler(outHand);

        for (int i = 0; i < filenames.size(); i++) {
            IPath temp = new Path(filenames.get(i));
            IResource CustomFile = root.findMember(temp);

            if (CustomFile == null) {
                String msg = "The file "
                        + "<"
                        + temp.toString()
                        + ">"
                        + " could not be found in the workspace.\nIt may have been deleted or renamed.";
                throw new FileNotFoundException(msg);
            }
            CustomFile.deleteMarkers(IMarker.PROBLEM, false,
                    IResource.DEPTH_INFINITE);
            CustomErrorHandler errHand = new CustomErrorHandler(CustomFile);

            runner.setErrorHandler(errHand);

            //Runs the custom language file
            runner.run(rawPaths.get(i));
        }

After that there is just a bunch of catch blocks. 之后,只有一堆捕获块。

I need to be able to now terminate this launch via the Debug view and in the case of Run mode via the Run menu's terminate command. 现在,我需要能够通过“调试”视图终止启动,而在“运行”模式下,可以通过“运行”菜单的终止命令终止启动。

I do not have any DebugTarget right now at this stage. 我目前在此阶段没有任何DebugTarget。 And my question is: Is there another way to terminate this launch without extending the Debug Framework? 我的问题是:是否有另一种方法可以在不扩展调试框架的情况下终止启动?

I did try launch.Terminate() in this launch method but that did not work. 我确实尝试了这种启动方法中的launch.Terminate(),但是没有用。

Unless you extend the Platform-debug support you cannot hook into the Terminate button in the Debug view - at least there isn't an API for that. 除非您扩展Platform-debug支持,否则您将无法进入“调试”视图中的“终止”按钮-至少没有用于此的API。 You can hack into the internals of the debug framework to add support without extending, but extending might be lot easier than that and will work in the future versions of Eclipse 您可以侵入调试框架的内部以添加支持而无需扩展,但是扩展可能比这容易得多,并且可以在将来的Eclipse版本中使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM