2013-10-03 121 views
1

不知道它是Eclipse還是Eclipse-plugin-dev的答案。Eclipse:已保存的LaunchConfiguration覆蓋LaunchType

open-source Nodeclipse項目plugin.xml defines that .coffee file can be launchedcoffeecoffee --compileNode 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沒有任何區別。

+0

你tryed什麼到現在?是否可以覆蓋默認啓動配置文件? –

+0

你的意思是文件系統級別?找到Eclipse存儲數據的位置,並刪除這些文件?嗯...是的,這是主意。 –

+0

問題刪除不會解決因爲有一個默認配置來重建他們的情況下刪除數據,我的意思是找到默認配置文件,並在其中進行更改,因此你不會失去數據文件已創建 –

回答

0

所以,我不知道如果我在你所有的問題了,但讓我看看,如果我可以幫你:

Basicly您可以創建與此啓動配置:

Creating a Java application launch configuration

啓動組也可以與此幫助setle:

Launch Group

直到這裏林prett你確定你有關於的知識,所以讓我們繼續前進;對於同一個文件,可以使用不同的啓動配置,使用啓動組工具進行處理,但是我不知道的是如果您希望針對相同環境使用不同的配置。

而且,這裏Launch Configuration Types這裏Adding launchers to the platform您CAND找到啓動類型文件的結構信息

要在這裏完成Interface ILaunchConfigurationTabGroup是啓動類型選項卡組的接口;

我的代碼行建議:

<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups"> 
    <launchConfigurationTabGroup 

     <"launchConfigurationType1" 

     <"/launchConfigurationType1"> 

      <"launchConfigurationType2" 

      <"/launchConfigurationType2"> 

     //and so on... 

    </launchConfigurationTabGroup> 
</extension> 

我希望這可以幫助您,或者至少打開你的心靈的東西,可以解決你的問題。)

歡呼

+0

這是我的plugin.xml https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.debug/plugin.xml 它爲.coffee定義了兩個啓動項,類似於.js但是在幾個plugin.xml文件中。 問題是Eclipse記住了第一次使用啓動時的情況,並忽略了之後使用的任何啓動。 –

+0

我還是不明白爲什麼打擾一切,我的意思是,如果你第一個文件的工作方式,你想要什麼問題呢?你需要改變它「dinamcally」(每次打開)?或者你想創建一個這樣的功能? –

+0

假設有Node.js應用程序的.js文件。 它們可以用'node'可執行文件或像'forever'這樣的監視器來運行 第一次啓動啓動類型後的問題是固定的。 或者思考一下可以與node,mozilla rhino,java 8 nashorn和其他JS引擎一起運行的.js文件。 –