我正在开发一个 eclipse-java 插件以编程方式将包含路径添加到项目中。我使用的代码部分如下。
String includePath = null;
ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(project, true);
ICConfigurationDescription configDecriptions[] = projectDescription.getConfigurations();
for (ICConfigurationDescription configDescription : configDecriptions) {
ICFolderDescription projectRoot = configDescription.getRootFolderDescription();
ICLanguageSetting[] settings = projectRoot.getLanguageSettings();
for (ICLanguageSetting setting : settings) {
if (!"org.eclipse.cdt.core.gcc".equals(setting.getLanguageId())) {
continue;
}
List<ICLanguageSettingEntry> includes = new ArrayList<ICLanguageSettingEntry>();
includes.addAll(setting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH));
for (int i = 0; i < tableViewer.getTable().getItemCount(); i++) {
includePath = tableViewer.getTable().getItem(i).getText();
includes.add(new CIncludePathEntry(includePath, ICSettingEntry.LOCAL));
}
setting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, includes);
}
}
CoreModel.getDefault().setProjectDescription(project, projectDescription);
当我打印从 ICLanguageSetting.getSettingEntries() 返回的值时,包含路径已成功添加。但它们不会反映在属性->C/C++General->Paths&Symbols 对话框或 Project Explorer 视图中。
我是否缺少任何 update() 或 refresh() ?