From b04a172c1abf46384926e72ef379a81a726d44c4 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Mon, 5 Dec 2011 11:31:38 -0500 Subject: [PATCH] ILanguageSettingsProvidersKeeper --- .../core/ExternalBuildRunner.java | 45 +-- .../core/InternalBuildRunner.java | 26 +- .../ui/wizards/MBSWizardHandler.java | 266 +++++++------ .../ui/wizards/NewMakeProjFromExisting.java | 21 +- .../ui/wizards/STDWizardHandler.java | 39 +- .../LanguageSettingsListenersTests.java | 128 +++--- .../LanguageSettingsManagerTests.java | 34 +- ...nguageSettingsPersistenceProjectTests.java | 150 +++++-- ...guageSettingsScannerInfoProviderTests.java | 50 ++- .../model/CProjectDescriptionDeltaTests.java | 373 +++++++++--------- .../index/tests/IndexProviderManagerTest.java | 156 +++++--- .../cdt/core/testplugin/CModelMock.java | 96 ++++- .../ILanguageSettingsProvidersKeeper.java | 46 +++ .../LanguageSettingsManager_TBD.java | 25 +- .../ScannerDiscoveryLegacySupport.java | 10 +- .../model/ICConfigurationDescription.java | 29 -- .../LanguageSettingsProvidersSerializer.java | 82 ++-- .../model/CConfigurationDescription.java | 4 +- .../model/CConfigurationDescriptionCache.java | 3 +- .../model/CProjectDescriptionManager.java | 11 +- .../model/MultiConfigDescription.java | 15 - .../providers/LanguageSettingsEntriesTab.java | 35 +- .../LanguageSettingsProviderTab.java | 106 ++--- 23 files changed, 1034 insertions(+), 716 deletions(-) create mode 100644 core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java index 36e2fb59281..4e61b502624 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java @@ -32,15 +32,14 @@ import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.RefreshScopeManager; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; -import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser; @@ -126,7 +125,7 @@ public class ExternalBuildRunner extends AbstractBuildRunner { if(pathFromURI == null) { throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, ManagedMakeMessages.getString("ManagedMakeBuilder.message.error"), null)); //$NON-NLS-1$ } - + IPath workingDirectory = new Path(pathFromURI); // Set the environment @@ -211,10 +210,10 @@ public class ExternalBuildRunner extends AbstractBuildRunner { // Do not allow the cancel of the refresh, since the builder is external // to Eclipse, files may have been created/modified and we will be out-of-sync. // The caveat is for huge projects, it may take sometimes at every build. - + // TODO should only refresh output folders //project.refreshLocal(IResource.DEPTH_INFINITE, null); - + // use the refresh scope manager to refresh RefreshScopeManager refreshManager = RefreshScopeManager.getInstance(); IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project); @@ -247,7 +246,7 @@ public class ExternalBuildRunner extends AbstractBuildRunner { consoleErr.write(buf.toString().getBytes()); consoleErr.flush(); } - + buf = new StringBuffer(NEWLINE); buf.append(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.build.finished")).append(NEWLINE); //$NON-NLS-1$ consoleOut.write(buf.toString().getBytes()); @@ -324,15 +323,15 @@ public class ExternalBuildRunner extends AbstractBuildRunner { envMap.put(var.getName(), var.getValue()); } } - + // Add variables from build info Map builderEnv = builder.getExpandedEnvironment(); if (builderEnv != null) envMap.putAll(builderEnv); - + return envMap; } - + protected static String[] getEnvStrings(Map env) { // Convert into env strings List strings= new ArrayList(env.size()); @@ -341,10 +340,10 @@ public class ExternalBuildRunner extends AbstractBuildRunner { buffer.append('=').append(entry.getValue()); strings.add(buffer.toString()); } - + return strings.toArray(new String[strings.size()]); } - + private ConsoleOutputSniffer createBuildOutputSniffer(OutputStream outputStream, OutputStream errorStream, IProject project, @@ -386,17 +385,19 @@ public class ExternalBuildRunner extends AbstractBuildRunner { } ICConfigurationDescription cfgDescription = ManagedBuildManager.getDescriptionForConfiguration(cfg); - List lsProviders = cfgDescription.getLanguageSettingProviders(); - for (ILanguageSettingsProvider lsProvider : lsProviders) { - ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(lsProvider); - if (rawProvider instanceof ICConsoleParser) { - ICConsoleParser consoleParser = (ICConsoleParser) rawProvider; - try { - consoleParser.startup(cfgDescription); - clParserList.add(consoleParser); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + for (ILanguageSettingsProvider lsProvider : lsProviders) { + ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(lsProvider); + if (rawProvider instanceof ICConsoleParser) { + ICConsoleParser consoleParser = (ICConsoleParser) rawProvider; + try { + consoleParser.startup(cfgDescription); + clParserList.add(consoleParser); + } catch (CoreException e) { + ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, + "Language Settings Provider failed to start up", e)); //$NON-NLS-1$ + } } } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java index 0efc2b6724f..84c0d9c7d2b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java @@ -18,16 +18,14 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.make.core.scannerconfig.AbstractBuildCommandParser; import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription; @@ -52,7 +50,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; /** * The build runner for the internal builder. - * + * * @author dschaefer * @since 8.0 */ @@ -160,16 +158,18 @@ public class InternalBuildRunner extends AbstractBuildRunner { if (kind!=IncrementalProjectBuilder.CLEAN_BUILD) { // TODO - AG - sanity check? elaborate ICConfigurationDescription cfgDescription = ManagedBuildManager.getDescriptionForConfiguration(configuration); - List providers = cfgDescription.getLanguageSettingProviders(); - for (ILanguageSettingsProvider provider : providers) { - if (provider instanceof AbstractBuildCommandParser) { - buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ - String msg = ManagedMakeMessages.getFormattedString("BOP Language Settings Provider [{0}] is not supported by Internal Builder.", provider.getName()); - buf.append("**** "+msg+" ****"); - buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ - buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + for (ILanguageSettingsProvider provider : providers) { + if (provider instanceof AbstractBuildCommandParser) { + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ + String msg = ManagedMakeMessages.getFormattedString("BOP Language Settings Provider [{0}] is not supported by Internal Builder.", provider.getName()); + buf.append("**** "+msg+" ****"); + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ - ManagedBuilderCorePlugin.error(msg); + ManagedBuilderCorePlugin.error(msg); + } } } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java index 1e3214e6d37..e8f532e79c6 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java @@ -23,8 +23,8 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.TreeSet; -import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; import org.eclipse.cdt.core.model.CoreModel; @@ -77,10 +77,10 @@ import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; /** * This object is created per each Project type - * + * * It is responsible for: * - corresponding line in left pane of 1st wizard page - * - whole view of right pane, including + * - whole view of right pane, including * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. @@ -88,16 +88,16 @@ import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; public class MBSWizardHandler extends CWizardHandler { public static final String ARTIFACT = "org.eclipse.cdt.build.core.buildArtefactType"; //$NON-NLS-1$ public static final String EMPTY_STR = ""; //$NON-NLS-1$ - + private static final String PROPERTY = "org.eclipse.cdt.build.core.buildType"; //$NON-NLS-1$ private static final String PROP_VAL = PROPERTY + ".debug"; //$NON-NLS-1$ - private static final String tooltip = - Messages.CWizardHandler_1 + - Messages.CWizardHandler_2 + - Messages.CWizardHandler_3 + - Messages.CWizardHandler_4 + - Messages.CWizardHandler_5; - + private static final String tooltip = + Messages.CWizardHandler_1 + + Messages.CWizardHandler_2 + + Messages.CWizardHandler_3 + + Messages.CWizardHandler_4 + + Messages.CWizardHandler_5; + protected SortedMap full_tcs = new TreeMap(); private String propertyId = null; private IProjectType pt = null; @@ -110,12 +110,12 @@ public class MBSWizardHandler extends CWizardHandler { private EntryInfo entryInfo; protected CfgHolder[] cfgs = null; protected IWizardPage[] customPages; - + /** * Current list of preferred toolchains */ private List preferredTCs = new ArrayList(); - + protected static final class EntryInfo { private SortedMap tcs; private EntryDescriptor entryDescriptor; @@ -128,12 +128,12 @@ public class MBSWizardHandler extends CWizardHandler { private IWizardPage predatingPage; private IWizardPage followingPage; private IWizard wizard; - + public EntryInfo(EntryDescriptor dr, SortedMap _tcs){ entryDescriptor = dr; tcs = _tcs; } - + /** * @since 5.1 */ @@ -141,7 +141,7 @@ public class MBSWizardHandler extends CWizardHandler { this(dr, _tcs); wizard = w; } - + public boolean isValid(){ initialize(); return isValid; @@ -151,7 +151,7 @@ public class MBSWizardHandler extends CWizardHandler { initialize(); return template; } - + public EntryDescriptor getDescriptor(){ return entryDescriptor; } @@ -159,19 +159,19 @@ public class MBSWizardHandler extends CWizardHandler { private void initialize(){ if(initialized) return; - + do { if(entryDescriptor == null) break; String path[] = entryDescriptor.getPathArray(); if(path == null || path.length == 0) break; - + projectTypeId = path[0]; - if(!entryDescriptor.isDefaultForCategory() && + if(!entryDescriptor.isDefaultForCategory() && path.length > 1 && (!path[0].equals(ManagedBuildWizard.OTHERS_LABEL))){ - templateId = path[path.length - 1]; - Template templates[] = null; + templateId = path[path.length - 1]; + Template templates[] = null; if(wizard instanceof ICDTCommonProjectWizard) { ICDTCommonProjectWizard wz = (ICDTCommonProjectWizard)wizard; String[] langIDs = wz.getLanguageIDs(); @@ -180,38 +180,38 @@ public class MBSWizardHandler extends CWizardHandler { for (String id : langIDs) { lstTemplates.addAll(Arrays.asList(TemplateEngineUI.getDefault(). getTemplates(projectTypeId, null, id))); - } + } templates = lstTemplates.toArray(new Template[lstTemplates.size()]); } - } + } if(null == templates) { templates = TemplateEngineUI.getDefault().getTemplates(projectTypeId); } if((null == templates) || (templates.length == 0)) break; - + for (Template t : templates) { if(t.getTemplateId().equals(templateId)){ template = t; break; } } - + if(template == null) break; } - + isValid = true; } while(false); initialized = true; } - + public Template getInitializedTemplate(IWizardPage predatingPage, IWizardPage followingPage, Map map){ getNextPage(predatingPage, followingPage); - + Template template = getTemplate(); - + if(template != null){ Map valueStore = template.getValueStore(); // valueStore.clear(); @@ -227,11 +227,11 @@ public class MBSWizardHandler extends CWizardHandler { } return template; } - + public IWizardPage getNextPage(IWizardPage predatingPage, IWizardPage followingPage) { initialize(); - if(this.templatePages == null - || this.predatingPage != predatingPage + if(this.templatePages == null + || this.predatingPage != predatingPage || this.followingPage != followingPage){ this.predatingPage = predatingPage; this.followingPage = followingPage; @@ -242,12 +242,12 @@ public class MBSWizardHandler extends CWizardHandler { followingPage.setPreviousPage(predatingPage); } } - + if(templatePages.length != 0) return templatePages[0]; return followingPage; } - + private boolean canFinish(IWizardPage predatingPage, IWizardPage followingPage){ getNextPage(predatingPage, followingPage); for(int i = 0; i < templatePages.length; i++){ @@ -256,47 +256,47 @@ public class MBSWizardHandler extends CWizardHandler { } return true; } - + /** - * Filters toolchains - * + * Filters toolchains + * * @return - set of compatible toolchain's IDs */ protected Set tc_filter() { Set full = tcs.keySet(); - if (entryDescriptor == null) + if (entryDescriptor == null) return full; Set out = new LinkedHashSet(full.size()); for (String s : full) - if (isToolChainAcceptable(s)) + if (isToolChainAcceptable(s)) out.add(s); return out; } /** * Checks whether given toolchain can be displayed - * + * * @param tcId - toolchain _NAME_ to check * @return - true if toolchain can be displayed */ public boolean isToolChainAcceptable(String tcId) { - if (template == null || template.getTemplateInfo() == null) + if (template == null || template.getTemplateInfo() == null) return true; - + String[] toolChainIds = template.getTemplateInfo().getToolChainIds(); - if (toolChainIds == null || toolChainIds.length == 0) + if (toolChainIds == null || toolChainIds.length == 0) return true; - + Object ob = tcs.get(tcId); if (ob == null) return true; // sic ! This can occur with Other Toolchain only if (!(ob instanceof IToolChain)) return false; - + String id1 = ((IToolChain)ob).getId(); IToolChain sup = ((IToolChain)ob).getSuperClass(); String id2 = sup == null ? null : sup.getId(); - + for (String id : toolChainIds) { if ((id != null && id.equals(id1)) || (id != null && id.equals(id2))) @@ -309,20 +309,20 @@ public class MBSWizardHandler extends CWizardHandler { return tc_filter().size(); } } - + public MBSWizardHandler(IProjectType _pt, Composite p, IWizard w) { - super(p, Messages.CWizardHandler_0, _pt.getName()); + super(p, Messages.CWizardHandler_0, _pt.getName()); pt = _pt; setWizard(w); } public MBSWizardHandler(String name, Composite p, IWizard w) { - super(p, Messages.CWizardHandler_0, name); + super(p, Messages.CWizardHandler_0, name); setWizard(w); } public MBSWizardHandler(IBuildPropertyValue val, Composite p, IWizard w) { - super(p, Messages.CWizardHandler_0, val.getName()); + super(p, Messages.CWizardHandler_0, val.getName()); propertyId = val.getId(); setWizard(w); } @@ -334,16 +334,16 @@ public class MBSWizardHandler extends CWizardHandler { startingPage = w.getStartingPage(); } } - + protected IWizardPage getStartingPage(){ return startingPage; } - + public Map getMainPageData() { WizardNewProjectCreationPage page = (WizardNewProjectCreationPage)getStartingPage(); Map data = new HashMap(); String projName = page.getProjectName(); - projName = projName != null ? projName.trim() : EMPTY_STR; + projName = projName != null ? projName.trim() : EMPTY_STR; data.put("projectName", projName); //$NON-NLS-1$ data.put("baseName", getBaseName(projName)); //$NON-NLS-1$ data.put("baseNameUpper", getBaseName(projName).toUpperCase() ); //$NON-NLS-1$ @@ -354,7 +354,7 @@ public class MBSWizardHandler extends CWizardHandler { data.put("location", location); //getProjectLocation().toPortableString()); //$NON-NLS-1$ return data; } - + private String getBaseName(String name) { String baseName = name; int dot = baseName.lastIndexOf('.'); @@ -367,11 +367,11 @@ public class MBSWizardHandler extends CWizardHandler { } return baseName; } - + @Override public void handleSelection() { List preferred = CDTPrefUtil.getPreferredTCs(); - + if (table == null) { table = new Table(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); table.getAccessible().addAccessibleListener( @@ -404,7 +404,7 @@ public class MBSWizardHandler extends CWizardHandler { counter++; } if (counter > 0) table.select(position); - } + } table.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -425,11 +425,11 @@ public class MBSWizardHandler extends CWizardHandler { if (listener != null) listener.toolChainListChanged(table.getSelectionCount()); } - + private void loadCustomPages() { - if (! (getWizard() instanceof ICDTCommonProjectWizard)) - return; // not probable - + if (! (getWizard() instanceof ICDTCommonProjectWizard)) + return; // not probable + ICDTCommonProjectWizard wz = (ICDTCommonProjectWizard)getWizard(); MBSCustomPageManager.init(); MBSCustomPageManager.addStockPage(getStartingPage(), CDTMainWizardPage.PAGE_ID); @@ -442,9 +442,9 @@ public class MBSWizardHandler extends CWizardHandler { customPages = MBSCustomPageManager.getCustomPages(); - if (customPages == null) + if (customPages == null) customPages = new IWizardPage[0]; - + for (IWizardPage customPage : customPages) customPage.setWizard(wz); setCustomPagesFilter(wz); @@ -467,13 +467,13 @@ public class MBSWizardHandler extends CWizardHandler { boolean ptIsNull = (getProjectType() == null); if (!ptIsNull) MBSCustomPageManager.addPageProperty( - MBSCustomPageManager.PAGE_ID, - MBSCustomPageManager.PROJECT_TYPE, + MBSCustomPageManager.PAGE_ID, + MBSCustomPageManager.PROJECT_TYPE, getProjectType().getId() ); IToolChain[] tcs = getSelectedToolChains(); - ArrayList x = new ArrayList(); + ArrayList x = new ArrayList(); TreeSet y = new TreeSet(); if (tcs!=null) { int n = tcs.length; @@ -481,7 +481,7 @@ public class MBSWizardHandler extends CWizardHandler { if (tcs[i] == null) // --- NO TOOLCHAIN --- continue; // has no custom pages. x.add(tcs[i]); - + IConfiguration cfg = tcs[i].getParent(); if (cfg == null) continue; @@ -491,24 +491,24 @@ public class MBSWizardHandler extends CWizardHandler { } } MBSCustomPageManager.addPageProperty( - MBSCustomPageManager.PAGE_ID, - MBSCustomPageManager.TOOLCHAIN, + MBSCustomPageManager.PAGE_ID, + MBSCustomPageManager.TOOLCHAIN, x); - + if (ptIsNull) { if (y.size() > 0) MBSCustomPageManager.addPageProperty( - MBSCustomPageManager.PAGE_ID, - MBSCustomPageManager.PROJECT_TYPE, + MBSCustomPageManager.PAGE_ID, + MBSCustomPageManager.PROJECT_TYPE, y); else MBSCustomPageManager.addPageProperty( - MBSCustomPageManager.PAGE_ID, - MBSCustomPageManager.PROJECT_TYPE, + MBSCustomPageManager.PAGE_ID, + MBSCustomPageManager.PROJECT_TYPE, null); } } - + @Override public void handleUnSelection() { if (table != null) { @@ -521,16 +521,16 @@ public class MBSWizardHandler extends CWizardHandler { if (tc.isAbstract() || tc.isSystemObject()) return; IConfiguration[] cfgs = null; // New style managed project type. Configurations are referenced via propertyId. - if (propertyId != null) { + if (propertyId != null) { cfgs = ManagedBuildManager.getExtensionConfigurations(tc, ARTIFACT, propertyId); // Old style managewd project type. Configs are obtained via projectType } else if (pt != null) { cfgs = ManagedBuildManager.getExtensionConfigurations(tc, pt); - } + } if (cfgs == null || cfgs.length == 0) return; full_tcs.put(tc.getUniqueRealName(), tc); } - + @Override public void createProject(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor) throws CoreException { try { @@ -548,7 +548,7 @@ public class MBSWizardHandler extends CWizardHandler { public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException { setProjectDescription(proj, true, true, monitor); } - + private void setProjectDescription(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor) throws CoreException { boolean isTryingNewSD = false; IWizardPage page = getStartingPage(); @@ -562,13 +562,13 @@ public class MBSWizardHandler extends CWizardHandler { ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project); monitor.worked(10); cfgs = getCfgItems(false); - if (cfgs == null || cfgs.length == 0) + if (cfgs == null || cfgs.length == 0) cfgs = CDTConfigWizardPage.getDefaultCfgs(this); - + if (cfgs == null || cfgs.length == 0 || cfgs[0].getConfiguration() == null) { - throw new CoreException(new Status(IStatus.ERROR, + throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderUIPlugin.getUniqueIdentifier(), - Messages.CWizardHandler_6)); + Messages.CWizardHandler_6)); } Configuration cf = (Configuration)cfgs[0].getConfiguration(); ManagedProject mProj = new ManagedProject(project, cf.getProjectType()); @@ -576,12 +576,12 @@ public class MBSWizardHandler extends CWizardHandler { monitor.worked(10); cfgs = CfgHolder.unique(cfgs); cfgs = CfgHolder.reorder(cfgs); - + ICConfigurationDescription cfgDebug = null; ICConfigurationDescription cfgFirst = null; - + int work = 50/cfgs.length; - + for (CfgHolder cfg : cfgs) { cf = (Configuration)cfg.getConfiguration(); String id = ManagedBuildManager.calculateChildId(cf.getId(), null); @@ -593,44 +593,48 @@ public class MBSWizardHandler extends CWizardHandler { IBuilder bld = config.getEditableBuilder(); if (bld != null) { bld.setManagedBuildOn(true); } - + config.setName(cfg.getName()); config.setArtifactName(mProj.getDefaultArtifactName()); - + IBuildProperty b = config.getBuildProperties().getProperty(PROPERTY); if (cfgDebug == null && b != null && b.getValue() != null && PROP_VAL.equals(b.getValue().getId())) cfgDebug = cfgDes; - if (cfgFirst == null) // select at least first configuration - cfgFirst = cfgDes; + if (cfgFirst == null) // select at least first configuration + cfgFirst = cfgDes; - ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD); - if (isTryingNewSD) { - List providers = ManagedBuildManager.getLanguageSettingsProviders(config); - cfgDes.setLanguageSettingProviders(providers); + if (cfgDes instanceof ILanguageSettingsProvidersKeeper) { + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD); + if (isTryingNewSD) { + List providers = ManagedBuildManager.getLanguageSettingsProviders(config); + ((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers); + } else { + ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ManagedBuildManager.MBS_LANGUAGE_SETTINGS_PROVIDER); + List providers = new ArrayList(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers); + } } else { - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ManagedBuildManager.MBS_LANGUAGE_SETTINGS_PROVIDER); - List providers = new ArrayList(); - providers.add(provider); - cfgDes.setLanguageSettingProviders(providers); + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false); } monitor.worked(work); } mngr.setProjectDescription(project, des); } - + @Override protected void doTemplatesPostProcess(IProject prj) { if(entryInfo == null) return; - + Template template = entryInfo.getInitializedTemplate(getStartingPage(), getConfigPage(), getMainPageData()); if(template == null) return; List configs = new ArrayList(); for (CfgHolder cfg : cfgs) { - configs.add((IConfiguration)cfg.getConfiguration()); + configs.add(cfg.getConfiguration()); } template.getTemplateInfo().setConfigurations(configs); @@ -639,19 +643,19 @@ public class MBSWizardHandler extends CWizardHandler { TemplateEngineUIUtil.showError(statuses[0].getMessage(), statuses[0].getException()); } } - + protected CDTConfigWizardPage getConfigPage() { if (fConfigPage == null) { fConfigPage = new CDTConfigWizardPage(this); } return fConfigPage; } - + @Override public IWizardPage getSpecificPage() { return entryInfo.getNextPage(getStartingPage(), getConfigPage()); } - + /** * Mark preferred toolchains with specific images */ @@ -670,11 +674,11 @@ public class MBSWizardHandler extends CWizardHandler { } } } - + public List getPreferredTCNames() { return preferredTCs; } - + @Override public String getHeader() { return head; } public boolean isDummy() { return false; } @@ -682,11 +686,11 @@ public class MBSWizardHandler extends CWizardHandler { public boolean supportsPreferred() { return true; } @Override - public boolean isChanged() { + public boolean isChanged() { if (savedToolChains == null) return true; IToolChain[] tcs = getSelectedToolChains(); - if (savedToolChains.length != tcs.length) + if (savedToolChains.length != tcs.length) return true; for (IToolChain savedToolChain : savedToolChains) { boolean found = false; @@ -701,12 +705,12 @@ public class MBSWizardHandler extends CWizardHandler { } return false; } - + @Override public void saveState() { savedToolChains = getSelectedToolChains(); } - + // Methods specific for MBSWizardHandler public IToolChain[] getSelectedToolChains() { @@ -722,7 +726,7 @@ public class MBSWizardHandler extends CWizardHandler { public int getToolChainsCount() { if (entryInfo == null) return full_tcs.size(); - else + else return entryInfo.tc_filter().size(); } public String getPropertyId() { @@ -739,13 +743,13 @@ public class MBSWizardHandler extends CWizardHandler { return fConfigPage.getCfgItems(defaults); } @Override - public String getErrorMessage() { + public String getErrorMessage() { TableItem[] tis = table.getSelection(); if (tis == null || tis.length == 0) - return Messages.MBSWizardHandler_0; + return Messages.MBSWizardHandler_0; return null; } - + @Override protected void doCustom(IProject newProject) { IRunnableWithProgress[] operations = MBSCustomPageManager.getOperations(); @@ -759,7 +763,7 @@ public class MBSWizardHandler extends CWizardHandler { ManagedBuilderUIPlugin.log(e); } } - + @Override public void postProcess(IProject newProject, boolean created) { deleteExtraConfigs(newProject); @@ -770,17 +774,17 @@ public class MBSWizardHandler extends CWizardHandler { doCustom(newProject); } } - + /** - * Deletes configurations - * + * Deletes configurations + * * @param newProject - affected project */ private void deleteExtraConfigs(IProject newProject) { - if (isChanged()) return; // no need to delete + if (isChanged()) return; // no need to delete if (listener != null && listener.isCurrent()) return; // nothing to delete if (fConfigPage == null || !fConfigPage.pagesLoaded) return; - + ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(newProject, true); if (prjd == null) return; ICConfigurationDescription[] all = prjd.getConfigurations(); @@ -804,19 +808,19 @@ public class MBSWizardHandler extends CWizardHandler { CoreModel.getDefault().setProjectDescription(newProject, prjd); } catch (CoreException e) {} } - + @Override - public boolean isApplicable(EntryDescriptor data) { + public boolean isApplicable(EntryDescriptor data) { EntryInfo info = new EntryInfo(data, full_tcs, wizard); return info.isValid() && (info.getToolChainsCount() > 0); } - + @Override public void initialize(EntryDescriptor data) throws CoreException { EntryInfo info = new EntryInfo(data, full_tcs, wizard); if(!info.isValid()) throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderUIPlugin.getUniqueIdentifier(), "inappropriate descriptor")); //$NON-NLS-1$ - + entryInfo = info; } @@ -842,20 +846,20 @@ public class MBSWizardHandler extends CWizardHandler { public boolean canFinish() { if(entryInfo == null) return false; - + if (!getConfigPage().isCustomPageComplete()) return false; - + if(!entryInfo.canFinish(startingPage, getConfigPage())) return false; - + if (customPages != null) for (int i=0; i providers = ManagedBuildManager.getLanguageSettingsProviders(config); - cfgDes.setLanguageSettingProviders(providers); + if (cfgDes instanceof ILanguageSettingsProvidersKeeper) { + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD); + if (isTryingNewSD) { + List providers = ManagedBuildManager.getLanguageSettingsProviders(config); + ((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers); + } else { + ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ManagedBuildManager.MBS_LANGUAGE_SETTINGS_PROVIDER); + List providers = new ArrayList(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers); + } } else { - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ManagedBuildManager.MBS_LANGUAGE_SETTINGS_PROVIDER); - List providers = new ArrayList(); - providers.add(provider); - cfgDes.setLanguageSettingProviders(providers); + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false); } monitor.worked(1); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/STDWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/STDWizardHandler.java index cb515055f89..6ac895391ed 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/STDWizardHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/STDWizardHandler.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; import org.eclipse.cdt.core.model.CoreModel; @@ -46,13 +47,13 @@ import org.eclipse.swt.widgets.Composite; public class STDWizardHandler extends MBSWizardHandler { public STDWizardHandler(Composite p, IWizard w) { - super(Messages.StdBuildWizard_0, p, w); + super(Messages.StdBuildWizard_0, p, w); } @Override public void addTc(IToolChain tc) { if (tc == null) { - full_tcs.put(Messages.StdProjectTypeHandler_0, null); + full_tcs.put(Messages.StdProjectTypeHandler_0, null); } else { if (tc.isAbstract() || tc.isSystemObject()) return; // unlike CWizardHandler, we don't check for configs @@ -67,9 +68,9 @@ public class STDWizardHandler extends MBSWizardHandler { public void createProject(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor) throws CoreException { try { monitor.beginTask("", 100);//$NON-NLS-1$ - + setProjectDescription(project, defaults, onFinish, monitor); - + doTemplatesPostProcess(project); doCustom(project); monitor.worked(30); @@ -112,40 +113,44 @@ public class STDWizardHandler extends MBSWizardHandler { } bld.setManagedBuildOn(false); } else { - System.out.println(Messages.StdProjectTypeHandler_3); + System.out.println(Messages.StdProjectTypeHandler_3); } cfg.setArtifactName(mProj.getDefaultArtifactName()); CConfigurationData data = cfg.getConfigurationData(); ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); - ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD); - if (isTryingNewSD) { - List providers = ManagedBuildManager.getLanguageSettingsProviders(cfg); - cfgDes.setLanguageSettingProviders(providers); + if (cfgDes instanceof ILanguageSettingsProvidersKeeper) { + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD); + if (isTryingNewSD) { + List providers = ManagedBuildManager.getLanguageSettingsProviders(cfg); + ((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers); + } else { + ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ManagedBuildManager.MBS_LANGUAGE_SETTINGS_PROVIDER); + List providers = new ArrayList(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers); + } } else { - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ManagedBuildManager.MBS_LANGUAGE_SETTINGS_PROVIDER); - List providers = new ArrayList(); - providers.add(provider); - cfgDes.setLanguageSettingProviders(providers); + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false); } monitor.worked(work); } mngr.setProjectDescription(project, des); } - public boolean canCreateWithoutToolchain() { return true; } - + public boolean canCreateWithoutToolchain() { return true; } + @Override public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException { setProjectDescription(proj, true, true, monitor); } - + /** * If no toolchains selected by user, use default toolchain */ @Override public IToolChain[] getSelectedToolChains() { - if (full_tcs.size() == 0 || table.getSelection().length == 0) + if (full_tcs.size() == 0 || table.getSelection().length == 0) return new IToolChain[] { null }; else return super.getSelectedToolChains(); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java index 0ccb02d6603..922cf8e2ed9 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java @@ -124,13 +124,14 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create a provider ILanguageSettingsProvider mockProvider = new MockListenerRegisterer(PROVIDER_1, PROVIDER_NAME_1); List providers = new ArrayList(); providers.add(mockProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -170,14 +171,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase { assertEquals(2, cfgDescriptions.length); ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; + assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); + assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); { // create a provider 1 ILanguageSettingsProvider mockProvider = new MockListenerRegisterer(PROVIDER_1, PROVIDER_NAME_1); List providers = new ArrayList(); providers.add(mockProvider); - cfgDescription1.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription1.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } { @@ -185,8 +188,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ILanguageSettingsProvider mockProvider = new MockListenerRegisterer(PROVIDER_1, PROVIDER_NAME_1); List providers = new ArrayList(); providers.add(mockProvider); - cfgDescription2.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription2.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } @@ -222,13 +225,14 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // add global provider ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); List providers = new ArrayList(); providers.add(workspaceProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -270,21 +274,23 @@ public class LanguageSettingsListenersTests extends BaseTestCase { assertEquals(2, cfgDescriptions.length); ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; + assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); + assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); { // add global provider to configuration 1 List providers = new ArrayList(); providers.add(workspaceProvider); - cfgDescription1.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription1.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } { // add global provider to configuration 2 List providers = new ArrayList(); providers.add(workspaceProvider); - cfgDescription2.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription2.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } // write to project description @@ -325,21 +331,23 @@ public class LanguageSettingsListenersTests extends BaseTestCase { assertEquals(2, cfgDescriptions.length); ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; + assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); + assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); { // add global provider to configuration 1 List providers = new ArrayList(); providers.add(workspaceProvider); - cfgDescription1.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription1.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } { // add global provider to configuration 2 List providers = new ArrayList(); providers.add(workspaceProvider); - cfgDescription2.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription2.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } // write to project description @@ -356,12 +364,14 @@ public class LanguageSettingsListenersTests extends BaseTestCase { assertEquals(2, cfgDescriptions.length); ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; + assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); + assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); { // remove global provider from configuration 1 List providers = new ArrayList(); - cfgDescription1.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription1.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); } // write to project description @@ -387,13 +397,14 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // add global provider ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); List providers = new ArrayList(); providers.add(workspaceProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -410,13 +421,14 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // add global provider ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); List providers = new ArrayList(); providers.add(workspaceProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -484,12 +496,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // add global provider List providers = new ArrayList(); providers.add(workspaceProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -532,11 +545,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // clear providers List providers = new ArrayList(); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); // write to project description @@ -556,13 +570,14 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create a provider and add to cfgDescription ILanguageSettingsProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); List providers = new ArrayList(); providers.add(mockProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -586,11 +601,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // clear providers List providers = new ArrayList(); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); // write to project description @@ -611,6 +627,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase { assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; String cfgDescriptionId = cfgDescription.getId(); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create a provider and add entries MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); @@ -619,8 +636,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { mockProvider.setSettingEntries(cfgDescription, project, null, entries); List providers = new ArrayList(); providers.add(mockProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -650,12 +667,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create a provider and add to cfgDescription List providers = new ArrayList(); providers.add(new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1)); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -675,12 +693,14 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + String cfgDescriptionId = cfgDescription.getId(); // Add entries List entries = new ArrayList(); entries.add(SAMPLE_LSE); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, providers.size()); assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); @@ -714,12 +734,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create a provider and add to cfgDescription List providers = new ArrayList(); providers.add(new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1)); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -742,12 +763,14 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = prjDescription_1.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; + assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); + String cfgDescriptionId = cfgDescriptionWritable.getId(); // Add entries List entries = new ArrayList(); entries.add(SAMPLE_LSE); - List providers = cfgDescriptionWritable.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); assertEquals(1, providers.size()); assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); @@ -773,12 +796,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = prjDescription_2.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; + assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); String cfgDescriptionId = cfgDescriptionWritable.getId(); // Add same entries List entries = new ArrayList(); entries.add(SAMPLE_LSE); - List providers = cfgDescriptionWritable.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); assertEquals(1, providers.size()); assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); @@ -810,11 +834,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // clear providers List providers = new ArrayList(); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); // write to project description @@ -834,6 +859,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // retrieve a global provider ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); @@ -846,8 +872,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add the provider to cfgDescription List providers = new ArrayList(); providers.add(wspProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -871,11 +897,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // clear providers List providers = new ArrayList(); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); // write to project description @@ -895,6 +922,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + String cfgDescriptionId = cfgDescription.getId(); // retrieve a global provider @@ -911,8 +940,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add the provider to cfgDescription List providers = new ArrayList(); providers.add(wspProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -945,6 +974,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // retrieve a global provider ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); @@ -957,8 +987,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add the provider to cfgDescription List providers = new ArrayList(); providers.add(wspProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java index cde365d0471..16b286f145a 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java @@ -58,7 +58,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { private static final String PROVIDER_NAME_1 = "test.provider.1.name"; private static final String PROVIDER_NAME_2 = "test.provider.2.name"; - class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription { + class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper { List providers = new ArrayList(); public MockConfigurationDescription(String id) { super(id); @@ -130,7 +130,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Test ICConfigurationDescription API (getters and setters). */ public void testConfigurationDescription_Providers() throws Exception { - ICConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); // set providers ILanguageSettingsProvider provider1 = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null); @@ -170,7 +170,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { providers.add(dupe2); try { - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); fail("cfgDescription.setLanguageSettingProviders() should not accept duplicate providers"); } catch (Exception e) { // Exception is welcome here @@ -181,7 +181,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Test various cases of ill-defined providers. */ public void testRudeProviders() throws Exception { - ICConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); // set impolite provider returning null by getSettingEntries() ILanguageSettingsProvider providerNull = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null); { @@ -257,7 +257,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Test simple use case. */ public void testProvider_Basic() throws Exception { - final ICConfigurationDescription modelCfgDescription = new MockConfigurationDescription(CFG_ID); + final MockConfigurationDescription modelCfgDescription = new MockConfigurationDescription(CFG_ID); final List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); @@ -309,7 +309,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Test regular functionality with a few providers. */ public void testProvider_Regular() throws Exception { - ICConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); // create couple of providers List entries1 = new ArrayList(); @@ -392,7 +392,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { }; providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); { // retrieve entries for a derived resource (in a subfolder) @@ -453,7 +453,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { }; providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); { // retrieve entries for a resource @@ -470,7 +470,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Test ability to get entries by kind. */ public void testEntriesByKind_Regular() throws Exception { - ICConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); // contribute the entries List entries = new ArrayList(); @@ -504,7 +504,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Test how conflicting entries are resolved. */ public void testEntriesByKind_ConflictingEntries() throws Exception { - ICConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); // contribute the entries List entries = new ArrayList(); @@ -528,7 +528,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Check handling of {@link ICSettingEntry#UNDEFINED} flag. */ public void testEntriesByKind_Undefined() throws Exception { - ICConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); // contribute the entries List entries = new ArrayList(); @@ -550,7 +550,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Check handling of local vs. system entries, see {@link ICSettingEntry#LOCAL} flag. */ public void testEntriesByKind_LocalAndSystem() throws Exception { - ICConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); // contribute the entries List entries = new ArrayList(); @@ -594,7 +594,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Test conflicting entries contributed by different providers. */ public void testEntriesByKind_ConflictingProviders() throws Exception { - ICConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); // contribute the entries List providers = new ArrayList(); @@ -648,18 +648,18 @@ public class LanguageSettingsManagerTests extends BaseTestCase { assertNotNull(workspaceProvider); { // ensure no test provider is set yet - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, providers.size()); } { // set test provider List providers = new ArrayList(); providers.add(workspaceProvider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); } { // check that test provider got there - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(workspaceProvider, providers.get(0)); } @@ -678,7 +678,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { ICConfigurationDescription loadedCfgDescription = loadedCfgDescriptions[0]; assertTrue(cfgDescription instanceof CConfigurationDescription); - List loadedProviders = loadedCfgDescription.getLanguageSettingProviders(); + List loadedProviders = ((ILanguageSettingsProvidersKeeper) loadedCfgDescription).getLanguageSettingProviders(); assertTrue(LanguageSettingsManager.isWorkspaceProvider(loadedProviders.get(0))); } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java index 8b130abe4b0..1e95c8d6f4b 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java @@ -61,7 +61,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { private static CoreModel coreModel = CoreModel.getDefault(); - class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription { + class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper { List providers; public MockConfigurationDescription(String id) { super(id); @@ -183,7 +183,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; - List originalProviders = cfgDescription.getLanguageSettingProviders(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + List originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); int originalSize = originalProviders.size(); // create new provider list @@ -193,7 +196,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertTrue(originalSize != providers.size()); // changing providers shouldn't affect the original list - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); assertEquals(originalSize, originalProviders.size()); } @@ -209,11 +212,12 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // try to write to it try { List providers = new ArrayList(); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); fail("WriteAccessException was expected but it was not throw."); } catch (WriteAccessException e) { // exception is expected @@ -230,6 +234,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create a provider LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_0, PROVIDER_NAME_0); @@ -237,8 +243,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { mockProvider.setSettingEntries(cfgDescription, null, null, entries); List providers = new ArrayList(); providers.add(mockProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // apply new project description to the project model @@ -251,8 +257,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = readOnlyProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider loadedProvider = providers.get(0); assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider); @@ -270,8 +278,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider loadedProvider = providers.get(0); assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider); @@ -436,6 +446,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); serializableProvider.setSettingEntries(null, null, null, entries); @@ -443,13 +454,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ArrayList providers = new ArrayList(); providers.add(serializableProvider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // prepare DOM storage Document doc = XmlUtil.newDocument(); rootElement = XmlUtil.appendElement(doc, ELEM_TEST); // serialize language settings to the DOM LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription); + assertTrue(XmlUtil.toString(doc).contains(PROVIDER_0)); } { // re-load and check language settings of the newly loaded provider @@ -461,8 +473,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -499,25 +512,29 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // populate configuration 1 with provider ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; assertNotNull(cfgDescription1); + assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); + assertEquals(CFG_ID, cfgDescription1.getId()); LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); provider1.setStoringEntriesInProjectArea(true); provider1.setSettingEntries(null, null, null, entries); ArrayList providers = new ArrayList(); providers.add(provider1); - cfgDescription1.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers); } { // populate configuration 2 with provider ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; assertNotNull(cfgDescription2); + assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); + assertEquals(CFG_ID_2, cfgDescription2.getId()); LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); provider2.setStoringEntriesInProjectArea(true); provider2.setSettingEntries(null, null, null, entries2); ArrayList providers = new ArrayList(); providers.add(provider2); - cfgDescription2.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers); } } @@ -530,7 +547,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // doublecheck configuration 1 ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; assertNotNull(cfgDescription1); - List providers = cfgDescription1.getLanguageSettingProviders(); + assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); + assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -543,7 +562,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // doublecheck configuration 2 ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; assertNotNull(cfgDescription2); - List providers = cfgDescription2.getLanguageSettingProviders(); + assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -577,7 +598,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // check configuration 1 ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; assertNotNull(cfgDescription1); - List providers = cfgDescription1.getLanguageSettingProviders(); + assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -590,7 +613,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // check configuration 2 ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; assertNotNull(cfgDescription2); - List providers = cfgDescription2.getLanguageSettingProviders(); + assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); + assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -617,6 +642,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); LanguageSettingsSerializableProvider serializableProvider = new MockLanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); serializableProvider.setSettingEntries(null, null, null, entries); @@ -624,7 +650,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ArrayList providers = new ArrayList(); providers.add(serializableProvider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // prepare DOM storage Document doc = XmlUtil.newDocument(); @@ -642,8 +668,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -669,11 +696,12 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // populate with provider defined as extension List providers = new ArrayList(); providers.add(providerExt); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // prepare DOM storage Document doc = XmlUtil.newDocument(); @@ -691,9 +719,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // and check the newly loaded provider which should be workspace provider - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -717,13 +746,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // populate with provider overriding the extension (must be SerializableLanguageSettingsProvider or a class from another extension) MockLanguageSettingsSerializableProvider providerOverride = new MockLanguageSettingsSerializableProvider(idExt, PROVIDER_NAME_0); providerOverride.setStoringEntriesInProjectArea(true); List providers = new ArrayList(); providers.add(providerOverride); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // prepare DOM storage @@ -742,9 +772,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // check the newly loaded provider - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -776,6 +807,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // 1. Provider reference to extension from plugin.xml providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); @@ -796,7 +828,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { providers.add(providerExt); providers.add(mockProvider1); providers.add(mockProvider2); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); } // prepare DOM storage @@ -815,8 +847,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescriptions); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertNotNull(providers); // 1. Provider reference to extension from plugin.xml ILanguageSettingsProvider provider0 = providers.get(0); @@ -862,6 +896,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create a provider LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); @@ -869,8 +905,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { mockProvider.setSettingEntries(cfgDescription, null, null, entries); List providers = new ArrayList(); providers.add(mockProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -882,7 +918,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { coreModel.getProjectDescription(project); ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); - List providers = cfgDescription.getLanguageSettingProviders(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertTrue(provider instanceof LanguageSettingsSerializableProvider); @@ -916,16 +955,20 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - cfgDescription.setLanguageSettingProviders(new ArrayList()); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(new ArrayList()); coreModel.setProjectDescription(project, writableProjDescription); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, providers.size()); } { // re-check if it really took it ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); - List providers = cfgDescription.getLanguageSettingProviders(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, providers.size()); } { @@ -936,7 +979,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // open to double-check the data is not kept in some other kind of cache project.open(null); ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); - List providers = cfgDescription.getLanguageSettingProviders(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, providers.size()); // and close project.close(null); @@ -959,7 +1005,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // open project and check if providers are loaded project.open(null); ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); - List providers = cfgDescription.getLanguageSettingProviders(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider loadedProvider = providers.get(0); assertTrue(loadedProvider instanceof LanguageSettingsSerializableProvider); @@ -988,6 +1037,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); serializableProvider.setSettingEntries(null, null, null, entries); @@ -996,7 +1046,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ArrayList providers = new ArrayList(); providers.add(serializableProvider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // prepare DOM storage Document prjDoc = XmlUtil.newDocument(); @@ -1016,8 +1066,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -1059,6 +1110,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = writableProjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create a provider LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); @@ -1066,8 +1119,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { mockProvider.setSettingEntries(cfgDescription, null, null, entries); List providers = new ArrayList(); providers.add(mockProvider); - cfgDescription.setLanguageSettingProviders(providers); - List storedProviders = cfgDescription.getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -1083,7 +1136,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { coreModel.getProjectDescription(project); ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); - List providers = cfgDescription.getLanguageSettingProviders(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertTrue(provider instanceof LanguageSettingsSerializableProvider); @@ -1122,16 +1178,20 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - cfgDescription.setLanguageSettingProviders(new ArrayList()); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(new ArrayList()); coreModel.setProjectDescription(project, writableProjDescription); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, providers.size()); } { // re-check if it really took it ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); - List providers = cfgDescription.getLanguageSettingProviders(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, providers.size()); } { @@ -1142,7 +1202,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // open to double-check the data is not kept in some other kind of cache project.open(null); ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); - List providers = cfgDescription.getLanguageSettingProviders(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(0, providers.size()); // and close project.close(null); @@ -1177,7 +1240,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // open project and check if providers are loaded project.open(null); ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); - List providers = cfgDescription.getLanguageSettingProviders(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider loadedProvider = providers.get(0); assertTrue(loadedProvider instanceof LanguageSettingsSerializableProvider); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java index bdc83f649a2..ed178ac4982 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java @@ -51,7 +51,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { private static final String PROVIDER_ID = "test.provider.id"; private static final String PROVIDER_ID_2 = "test.provider.id.2"; private static final String PROVIDER_NAME = "test.provider.name"; - + // constants for getProjectDescription() private static final boolean READ_ONLY = false; private static final boolean WRITEABLE = true; @@ -225,6 +225,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // sample file IFile file = ResourceHelper.createFile(project, "file.c"); @@ -256,7 +257,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -296,6 +297,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // sample file IFile file = ResourceHelper.createFile(project, "file.c"); @@ -319,7 +321,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -349,22 +351,23 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); - + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + // sample file IFile file = ResourceHelper.createFile(project, "file.c"); - + // contribute the entries IFolder frameworkFolder = ResourceHelper.createFolder(project, "Fmwk"); CIncludePathEntry frameworkPathEntry = new CIncludePathEntry(frameworkFolder, ICSettingEntry.FRAMEWORKS_MAC); - + List entries = new ArrayList(); entries.add(frameworkPathEntry); - + // add provider to the configuration ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -380,7 +383,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { new Path(actualIncludePaths[1])); assertEquals(2, actualIncludePaths.length); } - + /** * Test duplicate entries. */ @@ -391,6 +394,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // sample file IFile file = ResourceHelper.createFile(project, "file.c"); @@ -412,7 +416,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -440,6 +444,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create sample file IFile file = ResourceHelper.createFile(project, "file.c"); @@ -472,7 +477,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -508,6 +513,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create sample file IFile file = ResourceHelper.createFile(project, "file.c"); @@ -523,7 +529,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -559,6 +565,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create sample file IFile file = ResourceHelper.createFile(project, "file.c"); @@ -576,7 +583,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -628,6 +635,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create sample file IFile file = ResourceHelper.createFile(project, "file.c"); @@ -655,7 +663,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -710,6 +718,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create sample file IFile file = ResourceHelper.createFile(project, "file.c"); @@ -723,7 +732,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -765,6 +774,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // sample file IFolder parentFolder = ResourceHelper.createFolder(project, "ParentFolder"); @@ -784,7 +794,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -812,6 +822,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create sample file IFile file = ResourceHelper.createFile(project, "file.c"); @@ -825,8 +836,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); - + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); @@ -893,6 +904,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // find 2 languages applicable to the folder List languageIds = getLanguages(folder, cfgDescription); @@ -917,7 +929,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { List providers = new ArrayList(); providers.add(provider1); providers.add(provider2); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // set project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java index b2de9f3bef9..921b2256cb5 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java @@ -20,6 +20,7 @@ import junit.framework.TestSuite; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.util.CDataUtil; @@ -31,25 +32,26 @@ import org.eclipse.core.resources.IProject; public class CProjectDescriptionDeltaTests extends BaseTestCase{ private MockListener listener; - + private class MockListener implements ICProjectDescriptionListener { private boolean fIsNotified; private String fProjName; private ICDescriptionDelta fDelta; - + public MockListener(String projName){ fProjName = projName; fIsNotified = false; fDelta = null; } - + + @Override public void handleEvent(CProjectDescriptionEvent event) { if(!event.getProject().getName().equals(fProjName)) return; fIsNotified = true; fDelta = event.getProjectDelta(); } - + boolean isNotified(){ return fIsNotified; } @@ -63,36 +65,38 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ return fDelta; } } - + public static TestSuite suite() { return suite(CProjectDescriptionDeltaTests.class, "_"); } + @Override protected void setUp() throws Exception { } - + + @Override protected void tearDown() throws Exception { ResourceHelper.cleanUp(); } - + private void initListener(String projName){ ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); if(listener != null) mngr.removeCProjectDescriptionListener(listener); listener = new MockListener(projName); mngr.addCProjectDescriptionListener(listener, CProjectDescriptionEvent.APPLIED); - + assertFalse(listener.isNotified()); } - + private static List findDeltas(ICDescriptionDelta delta, int type) { List list = new ArrayList(); if ((delta.getChangeFlags()&type)!=0) { list.add(delta); } - + ICDescriptionDelta[] children = delta.getChildren(); for (ICDescriptionDelta d : children) { list.addAll(findDeltas(d, type)); @@ -103,32 +107,32 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ public void testDelta_ACTIVE_CFG() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProject(projName, null, new String[] {"test.configuration.1", "test.configuration.2"}); - + // Get writable project description and its configurations ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); assertEquals(2, prjDescription.getConfigurations().length); - + ICConfigurationDescription cfgDescription0 = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription0); assertSame(cfgDescription0, prjDescription.getActiveConfiguration()); - + ICConfigurationDescription cfgDescription1 = prjDescription.getConfigurations()[1]; assertNotNull(cfgDescription1); assertNotSame(cfgDescription1, prjDescription.getActiveConfiguration()); - + // ACTIVE_CFG: Change active configuration prjDescription.setActiveConfiguration(cfgDescription1); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -136,41 +140,41 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ assertEquals(1, deltas.size()); ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICProjectDescription); ICProjectDescription oldSetting = (ICProjectDescription)delta.getOldSetting(); assertEquals(cfgDescription0.getName(), oldSetting.getActiveConfiguration().getName()); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICProjectDescription); ICProjectDescription newSetting = (ICProjectDescription)delta.getNewSetting(); assertEquals(cfgDescription1.getName(), newSetting.getActiveConfiguration().getName()); } - + public void testDelta_NAME() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); String oldName = cfgDescription.getName(); - + // Modification ICDescriptionDelta.NAME String newName = "New name"; cfgDescription.setName(newName); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -179,40 +183,40 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); assertEquals(ICDescriptionDelta.NAME, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription); ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting(); assertEquals(oldName, oldSetting.getName()); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); assertEquals(newName, newSetting.getName()); } - + public void testDelta_DESCRIPTION() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); String oldDescription = cfgDescription.getDescription(); - + // Modification ICDescriptionDelta.DESCRIPTION cfgDescription.setDescription("New description"); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -221,45 +225,45 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); assertEquals(ICDescriptionDelta.DESCRIPTION, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription); ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting(); assertEquals(oldDescription, oldSetting.getDescription()); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); assertEquals(cfgDescription.getDescription(), newSetting.getDescription()); - + } public void testDelta_LANGUAGE_ID() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); IFile file = ResourceHelper.createFile(project, "test.cpp"); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification LANGUAGE_ID ICLanguageSetting langSetting = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), false); String oldLanguageId = langSetting.getLanguageId(); String newLanguageId = "test.language.id"; assertTrue(!newLanguageId.equals(oldLanguageId)); langSetting.setLanguageId(newLanguageId); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -273,38 +277,38 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ assertTrue(delta.getOldSetting() instanceof ICLanguageSetting); ICLanguageSetting oldSetting = (ICLanguageSetting)delta.getOldSetting(); assertEquals(oldLanguageId, oldSetting.getLanguageId()); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICLanguageSetting); ICLanguageSetting newSetting = (ICLanguageSetting)delta.getNewSetting(); assertEquals(newLanguageId, newSetting.getLanguageId()); - + } - + public void testDelta_SOURCE_CONTENT_TYPE() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); IFile file = ResourceHelper.createFile(project, "test.cpp"); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification SOURCE_CONTENT_TYPE final String testContentType = "test.content.type"; ICLanguageSetting langSetting = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), false); langSetting.setSourceContentTypeIds(new String[] {testContentType}); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -312,35 +316,35 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ assertEquals(1, deltas.size()); ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICLanguageSetting); ICLanguageSetting oldSetting = (ICLanguageSetting)delta.getOldSetting(); List oldContentTypes = Arrays.asList(oldSetting.getSourceContentTypeIds()); assertTrue(!oldContentTypes.contains(testContentType)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICLanguageSetting); ICLanguageSetting newSetting = (ICLanguageSetting)delta.getNewSetting(); List newContentTypes = Arrays.asList(newSetting.getSourceContentTypeIds()); assertTrue(newContentTypes.contains(testContentType)); - + } - + public void testDelta_SOURCE_EXTENSIONS() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); IFile file = ResourceHelper.createFile(project, "test.cpp"); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification SOURCE_ENTENSIONS ICLanguageSetting langSetting = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), false); final String testContentType = CCorePlugin.CONTENT_TYPE_ASMSOURCE; @@ -349,12 +353,12 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ assertTrue(exts.length>0); final String testSourceExtension = exts[0]; - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -363,46 +367,46 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); // assertEquals(ICDescriptionDelta.SOURCE_ENTENSIONS, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICLanguageSetting); ICLanguageSetting oldSetting = (ICLanguageSetting)delta.getOldSetting(); List oldSourceExtensions = Arrays.asList(oldSetting.getSourceExtensions()); assertTrue(!oldSourceExtensions.contains(testSourceExtension)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICLanguageSetting); ICLanguageSetting newSetting = (ICLanguageSetting)delta.getNewSetting(); List newSourceExtensions = Arrays.asList(newSetting.getSourceExtensions()); assertTrue(newSourceExtensions.contains(testSourceExtension)); - + } - + public void testDelta_SETTING_ENTRIES() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); IFile file = ResourceHelper.createFile(project, "test.cpp"); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification SETTING_ENTRIES ICLanguageSettingEntry testSettingEntry = new CIncludePathEntry("/path", 0); ICLanguageSetting langSetting = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), false); ICLanguageSettingEntry[] entries = new ICLanguageSettingEntry[] {testSettingEntry}; langSetting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, entries); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -411,43 +415,43 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); assertEquals(ICDescriptionDelta.SETTING_ENTRIES, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICLanguageSetting); ICLanguageSetting oldSetting = (ICLanguageSetting)delta.getOldSetting(); List oldSettingEntries = oldSetting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH); assertTrue(!oldSettingEntries.contains(testSettingEntry)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICLanguageSetting); ICLanguageSetting newSetting = (ICLanguageSetting)delta.getNewSetting(); List newSettingEntries = newSetting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH); assertTrue(newSettingEntries.contains(testSettingEntry)); } - + public void testDelta_BINARY_PARSER_IDS() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - - // Modification BINARY_PARSER_IDS + + // Modification BINARY_PARSER_IDS final String testBinaryParserId = "test.binary.parser.id"; ICTargetPlatformSetting targetPlatformSetting = cfgDescription.getTargetPlatformSetting(); targetPlatformSetting.setBinaryParserIds(new String[] {testBinaryParserId}); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -456,43 +460,43 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); assertEquals(ICDescriptionDelta.BINARY_PARSER_IDS, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICTargetPlatformSetting); ICTargetPlatformSetting oldSetting = (ICTargetPlatformSetting)delta.getOldSetting(); List oldBinaryParserIds = Arrays.asList(oldSetting.getBinaryParserIds()); assertTrue(!oldBinaryParserIds.contains(testBinaryParserId)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICTargetPlatformSetting); ICTargetPlatformSetting newSetting = (ICTargetPlatformSetting)delta.getNewSetting(); List newBinaryParserIds = Arrays.asList(newSetting.getBinaryParserIds()); assertTrue(newBinaryParserIds.contains(testBinaryParserId)); - + } - + public void testDelta_ERROR_PARSER_IDS() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification ERROR_PARSER_IDS String testErrorParserId = "test.error.parser.id"; cfgDescription.getBuildSetting().setErrorParserIDs(new String[] {testErrorParserId}); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -507,55 +511,55 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICBuildSetting oldSetting = (ICBuildSetting)delta.getOldSetting(); List oldErrorParserIds = Arrays.asList(oldSetting.getErrorParserIDs()); assertTrue(!oldErrorParserIds.contains(testErrorParserId)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICBuildSetting); ICBuildSetting newSetting = (ICBuildSetting)delta.getNewSetting(); List newErrorParserIds = Arrays.asList(newSetting.getErrorParserIDs()); assertTrue(newErrorParserIds.contains(testErrorParserId)); - + } - + public void testDelta_EXCLUDE() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); IFile file = ResourceHelper.createFile(project, "test.cpp"); - + { // Prepare file descriptions ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + cfgDescription.createFileDescription(file.getProjectRelativePath(),cfgDescription.getRootFolderDescription()); ICFileDescription[] fileDescriptions = cfgDescription.getFileDescriptions(); assertTrue(fileDescriptions.length>0); - + mngr.setProjectDescription(project, prjDescription); } - + { // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification EXCLUDE ICFileDescription[] fileDescriptions = cfgDescription.getFileDescriptions(); assertTrue(fileDescriptions.length>0); ICFileDescription fileDescription = fileDescriptions[0]; fileDescription.setExcluded(true); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -569,39 +573,39 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ assertTrue(delta.getOldSetting() instanceof ICFileDescription); ICFileDescription oldSetting = (ICFileDescription)delta.getOldSetting(); assertTrue(!oldSetting.isExcluded()); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICFileDescription); ICFileDescription newSetting = (ICFileDescription)delta.getNewSetting(); assertTrue(newSetting.isExcluded()); } - + } - + public void testDelta_SOURCE_ADDED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification SOURCE_ADDED List sourceEntries = new ArrayList(Arrays.asList(cfgDescription.getSourceEntries())); ICSourceEntry testSourceEntry = new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED); sourceEntries.add(testSourceEntry); cfgDescription.setSourceEntries(sourceEntries.toArray(new ICSourceEntry[0])); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -610,27 +614,27 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); // assertEquals(ICDescriptionDelta.SOURCE_ADDED, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription); ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting(); List oldSourceEntries = Arrays.asList(oldSetting.getSourceEntries()); assertTrue(!oldSourceEntries.contains(testSourceEntry)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); List newSourceEntries = Arrays.asList(newSetting.getSourceEntries()); assertTrue(newSourceEntries.contains(testSourceEntry)); } - + public void testDelta_SOURCE_REMOVED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + ICSourceEntry testSourceEntry = new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED); { // Add some source entry to remove it during the test @@ -638,29 +642,29 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + List sourceEntries = new ArrayList(Arrays.asList(cfgDescription.getSourceEntries())); sourceEntries.add(testSourceEntry); cfgDescription.setSourceEntries(sourceEntries.toArray(new ICSourceEntry[0])); - + mngr.setProjectDescription(project, prjDescription); } - + { // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification SOURCE_REMOVED cfgDescription.setSourceEntries(new ICSourceEntry[0]); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -669,44 +673,44 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); // assertEquals(ICDescriptionDelta.SOURCE_REMOVED, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription); ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting(); List oldSourceEntries = Arrays.asList(oldSetting.getSourceEntries()); assertTrue(oldSourceEntries.contains(testSourceEntry)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); List newSourceEntries = Arrays.asList(newSetting.getSourceEntries()); assertTrue(!newSourceEntries.contains(testSourceEntry)); } - + } - + public void testDelta_EXTERNAL_SETTINGS_ADDED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification EXTERNAL_SETTINGS_ADDED ICSettingEntry testSettingEntry = new CIncludePathEntry("/path", 0); ICExternalSetting testExternalSetting = cfgDescription.createExternalSetting(null, null, null, new ICSettingEntry[] {testSettingEntry}); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -715,13 +719,13 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); assertEquals(ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription); ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting(); List oldExternalSettings = Arrays.asList(oldSetting.getExternalSettings()); assertEquals(0, oldExternalSettings.size()); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); @@ -730,41 +734,41 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ List newSettingEntries = Arrays.asList(newExternalSettings.get(0).getEntries()); assertTrue(newSettingEntries.contains(testSettingEntry)); } - + public void testDelta_EXTERNAL_SETTINGS_REMOVED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); ICSettingEntry testSettingEntry = new CIncludePathEntry("/path", 0); - + { // Add some external setting to remove it during the test ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + ICExternalSetting testExternalSetting = cfgDescription.createExternalSetting(null, null, null, new ICSettingEntry[] {testSettingEntry}); mngr.setProjectDescription(project, prjDescription); } - + { // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification EXTERNAL_SETTINGS_REMOVED cfgDescription.removeExternalSettings(); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -781,41 +785,41 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ assertEquals(1, oldExternalSettings.size()); List oldSettingEntries = Arrays.asList(oldExternalSettings.get(0).getEntries()); assertTrue(oldSettingEntries.contains(testSettingEntry)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); List newExternalSettings = Arrays.asList(newSetting.getExternalSettings()); assertEquals(0, newExternalSettings.size()); } - + } - + public void testDelta_CFG_REF_ADDED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification CFG_REF_ADDED String testKey = "key"; String testValue = "value"; Map refs = new HashMap(); refs.put(testKey, testValue); cfgDescription.setReferenceInfo(refs); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -824,13 +828,13 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); assertEquals(ICDescriptionDelta.CFG_REF_ADDED, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription); ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting(); Map oldReferenceInfo = oldSetting.getReferenceInfo(); assertEquals(0, oldReferenceInfo.size()); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); @@ -838,44 +842,44 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ assertEquals(1, newReferenceInfo.size()); assertEquals(testValue, newReferenceInfo.get(testKey)); } - + public void testDelta_CFG_REF_REMOVED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); String testKey = "key"; String testValue = "value"; - + { // Add some reference info to remove it during the test ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + Map refs = new HashMap(); refs.put(testKey, testValue); cfgDescription.setReferenceInfo(refs); mngr.setProjectDescription(project, prjDescription); } - + { // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification CFG_REF_REMOVED cfgDescription.setReferenceInfo(new HashMap()); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -884,46 +888,46 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); assertEquals(ICDescriptionDelta.CFG_REF_REMOVED, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription); ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting(); Map oldReferenceInfo = oldSetting.getReferenceInfo(); assertEquals(1, oldReferenceInfo.size()); assertEquals(testValue, oldReferenceInfo.get(testKey)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); Map newReferenceInfo = newSetting.getReferenceInfo(); assertEquals(0, newReferenceInfo.size()); } - + } - + public void testDelta_EXT_REF() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - + // Modification EXT_REF, currently binary parsers are represented as CConfigExtensionReference final String testBinaryParserId = "test.binary.parser.id"; ICTargetPlatformSetting targetPlatformSetting = cfgDescription.getTargetPlatformSetting(); targetPlatformSetting.setBinaryParserIds(new String[] {testBinaryParserId}); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -939,7 +943,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICTargetPlatformSetting oldTargetPlatformSetting = oldSetting.getTargetPlatformSetting(); List oldBinaryParserIds = Arrays.asList(oldTargetPlatformSetting.getBinaryParserIds()); assertTrue(!oldBinaryParserIds.contains(testBinaryParserId)); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); @@ -947,36 +951,36 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ List newBinaryParserIds = Arrays.asList(newTargetPlatformSetting.getBinaryParserIds()); assertTrue(newBinaryParserIds.contains(testBinaryParserId)); } - + public void testDelta_INDEX_CFG() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProject(projName, null, new String[] {"test.configuration.1", "test.configuration.2"}); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); assertEquals(2, prjDescription.getConfigurations().length); - + ICConfigurationDescription cfgDescription0 = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription0); assertSame(cfgDescription0, prjDescription.getDefaultSettingConfiguration()); - + ICConfigurationDescription cfgDescription1 = prjDescription.getConfigurations()[1]; assertNotNull(cfgDescription1); assertNotSame(cfgDescription1, prjDescription.getDefaultSettingConfiguration()); - + // Modification INDEX_CFG prjDescription.setDefaultSettingConfiguration(cfgDescription1); - + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -990,38 +994,39 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ assertTrue(delta.getOldSetting() instanceof ICProjectDescription); ICProjectDescription oldSetting = (ICProjectDescription)delta.getOldSetting(); assertEquals(cfgDescription0.getName(), oldSetting.getDefaultSettingConfiguration().getName()); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICProjectDescription); ICProjectDescription newSetting = (ICProjectDescription)delta.getNewSetting(); assertEquals(cfgDescription1.getName(), newSetting.getDefaultSettingConfiguration().getName()); } - + public void testDelta_LANGUAGE_SETTINGS_PROVIDERS() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + initListener(projName); IProject project = ResourceHelper.createCDTProjectWithConfig(projName); - + // Get writable project description and its configuration ICProjectDescription prjDescription = mngr.getProjectDescription(project, true); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription); - List originalProviders = cfgDescription.getLanguageSettingProviders(); - + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + List originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + // Modification LANGUAGE_SETTINGS_PROVIDERS ILanguageSettingsProvider provider = new LanguageSettingsSerializableProvider("id", "name"); List providers = new ArrayList(); providers.add(provider); - cfgDescription.setLanguageSettingProviders(providers); - + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + // Write project description listener.clearNotified(); mngr.setProjectDescription(project, prjDescription); assertEquals(true, listener.isNotified()); - + // Analyze delta ICDescriptionDelta rootDelta = listener.getDelta(); assertNotNull(rootDelta); @@ -1030,16 +1035,18 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{ ICDescriptionDelta delta = deltas.get(0); assertNotNull(delta); assertEquals(ICDescriptionDelta.LANGUAGE_SETTINGS_PROVIDERS, delta.getChangeFlags()); - + // Check old setting assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription); - ICConfigurationDescription oldSetting = (ICConfigurationDescription)delta.getOldSetting(); + assertTrue(delta.getOldSetting() instanceof ILanguageSettingsProvidersKeeper); + ILanguageSettingsProvidersKeeper oldSetting = (ILanguageSettingsProvidersKeeper)delta.getOldSetting(); List oldProviders = oldSetting.getLanguageSettingProviders(); assertEquals(originalProviders, oldProviders); - + // Check new setting assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription); - ICConfigurationDescription newSetting = (ICConfigurationDescription)delta.getNewSetting(); + assertTrue(delta.getNewSetting() instanceof ILanguageSettingsProvidersKeeper); + ILanguageSettingsProvidersKeeper newSetting = (ILanguageSettingsProvidersKeeper)delta.getNewSetting(); List newProviders = newSetting.getLanguageSettingProviders(); assertEquals(providers, newProviders); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java index e1a55874e49..4918c6d1873 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java @@ -25,7 +25,6 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.provider.IIndexProvider; import org.eclipse.cdt.core.internal.index.provider.test.DummyProviderTraces; import org.eclipse.cdt.core.internal.index.provider.test.Providers; -import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.parser.util.ArrayUtil; @@ -76,7 +75,7 @@ public class IndexProviderManagerTest extends IndexTestBase { final static Class DP4= Providers.Dummy4.class; final static Class DP5= Providers.Dummy5.class; final static Class[] DPS= new Class[] {DP4, DP2, DP1, DP3, DP5}; - + /* * Fictional compatibility ranges for testing */ @@ -84,9 +83,9 @@ public class IndexProviderManagerTest extends IndexTestBase { final static VersionRange VERSION_401= new VersionRange("[36,37]"); final static VersionRange VERSION_405= new VersionRange("[37,39]"); final static VersionRange VERSION_502= new VersionRange("[89,91]"); - + final CCorePlugin core= CCorePlugin.getDefault(); - + public IndexProviderManagerTest() { super("IndexProviderManagerTest"); } @@ -107,11 +106,11 @@ public class IndexProviderManagerTest extends IndexTestBase { IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager(); ipm.reset(); ipm.startup(); } - + public void testProvider_SimpleLifeCycle_200958() throws Exception { for (Class element : DPS) DPT.reset(element); - + List cprojects = new ArrayList(), expectedTrace = new ArrayList(); try { for(int i=0; i<3; i++) { @@ -138,7 +137,7 @@ public class IndexProviderManagerTest extends IndexTestBase { public void testProvider_OverDeleteAndAdd() throws Exception { DPT.reset(DP1); - + List expectedTrace = new ArrayList(); ICProject cproject = null; try { @@ -181,7 +180,7 @@ public class IndexProviderManagerTest extends IndexTestBase { File newLocation = CProjectHelper.freshDir(); IProjectDescription description = cproject.getProject().getDescription(); description.setLocationURI(newLocation.toURI()); - cproject.getProject().move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor()); + cproject.getProject().move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor()); index = CCorePlugin.getIndexManager().getIndex(cproject); assertEquals(expectedTrace, DPT.getProjectsTrace(DP1)); @@ -191,19 +190,19 @@ public class IndexProviderManagerTest extends IndexTestBase { } } } - + public void testVersioning_IncompatibleIgnored() throws Exception { IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager(); - + ICProject cproject = null; try { cproject= CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER); IProject project= cproject.getProject(); - - + + MockState mockState = new MockState(cproject); mockState.setConfig(MockState.REL_V1_ID); - + IIndexProvider provider1= new IIndexFragmentProvider() { IIndexFragment[] fragments= new IIndexFragment[] { new MockPDOM("contentID.contentA", "36"), @@ -212,9 +211,11 @@ public class IndexProviderManagerTest extends IndexTestBase { new MockPDOM("contentID.bar", "91"), new MockPDOM("contentID.baz", "89") }; + @Override public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) { return fragments; } + @Override public boolean providesFor(ICProject project) throws CoreException { return true; } @@ -224,20 +225,22 @@ public class IndexProviderManagerTest extends IndexTestBase { new MockPDOM("contentID.baz", "90"), new MockPDOM("contentID.contentA", "38"), }; + @Override public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) { return fragments; } + @Override public boolean providesFor(ICProject project) throws CoreException { return true; } }; - + CCorePlugin.getIndexManager().joinIndexer(8000, npm()); // ensure IPM is called only once under test conditions setExpectedNumberOfLoggedNonOKStatusObjects(3); // foo, bar and baz have no compatible fragments available - + ipm.reset(VERSION_405); ipm.startup(); ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2); - + IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(1, actual.length); assertFragmentPresent("contentID.contentA", "38", actual); @@ -247,19 +250,19 @@ public class IndexProviderManagerTest extends IndexTestBase { } } } - + public void testVersioning_NoCompatibleVersionsFound() throws Exception { IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager(); - + ICProject cproject = null; try { cproject= CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER); IProject project= cproject.getProject(); - - + + MockState mockState = new MockState(cproject); mockState.setConfig(MockState.REL_V1_ID); - + IIndexProvider provider1= new IIndexFragmentProvider() { IIndexFragment[] fragments= new IIndexFragment[] { new MockPDOM("contentID.contentA", "36"), @@ -268,9 +271,11 @@ public class IndexProviderManagerTest extends IndexTestBase { new MockPDOM("contentID.bar", "91"), new MockPDOM("contentID.baz", "89") }; + @Override public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) { return fragments; } + @Override public boolean providesFor(ICProject project) throws CoreException { return true; } @@ -279,20 +284,22 @@ public class IndexProviderManagerTest extends IndexTestBase { IIndexFragment[] fragments= new IIndexFragment[] { new MockPDOM("contentID.contentA", "41"), }; + @Override public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) { return fragments; } + @Override public boolean providesFor(ICProject project) throws CoreException { return true; } }; - + CCorePlugin.getIndexManager().joinIndexer(8000, npm()); // ensure IPM is called only once under test conditions setExpectedNumberOfLoggedNonOKStatusObjects(1); // contentA has no compatible fragments available - + ipm.reset(VERSION_502); ipm.startup(); ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2); - + IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), true); assertEquals(3, actual.length); assertFragmentPresent("contentID.foo", "90", actual); @@ -304,7 +311,7 @@ public class IndexProviderManagerTest extends IndexTestBase { } } } - + private void assertFragmentPresent(String id, String version, IIndexFragment[] fragments) throws Exception { for (IIndexFragment candidate : fragments) { String cid= null, csver= null; @@ -320,49 +327,49 @@ public class IndexProviderManagerTest extends IndexTestBase { } fail("Fragment matching (id="+id+",version="+version+") was not present"); } - + public void testIndexFactoryConfigurationUsage() throws Exception { IIndex index; - + ICProject cproject = null; // Modifying the .project file triggers an indexer job, suppress that: DeltaAnalyzer.sSuppressPotentialTUs= true; try { cproject = CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER); IProject project= cproject.getProject(); - + ICProjectDescription pd= core.getProjectDescription(project); ICConfigurationDescription cfg1= newCfg(pd, "project", "config1"); ICConfigurationDescription cfg2= newCfg(pd, "project", "config2"); core.setProjectDescription(project, pd); - + index= CCorePlugin.getIndexManager().getIndex(cproject); CCorePlugin.getIndexManager().joinIndexer(8000, npm()); - + DPT.reset(DP1); changeConfigRelations(project, ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE); assertEquals(0, DPT.getProjectsTrace(DP1).size()); assertEquals(0, DPT.getCfgsTrace(DP1).size()); - + changeActiveConfiguration(project, cfg1); DPT.reset(DP1); index= CCorePlugin.getIndexManager().getIndex(cproject); assertEquals(0, DPT.getProjectsTrace(DP1).size()); assertEquals(1, DPT.getCfgsTrace(DP1).size()); assertEquals("project.config1", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId()); - + changeActiveConfiguration(project, cfg2); DPT.reset(DP1); index= CCorePlugin.getIndexManager().getIndex(cproject); assertEquals(0, DPT.getProjectsTrace(DP1).size()); assertEquals(1, DPT.getCfgsTrace(DP1).size()); assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId()); - + DPT.reset(DP1); changeConfigRelations(project, ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT); assertEquals(0, DPT.getProjectsTrace(DP1).size()); assertEquals(0, DPT.getCfgsTrace(DP1).size()); - + changeActiveConfiguration(project, cfg1); DPT.reset(DP1); index= CCorePlugin.getIndexManager().getIndex(cproject); @@ -370,7 +377,7 @@ public class IndexProviderManagerTest extends IndexTestBase { assertEquals(1, DPT.getCfgsTrace(DP1).size()); // should still be config2, as the change in active configuration does not matter assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId()); - + changeActiveConfiguration(project, cfg2); DPT.reset(DP1); index= CCorePlugin.getIndexManager().getIndex(cproject); @@ -385,7 +392,7 @@ public class IndexProviderManagerTest extends IndexTestBase { } } } - + public void testGetProvidedFragments() throws Exception { ICProject cproject= CProjectHelper.createCProject("IndexProviderManagerTest", "bin", IPDOMManager.ID_NO_INDEXER); @@ -492,20 +499,20 @@ public class IndexProviderManagerTest extends IndexTestBase { } } } - + private ICConfigurationDescription newCfg(ICProjectDescription des, String project, String config) throws CoreException { CDefaultConfigurationData data= new CDefaultConfigurationData(project+"."+config, project+" "+config+" name", null); data.initEmptyData(); - return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data); + return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data); } - + private void changeActiveConfiguration(IProject project, ICConfigurationDescription cfg) throws CoreException { ICProjectDescription pd= core.getProjectDescription(project); pd.setActiveConfiguration(pd.getConfigurationById(cfg.getId())); core.setProjectDescription(project, pd); CCorePlugin.getIndexManager().joinIndexer(8000, npm()); } - + private void changeConfigRelations(IProject project, int option) throws CoreException { ICProjectDescription pd= core.getProjectDescription(project); pd.setConfigurationRelations(option); @@ -521,6 +528,7 @@ class MockStateIndexProvider implements IIndexProvider { this.targetProject = cproject; } + @Override public boolean providesFor(ICProject cproject) throws CoreException { return this.targetProject.equals(cproject); } @@ -529,7 +537,7 @@ class MockStateIndexProvider implements IIndexProvider { class MockStateIndexFragmentProvider extends MockStateIndexProvider implements IIndexFragmentProvider { private boolean invert; final IIndexFragment[] fragments; - + public void invert() { invert = !invert; } @@ -543,6 +551,7 @@ class MockStateIndexFragmentProvider extends MockStateIndexProvider implements I } } + @Override public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) throws CoreException { int index = MockState.states.indexOf(config.getId()); index = invert ? (fragments.length-1)-index : index; @@ -565,152 +574,201 @@ class MockConfig implements ICConfigurationDescription { this.project= project; } + @Override public String getId() { return id; } + @Override public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException { return null; } + @Override public ICExternalSetting createExternalSetting(String[] languageIDs, String[] contentTypeIds, String[] extensions, ICSettingEntry[] entries) throws WriteAccessException { return null; } + @Override public ICFileDescription createFileDescription(IPath path, ICResourceDescription base) throws CoreException, WriteAccessException { return null; } + @Override public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base) throws CoreException, WriteAccessException { return null; } + @Override public ICConfigExtensionReference[] get(String extensionPointID) { return null; } + @Override public ICBuildSetting getBuildSetting() { return null; } + @Override public String getBuildSystemId() { return null; } + @Override public ICdtVariablesContributor getBuildVariablesContributor() { return null; } + @Override public CConfigurationData getConfigurationData() { return null; } + @Override public String getDescription() { return null; } + @Override public ICExternalSetting[] getExternalSettings() { return null; } + @Override public ICFileDescription[] getFileDescriptions() { return null; } + @Override public ICFolderDescription[] getFolderDescriptions() { return null; } + @Override public ICProjectDescription getProjectDescription() { return CoreModel.getDefault().getProjectDescription(project); } + @Override public Map getReferenceInfo() { return null; } + @Override public ICResourceDescription getResourceDescription(IPath path, boolean exactPath) { return null; } + @Override public ICResourceDescription[] getResourceDescriptions() { return null; } + @Override public ICFolderDescription getRootFolderDescription() {return null;} + @Override public Object getSessionProperty(QualifiedName name) {return null;} + @Override public ICSourceEntry[] getSourceEntries() {return null;} + @Override public ICTargetPlatformSetting getTargetPlatformSetting() {return null;} + @Override public boolean isActive() {return false;} + @Override public boolean isModified() {return false;} + @Override public boolean isPreferenceConfiguration() {return false;} + @Override public void remove(ICConfigExtensionReference ext) throws CoreException {} + @Override public void remove(String extensionPoint) throws CoreException {} + @Override public void removeExternalSetting(ICExternalSetting setting) throws WriteAccessException {} + @Override public void removeExternalSettings() throws WriteAccessException {} + @Override public void removeResourceDescription(ICResourceDescription des) throws CoreException, WriteAccessException {} + @Override public void setActive() throws WriteAccessException {} + @Override public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException {} + @Override public void setDescription(String des) throws WriteAccessException {} + @Override public void setName(String name) throws WriteAccessException {} + @Override public void setReferenceInfo(Map refs) throws WriteAccessException {} + @Override public void setSessionProperty(QualifiedName name, Object value) {} + @Override public void setSourceEntries(ICSourceEntry[] entries) throws CoreException, WriteAccessException {} + @Override public ICSettingObject[] getChildSettings() {return null;} + @Override public ICConfigurationDescription getConfiguration() {return null;} + @Override public String getName() {return null;} + @Override public ICSettingContainer getParent() {return null;} + @Override public int getType() {return 0;} + @Override public boolean isReadOnly() {return false;} + @Override public boolean isValid() {return false;} + @Override public ICStorageElement getStorage(String id, boolean create) throws CoreException { return null; } + @Override public ICStorageElement importStorage(String id, ICStorageElement storage) { return null; } + @Override public void removeStorage(String id) throws CoreException { } + @Override public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExludeStatus) { return null; } + @Override public String[] getExternalSettingsProviderIds() { return null; } + @Override public void setExternalSettingsProviderIds(String[] ids) {} + @Override public void updateExternalSettingsProviders(String[] ids) {} + @Override public ICSourceEntry[] getResolvedSourceEntries() { return null; } + @Override public CConfigurationStatus getConfigurationStatus() { return CConfigurationStatus.CFG_STATUS_OK; } + @Override public void setReadOnly(boolean readOnly, boolean keepModify) {} - public void setLanguageSettingProviders(List providers) {} - - public List getLanguageSettingProviders() { - return null; - } } /* @@ -743,12 +801,12 @@ class MockState { class MockPDOM extends EmptyIndexFragment { String id; String version; - + MockPDOM(String id, String version) { this.id= id; this.version= version; } - + @Override public String getProperty(String propertyName) throws CoreException { if(IIndexFragment.PROPERTY_FRAGMENT_ID.equals(propertyName)) { @@ -762,7 +820,7 @@ class MockPDOM extends EmptyIndexFragment { } return null; } - + @Override public String toString() { return "[Mock index fragment "+id+"."+System.identityHashCode(this)+"]"; diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java index 95ebf29149c..4b463573366 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java @@ -11,11 +11,9 @@ package org.eclipse.cdt.core.testplugin; -import java.util.List; import java.util.Map; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; -import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.settings.model.CConfigurationStatus; import org.eclipse.cdt.core.settings.model.ICBuildSetting; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; @@ -48,136 +46,169 @@ public class CModelMock { */ public static class DummyCProjectDescription implements ICProjectDescription { + @Override public ICSettingObject[] getChildSettings() { return null; } + @Override public String getId() { return null; } + @Override public String getName() { return null; } + @Override public int getType() { return 0; } + @Override public boolean isValid() { return false; } + @Override public ICConfigurationDescription getConfiguration() { return null; } + @Override public ICSettingContainer getParent() { return null; } + @Override public boolean isReadOnly() { return false; } + @Override public ICStorageElement getStorage(String id, boolean create) throws CoreException { return null; } + @Override public void removeStorage(String id) throws CoreException { } + @Override public ICStorageElement importStorage(String id, ICStorageElement el) throws UnsupportedOperationException, CoreException { return null; } + @Override public void setReadOnly(boolean readOnly, boolean keepModify) { } + @Override public int getConfigurationRelations() { return 0; } + @Override public void setConfigurationRelations(int status) { } + @Override public void useDefaultConfigurationRelations() { } + @Override public boolean isDefaultConfigurationRelations() { return false; } + @Override public ICConfigurationDescription[] getConfigurations() { return null; } + @Override public ICConfigurationDescription getActiveConfiguration() { return null; } + @Override public void setActiveConfiguration(ICConfigurationDescription cfg) throws WriteAccessException { } + @Override public ICConfigurationDescription createConfiguration(String id, String name, ICConfigurationDescription base) throws CoreException, WriteAccessException { return null; } + @Override public ICConfigurationDescription createConfiguration( String buildSystemId, CConfigurationData data) throws CoreException, WriteAccessException { return null; } + @Override public ICConfigurationDescription getConfigurationByName(String name) { return null; } + @Override public ICConfigurationDescription getConfigurationById(String id) { return null; } + @Override public void removeConfiguration(String name) throws WriteAccessException { } + @Override public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException { } + @Override public IProject getProject() { return null; } + @Override public boolean isModified() { return false; } + @Override public Object getSessionProperty(QualifiedName name) { return null; } + @Override public void setSessionProperty(QualifiedName name, Object value) { } + @Override public ICConfigurationDescription getDefaultSettingConfiguration() { return null; } + @Override public void setDefaultSettingConfiguration( ICConfigurationDescription cfg) { } + @Override public boolean isCdtProjectCreating() { return false; } + @Override public void setCdtProjectCreated() { } @@ -195,222 +226,269 @@ public class CModelMock { this.id = id; } + @Override public ICSettingObject[] getChildSettings() { return null; } + @Override public String getId() { return id; } + @Override public String getName() { return null; } + @Override public int getType() { return 0; } + @Override public boolean isValid() { return false; } + @Override public ICConfigurationDescription getConfiguration() { return null; } + @Override public ICSettingContainer getParent() { return null; } + @Override public boolean isReadOnly() { return false; } + @Override public ICStorageElement getStorage(String id, boolean create) throws CoreException { return null; } + @Override public void removeStorage(String id) throws CoreException { } + @Override public ICStorageElement importStorage(String id, ICStorageElement el) throws UnsupportedOperationException, CoreException { return null; } + @Override public void setReadOnly(boolean readOnly, boolean keepModify) { } + @Override public boolean isActive() { return false; } + @Override public String getDescription() { return null; } + @Override public void setDescription(String des) throws WriteAccessException { } + @Override public ICProjectDescription getProjectDescription() { return null; } + @Override public ICFolderDescription getRootFolderDescription() { return null; } + @Override public ICFolderDescription[] getFolderDescriptions() { return null; } + @Override public ICFileDescription[] getFileDescriptions() { return null; } + @Override public ICResourceDescription[] getResourceDescriptions() { return null; } + @Override public ICResourceDescription getResourceDescription(IPath path, boolean exactPath) { return null; } + @Override public void removeResourceDescription(ICResourceDescription des) throws CoreException, WriteAccessException { } + @Override public ICFileDescription createFileDescription(IPath path, ICResourceDescription base) throws CoreException, WriteAccessException { return null; } + @Override public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base) throws CoreException, WriteAccessException { return null; } + @Override public String getBuildSystemId() { return null; } + @Override public CConfigurationData getConfigurationData() { return null; } + @Override public void setActive() throws WriteAccessException { } + @Override public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException { } + @Override public boolean isModified() { return false; } + @Override public ICTargetPlatformSetting getTargetPlatformSetting() { return null; } + @Override public ICSourceEntry[] getSourceEntries() { return null; } + @Override public ICSourceEntry[] getResolvedSourceEntries() { return null; } + @Override public void setSourceEntries(ICSourceEntry[] entries) throws CoreException, WriteAccessException { } + @Override public Map getReferenceInfo() { return null; } + @Override public void setReferenceInfo(Map refs) throws WriteAccessException { } + @Override public ICExternalSetting[] getExternalSettings() { return null; } + @Override public ICExternalSetting createExternalSetting(String[] languageIDs, String[] contentTypeIds, String[] extensions, ICSettingEntry[] entries) throws WriteAccessException { return null; } + @Override public void removeExternalSetting(ICExternalSetting setting) throws WriteAccessException { } + @Override public void removeExternalSettings() throws WriteAccessException { } + @Override public ICBuildSetting getBuildSetting() { return null; } + @Override public ICdtVariablesContributor getBuildVariablesContributor() { return null; } + @Override public Object getSessionProperty(QualifiedName name) { return null; } + @Override public void setSessionProperty(QualifiedName name, Object value) { } + @Override public void setName(String name) throws WriteAccessException { } + @Override public ICConfigExtensionReference[] get(String extensionPointID) { return null; } + @Override public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException { return null; } + @Override public void remove(ICConfigExtensionReference ext) throws CoreException { } + @Override public void remove(String extensionPoint) throws CoreException { } + @Override public boolean isPreferenceConfiguration() { return false; } + @Override public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExludeStatus) { return null; } + @Override public void setExternalSettingsProviderIds(String[] ids) { } + @Override public String[] getExternalSettingsProviderIds() { return null; } + @Override public void updateExternalSettingsProviders(String[] ids) throws WriteAccessException { } + @Override public CConfigurationStatus getConfigurationStatus() { return null; } - public void setLanguageSettingProviders(List providers) { - } - - public List getLanguageSettingProviders() { - return null; - } - } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java new file mode 100644 index 00000000000..76c2e28c72c --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2011, 2011 Andrew Gvozdev and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrew Gvozdev - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.language.settings.providers; + +import java.util.List; + +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +/** + * Interface to express ability (of a configuration description) to handle Language Settings + * Providers. + * @see ILanguageSettingsProvider + * + */ +public interface ILanguageSettingsProvidersKeeper { + /** + * Sets the list of language settings providers. Language settings providers are + * used to supply language settings {@link ICLanguageSettingEntry} such as include paths + * or preprocessor macros. + * + * @param providers the list of providers to assign to the owner (configuration description). + * This method clones the internal list or otherwise ensures immutability of the internal + * list before actual addition to the project model. + * That is due to TODO - very important reason but I forgot why by now. + */ + public void setLanguageSettingProviders(List providers); + + /** + * Returns the list of language settings providers. Language settings providers are + * used to supply language settings {@link ICLanguageSettingEntry} such as include paths + * or preprocessor macros. + * + * @return the list of providers to assign to the owner (configuration description). This + * returns immutable list. Use {@link #setLanguageSettingProviders(List)} to change. + * This method does not return {@code null}. + */ + public List getLanguageSettingProviders(); + +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager_TBD.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager_TBD.java index d0ea6724b89..c8464960d7c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager_TBD.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager_TBD.java @@ -21,23 +21,26 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; /** - * This temporary class keeps the utility methods being looking for better home + * This temporary class keeps the utility methods being looking for better home. + * Checking if any Language Settings Provider has custom entries for the resource. */ public class LanguageSettingsManager_TBD { public static boolean isCustomizedResource(ICConfigurationDescription cfgDescription, IResource rc) { if (rc instanceof IProject) return false; - for (ILanguageSettingsProvider provider: cfgDescription.getLanguageSettingProviders()) { - if (provider instanceof ILanguageSettingsBroadcastingProvider) { - for (String languageId : LanguageSettingsManager.getLanguages(rc, cfgDescription)) { - List list = provider.getSettingEntries(cfgDescription, rc, languageId); - if (list!=null) { - // TODO - check default or check parent? - List listDefault = provider.getSettingEntries(null, null, languageId); - // != is OK here due as the equal lists will have the same reference in WeakHashSet - if (list != listDefault) - return true; + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + for (ILanguageSettingsProvider provider: ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()) { + if (provider instanceof ILanguageSettingsBroadcastingProvider) { + for (String languageId : LanguageSettingsManager.getLanguages(rc, cfgDescription)) { + List list = provider.getSettingEntries(cfgDescription, rc, languageId); + if (list!=null) { + // TODO - check default or check parent? + List listDefault = provider.getSettingEntries(null, null, languageId); + // != is OK here due as the equal lists will have the same reference in WeakHashSet + if (list != listDefault) + return true; + } } } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java index be5c8f611cc..610db25b207 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java @@ -86,10 +86,12 @@ public class ScannerDiscoveryLegacySupport { * which is not intended to be referenced by clients. */ public static boolean isMbsLanguageSettingsProviderOn(ICConfigurationDescription cfgDescription) { - List lsProviders = cfgDescription.getLanguageSettingProviders(); - for (ILanguageSettingsProvider lsp : lsProviders) { - if (MBS_LANGUAGE_SETTINGS_PROVIDER.equals(lsp.getId())) { - return true; + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + for (ILanguageSettingsProvider lsp : lsProviders) { + if (MBS_LANGUAGE_SETTINGS_PROVIDER.equals(lsp.getId())) { + return true; + } } } return false; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java index 8ca2a43140e..eac75d44021 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java @@ -10,11 +10,9 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; -import java.util.List; import java.util.Map; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; -import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider; @@ -389,31 +387,4 @@ public interface ICConfigurationDescription extends ICSettingContainer, ICSettin void updateExternalSettingsProviders(String[] ids) throws WriteAccessException; CConfigurationStatus getConfigurationStatus(); - - /** - * Sets the list of language settings providers. Language settings providers are - * used to supply language settings {@link ICLanguageSettingEntry} such as include paths - * or preprocessor macros. - * - * @param providers the list of providers to assign to the configuration description. - * Warning: the providers will be cloned before actual addition to the project model - * due to TODO - very important reason but I forgot why by now. - * - * @since 6.0 - */ - public void setLanguageSettingProviders(List providers); - - /** - * Returns the list of language settings providers. Language settings providers are - * used to supply language settings {@link ICLanguageSettingEntry} such as include paths - * or preprocessor macros. - * - * @return the list of providers to assign to the configuration description. This - * returns immutable list. Use {@link #setLanguageSettingProviders(List)} to change. - * This method does not return {@code null}. - * - * @since 6.0 - */ - public List getLanguageSettingProviders(); - } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java index 864229a31f2..ae19d072285 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsChangeE import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsChangeListener; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsEditableProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage; @@ -358,13 +359,15 @@ projects: if (prjDescription != null) { ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); for (ICConfigurationDescription cfgDescription : cfgDescriptions) { - for (ILanguageSettingsProvider provider : cfgDescription.getLanguageSettingProviders()) { - if (isWorkspaceProvider(provider) && serializableIds.contains(provider.getId())) { - LanguageSettingsChangeEvent event = new LanguageSettingsChangeEvent(prjDescription); - if (event.getConfigurationDescriptionIds().length > 0) { - events.add(event); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + for (ILanguageSettingsProvider provider : ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()) { + if (isWorkspaceProvider(provider) && serializableIds.contains(provider.getId())) { + LanguageSettingsChangeEvent event = new LanguageSettingsChangeEvent(prjDescription); + if (event.getConfigurationDescriptionIds().length > 0) { + events.add(event); + } + continue projects; } - continue projects; } } } @@ -485,12 +488,15 @@ projects: ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); for (ICConfigurationDescription cfgDescription : cfgDescriptions) { + if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) + continue; + Element elementConfiguration = XmlUtil.appendElement(projectElementPrjStore, ELEM_CONFIGURATION, new String[] { LanguageSettingsExtensionManager.ATTR_ID, cfgDescription.getId(), LanguageSettingsExtensionManager.ATTR_NAME, cfgDescription.getName(), }); Element elementConfigurationWsp = null; - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); if (providers.size()>0) { Element elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] { ATTR_POINT, LanguageSettingsExtensionManager.PROVIDER_EXTENSION_FULL_ID}); @@ -656,8 +662,8 @@ projects: } ICConfigurationDescription cfgDescription = prjDescription.getConfigurationById(cfgId); - if (cfgDescription!=null) { - cfgDescription.setLanguageSettingProviders(providers); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); if (cfgDescription instanceof IInternalCCfgInfo) { try { ((IInternalCCfgInfo) cfgDescription).getSpecSettings().dropDelta(); @@ -773,11 +779,11 @@ projects: // Already existing legacy projects ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); for (ICConfigurationDescription cfgDescription : cfgDescriptions) { - if (cfgDescription!=null) { + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { List providers = new ArrayList(2); ILanguageSettingsProvider providerMBS = getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER); providers.add(providerMBS); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); } } @@ -840,17 +846,19 @@ projects: if (prjDescription != null) { List prjProviders = new ArrayList(); for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { - List providers = cfgDescription.getLanguageSettingProviders(); - for (ILanguageSettingsProvider provider : providers) { - if (!LanguageSettingsManager.isWorkspaceProvider(provider)) { - if (isObjectInTheList(prjProviders, provider)) { - IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Inconsistent state, duplicate LSP in project description " - + "[" + System.identityHashCode(provider) + "] " - + provider); - CoreException e = new CoreException(status); - CCorePlugin.log(e); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + for (ILanguageSettingsProvider provider : providers) { + if (!LanguageSettingsManager.isWorkspaceProvider(provider)) { + if (isObjectInTheList(prjProviders, provider)) { + IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Inconsistent state, duplicate LSP in project description " + + "[" + System.identityHashCode(provider) + "] " + + provider); + CoreException e = new CoreException(status); + CCorePlugin.log(e); + } + prjProviders.add(provider); } - prjProviders.add(provider); } } } @@ -883,12 +891,14 @@ projects: List listeners = new ArrayList(); if (prjDescription != null) { for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { - List providers = cfgDescription.getLanguageSettingProviders(); - for (ILanguageSettingsProvider provider : providers) { - if (provider instanceof ICListenerAgent) { - ICListenerAgent listener = (ICListenerAgent) provider; - if (!isObjectInTheList(listeners, listener)) { - listeners.add(listener); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + for (ILanguageSettingsProvider provider : providers) { + if (provider instanceof ICListenerAgent) { + ICListenerAgent listener = (ICListenerAgent) provider; + if (!isObjectInTheList(listeners, listener)) { + listeners.add(listener); + } } } } @@ -914,11 +924,13 @@ projects: List associations = new ArrayList(); if (prjDescription != null) { for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { - List providers = cfgDescription.getLanguageSettingProviders(); - List listeners = selectListeners(providers); - for (ICListenerAgent listener : listeners) { - if (!isListenerInTheListOfAssociations(associations, listener)) { - associations.add(new ListenerAssociation(listener, cfgDescription)); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List listeners = selectListeners(providers); + for (ICListenerAgent listener : listeners) { + if (!isListenerInTheListOfAssociations(associations, listener)) { + associations.add(new ListenerAssociation(listener, cfgDescription)); + } } } } @@ -1210,10 +1222,14 @@ projects: private static List getSettingEntriesByKind(ICConfigurationDescription cfgDescription, IResource rc, String languageId, int kind, boolean checkLocality, boolean isLocal) { + if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) { + return null; + } + List entries = new ArrayList(); List alreadyAdded = new ArrayList(); - List providers = cfgDescription.getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); for (ILanguageSettingsProvider provider: providers) { List providerEntries = getSettingEntriesUpResourceTree(provider, cfgDescription, rc, languageId); for (ICLanguageSettingEntry entry : providerEntries) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java index a068d9a0d39..771eb1280de 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java @@ -19,6 +19,7 @@ import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.settings.model.CConfigurationStatus; import org.eclipse.cdt.core.settings.model.ICBuildSetting; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; @@ -51,7 +52,8 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.QualifiedName; -public class CConfigurationDescription extends CDataProxyContainer implements ICConfigurationDescription, IProxyFactory, IInternalCCfgInfo { +public class CConfigurationDescription extends CDataProxyContainer + implements ICConfigurationDescription, IProxyFactory, IInternalCCfgInfo, ILanguageSettingsProvidersKeeper { private CfgProxyCache fCache; // private ProxyProvider fFileProxyProvider; // private ProxyProvider fFolderProxyProvider; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java index a58a4e717c0..42087ea7220 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java @@ -17,6 +17,7 @@ import java.util.Map; import org.eclipse.cdt.core.cdtvariables.ICdtVariable; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.settings.model.CConfigurationStatus; import org.eclipse.cdt.core.settings.model.ICBuildSetting; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; @@ -77,7 +78,7 @@ import org.eclipse.core.runtime.QualifiedName; * reference fBaseDescription gets set to null. */ public class CConfigurationDescriptionCache extends CDefaultConfigurationData - implements ICConfigurationDescription, IInternalCCfgInfo, ICachedData { + implements ICConfigurationDescription, IInternalCCfgInfo, ILanguageSettingsProvidersKeeper, ICachedData { private CProjectDescription fParent; private PathSettingsContainer fPathSettingContainer = PathSettingsContainer.createRootContainer(); private ResourceDescriptionHolder fRcHolder = new ResourceDescriptionHolder(fPathSettingContainer, true); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index 231694eb3f9..f119f6bffa5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -51,6 +51,7 @@ import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElementDelta; @@ -1571,9 +1572,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { CCorePlugin.log(e); } - List newLSProviders = newCfg.getLanguageSettingProviders(); - List oldLSProviders = oldCfg.getLanguageSettingProviders(); - if(!newLSProviders.equals(oldLSProviders)) + List newLSProviders = null; + if (newCfg instanceof ILanguageSettingsProvidersKeeper) + newLSProviders = ((ILanguageSettingsProvidersKeeper) newCfg).getLanguageSettingProviders(); + List oldLSProviders = null; + if (oldCfg instanceof ILanguageSettingsProvidersKeeper) + oldLSProviders = ((ILanguageSettingsProvidersKeeper) oldCfg).getLanguageSettingProviders(); + if(newLSProviders != oldLSProviders && (newLSProviders == null || !newLSProviders.equals(oldLSProviders))) delta.addChangeFlags(ICDescriptionDelta.LANGUAGE_SETTINGS_PROVIDERS); calculateCfgExtSettingsDelta(delta); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java index 939161cdf2e..653b0c662bd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java @@ -14,11 +14,9 @@ package org.eclipse.cdt.internal.core.settings.model; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.List; import java.util.Map; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; -import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.settings.model.CConfigurationStatus; import org.eclipse.cdt.core.settings.model.ICBuildSetting; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; @@ -639,17 +637,4 @@ public class MultiConfigDescription extends MultiItemsHolder implements fCfgs[i].removeStorage(id); } - @Override - public void setLanguageSettingProviders(List providers) { - if (DEBUG) - System.out.println("Bad multi access: MultiConfigDescription.setLanguageSettingProviders()"); //$NON-NLS-1$ - } - - @Override - public List getLanguageSettingProviders() { - if (DEBUG) - System.out.println("Bad multi access: MultiConfigDescription.getLanguageSettingProviders()"); //$NON-NLS-1$ - return null; - } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java index 4f01895a27f..183a6df53db 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java @@ -45,6 +45,7 @@ import org.eclipse.swt.widgets.TreeItem; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsBroadcastingProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsEditableProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; @@ -391,9 +392,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { if (!page.isForPrefs()) { ICConfigurationDescription[] cfgDescriptions = page.getCfgsEditable(); for (ICConfigurationDescription cfgDescription : cfgDescriptions) { - if (cfgDescription!=null) { + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { String cfgId = cfgDescription.getId(); - List initialProviders = cfgDescription.getLanguageSettingProviders(); + List initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); initialProvidersMap.put(cfgId, initialProviders); } } @@ -740,13 +741,13 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { ICConfigurationDescription cfgDescription = getConfigurationDescription(); List initialProviders = initialProvidersMap.get(cfgDescription.getId()); if (initialProviders.contains(selectedProvider)) { - List providers = new ArrayList(cfgDescription.getLanguageSettingProviders()); + List providers = new ArrayList(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()); int pos = providers.indexOf(selectedProvider); if (pos>=0) { try { selectedProvider = selectedProvider.clone(); providers.set(pos, selectedProvider); - cfgDescription.setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); } catch (CloneNotSupportedException e) { CUIPlugin.log("Internal Error: cannot clone provider "+selectedProvider.getId(), e); } @@ -858,8 +859,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { if (currentLanguageId!=null) { IResource rc = getResource(); ICConfigurationDescription cfgDescription = getConfigurationDescription(); - if (rc!=null && cfgDescription!=null) { - List cfgProviders = cfgDescription.getLanguageSettingProviders(); + if (rc != null && cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List cfgProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); for (ILanguageSettingsProvider cfgProvider : cfgProviders) { ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(cfgProvider); if (rawProvider instanceof LanguageSettingsBaseProvider) { @@ -958,10 +959,13 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { // However for the performance reasons for resource decorators where the same logic is used // we use null for resetting file/folder resource which should be correct in most cases. // Count that as a feature. - boolean changed = false; ICConfigurationDescription cfgDescription = getConfigurationDescription(); + if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) + return; + + boolean changed = false; IResource rc = getResource(); - List oldProviders = cfgDescription.getLanguageSettingProviders(); + List oldProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List newProviders = new ArrayList(oldProviders.size()); providers: for (ILanguageSettingsProvider provider : oldProviders) { @@ -992,7 +996,7 @@ providers: for (ILanguageSettingsProvider provider : oldProviders) { newProviders.add(provider); } if (changed) { - cfgDescription.setLanguageSettingProviders(newProviders); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(newProviders); // updateTreeEntries(); // updateData(getResDesc()); List tableItems = getProviders(currentLanguageId); @@ -1007,15 +1011,20 @@ providers: for (ILanguageSettingsProvider provider : oldProviders) { ICConfigurationDescription srcCfgDescription = srcRcDescription.getConfiguration(); ICConfigurationDescription destCfgDescription = destRcDescription.getConfiguration(); - List providers = srcCfgDescription.getLanguageSettingProviders(); - destCfgDescription.setLanguageSettingProviders(providers); + if (srcCfgDescription instanceof ILanguageSettingsProvidersKeeper + && destCfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List providers = ((ILanguageSettingsProvidersKeeper) srcCfgDescription).getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) destCfgDescription).setLanguageSettingProviders(providers); + } } if (!page.isForPrefs()) { ICConfigurationDescription sd = srcRcDescription.getConfiguration(); ICConfigurationDescription dd = destRcDescription.getConfiguration(); - List newProviders = sd.getLanguageSettingProviders(); - dd.setLanguageSettingProviders(newProviders); + if (sd instanceof ILanguageSettingsProvidersKeeper && dd instanceof ILanguageSettingsProvidersKeeper) { + List newProviders = ((ILanguageSettingsProvidersKeeper) sd).getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) dd).setLanguageSettingProviders(newProviders); + } } performOK(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java index 99f0614f3b5..380a24ff353 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java @@ -47,6 +47,7 @@ import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsEditableProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager_TBD; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider; @@ -195,8 +196,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { return null; ICConfigurationDescription cfgDescription = getResDesc().getConfiguration(); - return cfgDescription; - } + return cfgDescription; + } /** * Shortcut for getting the currently selected provider. @@ -216,9 +217,9 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { if (page.isForProject()) { ICConfigurationDescription[] cfgDescriptions = page.getCfgsEditable(); for (ICConfigurationDescription cfgDescription : cfgDescriptions) { - if (cfgDescription!=null) { + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { String cfgId = cfgDescription.getId(); - List initialProviders = cfgDescription.getLanguageSettingProviders(); + List initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); initialProvidersByCfg.put(cfgId, initialProviders); } } @@ -371,11 +372,13 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { if (!page.isForPrefs()) { cfgDescription = getConfigurationDescription(); - List cfgProviders = new ArrayList(cfgDescription.getLanguageSettingProviders()); - pos = getProviderIndex(newProvider.getId(), cfgProviders); - cfgProviders.set(pos, newProvider); - cfgDescription.setLanguageSettingProviders(cfgProviders); - tableProvidersViewer.setCheckedElements(cfgProviders.toArray(new ILanguageSettingsProvider[0])); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List cfgProviders = new ArrayList(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()); + pos = getProviderIndex(newProvider.getId(), cfgProviders); + cfgProviders.set(pos, newProvider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(cfgProviders); + tableProvidersViewer.setCheckedElements(cfgProviders.toArray(new ILanguageSettingsProvider[0])); + } } refreshItem(newProvider); } @@ -479,8 +482,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { tableProviders.setSelection(pos); ICConfigurationDescription cfgDescription = getConfigurationDescription(); - if (cfgDescription!=null) { - List cfgProviders = cfgDescription.getLanguageSettingProviders(); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List cfgProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); tableProvidersViewer.setCheckedElements(cfgProviders.toArray(new ILanguageSettingsProvider[0])); } @@ -509,8 +512,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { List providers; ICConfigurationDescription cfgDescription = getConfigurationDescription(); - if (cfgDescription!=null) { - providers = new ArrayList(cfgDescription.getLanguageSettingProviders()); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + providers = new ArrayList(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()); for (ILanguageSettingsProvider provider : providers) { idsList.add(provider.getId()); } @@ -640,14 +643,16 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { providers.add(provider); } ICConfigurationDescription cfgDescription = getConfigurationDescription(); - cfgDescription.setLanguageSettingProviders(providers); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - if (selectedElement!=null) { - tableProvidersViewer.update(selectedElement, null); - if (selectedElement instanceof ILanguageSettingsProvider) { - ILanguageSettingsProvider selectedProvider = (ILanguageSettingsProvider) selectedElement; - initializeOptionsPage(selectedProvider, cfgDescription); - displaySelectedOptionPage(); + if (selectedElement!=null) { + tableProvidersViewer.update(selectedElement, null); + if (selectedElement instanceof ILanguageSettingsProvider) { + ILanguageSettingsProvider selectedProvider = (ILanguageSettingsProvider) selectedElement; + initializeOptionsPage(selectedProvider, cfgDescription); + displaySelectedOptionPage(); + } } } } @@ -865,18 +870,20 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { if (page.isForProject()) { ICConfigurationDescription cfgDescription = getConfigurationDescription(); - List cfgProviders = new ArrayList(cfgDescription.getLanguageSettingProviders()); - boolean atLeastOneChanged = false; - for (int i=0;i cfgProviders = new ArrayList(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()); + boolean atLeastOneChanged = false; + for (int i=0;i destProviders = new ArrayList(); + if (srcCfgDescription instanceof ILanguageSettingsProvidersKeeper + && destCfgDescription instanceof ILanguageSettingsProvidersKeeper) { - List srcProviders = srcCfgDescription.getLanguageSettingProviders(); - for (ILanguageSettingsProvider pro : srcProviders) { - // TODO: clone - destProviders.add(pro); + List destProviders = new ArrayList(); + List srcProviders = ((ILanguageSettingsProvidersKeeper) srcCfgDescription).getLanguageSettingProviders(); + for (ILanguageSettingsProvider pro : srcProviders) { + // TODO: clone + destProviders.add(pro); + } + ((ILanguageSettingsProvidersKeeper) destCfgDescription).setLanguageSettingProviders(destProviders); } - - destCfgDescription.setLanguageSettingProviders(destProviders); } if (!page.isForPrefs()) { ICConfigurationDescription sd = srcRcDescription.getConfiguration(); ICConfigurationDescription dd = destRcDescription.getConfiguration(); - List newProviders = sd.getLanguageSettingProviders(); - dd.setLanguageSettingProviders(newProviders); + if (sd instanceof ILanguageSettingsProvidersKeeper && dd instanceof ILanguageSettingsProvidersKeeper) { + List newProviders = ((ILanguageSettingsProvidersKeeper) sd).getLanguageSettingProviders(); + ((ILanguageSettingsProvidersKeeper) dd).setLanguageSettingProviders(newProviders); + } } performOK(); @@ -942,14 +953,15 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { ICResourceDescription rcDesc = getResDesc(); IResource rc = getResource(); ICConfigurationDescription cfgDescription = rcDesc.getConfiguration(); - - List destProviders = new ArrayList(); - List providers = cfgDescription.getLanguageSettingProviders(); - for (ILanguageSettingsProvider pro : providers) { - // TODO: clone - destProviders.add(pro); + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List destProviders = new ArrayList(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + for (ILanguageSettingsProvider pro : providers) { + // TODO: clone + destProviders.add(pro); + } + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(destProviders); } - cfgDescription.setLanguageSettingProviders(destProviders); } // Build Settings page