Re: [問題] 請問有沒有人用過CDT
原本Plug-ins會產生一個runtime-New_configuration資料夾,裡面會產生設定好的
.metadata資料夾 和 project 資料夾(也就是metadata area 和 data area)
我的想法是
以上的資料都先自動產生 ,然後 把要parse的c/c++程式檔 自動放在project裡
在電腦上的位置 去parse
public static IFile execute(){
IWorkspace ws = ResourcesPlugin.getWorkspace();
IProject[] ps = ws.getRoot().getProjects();
IFile ifile = null;
for(int i=0;i<ps.length;i++){
IProject p = ps[i]; //runtime-New_configuration底下的資料夾名稱
IPath location = p.getLocation();
ifile = p.getFile("SampleApp.bbcc"); //filename
}
return ifile;
}
public static void main(String[] args) {
IFile inputFile=execute();
......................
if (CoreModel.isTranslationUnit(inputFile)) {
.......
}
}
但是出現一個問題
Exception in thread "main" java.lang.IllegalStateException:
Workspace is closed.
at org.eclipse.core.resources.ResourcesPlugin.
getWorkspace(ResourcesPlugin.java:340)
at org.dworks.bbcdt.ui.action.main.execute(main.java:25)
at org.dworks.bbcdt.ui.action.main.main(main.java:50)
上網查了一下
好像 一定要run 插件
You have to run it from a run-time Eclipse/RCP application,
and do the work in one of the Eclipse-supported methods.
這行才能work IWorkspace ws = ResourcesPlugin.getWorkspace();
我的問題是
不能指定絕對路徑 去parse嗎?
EX:E:\\progSrc\runtime-New_configuration\project\file_name.bbcc 嗎?
--------------------------------------------------------------------------
public IFile execute(){
和以上相同....
ifile = p.getFile("SampleApp.bbcc");
.........
}
public void run(IAction action) {
...........以上相同
}
這樣可以不用在new 新的project和建新的file
把file放在runtime-New_configuration然後指定檔名,就可以parse。
但是目標是可以從main開啟
這只是我的想法~請大大幫我看~ 有甚麼問題~~
有沒有甚麼方法可以解決目前的問題,或者此路根本行不通,或者有別的看法~~
給我些建議或指引!!
謝謝大家!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.245.61
※ 編輯: ntouckcm 來自: 140.116.245.61 (04/15 20:37)
※ 編輯: ntouckcm 來自: 140.116.245.61 (04/15 20:50)
※ 編輯: ntouckcm 來自: 140.116.245.61 (04/15 20:55)
討論串 (同標題文章)
完整討論串 (本文為第 3 之 4 篇):