不知道它是Eclipse還是Eclipse-plugin-dev的答案。Eclipse:已保存的LaunchConfiguration覆蓋LaunchType
在open-source Nodeclipse項目plugin.xml defines that .coffee file can be launched爲coffee
,coffee --compile
或Node with monitor
(有3 defined LaunchShortcuts)。
第一次工作正常,但後來發射只重複以前的LaunchType。我發現,刪除保存LaunchConfiguration(從運行 - >運行配置)會讓它再次(只此類型再然後)
有問題的代碼運行是LaunchShortcut(見下面的代碼段),但沒有任何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
}
幫助!代碼片段可能不足以回答問題,但引用文件和一切都在Github存儲庫中。提出了這個問題,因爲我不確定是否有可能爲同一個文件進行多次運行配置。那麼代碼片段根本就沒有關係。
更新:在plugin.xml defines that .coffee file can be launched後面看了一會兒,我發現我實際上在所有5種情況下都使用相同的<configurationType id= "org.nodeclipse.debug.launch.LaunchConfigurationType" >
。但是,爲每次啓動添加獨特的LaunchConfigurationType ID沒有任何區別。
你tryed什麼到現在?是否可以覆蓋默認啓動配置文件? –
你的意思是文件系統級別?找到Eclipse存儲數據的位置,並刪除這些文件?嗯...是的,這是主意。 –
問題刪除不會解決因爲有一個默認配置來重建他們的情況下刪除數據,我的意思是找到默認配置文件,並在其中進行更改,因此你不會失去數據文件已創建 –