【发布时间】:2013-10-03 10:53:05
【问题描述】:
不确定是 Eclipse 还是 Eclipse-plugin-dev 答案。
在open-source Nodeclipse 项目中plugin.xml defines that .coffee file can be launched 为coffee、coffee --compile 或Node with monitor(有3 defined LaunchShortcuts)。
第一次它工作正常,但随后的启动只重复以前的 LaunchType。我发现删除已保存的 LaunchConfiguration(从运行 -> 运行配置)将让它再次运行(然后仅作为这种类型再次运行)
有问题的代码是LaunchShortcut(参见下面的sn-p),但是没有任何if 检查,所以这个行为应该在Eclipse org.eclipse.debug 模块中更深入。
如何保存 LaunchConfiguration 覆盖 LaunchType ?
/**
* Launch an file,using the file information, which means using default
* launch configurations.
*
* @param file
* @param mode
*/
private void launchFile(IFile file, String mode) throws CoreException {
// check for an existing launch config for the file
String path = file.getFullPath().toString();
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(Constants.LAUNCH_CONFIGURATION_TYPE_ID);
ILaunchConfiguration configuration = createLaunchConfiguration(type, path, file);
DebugUITools.launch(configuration, mode);
// then execution goes in LaunchConfigurationDelegate.java launch() method
}
/**
* Create a new configuration and set useful data.
*
* @param type
* @param path
* @param file
* @return
* @throws CoreException
*/
private ILaunchConfiguration createLaunchConfiguration(ILaunchConfigurationType type, String path, IFile file) throws CoreException {
String configname = file.getFullPath().toString().replace('/', '-');
if(configname.startsWith("-")) {
configname = configname.substring(1);
}
ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type);
for(ILaunchConfiguration config : configs) {
if(configname.equals(config.getName())) {
return config;
}
}
// create a new configuration for the file
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, configname);
workingCopy.setAttribute(Constants.KEY_FILE_PATH, path);
setMoreAttributes(workingCopy);
return workingCopy.doSave();
}
protected void setMoreAttributes(ILaunchConfigurationWorkingCopy workingCopy) {
// stub for extension
}
帮助!代码 sn-p 可能不足以回答问题,但引用文件和所有内容都在 Github 存储库中。提出了这个问题,因为我不确定是否有可能为同一个文件设置多个运行配置。那么代码sn-ps就无所谓了。
更新:看了一段时间plugin.xml defines that .coffee file can be launched ,我注意到我实际上在所有 5 个案例中都使用了相同的 <configurationType
id= "org.nodeclipse.debug.launch.LaunchConfigurationType" >。但是,为每次启动添加唯一的 LaunchConfigurationType id 并没有什么区别。
【问题讨论】:
-
到目前为止您尝试过什么?是否可以选择覆盖默认启动配置文件?
-
你的意思是在文件系统级别?找到 Eclipse 存储这些数据的位置,然后删除这些文件?嗯...是的,这是个主意。
-
Problem delete 不会解决因为有一个默认配置可以在删除数据的情况下重建它们,我的意思是找到默认配置文件并在其中进行更改,因此您不会丢失数据 cos该文件已创建
-
我不清楚你到底是什么意思。您能否添加答案,以便讨论。
标签: java launch eclipse-plugin nodeclipse