diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java index aa76da2cc94..ff161b465e3 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java @@ -14,7 +14,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.eclipse.cdt.core.settings.model.CMacroEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICMacroEntry; import org.eclipse.cdt.core.settings.model.util.CDataUtil; @@ -31,14 +30,14 @@ public class PathInfoToLangSettingsConverter { return ICLanguageSettingEntry.INCLUDE_PATH | ICLanguageSettingEntry.MACRO; } - + public static int getSupportedEntryKinds(IPerFileDiscoveredPathInfo info){ return ICLanguageSettingEntry.INCLUDE_FILE | ICLanguageSettingEntry.INCLUDE_PATH | ICLanguageSettingEntry.MACRO | ICLanguageSettingEntry.MACRO_FILE; } - + public static ICLanguageSettingEntry[] entriesForKind(int kind, int flags, PathInfo info){ switch (kind) { case ICLanguageSettingEntry.INCLUDE_PATH: @@ -73,7 +72,7 @@ public class PathInfoToLangSettingsConverter { } return entries; } - + private static ICMacroEntry[] calculateEntries(int flags, Map map){ ICMacroEntry entries[] = new ICMacroEntry[map.size()]; int num = 0; @@ -81,7 +80,7 @@ public class PathInfoToLangSettingsConverter { for (Entry entry : entrySet) { String name = entry.getKey(); String value = entry.getValue(); - entries[num++] = new CMacroEntry(name, value, flags); + entries[num++] = CDataUtil.createCMacroEntry(name, value, flags); } return entries; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index 102a944c669..8c519746873 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -27,7 +27,6 @@ import java.util.Vector; import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set; import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache; import org.eclipse.cdt.core.ErrorParserManager; -import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CLibraryFileEntry; import org.eclipse.cdt.core.settings.model.CLibraryPathEntry; import org.eclipse.cdt.core.settings.model.CSourceEntry; @@ -92,10 +91,10 @@ import org.eclipse.osgi.util.NLS; import org.osgi.framework.Version; public class Configuration extends BuildObject implements IConfiguration, IBuildPropertiesRestriction, IBuildPropertyChangeListener, IRealBuildObjectAssociation { - + private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String EMPTY_CFG_ID = "org.eclipse.cdt.build.core.emptycfg"; //$NON-NLS-1$ - + // Parent and children private String parentId; private IConfiguration parent; @@ -105,10 +104,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild private String cleanCommand; private String artifactExtension; private String errorParserIds; - private String prebuildStep; - private String postbuildStep; - private String preannouncebuildStep; - private String postannouncebuildStep; + private String prebuildStep; + private String postbuildStep; + private String preannouncebuildStep; + private String postannouncebuildStep; private String description; private ICSourceEntry[] sourceEntries; private BuildObjectProperties buildProperties; @@ -135,10 +134,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild private ICfgScannerConfigBuilderInfo2Set cfgScannerInfo; private boolean isPreferenceConfig; private List excludeList; - + //property name for holding the rebuild state private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$ - + //The resource delta passed to the builder is not always up-to-date //for the given configuration because between two builds of the same configuration //any number of other configuration builds may occur @@ -146,7 +145,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild //with the resource tree between the two configuration builds // //The trivial approach implemented currently is to hold - //the general information of whether some resources were + //the general information of whether some resources were //removed,changed,etc. and detect whether the rebuild is needed //based upon this information // @@ -165,7 +164,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild //builder enabling/disabling as the Builder substitution functionality // // private static final String INTERNAL_BUILDER = "internalBuilder"; //$NON-NLS-1$ - //preference key that holds the Internal Builder enable state + //preference key that holds the Internal Builder enable state // private static final String INTERNAL_BUILDER_ENABLED = "enabled"; //$NON-NLS-1$ //preference key that holds the internal builder mode // private static final String INTERNAL_BUILDER_IGNORE_ERR = "ignoreErr"; //$NON-NLS-1$ @@ -191,35 +190,35 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /** * Create an extension configuration from the project manifest file element. - * - * @param projectType The ProjectType the configuration will be added to. + * + * @param projectType The ProjectType the configuration will be added to. * @param element The element from the manifest that contains the configuration information. */ public Configuration(ProjectType projectType, IManagedConfigElement element, String managedBuildRevision) { this.projectType = projectType; isExtensionConfig = true; - + // setup for resolving resolved = false; - + setManagedBuildRevision(managedBuildRevision); - + // Initialize from the XML attributes loadFromManifest(element); - + // Hook me up to the Managed Build Manager ManagedBuildManager.addExtensionConfiguration(this); - + // Hook me up to the ProjectType if (projectType != null) { projectType.addConfiguration(this); } - + IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME); if(enablements.length > 0) booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements); - + // Load the children IManagedConfigElement[] configElements = element.getChildren(); List srcPathList = new ArrayList(); @@ -247,23 +246,23 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild sourceEntries = seList.toArray(new ICSourceEntry[seList.size()]); } } - + sourceEntries = createSourceEntries(sourceEntries, srcPathList, excludeList); - + excludeList = null; - + if(rootFolderInfo == null) createRootFolderInfo(); - + String props = SafeStringInterner.safeIntern(element.getAttribute(BUILD_PROPERTIES)); if(props != null) buildProperties = new BuildObjectProperties(props, this, this); - + String artType = SafeStringInterner.safeIntern(element.getAttribute(BUILD_ARTEFACT_TYPE)); if(artType != null){ if(buildProperties == null) buildProperties = new BuildObjectProperties(this, this); - + try { buildProperties.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artType, true); } catch (CoreException e) { @@ -288,7 +287,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild setDirty(false); } - + private static ICSourceEntry[] createSourceEntries(ICSourceEntry[] curEntries, List pathList, List excludeList){ for(int i = 0; i < excludeList.size(); i++){ IPath path = excludeList.get(i); @@ -297,12 +296,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } if(pathList.size() == 0) pathList.add(Path.EMPTY); - + if(pathList.size() == 1 && pathList.get(0).equals(Path.EMPTY) && excludeList.size() == 0) return curEntries; - + int pathSize = pathList.size(); Map map = new LinkedHashMap(); @@ -311,19 +310,19 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild ICSourceEntry entry = map.get(path); if(entry == null) entry = new CSourceEntry(path, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); - + entry = CDataUtil.addExcludePaths(entry, excludeList, true); if(entry != null) map.put(path, entry); } - + return map.values().toArray(new ICSourceEntry[map.size()]); } /** * Create a new extension configuration based on one already defined. - * - * @param projectType The ProjectType the configuration will be added to. + * + * @param projectType The ProjectType the configuration will be added to. * @param parentConfig The IConfiguration that is the parent configuration of this configuration * @param id A unique ID for the new configuration. */ @@ -331,25 +330,25 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild setId(id); this.projectType = projectType; isExtensionConfig = true; - + // setup for resolving resolved = false; if (parentConfig != null) { name = parentConfig.getName(); - // If this constructor is called to clone an existing - // configuration, the parent of the parent should be stored. + // If this constructor is called to clone an existing + // configuration, the parent of the parent should be stored. // As of 2.1, there is still one single level of inheritance to // worry about parent = parentConfig.getParent() == null ? parentConfig : parentConfig.getParent(); } - + // Hook me up to the Managed Build Manager ManagedBuildManager.addExtensionConfiguration(this); - + // Hook me up to the ProjectType if (projectType != null) { - projectType.addConfiguration(this); + projectType.addConfiguration(this); // set managedBuildRevision setManagedBuildRevision(projectType.getManagedBuildRevision()); } @@ -357,8 +356,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /** * Create a new extension configuration and fill in the attributes and childen later. - * - * @param projectType The ProjectType the configuration will be added to. + * + * @param projectType The ProjectType the configuration will be added to. * @param parentConfig The IConfiguration that is the parent configuration of this configuration * @param id A unique ID for the new configuration. * @param name A name for the new configuration. @@ -369,10 +368,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild this.projectType = projectType; parent = parentConfig; isExtensionConfig = true; - + // Hook me up to the Managed Build Manager ManagedBuildManager.addExtensionConfiguration(this); - + // Hook me up to the ProjectType if (projectType != null) { projectType.addConfiguration(this); @@ -381,21 +380,21 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } /** - * Create a Configuration based on the specification stored in the + * Create a Configuration based on the specification stored in the * project file (.cdtbuild). - * - * @param managedProject The ManagedProject the configuration will be added to. + * + * @param managedProject The ManagedProject the configuration will be added to. * @param element The XML element that contains the configuration settings. - * + * */ public Configuration(ManagedProject managedProject, ICStorageElement element, String managedBuildRevision, boolean isPreference) { this.managedProject = managedProject; this.isPreferenceConfig = isPreference; isExtensionConfig = false; fCfgData = new BuildConfigurationData(this); - + setManagedBuildRevision(managedBuildRevision); - + // Initialize from the XML attributes loadFromProject(element); @@ -427,18 +426,18 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild sourceEntries = seList.toArray(new ICSourceEntry[seList.size()]); } } - + resolveProjectReferences(true); - + sourceEntries = createSourceEntries(sourceEntries, srcPathList, excludeList); excludeList = null; - + PropertyManager mngr = PropertyManager.getInstance(); String rebuild = mngr.getProperty(this, REBUILD_STATE); if(rebuild == null || Boolean.valueOf(rebuild).booleanValue()) rebuildNeeded = true; - + String rcChangeState = mngr.getProperty(this, RC_CHANGE_STATE); if(rcChangeState == null) resourceChangeState = ~0; @@ -449,11 +448,11 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild resourceChangeState = ~0; } } - + setDirty(false); - + // Preferences prefs = getPreferences(INTERNAL_BUILDER); -// +// // internalBuilderEnabled = prefs != null ? // prefs.getBoolean(INTERNAL_BUILDER_ENABLED, false) : false; // internalBuilderIgnoreErr = prefs != null ? @@ -463,7 +462,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public Configuration(ManagedProject managedProject, ToolChain tCh, String id, String name) { setId(id); setName(name); - + // this.description = cloneConfig.getDescription(); this.managedProject = managedProject; isExtensionConfig = false; @@ -479,38 +478,38 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild fCfgData = new BuildConfigurationData(this); if(baseCfg.buildProperties != null) this.buildProperties = new BuildObjectProperties(baseCfg.buildProperties, this, this); - + // set managedBuildRevision setManagedBuildRevision(baseCfg.getManagedBuildRevision()); - + // if(!baseCfg.isExtensionConfig) // cloneChildren = true; - // If this constructor is called to clone an existing - // configuration, the parent of the cloning config should be stored. + // If this constructor is called to clone an existing + // configuration, the parent of the cloning config should be stored. parent = baseCfg.isExtensionConfig || baseCfg.getParent() == null ? baseCfg : baseCfg.getParent(); - + // Copy the remaining attributes projectType = baseCfg.projectType; - + artifactName = baseCfg.artifactName; - + cleanCommand = baseCfg.cleanCommand; - + artifactExtension = baseCfg.artifactExtension; - + errorParserIds = baseCfg.errorParserIds; - + prebuildStep = baseCfg.prebuildStep; - + postbuildStep = baseCfg.postbuildStep; - + preannouncebuildStep = baseCfg.preannouncebuildStep; - + postannouncebuildStep = baseCfg.postannouncebuildStep; - + if(baseCfg.sourceEntries != null) sourceEntries = baseCfg.sourceEntries.clone(); - + // enableInternalBuilder(baseCfg.isInternalBuilderEnabled()); // setInternalBuilderIgnoreErr(baseCfg.getInternalBuilderIgnoreErr()); // setInternalBuilderParallel(baseCfg.getInternalBuilderParallel()); @@ -518,23 +517,23 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild // setParallelNumber(baseCfg.getParallelNumber()); // internalBuilderEnabled = cloneConfig.internalBuilderEnabled; // internalBuilderIgnoreErr = cloneConfig.internalBuilderIgnoreErr; - + // Clone the configuration's children // Tool Chain - + String tcId = ManagedBuildManager.calculateChildId(tCh.getId(), null); - + IToolChain newChain = createToolChain(tCh, tcId, tCh.getId(), false); - + // For each option/option category child of the tool-chain that is // the child of the selected configuration element, create an option/ // option category child of the cloned configuration's tool-chain element // that specifies the original tool element as its superClass. newChain.createOptions(tCh); - // For each tool element child of the tool-chain that is the child of - // the selected configuration element, create a tool element child of - // the cloned configuration's tool-chain element that specifies the + // For each tool element child of the tool-chain that is the child of + // the selected configuration element, create a tool element child of + // the cloned configuration's tool-chain element that specifies the // original tool element as its superClass. String subId; ITool[] tools = tCh.getTools(); @@ -543,11 +542,11 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild subId = ManagedBuildManager.calculateChildId(toolChild.getId(),null); newChain.createTool(toolChild, subId, toolChild.getName(), false); } - + ITargetPlatform tpBase = tCh.getTargetPlatform(); ITargetPlatform extTp = tpBase; for(;extTp != null && !extTp.isExtensionElement();extTp = extTp.getSuperClass()) {} - + TargetPlatform tp; if(extTp != null){ int nnn = ManagedBuildManager.getRandomNumber(); @@ -562,36 +561,36 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild ((ToolChain)newChain).setTargetPlatform(tp); - + // if(cloneChildren){ //copy expand build macros setting // BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider(); // macroProvider.expandMacrosInBuildfile(this, // macroProvider.areMacrosExpandedInBuildfile(baseCfg)); - + //copy user-defined build macros /* UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier; userMacros.setMacros( userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig), BuildMacroProvider.CONTEXT_CONFIGURATION, this); - */ + */ //copy user-defined environment // UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier; // userEnv.setVariables( // userEnv.getVariables(cloneConfig), this); - + // } - + // Hook me up managedProject.addConfiguration(this); - + IBuilder builder = getEditableBuilder(); try { builder.setManagedBuildOn(false); } catch (CoreException e) { } - + propertiesChanged(); } setDirty(true); @@ -601,14 +600,14 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary) { this(managedProject, cloneConfig, id, cloneChildren, temporary, false); } - + /** * Create a new project, non-extension, configuration based on one already defined. - * - * @param managedProject The ManagedProject the configuration will be added to. + * + * @param managedProject The ManagedProject the configuration will be added to. * @param cloneConfig The IConfiguration to copy the settings from. * @param id A unique ID for the new configuration. - * @param cloneChildren If true, the configuration's tools are cloned + * @param cloneChildren If true, the configuration's tools are cloned */ public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary, boolean isPreferenceConfig) { setId(id); @@ -617,10 +616,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild this.managedProject = managedProject; isExtensionConfig = false; this.isTemporary = temporary; - + copySettingsFrom(cloneConfig, cloneChildren); } - + private void copySettingsFrom(Configuration cloneConfig, boolean cloneChildren){ fCfgData = new BuildConfigurationData(this); if(cloneConfig.buildProperties != null) @@ -633,11 +632,11 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(!cloneConfig.isExtensionConfig) cloneChildren = true; - // If this constructor is called to clone an existing - // configuration, the parent of the cloning config should be stored. + // If this constructor is called to clone an existing + // configuration, the parent of the cloning config should be stored. parent = cloneConfig.isExtensionConfig || cloneConfig.getParent() == null ? cloneConfig : cloneConfig.getParent(); parentId = parent.getId(); - + // Copy the remaining attributes projectType = cloneConfig.projectType; if (cloneConfig.artifactName != null) { @@ -663,10 +662,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } if (cloneConfig.postannouncebuildStep != null) { postannouncebuildStep = new String(cloneConfig.postannouncebuildStep); - } + } if(cloneConfig.sourceEntries != null) sourceEntries = cloneConfig.sourceEntries.clone(); - + // enableInternalBuilder(cloneConfig.isInternalBuilderEnabled()); // setInternalBuilderIgnoreErr(cloneConfig.getInternalBuilderIgnoreErr()); // setInternalBuilderParallel(cloneConfig.getInternalBuilderParallel()); @@ -674,7 +673,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild // setParallelNumber(cloneConfig.getParallelNumber()); // internalBuilderEnabled = cloneConfig.internalBuilderEnabled; // internalBuilderIgnoreErr = cloneConfig.internalBuilderIgnoreErr; - + // Clone the configuration's children // Tool Chain boolean copyIds = cloneConfig.getId().equals(id); @@ -693,12 +692,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild subId = copyIds ? fileInfo.getId() : ManagedBuildManager.calculateChildId(getId(), fileInfo.getPath().toString()); ResourceConfiguration newResConfig = new ResourceConfiguration(this, fileInfo, subId, toolIdMap, cloneChildren); addResourceConfiguration(newResConfig); - + } } - + resolveProjectReferences(false); - + if(cloneChildren){ //copy expand build macros setting BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider(); @@ -711,23 +710,23 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig), BuildMacroProvider.CONTEXT_CONFIGURATION, this); -*/ +*/ //copy user-defined environment // UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier; // userEnv.setVariables( // userEnv.getVariables(cloneConfig), this); } - + // Hook me up if(managedProject != null){ managedProject.addConfiguration(this); } - + if(cloneConfig.isExtensionConfig){ propertiesChanged(); } - + if(copyIds){ rebuildNeeded = cloneConfig.rebuildNeeded; resourceChangeState = cloneConfig.resourceChangeState; @@ -740,7 +739,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } } - + public void applyToManagedProject(ManagedProject mProj){ managedProject = mProj; isPreferenceConfig = false; @@ -751,28 +750,28 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /* * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S */ - + /** - * Initialize the configuration information from an element in the + * Initialize the configuration information from an element in the * manifest file or provided by a dynamicElementProvider - * - * @param element An obejct implementing IManagedConfigElement + * + * @param element An obejct implementing IManagedConfigElement */ protected void loadFromManifest(IManagedConfigElement element) { ManagedBuildManager.putConfigElement(this, element); - + // id setId(SafeStringInterner.safeIntern(element.getAttribute(IConfiguration.ID))); // name name = SafeStringInterner.safeIntern(element.getAttribute(IConfiguration.NAME)); - + // description description = SafeStringInterner.safeIntern(element.getAttribute(IConfiguration.DESCRIPTION)); - + // parent parentId = SafeStringInterner.safeIntern(element.getAttribute(IConfiguration.PARENT)); - + // if (parentID != null) { // // Lookup the parent configuration by ID // parent = ManagedBuildManager.getExtensionConfiguration(parentID); @@ -780,37 +779,37 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild // Get the name of the build artifact associated with configuration artifactName = SafeStringInterner.safeIntern(element.getAttribute(ARTIFACT_NAME)); - + // Get the semicolon separated list of IDs of the error parsers errorParserIds = SafeStringInterner.safeIntern(element.getAttribute(ERROR_PARSERS)); // Get the artifact extension artifactExtension = SafeStringInterner.safeIntern(element.getAttribute(EXTENSION)); - + // Get the clean command cleanCommand = SafeStringInterner.safeIntern(element.getAttribute(CLEAN_COMMAND)); - - // Get the pre-build and post-build commands - prebuildStep = SafeStringInterner.safeIntern(element.getAttribute(PREBUILD_STEP)); - postbuildStep = SafeStringInterner.safeIntern(element.getAttribute(POSTBUILD_STEP)); - - // Get the pre-build and post-build announcements - preannouncebuildStep = SafeStringInterner.safeIntern(element.getAttribute(PREANNOUNCEBUILD_STEP)); + + // Get the pre-build and post-build commands + prebuildStep = SafeStringInterner.safeIntern(element.getAttribute(PREBUILD_STEP)); + postbuildStep = SafeStringInterner.safeIntern(element.getAttribute(POSTBUILD_STEP)); + + // Get the pre-build and post-build announcements + preannouncebuildStep = SafeStringInterner.safeIntern(element.getAttribute(PREANNOUNCEBUILD_STEP)); postannouncebuildStep = SafeStringInterner.safeIntern(element.getAttribute(POSTANNOUNCEBUILD_STEP)); - + String tmp = element.getAttribute(IS_SYSTEM); if(tmp != null) isTest = Boolean.valueOf(tmp).booleanValue(); } - + /** - * Initialize the configuration information from the XML element + * Initialize the configuration information from the XML element * specified in the argument - * - * @param element An XML element containing the configuration information + * + * @param element An XML element containing the configuration information */ protected void loadFromProject(ICStorageElement element) { - + // id // note: IDs are unique so no benefit to intern them setId(element.getAttribute(IConfiguration.ID)); @@ -818,20 +817,20 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild // name if (element.getAttribute(IConfiguration.NAME) != null) setName(SafeStringInterner.safeIntern(element.getAttribute(IConfiguration.NAME))); - + // description if (element.getAttribute(IConfiguration.DESCRIPTION) != null) description = SafeStringInterner.safeIntern(element.getAttribute(IConfiguration.DESCRIPTION)); - + String props = element.getAttribute(BUILD_PROPERTIES); if(props != null) buildProperties = new BuildObjectProperties(props, this, this); - + String artType = SafeStringInterner.safeIntern(element.getAttribute(BUILD_ARTEFACT_TYPE)); if(artType != null){ if(buildProperties == null) buildProperties = new BuildObjectProperties(this, this); - + try { buildProperties.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artType, true); } catch (CoreException e) { @@ -854,12 +853,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } } - // Get the name of the build artifact associated with target (usually + // Get the name of the build artifact associated with target (usually // in the plugin specification). if (element.getAttribute(ARTIFACT_NAME) != null) { artifactName = SafeStringInterner.safeIntern(element.getAttribute(ARTIFACT_NAME)); } - + // Get the semicolon separated list of IDs of the error parsers if (element.getAttribute(ERROR_PARSERS) != null) { errorParserIds = SafeStringInterner.safeIntern(element.getAttribute(ERROR_PARSERS)); @@ -869,7 +868,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if (element.getAttribute(EXTENSION) != null) { artifactExtension = SafeStringInterner.safeIntern(element.getAttribute(EXTENSION)); } - + // Get the clean command if (element.getAttribute(CLEAN_COMMAND) != null) { cleanCommand = SafeStringInterner.safeIntern(element.getAttribute(CLEAN_COMMAND)); @@ -899,13 +898,13 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild */ public void serialize(ICStorageElement element) { element.setAttribute(IConfiguration.ID, id); - + if (name != null) element.setAttribute(IConfiguration.NAME, name); - + if (description != null) element.setAttribute(IConfiguration.DESCRIPTION, description); - + if(buildProperties != null){ element.setAttribute(BUILD_PROPERTIES, buildProperties.toString()); @@ -915,13 +914,13 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild element.setAttribute(BUILD_ARTEFACT_TYPE, val.getId()); } } - + if (parent != null) element.setAttribute(IConfiguration.PARENT, parent.getId()); - + if (artifactName != null) element.setAttribute(ARTIFACT_NAME, artifactName); - + if (errorParserIds != null) element.setAttribute(ERROR_PARSERS, errorParserIds); @@ -948,13 +947,13 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild for(int i = 0; i < infos.length; i++){ String elementName = infos[i].getKind() == ICSettingBase.SETTING_FILE ? IFileInfo.FILE_INFO_ELEMENT_NAME : IFolderInfo.FOLDER_INFO_ELEMENT_NAME; - + ICStorageElement resElement = element.createChild(elementName); ((ResourceInfo)infos[i]).serialize(resElement); } PropertyManager.getInstance().serialize(this); - + if(sourceEntries != null && sourceEntries.length > 0){ ICStorageElement el = element.createChild(SOURCE_ENTRIES); LanguageSettingEntriesSerializer.serializeEntries(sourceEntries, el); @@ -966,7 +965,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /* * P A R E N T A N D C H I L D H A N D L I N G */ - + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent() */ @@ -986,7 +985,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild return null; // Extension configurations don't have an "owner" } } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IConfiguration#getProjectType() */ @@ -994,7 +993,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public IProjectType getProjectType() { return projectType; } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IConfiguration#getManagedProject() */ @@ -1002,7 +1001,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public IManagedProject getManagedProject() { return managedProject; } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain(IToolChain, String, String, boolean) */ @@ -1011,25 +1010,25 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(rootFolderInfo == null){ createRootFolderInfo(); } - + return rootFolderInfo.createToolChain(superClass, Id, name, isExtensionElement); } - + private IFolderInfo createRootFolderInfo(){ String id = ManagedBuildManager.calculateChildId(this.id, null); String name = "/"; //$NON-NLS-1$ - + rootFolderInfo = new FolderInfo(this, new Path(name), id, name, isExtensionConfig); addResourceConfiguration(rootFolderInfo); return rootFolderInfo; } -/* +/* public IFolderInfo createFolderInfo(IPath path, IToolChain superClass, String Id, String name){ - + } public IFolderInfo createFolderInfo(IPath path, IFolderInfo baseFolderInfo, String Id, String name){ - + } */ /* (non-Javadoc) @@ -1039,7 +1038,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public IToolChain getToolChain() { return rootFolderInfo.getToolChain(); } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IConfiguration#getResourceConfigurations() */ @@ -1081,7 +1080,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolsBySuperClassId(java.lang.String) + * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolsBySuperClassId(java.lang.String) */ @Override public ITool[] getToolsBySuperClassId(String id) { @@ -1095,7 +1094,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public ITool getTargetTool() { String[] targetToolIds = rootFolderInfo.getToolChain().getTargetToolList(); if (targetToolIds == null || targetToolIds.length == 0) return null; - + // For each target tool id, in list order, // look for a tool with this ID, or a tool with a superclass with this id. // Stop when we find a match @@ -1108,7 +1107,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild do { if (targetToolId.equals(tool.getId())) { return targetTool; - } + } tool = tool.getSuperClass(); } while (tool != null); } @@ -1157,10 +1156,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public IOption setOption(IHoldsOptions holder, IOption option, String[] value) throws BuildException { return getRootFolderInfo().setOption(holder, option, value); } - + /* (non-Javadoc) * Adds the Resource Configuration to the Resource Configuration list and map - * + * * @param resConfig */ void addResourceConfiguration(IResourceInfo resConfig) { @@ -1173,7 +1172,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild @Override public void removeResourceConfiguration(IResourceInfo resConfig) { - ManagedBuildManager.performValueHandlerEvent(resConfig, + ManagedBuildManager.performValueHandlerEvent(resConfig, IManagedOptionValueHandler.EVENT_CLOSE); ITool tools[] = resConfig.getTools(); rcInfos.removeResourceInfo(resConfig.getPath()); @@ -1208,9 +1207,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild // Ask my parent first if (parent != null) { return parent.getArtifactExtension(); - } - return null; - } + } + return null; + } return artifactExtension; } @@ -1253,14 +1252,14 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild IToolChain tc = getToolChain(); IBuilder builder = tc.getBuilder(); if (builder != null) { - return builder.getCommand(); + return builder.getCommand(); } return new String("make"); //$NON-NLS-1$ } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPrebuildStep() */ @Override @@ -1280,7 +1279,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostbuildStep() */ @Override @@ -1300,7 +1299,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPreannouncebuildStep() */ @Override @@ -1320,7 +1319,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostannouncebuildStep() */ @Override @@ -1340,7 +1339,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.build.managed.IConfiguration#getCleanCommand() */ @Override @@ -1362,7 +1361,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild return cleanCommand; } } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IConfiguration#getDescription() */ @@ -1383,14 +1382,14 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserIds() */ @Override public String getErrorParserIds() { if (errorParserIds != null) { return errorParserIds; - } + } // If I have a parent, ask it String errorParsers = null; if (parent != null) { @@ -1409,13 +1408,13 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public String getErrorParserIdsAttribute() { if (errorParserIds != null) { return errorParserIds; - } + } // If I have a parent, ask it String errorParsers = null; if (parent != null) { errorParsers = ((Configuration)parent).getErrorParserIdsAttribute(); } - + return errorParsers; } @@ -1445,7 +1444,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } } } - + if(includeChildren){ IResourceInfo[] rcInfos = getResourceInfos(); for(int i = 0; i < rcInfos.length; i++){ @@ -1455,7 +1454,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return set; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactExtension(java.lang.String) */ @@ -1497,7 +1496,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if (entries.contains(lib)) { entries.remove(lib); des.removeExternalSetting(setting); - des.createExternalSetting(setting.getCompatibleLanguageIds(), setting.getCompatibleContentTypeIds(), + des.createExternalSetting(setting.getCompatibleLanguageIds(), setting.getCompatibleContentTypeIds(), setting.getCompatibleExtensions(), entries.toArray(new ICSettingEntry[entries.size()])); } } @@ -1544,17 +1543,17 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild isDirty = true; } } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IConfiguration#setDescription(java.lang.String) */ @Override public void setDescription(String description) { - if (description == null && this.description == null) return; - if (this.description == null || description == null || !description.equals(this.description)) { - this.description = description; - isDirty = true; - } + if (description == null && this.description == null) return; + if (this.description == null || description == null || !description.equals(this.description)) { + this.description = description; + isDirty = true; + } } /* (non-Javadoc) @@ -1602,60 +1601,60 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild // rebuildNeeded = true; } } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPrebuildStep(java.lang.String) - */ + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPrebuildStep(java.lang.String) + */ @Override - public void setPrebuildStep(String step) { - if (step == null && prebuildStep == null) return; - if (prebuildStep == null || step == null || !prebuildStep.equals(step)) { - prebuildStep = step; + public void setPrebuildStep(String step) { + if (step == null && prebuildStep == null) return; + if (prebuildStep == null || step == null || !prebuildStep.equals(step)) { + prebuildStep = step; // rebuildNeeded = true; - isDirty = true; - } - } - - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostbuildStep(java.lang.String) - */ + isDirty = true; + } + } + + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostbuildStep(java.lang.String) + */ @Override - public void setPostbuildStep(String step) { - if (step == null && postbuildStep == null) return; - if (postbuildStep == null || step == null || !postbuildStep.equals(step)) { - postbuildStep = step; + public void setPostbuildStep(String step) { + if (step == null && postbuildStep == null) return; + if (postbuildStep == null || step == null || !postbuildStep.equals(step)) { + postbuildStep = step; // rebuildNeeded = true; - isDirty = true; - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPreannouncebuildStep(java.lang.String) - */ + isDirty = true; + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPreannouncebuildStep(java.lang.String) + */ @Override - public void setPreannouncebuildStep(String announceStep) { - if (announceStep == null && preannouncebuildStep == null) return; + public void setPreannouncebuildStep(String announceStep) { + if (announceStep == null && preannouncebuildStep == null) return; if (preannouncebuildStep == null || announceStep == null || !preannouncebuildStep.equals(announceStep)) { - preannouncebuildStep = announceStep; + preannouncebuildStep = announceStep; // rebuildNeeded = true; - isDirty = true; - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostannouncebuildStep(java.lang.String) - */ + isDirty = true; + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostannouncebuildStep(java.lang.String) + */ @Override - public void setPostannouncebuildStep(String announceStep) { - if (announceStep == null && postannouncebuildStep == null) return; + public void setPostannouncebuildStep(String announceStep) { + if (announceStep == null && postannouncebuildStep == null) return; if (postannouncebuildStep == null || announceStep == null || !postannouncebuildStep.equals(announceStep)) { - postannouncebuildStep = announceStep; + postannouncebuildStep = announceStep; // rebuildNeeded = true; - isDirty = true; - } - } - + isDirty = true; + } + } + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isSupported() */ @@ -1666,7 +1665,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild return foInfo.isSupported(); return false; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isHeaderFile(java.lang.String) */ @@ -1678,7 +1677,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /* * O B J E C T S T A T E M A I N T E N A N C E */ - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isExtensionElement() */ @@ -1694,13 +1693,13 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public boolean isDirty() { // This shouldn't be called for an extension configuration if (isExtensionConfig) return false; - + // If I need saving, just say yes if (isDirty) return true; - + // Otherwise see if any children need saving IResourceInfo infos[] = rcInfos.getResourceInfos(); - + for(int i = 0; i < infos.length; i++){ if(infos[i].isDirty()) return true; @@ -1715,18 +1714,18 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public boolean needsRebuild() { return needsRebuild(true); } - + @Override public boolean needsFullRebuild() { return needsRebuild(false); } - + public boolean needsRebuild(boolean checkChildren) { - boolean needRebuild = rebuildNeeded || resourceChangesRequireRebuild(); - + boolean needRebuild = rebuildNeeded || resourceChangesRequireRebuild(); + if(needRebuild || !checkChildren) return needRebuild; - + IResourceInfo infos[] = rcInfos.getResourceInfos(); for(int i = 0; i < infos.length; i++){ @@ -1736,7 +1735,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild return false; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean) */ @@ -1761,15 +1760,15 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public void setRebuildState(boolean rebuild) { if(isExtensionElement() && rebuild) return; - + if(rebuildNeeded != rebuild){ rebuildNeeded = rebuild; saveRebuildState(); } - + if(!rebuildNeeded){ setResourceChangeState(0); - + IResourceInfo infos[] = rcInfos.getResourceInfos(); for(int i = 0; i < infos.length; i++){ @@ -1795,7 +1794,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild return true; } } - } + } String args = builder.getArguments(); if (args != null) { String superA = superB.getArguments(); @@ -1804,23 +1803,23 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild return true; } } - } + } } } return false; } - + public void resolveReferences() { if (!resolved) { resolved = true; - + // call resolve references on any children ResourceInfo infos[] = (ResourceInfo[])rcInfos.getResourceInfos(ResourceInfo.class); for(int i = 0; i < infos.length; i++){ infos[i].resolveReferences(); } - + if (parentId != null) { // Lookup the parent configuration by ID parent = ManagedBuildManager.getExtensionConfiguration(parentId); @@ -1828,7 +1827,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } } - + /** * Reset the configuration's, tools', options */ @@ -1843,7 +1842,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public IResourceConfiguration createResourceConfiguration(IFile file) { return createFileInfo(file.getFullPath().removeFirstSegments(1)); - + } @Override @@ -1865,12 +1864,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return fileInfo; } - + @Override public IFileInfo createFileInfo(IPath path, IFolderInfo base, ITool baseTool, String id, String name){ if(base.getPath().equals(path)) return null; - + IFileInfo fileInfo = new ResourceConfiguration((FolderInfo)base, baseTool, id, name, path); addResourceConfiguration(fileInfo); ManagedBuildManager.performValueHandlerEvent(fileInfo, IManagedOptionValueHandler.EVENT_OPEN); @@ -1882,7 +1881,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public IFileInfo createFileInfo(IPath path, IFileInfo base, String id, String name){ if(base.getPath().equals(path)) return null; - + IFileInfo fileInfo = new ResourceConfiguration((ResourceConfiguration)base, path, id, name); addResourceConfiguration(fileInfo); ManagedBuildManager.performValueHandlerEvent(fileInfo, IManagedOptionValueHandler.EVENT_OPEN); @@ -1913,12 +1912,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return version; } - + @Override public void setVersion(Version version) { // Do nothing } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildMacroSupplier() */ @@ -1928,9 +1927,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(toolChain != null) return toolChain.getBuildMacroSupplier(); return null; - + } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isTemporary() */ @@ -1938,41 +1937,41 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public boolean isTemporary(){ return isTemporary; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String) */ @Override public void updateManagedBuildRevision(String revision){ super.updateManagedBuildRevision(revision); - + ResourceInfo infos[] = (ResourceInfo[])rcInfos.getResourceInfos(ResourceInfo.class); for(int i = 0; i < infos.length; i++){ infos[i].updateManagedBuildRevision(revision); } } - + public void setParent(IConfiguration parent) { if ( this.parent != parent) { this.parent = parent; if (!isExtensionElement()) setDirty(true); - } + } } - + @Override public ITool calculateTargetTool(){ ITool tool = getTargetTool(); - + if(tool == null){ tool = getToolFromOutputExtension(getArtifactExtension()); } - + if(tool == null){ IConfiguration extCfg; - for(extCfg = this; - extCfg != null && !extCfg.isExtensionElement(); + for(extCfg = this; + extCfg != null && !extCfg.isExtensionElement(); extCfg = extCfg.getParent()){ } @@ -1980,15 +1979,15 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild tool = getToolFromOutputExtension(extCfg.getArtifactExtension()); } } - + return tool; } - + @Override public ITool getToolFromOutputExtension(String extension) { return getRootFolderInfo().getToolFromOutputExtension(extension); } - + @Override public ITool getToolFromInputExtension(String sourceExtension) { return getRootFolderInfo().getToolFromInputExtension(sourceExtension); @@ -2002,19 +2001,19 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild * with the resource tree between the two configuration builds * * The trivial approach implemented currently is to hold - * the general information of whether some resources were + * the general information of whether some resources were * removed,changed,etc. and detect whether the rebuild is needed * based upon this information - * + * * This method adds the resource change state for the configuration * specifying the resource change type performed on the project * reported while building another configuration * The method is not exported to the public API since delta handling - * mechanism will likely to be changed in the future + * mechanism will likely to be changed in the future * * In the future we might implement some more smart mechanism * for tracking delta, e.g calculate the pre-cinfiguration resource delta, etc. - * + * */ public void addResourceChangeState(int state){ setResourceChangeState(state | resourceChangeState); @@ -2026,13 +2025,13 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild saveResourceChangeState(); } } - + private boolean resourceChangesRequireRebuild(){ return isInternalBuilderEnabled() ? resourceChangeState != 0 : (resourceChangeState & IResourceDelta.REMOVED) == IResourceDelta.REMOVED; } - + private void saveRebuildState(){ PropertyManager.getInstance().setProperty(this, REBUILD_STATE, Boolean.toString(rebuildNeeded)); } @@ -2040,16 +2039,16 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild private void saveResourceChangeState(){ PropertyManager.getInstance().setProperty(this, RC_CHANGE_STATE, Integer.toString(resourceChangeState)); } - + /* * Internal Builder state API * NOTE: this is a temporary API * In the future we are going present the Internal Builder * as a special Builder object of the tool-chain and implement the internal * builder enabling/disabling as the Builder substitution functionality - * + * */ - + /* public void setInternalBuilderBoolean(boolean value, String pref) { Preferences prefs = getPreferences(INTERNAL_BUILDER); if(prefs != null){ @@ -2059,17 +2058,17 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } catch (BackingStoreException e) {} } } -*/ +*/ /* public boolean getInternalBuilderBoolean(String pref, boolean defaultValue) { Preferences prefs = getPreferences(INTERNAL_BUILDER); return prefs != null ? prefs.getBoolean(pref, false) : defaultValue; } -*/ +*/ /** * this method is used for enabling/disabling the internal builder * for the given configuration - * + * * @param enable boolean */ public void enableInternalBuilder(boolean enable){ @@ -2081,12 +2080,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(enable){ savePrevBuilderId(getBuilder()); } - - changeBuilder(builder, + + changeBuilder(builder, ManagedBuildManager.calculateChildId(builder.getId(), null), - builder.getName(), + builder.getName(), true); - + if(enable){ try { setManagedBuildOn(true); @@ -2095,11 +2094,11 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } } } - + public boolean canEnableInternalBuilder(boolean enable){ return getBuilderForInternalBuilderEnablement(enable, true) != null; } - + private IBuilder getBuilderForInternalBuilderEnablement(boolean enable, boolean checkCompatibility){ IBuilder newBuilder = null; if(enable){ @@ -2124,9 +2123,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild IBuilder b = tc.getBuilder(); if(b.isInternalBuilder()) continue; - + for(;b != null && !b.isExtensionElement(); b = b.getSuperClass()) {} - + if(b != null){ if(!checkCompatibility || isBuilderCompatible(b)){ newBuilder = b; @@ -2135,7 +2134,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } } } - + // if(newBuilder == null){ // IBuilder builders[] = ManagedBuildManager.getRealBuilders(); // IBuilder tmpB = null; @@ -2144,7 +2143,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild // if(b.isInternalBuilder()) // continue; // -// +// // if(isBuilderCompatible(b)){ // newBuilder = b; // break; @@ -2152,7 +2151,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild // tmpB = b; // } // } -// +// // if(newBuilder == null){ // if(tmpB != null) // newBuilder = tmpB; @@ -2163,14 +2162,14 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild return newBuilder; } - + private void savePrevBuilderId(IBuilder builder){ IBuilder b = builder; for(;b != null && !b.isExtensionElement(); b = b.getSuperClass()) {} - + if(b == null) b = builder; - + ToolChain tc = (ToolChain)getToolChain(); if(tc != null) tc.setNonInternalBuilderId(b.getId()); @@ -2188,14 +2187,14 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild * @return boolean */ public boolean isInternalBuilderEnabled(){ - return getBuilder().isInternalBuilder(); + return getBuilder().isInternalBuilder(); } - + /** - * + * * sets the Internal Builder mode - * - * @param ignore if true, internal builder will ignore + * + * @param ignore if true, internal builder will ignore * build errors while building, * otherwise it will stop at the first build error */ @@ -2210,54 +2209,54 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild * returns the Internal Builder mode * if true, internal builder will ignore build errors while building, * otherwise it will stop at the first build error - * + * * @return boolean */ public boolean getInternalBuilderIgnoreErr(){ return !getBuilder().isStopOnError(); } - + /** * sets the Internal Builder Parallel mode - * @param parallel if true, internal builder will use parallel mode - * + * @param parallel if true, internal builder will use parallel mode + * * @deprecated since CDT 9.0. Use {@link #setParallelDef(boolean)} */ @Deprecated public void setInternalBuilderParallel(boolean parallel){ setParallelDef(parallel); } - + /** * returns the Internal Builder parallel mode - * if true, internal builder will work in parallel mode + * if true, internal builder will work in parallel mode * otherwise it will use only one thread * @return boolean - * + * * @deprecated since CDT 9.0. Use {@link #getParallelDef()} */ @Deprecated public boolean getInternalBuilderParallel(){ return getParallelDef(); } - + /** * Set parallel execution mode for the configuration's builder. * @see Builder#setParallelBuildOn(boolean) - * + * * @param parallel - the flag to enable or disable parallel mode. */ public void setParallelDef(boolean parallel){ if(getParallelDef() == parallel) return; - + try { getEditableBuilder().setParallelBuildOn(parallel); } catch (CoreException e) { ManagedBuilderCorePlugin.log(e); } } - + /** * Check if the configuration's builder is operating in parallel mode. * @return {@code true} if parallel mode is enabled, {@code false} otherwise. @@ -2265,10 +2264,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public boolean getParallelDef(){ return getBuilder().isParallelBuildOn(); } - + /** * Sets maximum number of parallel threads/jobs to be used by builder. - * + * * @param jobs - maximum number of jobs or threads. For details how * the number is interpreted see {@link Builder#setParallelizationNum(int)}. */ @@ -2279,23 +2278,23 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild ManagedBuilderCorePlugin.log(e); } } - + /** * Returns maximum number of parallel threads/jobs used by the configuration's builder. * @see #setParallelDef(boolean) - * + * * @return - maximum number of parallel threads or jobs used by the builder. */ public int getParallelNumber(){ return getBuilder().getParallelizationNum(); } - + // private Preferences getPreferences(String name){ // if(isTemporary) // return null; -// +// // IProject project = (IProject)getOwner(); -// +// // if(project == null || !project.exists() || !project.isOpen()) // return null; // @@ -2332,12 +2331,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public IFolderInfo getRootFolderInfo() { return rootFolderInfo; } - + ResourceInfoContainer getRcInfoContainer(IResourceInfo rcInfo){ PathSettingsContainer cr = pathSettings.getChildContainer(rcInfo.getPath(), true, true); return new ResourceInfoContainer(cr, false); } - + @Override public CConfigurationData getConfigurationData(){ return fCfgData; @@ -2374,7 +2373,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public IFolderInfo createFolderInfo(IPath path, IFolderInfo base, String id, String name) { if(base.getPath().equals(path)) return null; - + FolderInfo folderInfo = new FolderInfo((FolderInfo)base, id, name, path); addResourceConfiguration(folderInfo); folderInfo.propertiesChanged(); @@ -2389,7 +2388,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(parent != null && sourceEntries == null) return parent.getSourceEntries(); return new ICSourceEntry[]{new CSourceEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED)}; - + } return sourceEntries.clone(); } @@ -2437,13 +2436,13 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild resetErrorParsers(); Set oldSet = contributeErrorParsers(null, true); if(oldSet != null) { - oldSet.removeAll(Arrays.asList(ids)); + oldSet.removeAll(Arrays.asList(ids)); removeErrorParsers(oldSet); - } + } setErrorParserAttribute(ids); } } - + public void resetErrorParsers(){ errorParserIds = null; IResourceInfo rcInfos[] = getResourceInfos(); @@ -2452,15 +2451,15 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild rcInfo.resetErrorParsers(); } } - + void removeErrorParsers(Set set){ Set oldSet = contributeErrorParsers(null, false); if(oldSet == null) oldSet = new LinkedHashSet(); - + oldSet.removeAll(set); setErrorParserAttribute(oldSet.toArray(new String[oldSet.size()])); - + IResourceInfo rcInfos[] = getResourceInfos(); for(int i = 0; i < rcInfos.length; i++){ ResourceInfo rcInfo = (ResourceInfo)rcInfos[i]; @@ -2472,7 +2471,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public CBuildData getBuildData() { return getEditableBuilder().getBuildData(); } - + @Override public IBuilder getEditableBuilder(){ IToolChain tc = getToolChain(); @@ -2484,17 +2483,17 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return builder; } - + @Override public IBuilder getBuilder(){ return getToolChain().getBuilder(); } - + @Override public String getOutputPrefix(String outputExtension) { // Treat null extensions as empty string String ext = outputExtension == null ? new String() : outputExtension; - + // Get all the tools for the current config String flags = new String(); ITool[] tools = getFilteredTools(); @@ -2506,11 +2505,11 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return flags; } - + public ICConfigurationDescription getConfigurationDescription(){ return fCfgDes; } - + public void setConfigurationDescription(ICConfigurationDescription cfgDes){ fCfgDes = cfgDes; } @@ -2526,7 +2525,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return buildProperties; } - + private BuildObjectProperties findBuildProperties(){ if(buildProperties == null){ if(parent != null){ @@ -2550,7 +2549,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public void propertiesChanged() { if(isExtensionConfig) return; - + BooleanExpressionApplicabilityCalculator calculator = getBooleanExpressionCalculator(); if(calculator != null) calculator.adjustConfiguration(this, false); @@ -2560,7 +2559,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild ((ResourceInfo)infos[i]).propertiesChanged(); } } - + public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){ if(booleanExpressionCalculator == null){ if(parent != null){ @@ -2574,10 +2573,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public boolean isSystemObject() { if(isTest) return true; - + if(getProjectType() != null) return getProjectType().isSystemObject(); - + return false; } @@ -2590,7 +2589,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public String getOutputFlag(String outputExt) { // Treat null extension as an empty string String ext = outputExt == null ? new String() : outputExt; - + // Get all the tools for the current config String flags = new String(); ITool[] tools = getFilteredTools(); @@ -2603,9 +2602,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return flags; } - + @Override - public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags, + public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags, String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation ){ ITool[] tools = getFilteredTools(); for (int index = 0; index < tools.length; index++) { @@ -2615,7 +2614,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild //try to resolve the build macros in the tool command try{ String resolvedCommand = null; - + if ((inputLocation != null && inputLocation.toString().indexOf(" ") != -1) || //$NON-NLS-1$ (outputLocation != null && outputLocation.toString().indexOf(" ") != -1) ) //$NON-NLS-1$ { @@ -2644,26 +2643,26 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } if((resolvedCommand = resolvedCommand.trim()).length() > 0) cmd = resolvedCommand; - + } catch (BuildMacroException e){ } IManagedCommandLineGenerator gen = tool.getCommandLineGenerator(); - return gen.generateCommandLineInfo( tool, cmd, - flags, outputFlag, outputPrefix, outputName, inputResources, + return gen.generateCommandLineInfo( tool, cmd, + flags, outputFlag, outputPrefix, outputName, inputResources, tool.getCommandLinePattern() ); } } return null; } - + @Override public String[] getUserObjects(String extension) { Vector objs = new Vector(); ITool tool = calculateTargetTool(); if(tool == null) tool = getToolFromOutputExtension(extension); - + if(tool != null){ IOption[] opts = tool.getOptions(); // Look for the user object option type @@ -2698,14 +2697,14 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return objs.toArray(new String[objs.size()]); } - + @Override public String[] getLibs(String extension) { Vector libs = new Vector(); ITool tool = calculateTargetTool(); if(tool == null) tool = getToolFromOutputExtension(extension); - + if(tool != null){ IOption[] opts = tool.getOptions(); // Look for the lib option type @@ -2713,10 +2712,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild IOption option = opts[i]; try { if (option.getValueType() == IOption.LIBRARIES) { - + // check to see if the option has an applicability calculator IOptionApplicability applicabilitytCalculator = option.getApplicabilityCalculator(); - + if (applicabilitytCalculator == null || applicabilitytCalculator.isOptionUsedInCommandLine(this, tool, option)) { String command = option.getCommand(); @@ -2741,7 +2740,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild // TODO: report error continue; } - + } } } @@ -2781,7 +2780,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild /** * Responsible for contributing 'external' settings back to the core for use * by referenced projects. - * + * * In this case it returns Include, Library path & Library File settings * to be used be references for linking the output of this library project */ @@ -2797,7 +2796,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild List list = new ArrayList(entries.length + 1); // Add project level include path - list.add(new CIncludePathEntry(path.toString(), ICLanguageSettingEntry.VALUE_WORKSPACE_PATH)); + list.add(CDataUtil.createCIncludePathEntry(path.toString(), ICLanguageSettingEntry.VALUE_WORKSPACE_PATH)); // Add Build output path as an exported library path entries = CDataUtil.resolveEntries(entries, des); @@ -2833,13 +2832,13 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(!rcs[i].supportsBuild(managed)) return false; } - + if(checkBuilder){ IBuilder builder = getBuilder(); if(builder != null && !builder.supportsBuild(managed)) return false; } - + return true; } @@ -2850,10 +2849,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(props != null){ supports = props.supportsType(typeId); } - + if(!supports) supports = ((ToolChain)getToolChain()).supportsType(typeId); - + return supports; } @@ -2864,13 +2863,13 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(props != null){ supports = props.supportsValue(typeId, valueId); } - + if(!supports) supports = ((ToolChain)getToolChain()).supportsValue(typeId, valueId); - + return supports; } - + private SupportedProperties findSupportedProperties(){ if(supportedProperties == null){ if(parent != null){ @@ -2879,7 +2878,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return supportedProperties; } - + private void loadProperties(IManagedConfigElement el){ supportedProperties = new SupportedProperties(el); } @@ -2891,9 +2890,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(props != null){ list.addAll(Arrays.asList(props.getRequiredTypeIds())); } - + list.addAll(Arrays.asList(((ToolChain)getToolChain()).getRequiredTypeIds())); - + return list.toArray(new String[list.size()]); } @@ -2904,9 +2903,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(props != null){ list.addAll(Arrays.asList(props.getSupportedTypeIds())); } - + list.addAll(Arrays.asList(((ToolChain)getToolChain()).getSupportedTypeIds())); - + return list.toArray(new String[list.size()]); } @@ -2917,9 +2916,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(props != null){ list.addAll(Arrays.asList(props.getSupportedValueIds(typeId))); } - + list.addAll(Arrays.asList(((ToolChain)getToolChain()).getSupportedValueIds(typeId))); - + return list.toArray(new String[list.size()]); } @@ -2930,10 +2929,10 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(props != null){ requires = props.requiresType(typeId); } - + if(!requires) requires = ((ToolChain)getToolChain()).requiresType(typeId); - + return requires; } @@ -2970,22 +2969,22 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild for(;extBuilder != null && !extBuilder.isExtensionElement(); extBuilder = extBuilder.getSuperClass()) {} if(extBuilder == null) extBuilder = newBuilder; - + newCfgBuilder = new Builder(tc, extBuilder, id, name, false); newCfgBuilder.copySettings(cur, allBuildSettings); } } - + if(newCfgBuilder != null){ tc.setBuilder(newCfgBuilder); } } - + @Override public boolean isBuilderCompatible(IBuilder builder){ return builder.supportsBuild(isManagedBuildOn()); } - + ITool findToolById(String id){ IResourceInfo[] rcInfos = getResourceInfos(); ITool tool = null; @@ -2997,7 +2996,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return tool; } - + void resolveProjectReferences(boolean onLoad){ IResourceInfo[] rcInfos = getResourceInfos(); for(int i = 0; i < rcInfos.length; i++){ @@ -3005,7 +3004,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild info.resolveProjectReferences(onLoad); } } - + public boolean isPerRcTypeDiscovery(){ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain(); return tc.isPerRcTypeDiscovery(); @@ -3035,33 +3034,33 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain(); return tc.getDiscoveredPathInfo(); } - + public String getDiscoveryProfileId(){ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain(); return tc.getScannerConfigDiscoveryProfileId(); } - + public PathInfoCache clearDiscoveredPathInfo(){ ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain(); return tc.clearDiscoveredPathInfo(); } - + public ICfgScannerConfigBuilderInfo2Set getCfgScannerConfigInfo(){ return cfgScannerInfo; } - + public void setCfgScannerConfigInfo(ICfgScannerConfigBuilderInfo2Set info){ cfgScannerInfo = info; } - + public void clearCachedData(){ cfgScannerInfo = null; } - + public boolean isPreference(){ return isPreferenceConfig; } - + @Override public IBuildPropertyValue getBuildArtefactType() { IBuildObjectProperties props = findBuildProperties(); @@ -3072,7 +3071,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return null; } - + @Override public void setBuildArtefactType(String id) throws BuildException { IBuildObjectProperties props = getBuildProperties(); @@ -3082,7 +3081,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild throw new BuildException(e.getLocalizedMessage()); } // May need to update the exports paths & symbols after artifact type change - exportArtifactInfo(); + exportArtifactInfo(); } boolean isExcluded(IPath path){ @@ -3091,7 +3090,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild ICSourceEntry[] entries = getSourceEntries(); return CDataUtil.isExcluded(path, entries); } - + void setExcluded(IPath path, boolean isFolder, boolean excluded){ // if(path.segmentCount() == 0) // return; @@ -3104,7 +3103,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild excludeList.add(path); } } - + private ICSourceEntry[] getUpdatedEntries(IPath path, boolean isFolder, boolean excluded){ try { ICSourceEntry[] entries = getSourceEntries(); @@ -3114,7 +3113,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild } return null; } - + boolean canExclude(IPath path, boolean isFolder, boolean excluded){ if(excludeList == null) { ICSourceEntry[] newEntries = getUpdatedEntries(path, isFolder, excluded); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java index dea699185f9..725b3f7b9c7 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java @@ -33,11 +33,9 @@ import java.util.regex.PatternSyntaxException; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.resources.ACBuilder; -import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; -import org.eclipse.cdt.core.settings.model.CIncludePathEntry; -import org.eclipse.cdt.core.settings.model.CMacroEntry; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; @@ -611,11 +609,11 @@ public class HeadlessBuilder implements IApplication { macroVal = macro.substring(macro.indexOf('=') + 1); macro = macro.substring(0, macro.indexOf('=')); } - HeadlessBuilderExternalSettingsProvider.additionalSettings.add(new CMacroEntry(macro, macroVal, 0)); + HeadlessBuilderExternalSettingsProvider.additionalSettings.add(CDataUtil.createCMacroEntry(macro, macroVal, 0)); } else if ("-I".equals(args[i])) { //$NON-NLS-1$ - HeadlessBuilderExternalSettingsProvider.additionalSettings.add(new CIncludePathEntry(args[++i], 0)); + HeadlessBuilderExternalSettingsProvider.additionalSettings.add(CDataUtil.createCIncludePathEntry(args[++i], 0)); } else if ("-include".equals(args[i])) { //$NON-NLS-1$ - HeadlessBuilderExternalSettingsProvider.additionalSettings.add(new CIncludeFileEntry(args[++i], 0)); + HeadlessBuilderExternalSettingsProvider.additionalSettings.add(CDataUtil.createCIncludeFileEntry(args[++i], 0)); } else if ("-E".equals(args[i])) { //$NON-NLS-1$ addEnvironmentVariable(args[++i], IEnvironmentVariable.ENVVAR_REPLACE); } else if ("-Ea".equals(args[i])) { //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEntryStorage.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEntryStorage.java index b7b385186ef..96865ab182b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEntryStorage.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildEntryStorage.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; import org.eclipse.cdt.core.cdtvariables.CdtVariableException; -import org.eclipse.cdt.core.settings.model.CMacroEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingPathEntry; import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry; @@ -221,8 +220,8 @@ public class BuildEntryStorage extends AbstractEntryStorage { } /** - * Return user entries (level 0) - * + * Return user entries (level 0) + * * The UserEntryInfo[] is an array of all user entries from all the options * applicable to the language setting entry kind. * @param emptyValuesInfos list to which unresolved entries are added @@ -302,7 +301,7 @@ public class BuildEntryStorage extends AbstractEntryStorage { } /** - * Makes non-absolute paths relative to the build directory + * Makes non-absolute paths relative to the build directory */ private PathInfo fromBuildToProj(PathInfo info) { if (info.isAbsolute()) @@ -397,7 +396,7 @@ public class BuildEntryStorage extends AbstractEntryStorage { if (kind == ICSettingEntry.MACRO) { String nv[] = macroNameValueFromValue(optionValue.getValue()); - return new CMacroEntry(nv[0], nv[1], flags); + return CDataUtil.createCMacroEntry(nv[0], nv[1], flags); } IPath srcPath = null, srcRootPath = null, srcPrefixMapping = null; @@ -659,7 +658,7 @@ public class BuildEntryStorage extends AbstractEntryStorage { * This method iterates over the passed in UserEntryInfo[]. The point of it is * to collapse entries which are contained in a given UserEntry's sequence into a single * UserEntryInfo. - * + * * FIXME: As far as I can see info.fSequense only ever has a single entry in it... * see UserEntryInfo constructor => this method doesn't accomplish anything useful */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java index bf67bc52176..39657fbf3d6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java @@ -20,6 +20,13 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry // IPath fLocation; // private IPath fPath; + /** + * Constructor. + * + * @param rc - a resource in the workspace. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + * If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied. + */ ACPathEntry(IResource rc, int flags) { super(rc.getFullPath().toString(), flags | RESOLVED | VALUE_WORKSPACE_PATH); // fFullPath = rc.getFullPath(); @@ -33,10 +40,25 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry fFullPath = fullPath; } */ - ACPathEntry(String value, int flags) { - super(value, flags); + + /** + * Constructor. + * + * @param name - resource path. The path can be an absolute location on the local file-system + * or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + */ + ACPathEntry(String name, int flags) { + super(name, flags); } + /** + * Constructor. + * + * @param path - resource path. The path can be an absolute location on the local + * file-system or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + */ ACPathEntry(IPath path, int flags) { super(path.toString(), flags /*| RESOLVED*/); // fPath = path; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java index beb55889422..1e4620db461 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java @@ -1,29 +1,59 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Intel Corporation and others. + * Copyright (c) 2007, 2012 Intel Corporation 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: - * Intel Corporation - Initial API and implementation + * Intel Corporation - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.settings.model; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; -public final class CIncludeFileEntry extends ACPathEntry implements - ICIncludeFileEntry { - - public CIncludeFileEntry(String value, int flags) { - super(value, flags); +/** + * Representation in the project model of include file settings entries. + * As an example, those are supplied by a gcc compiler with option "-include". + */ +public final class CIncludeFileEntry extends ACPathEntry implements ICIncludeFileEntry { + /** + * This constructor is discouraged to be referenced by clients. + * + * Instead, use pooled entries with CDataUtil.createCIncludeFileEntry(name, flags). + * + * @param name - include file path. The path can be an absolute location on the local file-system + * or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + */ + public CIncludeFileEntry(String name, int flags) { + super(name, flags); } + /** + * This constructor is discouraged to be used directly. + * + * Instead, use pooled entries with CDataUtil.createCIncludeFileEntry(location.toString(), flags) + * or wrap it with CDataUtil.getPooledEntry(new CIncludeFileEntry(location, flags)). + * + * @param location - include file path. The path can be an absolute location on the local + * file-system or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + */ public CIncludeFileEntry(IPath location, int flags) { super(location, flags); } + /** + * This constructor is discouraged to be used directly. + * + * Instead, use pooled entries wrapping with CDataUtil.getPooledEntry(new CIncludeFileEntry(rc, flags)). + * + * @param rc - include file as a resource in the workspace. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + * If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied. + */ public CIncludeFileEntry(IFile rc, int flags) { super(rc, flags); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java index 9b88425ee54..7eac22c77c9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java @@ -1,28 +1,59 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Intel Corporation and others. + * Copyright (c) 2007, 2012 Intel Corporation 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: - * Intel Corporation - Initial API and implementation + * Intel Corporation - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.settings.model; import org.eclipse.core.resources.IFolder; import org.eclipse.core.runtime.IPath; -public final class CIncludePathEntry extends ACPathEntry implements ICIncludePathEntry{ - - public CIncludePathEntry(String value, int flags) { - super(value, flags); +/** + * Representation in the project model of include path settings entries. + * As an example, those are supplied by a gcc compiler with option "-I". + */ +public final class CIncludePathEntry extends ACPathEntry implements ICIncludePathEntry { + /** + * This constructor is discouraged to be referenced by clients. + * + * Instead, use pooled entries with CDataUtil.createCIncludePathEntry(name, flags). + * + * @param name - include path. The path can be an absolute location on the local file-system + * or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + */ + public CIncludePathEntry(String name, int flags) { + super(name, flags); } + /** + * This constructor is discouraged to be used directly. + * + * Instead, use pooled entries with CDataUtil.createCIncludePathEntry(location.toString(), flags) + * or wrap it with CDataUtil.getPooledEntry(new CIncludePathEntry(location, flags)). + * + * @param location - include path. The path can be an absolute location on the local + * file-system or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + */ public CIncludePathEntry(IPath location, int flags) { super(location, flags); } + /** + * This constructor is discouraged to be used directly. + * + * Instead, use pooled entries wrapping with CDataUtil.getPooledEntry(new CIncludePathEntry(rc, flags)). + * + * @param rc - include path as a resource in the workspace. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + * If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied. + */ public CIncludePathEntry(IFolder rc, int flags) { super(rc, flags); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java index 078b70c1597..d0b940a6dee 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Intel Corporation and others. + * Copyright (c) 2007, 2012 Intel Corporation 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 @@ -12,11 +12,22 @@ package org.eclipse.cdt.core.settings.model; import org.eclipse.cdt.internal.core.SafeStringInterner; - - -public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{ +/** + * Representation in the project model of macro settings entries. + * As an example, those are supplied by a gcc compiler with option "-D". + */ +public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry { private String fValue; + /** + * This constructor is discouraged to be referenced by clients. + * + * Instead, use pooled entries with CDataUtil.createCMacroEntry(name, value, flags). + * + * @param name - name of the macro. + * @param value - value of the macro. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + */ public CMacroEntry(String name, String value, int flags) { super(name, flags); fValue = SafeStringInterner.safeIntern(value); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java index 10114fccfd2..f007c7c2d78 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Intel Corporation and others. + * Copyright (c) 2007, 2012 Intel Corporation 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 @@ -13,17 +13,48 @@ package org.eclipse.cdt.core.settings.model; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; -public final class CMacroFileEntry extends ACPathEntry implements - ICMacroFileEntry { +/** + * Representation in the project model of include file settings entries. + * As an example, those are supplied by a gcc compiler with option "-imacros". + */ +public final class CMacroFileEntry extends ACPathEntry implements ICMacroFileEntry { - public CMacroFileEntry(String value, int flags) { - super(value, flags); + /** + * This constructor is discouraged to be referenced by clients. + * + * Instead, use pooled entries with CDataUtil.createCMacroFileEntry(name, flags). + * + * @param name - macro file path. The path can be an absolute location on the local file-system + * or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + */ + public CMacroFileEntry(String name, int flags) { + super(name, flags); } + /** + * This constructor is discouraged to be used directly. + * + * Instead, use pooled entries with CDataUtil.createCMacroFileEntry(location.toString(), flags) + * or wrap it with CDataUtil.getPooledEntry(new CMacroFileEntry(location, flags)). + * + * @param location - macro file path. The path can be an absolute location on the local + * file-system or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + */ public CMacroFileEntry(IPath location, int flags) { super(location, flags); } + /** + * This constructor is discouraged to be used directly. + * + * Instead, use pooled entries wrapping with CDataUtil.getPooledEntry(new CMacroFileEntry(rc, flags)). + * + * @param rc - macro file as a resource in the workspace. + * @param flags - bitwise combination of {@link ICSettingEntry} flags. + * If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied. + */ public CMacroFileEntry(IFile rc, int flags) { super(rc, flags); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java index f6fc1d35fc9..187a4b036d4 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Intel Corporation and others. + * Copyright (c) 2007, 2012 Intel Corporation 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 @@ -57,6 +57,7 @@ import org.eclipse.cdt.core.settings.model.extension.CResourceData; import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData; import org.eclipse.cdt.core.settings.model.extension.impl.CDataFactory; import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData; +import org.eclipse.cdt.internal.core.parser.util.WeakHashSet; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ProjectScope; @@ -76,6 +77,18 @@ public class CDataUtil { private static Random randomNumber; public static final String[] EMPTY_STRING_ARRAY = new String[0]; + /** + * Pool of setting entries implemented as WeakHashSet. That allows to gain memory savings + * at the expense of CPU time. WeakHashSet handles garbage collection when a list is not + * referenced anywhere else. See JavaDoc {@link java.lang.ref.WeakReference} about weak reference objects. + */ + private static WeakHashSet settingEntriesPool = new WeakHashSet() { + @Override + public synchronized ICSettingEntry add(ICSettingEntry entry) { + return super.add(entry); + } + }; + public static int genRandomNumber(){ if (randomNumber == null) { // Set the random number seed @@ -262,12 +275,39 @@ public class CDataUtil { return path; } - public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flagsToAdd, int flafsToClear){ + /** + * Return entry cached in setting entries pool to optimize for memory usage. + * Note that the pool will handle garbage collection for unreferenced entries. + * + * @since 5.4 + */ + public static ICSettingEntry getPooledEntry(ICSettingEntry entry) { + return settingEntriesPool.add(entry); + } + + /** + * Convenience method to clone {@link ICLanguageSettingEntry} with modified flags. + * Note that this method keeps the entries in the pool to avoid proliferation of duplicates. + * + * @param entry - source entry. + * @param flagsToAdd - binary combination of bits to add to the flags. + * @param flafsToClear - binary combination of bits to clear in the flags. + * @return new entry with the modified flags. + */ + public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flagsToAdd, int flafsToClear) { return createEntry(entry, (entry.getFlags() | flagsToAdd) & (~flafsToClear)); } - public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flags){ - switch (entry.getKind()){ + /** + * Convenience method to clone {@link ICLanguageSettingEntry} with different flags. + * Note that this method keeps the entries in the pool to avoid proliferation of duplicates. + * + * @param entry - source entry. + * @param flags - new flags. + * @return new entry with the specified flags. + */ + public static ICLanguageSettingEntry createEntry(ICLanguageSettingEntry entry, int flags) { + switch (entry.getKind()) { case ICSettingEntry.INCLUDE_PATH: entry = new CIncludePathEntry(entry.getName(), flags); break; @@ -293,34 +333,94 @@ public class CDataUtil { ); break; } - return entry; + return (ICLanguageSettingEntry) getPooledEntry(entry); } - public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags){ + /** + * Convenience method to create {@link ICLanguageSettingEntry} depending on kind. + * Note that this method keeps the entries in the pool to avoid proliferation of duplicates. + * + * Note that the method always returns {@link ICLanguageSettingEntry}. + */ + public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags) { return createEntry(kind, name, value, exclusionPatterns, flags, null, null, null); } - - public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, IPath srcPath, IPath srcRootPath, IPath srcPrefixMapping){ + /** + * Convenience method to create {@link ICSettingEntry} depending on kind. + * Note that this method keeps the entries in the pool to avoid proliferation of duplicates. + */ + public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping) { + ICSettingEntry entry = null; switch (kind){ - case ICSettingEntry.INCLUDE_PATH: - return new CIncludePathEntry(name, flags); - case ICSettingEntry.MACRO: - return new CMacroEntry(name, value, flags); - case ICSettingEntry.INCLUDE_FILE: - return new CIncludeFileEntry(name, flags); - case ICSettingEntry.MACRO_FILE: - return new CMacroFileEntry(name, flags); - case ICSettingEntry.LIBRARY_PATH: - return new CLibraryPathEntry(name, flags); - case ICSettingEntry.LIBRARY_FILE: - return new CLibraryFileEntry(name, flags, srcPath, srcRootPath, srcPrefixMapping); - case ICSettingEntry.OUTPUT_PATH: - return new COutputEntry(name, exclusionPatterns, flags); - case ICSettingEntry.SOURCE_PATH: - return new CSourceEntry(name, exclusionPatterns, flags); + case ICLanguageSettingEntry.INCLUDE_PATH: + entry = new CIncludePathEntry(name, flags); + break; + case ICLanguageSettingEntry.MACRO: + entry = new CMacroEntry(name, value, flags); + break; + case ICLanguageSettingEntry.INCLUDE_FILE: + entry = new CIncludeFileEntry(name, flags); + break; + case ICLanguageSettingEntry.MACRO_FILE: + entry = new CMacroFileEntry(name, flags); + break; + case ICLanguageSettingEntry.LIBRARY_PATH: + entry = new CLibraryPathEntry(name, flags); + break; + case ICLanguageSettingEntry.LIBRARY_FILE: + entry = new CLibraryFileEntry(name, flags, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping); + break; + case ICLanguageSettingEntry.OUTPUT_PATH: + entry = new COutputEntry(name, exclusionPatterns, flags); + break; + case ICLanguageSettingEntry.SOURCE_PATH: + entry = new CSourceEntry(name, exclusionPatterns, flags); + break; + default: + throw new IllegalArgumentException(); } - throw new IllegalArgumentException(); + return getPooledEntry(entry); + } + + /** + * Utility method to create {@link CIncludePathEntry}. + * Note that this method keeps the entries in the pool to avoid proliferation of duplicates. + * + * @since 5.4 + */ + public static CIncludePathEntry createCIncludePathEntry(String name, int flags) { + return (CIncludePathEntry) getPooledEntry(new CIncludePathEntry(name, flags)); + } + + /** + * Utility method to create {@link CIncludeFileEntry}. + * Note that this method keeps the entries in the pool to avoid proliferation of duplicates. + * + * @since 5.4 + */ + public static CIncludeFileEntry createCIncludeFileEntry(String name, int flags) { + return (CIncludeFileEntry) getPooledEntry(new CIncludeFileEntry(name, flags)); + } + + /** + * Utility method to create {@link CMacroEntry}. + * Note that this method keeps the entries in the pool to avoid proliferation of duplicates. + * + * @since 5.4 + */ + public static CMacroEntry createCMacroEntry(String name, String value, int flags) { + return (CMacroEntry) getPooledEntry(new CMacroEntry(name, value, flags)); + } + + /** + * Utility method to create {@link CMacroFileEntry}. + * Note that this method keeps the entries in the pool to avoid proliferation of duplicates. + * + * @since 5.4 + */ + public static CMacroFileEntry createCMacroFileEntry(String name, int flags) { + return (CMacroFileEntry) getPooledEntry(new CMacroFileEntry(name, flags)); } public static String[] getSourceExtensions(IProject project, CLanguageData data) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java index 6a1ac0045b1..c69b3c5a36d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/LanguageSettingEntriesSerializer.java @@ -14,14 +14,6 @@ import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; -import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; -import org.eclipse.cdt.core.settings.model.CIncludePathEntry; -import org.eclipse.cdt.core.settings.model.CLibraryFileEntry; -import org.eclipse.cdt.core.settings.model.CLibraryPathEntry; -import org.eclipse.cdt.core.settings.model.CMacroEntry; -import org.eclipse.cdt.core.settings.model.CMacroFileEntry; -import org.eclipse.cdt.core.settings.model.COutputEntry; -import org.eclipse.cdt.core.settings.model.CSourceEntry; import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry; @@ -41,9 +33,8 @@ public class LanguageSettingEntriesSerializer { public static final String ATTRIBUTE_SOURCE_ATTACHMENT_ROOT_PATH = "srcRootPath"; //$NON-NLS-1$ public static final String ATTRIBUTE_SOURCE_ATTACHMENT_PREFIX_MAPPING = "srcPrefixMapping"; //$NON-NLS-1$ -// public static final String ATTRIBUTE_FULL_PATH = "fullPath"; //$NON-NLS-1$ -// public static final String ATTRIBUTE_LOCATION = "location"; //$NON-NLS-1$ - + // public static final String ATTRIBUTE_FULL_PATH = "fullPath"; //$NON-NLS-1$ + // public static final String ATTRIBUTE_LOCATION = "location"; //$NON-NLS-1$ public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$ public static final String INCLUDE_FILE = "includeFile"; //$NON-NLS-1$ @@ -64,31 +55,29 @@ public class LanguageSettingEntriesSerializer { public static final String FLAGS_SEPARATOR = "|"; //$NON-NLS-1$ - public static ICSettingEntry[] loadEntries(ICStorageElement el){ + public static ICSettingEntry[] loadEntries(ICStorageElement el) { return loadEntries(el, 0); } - public static ICSettingEntry[] loadEntries(ICStorageElement el, int kindFilter){ + public static ICSettingEntry[] loadEntries(ICStorageElement el, int kindFilter) { List list = loadEntriesList(el, kindFilter); return list.toArray(new ICSettingEntry[list.size()]); } - public static List loadEntriesList(ICStorageElement el){ + public static List loadEntriesList(ICStorageElement el) { return loadEntriesList(el, 0); } - public static List loadEntriesList(ICStorageElement el, int kindFilter){ + public static List loadEntriesList(ICStorageElement el, int kindFilter) { ICStorageElement children[] = el.getChildren(); ICStorageElement child; List list = new ArrayList(); ICSettingEntry entry; - for(int i = 0; i < children.length; i++){ + for (int i = 0; i < children.length; i++) { child = children[i]; - if(ELEMENT_ENTRY.equals(child.getName())){ + if (ELEMENT_ENTRY.equals(child.getName())) { entry = loadEntry(child); - if(entry != null - && (kindFilter == 0 - || (kindFilter & entry.getKind()) != 0)) + if (entry != null && (kindFilter == 0 || (kindFilter & entry.getKind()) != 0)) list.add(entry); } } @@ -102,51 +91,33 @@ public class LanguageSettingEntriesSerializer { int flags = composeFlags(el.getAttribute(ATTRIBUTE_FLAGS)); String name = el.getAttribute(ATTRIBUTE_NAME); + String value = el.getAttribute(ATTRIBUTE_VALUE); + IPath srcPath = loadPath(el, ATTRIBUTE_SOURCE_ATTACHMENT_PATH); + IPath srcRootPath = loadPath(el, ATTRIBUTE_SOURCE_ATTACHMENT_ROOT_PATH); + IPath[] exclusionPatterns = loadExclusions(el); + IPath srcPrefixMapping = loadPath(el, ATTRIBUTE_SOURCE_ATTACHMENT_PREFIX_MAPPING); - - switch(kind){ - case ICSettingEntry.INCLUDE_PATH: - return new CIncludePathEntry(name, flags); - case ICSettingEntry.INCLUDE_FILE: - return new CIncludeFileEntry(name, flags); - case ICSettingEntry.MACRO: - String value = el.getAttribute(ATTRIBUTE_VALUE); - return new CMacroEntry(name, value, flags); - case ICSettingEntry.MACRO_FILE: - return new CMacroFileEntry(name, flags); - case ICSettingEntry.LIBRARY_PATH: - return new CLibraryPathEntry(name, flags); - case ICSettingEntry.LIBRARY_FILE: - IPath srcPath = loadPath(el, ATTRIBUTE_SOURCE_ATTACHMENT_PATH); - IPath srcRootPath = loadPath(el, ATTRIBUTE_SOURCE_ATTACHMENT_ROOT_PATH); - IPath srcPrefixMapping = loadPath(el, ATTRIBUTE_SOURCE_ATTACHMENT_PREFIX_MAPPING); - return new CLibraryFileEntry(name, flags, srcPath, srcRootPath, srcPrefixMapping); - case ICSettingEntry.OUTPUT_PATH: - return new COutputEntry(name, loadExclusions(el), flags); - case ICSettingEntry.SOURCE_PATH: - return new CSourceEntry(name, loadExclusions(el), flags); - } - return null; + return CDataUtil.createEntry(kind, name, value, exclusionPatterns, flags, srcPath, srcRootPath, srcPrefixMapping); } - private static IPath loadPath(ICStorageElement el, String attr){ + private static IPath loadPath(ICStorageElement el, String attr) { String value = el.getAttribute(attr); - if(value != null) + if (value != null) return new Path(value); return null; } -// private static void storePath(ICStorageElement el, String attr, IPath path){ -// if(path != null) -// el.setAttribute(attr, path.toString()); -// } + // private static void storePath(ICStorageElement el, String attr, IPath path){ + // if(path != null) + // el.setAttribute(attr, path.toString()); + // } - private static IPath[] loadExclusions(ICStorageElement el){ + private static IPath[] loadExclusions(ICStorageElement el) { String attr = el.getAttribute(ATTRIBUTE_EXCLUDING); - if(attr != null){ + if (attr != null) { String[] strs = CDataUtil.stringToArray(attr, FLAGS_SEPARATOR); IPath[] paths = new IPath[strs.length]; - for(int i = 0; i < strs.length; i++){ + for (int i = 0; i < strs.length; i++) { paths[i] = new Path(strs[i]); } return paths; @@ -154,12 +125,12 @@ public class LanguageSettingEntriesSerializer { return null; } - private static void storeExclusions(ICStorageElement el, IPath[] paths){ - if(paths == null || paths.length == 0) + private static void storeExclusions(ICStorageElement el, IPath[] paths) { + if (paths == null || paths.length == 0) return; String[] strs = new String[paths.length]; - for(int i = 0; i < strs.length; i++){ + for (int i = 0; i < strs.length; i++) { strs[i] = paths[i].toString(); } @@ -167,51 +138,51 @@ public class LanguageSettingEntriesSerializer { el.setAttribute(ATTRIBUTE_EXCLUDING, attr); } - public static void serializeEntries(ICSettingEntry entries[], ICStorageElement element){ + public static void serializeEntries(ICSettingEntry entries[], ICStorageElement element) { ICStorageElement child; - if(entries != null){ - for(int i = 0; i < entries.length; i++){ + if (entries != null) { + for (int i = 0; i < entries.length; i++) { child = element.createChild(ELEMENT_ENTRY); serializeEntry(entries[i], child); } } } - public static void serializeEntry(ICSettingEntry entry, ICStorageElement element){ + public static void serializeEntry(ICSettingEntry entry, ICStorageElement element) { String kind = kindToString(entry.getKind()); String flags = composeFlagsString(entry.getFlags()); String name = entry.getName(); element.setAttribute(ATTRIBUTE_KIND, kind); element.setAttribute(ATTRIBUTE_FLAGS, flags); element.setAttribute(ATTRIBUTE_NAME, name); - switch(entry.getKind()){ + switch (entry.getKind()) { case ICSettingEntry.MACRO: String value = entry.getValue(); element.setAttribute(ATTRIBUTE_VALUE, value); break; case ICSettingEntry.SOURCE_PATH: case ICSettingEntry.OUTPUT_PATH: - IPath paths[] = ((ICExclusionPatternPathEntry)entry).getExclusionPatterns(); + IPath paths[] = ((ICExclusionPatternPathEntry) entry).getExclusionPatterns(); storeExclusions(element, paths); break; case ICSettingEntry.LIBRARY_FILE: - ICLibraryFileEntry libFile = (ICLibraryFileEntry)entry; + ICLibraryFileEntry libFile = (ICLibraryFileEntry) entry; IPath path = libFile.getSourceAttachmentPath(); - if(path != null) + if (path != null) element.setAttribute(ATTRIBUTE_SOURCE_ATTACHMENT_PATH, path.toString()); path = libFile.getSourceAttachmentRootPath(); - if(path != null) + if (path != null) element.setAttribute(ATTRIBUTE_SOURCE_ATTACHMENT_ROOT_PATH, path.toString()); path = libFile.getSourceAttachmentPrefixMapping(); - if(path != null) + if (path != null) element.setAttribute(ATTRIBUTE_SOURCE_ATTACHMENT_PREFIX_MAPPING, path.toString()); } } - public static String kindToString(int kind){ - switch(kind){ + public static String kindToString(int kind) { + switch (kind) { case ICSettingEntry.INCLUDE_PATH: return INCLUDE_PATH; case ICSettingEntry.INCLUDE_FILE: @@ -232,64 +203,64 @@ public class LanguageSettingEntriesSerializer { throw new IllegalArgumentException(); } - public static int stringToKind(String kind){ - if(INCLUDE_PATH.equals(kind)) + public static int stringToKind(String kind) { + if (INCLUDE_PATH.equals(kind)) return ICSettingEntry.INCLUDE_PATH; - if(INCLUDE_FILE.equals(kind)) + if (INCLUDE_FILE.equals(kind)) return ICSettingEntry.INCLUDE_FILE; - if(MACRO.equals(kind)) + if (MACRO.equals(kind)) return ICSettingEntry.MACRO; - if(MACRO_FILE.equals(kind)) + if (MACRO_FILE.equals(kind)) return ICSettingEntry.MACRO_FILE; - if(LIBRARY_PATH.equals(kind)) + if (LIBRARY_PATH.equals(kind)) return ICSettingEntry.LIBRARY_PATH; - if(LIBRARY_FILE.equals(kind)) + if (LIBRARY_FILE.equals(kind)) return ICSettingEntry.LIBRARY_FILE; - if(SOURCE_PATH.equals(kind)) + if (SOURCE_PATH.equals(kind)) return ICSettingEntry.SOURCE_PATH; - if(OUTPUT_PATH.equals(kind)) + if (OUTPUT_PATH.equals(kind)) return ICSettingEntry.OUTPUT_PATH; return 0; -// throw new UnsupportedOperationException(); + // throw new UnsupportedOperationException(); } - public static String composeFlagsString(int flags){ + public static String composeFlagsString(int flags) { StringBuffer buf = new StringBuffer(); - if((flags & ICSettingEntry.BUILTIN) != 0){ + if ((flags & ICSettingEntry.BUILTIN) != 0) { buf.append(BUILTIN); } - if((flags & ICSettingEntry.READONLY) != 0){ - if(buf.length() != 0) + if ((flags & ICSettingEntry.READONLY) != 0) { + if (buf.length() != 0) buf.append(FLAGS_SEPARATOR); buf.append(READONLY); } - if((flags & ICSettingEntry.LOCAL) != 0){ - if(buf.length() != 0) + if ((flags & ICSettingEntry.LOCAL) != 0) { + if (buf.length() != 0) buf.append(FLAGS_SEPARATOR); buf.append(LOCAL); } - if((flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0){ - if(buf.length() != 0) + if ((flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0) { + if (buf.length() != 0) buf.append(FLAGS_SEPARATOR); buf.append(VALUE_WORKSPACE_PATH); } - if((flags & ICSettingEntry.RESOLVED) != 0){ - if(buf.length() != 0) + if ((flags & ICSettingEntry.RESOLVED) != 0) { + if (buf.length() != 0) buf.append(FLAGS_SEPARATOR); buf.append(RESOLVED); } - if((flags & ICLanguageSettingEntry.UNDEFINED) != 0){ - if(buf.length() != 0) + if ((flags & ICLanguageSettingEntry.UNDEFINED) != 0) { + if (buf.length() != 0) buf.append(FLAGS_SEPARATOR); buf.append(UNDEFINED); } - if((flags & ICLanguageSettingEntry.FRAMEWORKS_MAC) != 0){ - if(buf.length() != 0) + if ((flags & ICLanguageSettingEntry.FRAMEWORKS_MAC) != 0) { + if (buf.length() != 0) buf.append(FLAGS_SEPARATOR); buf.append(FRAMEWORK); @@ -300,28 +271,28 @@ public class LanguageSettingEntriesSerializer { /** * @since 5.4 */ - public static int composeFlags(String flagsString){ - if(flagsString == null || flagsString.length() == 0) + public static int composeFlags(String flagsString) { + if (flagsString == null || flagsString.length() == 0) return 0; StringTokenizer tokenizer = new StringTokenizer(flagsString, FLAGS_SEPARATOR); int flags = 0; String f; - while(tokenizer.hasMoreElements()){ + while (tokenizer.hasMoreElements()) { f = tokenizer.nextToken(); - if(BUILTIN.equals(f)) - flags |= ICSettingEntry.BUILTIN; - if(READONLY.equals(f)) - flags |= ICSettingEntry.READONLY; - if(LOCAL.equals(f)) - flags |= ICSettingEntry.LOCAL; - if(VALUE_WORKSPACE_PATH.equals(f)) - flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; - if(RESOLVED.equals(f)) + if (BUILTIN.equals(f)) + flags |= ICSettingEntry.BUILTIN; + if (READONLY.equals(f)) + flags |= ICSettingEntry.READONLY; + if (LOCAL.equals(f)) + flags |= ICSettingEntry.LOCAL; + if (VALUE_WORKSPACE_PATH.equals(f)) + flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; + if (RESOLVED.equals(f)) flags |= ICSettingEntry.RESOLVED; - if(UNDEFINED.equals(f)) + if (UNDEFINED.equals(f)) flags |= ICSettingEntry.UNDEFINED; - if(FRAMEWORK.equals(f)) + if (FRAMEWORK.equals(f)) flags |= ICSettingEntry.FRAMEWORKS_MAC; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java index 4a9db6d9ebb..e96b6e1c700 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java @@ -40,11 +40,6 @@ import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.ISourceEntry; import org.eclipse.cdt.core.resources.IPathEntryVariableManager; import org.eclipse.cdt.core.settings.model.CExternalSetting; -import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; -import org.eclipse.cdt.core.settings.model.CIncludePathEntry; -import org.eclipse.cdt.core.settings.model.CLibraryFileEntry; -import org.eclipse.cdt.core.settings.model.CMacroEntry; -import org.eclipse.cdt.core.settings.model.CMacroFileEntry; import org.eclipse.cdt.core.settings.model.COutputEntry; import org.eclipse.cdt.core.settings.model.CSourceEntry; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; @@ -301,25 +296,28 @@ public class PathEntryTranslator { } private static ICLanguageSettingEntry createLangEntry(ResolvedEntry entry) { - PathEntryValueInfo value = entry.getResolvedValue(); + PathEntryValueInfo pathEntryValue = entry.getResolvedValue(); + String name = pathEntryValue.getName(); + int flags = ICSettingEntry.RESOLVED; if (entry.isReadOnly()) flags |= ICSettingEntry.READONLY; if (entry.isBuiltIn()) flags |= ICSettingEntry.BUILTIN; - switch (entry.fEntry.getEntryKind()) { - case IPathEntry.CDT_LIBRARY:{ - ILibraryEntry libEntry = (ILibraryEntry)entry.fEntry; - IPath path = value.getFullPath(); - if (path != null) { - flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; - } else { - path = value.getLocation(); - } + IPath path = pathEntryValue.getFullPath(); + if (path != null) { + flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; + } else { + path = pathEntryValue.getLocation(); + } + int kind = entry.fEntry.getEntryKind(); + switch (kind) { + case IPathEntry.CDT_LIBRARY:{ if (path != null) { - return new CLibraryFileEntry(value.getName(), flags, + ILibraryEntry libEntry = (ILibraryEntry)entry.fEntry; + return (ICLanguageSettingEntry) CDataUtil.createEntry(ICSettingEntry.LIBRARY_FILE, name, null, null, flags, libEntry.getSourceAttachmentPath(), libEntry.getSourceAttachmentRootPath(), libEntry.getSourceAttachmentPrefixMapping()); @@ -331,52 +329,30 @@ public class PathEntryTranslator { // case IPathEntry.CDT_SOURCE: // return INDEX_CDT_SOURCE; case IPathEntry.CDT_INCLUDE:{ - IPath path = value.getFullPath(); if (path != null) { - flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; - } else { - path = value.getLocation(); - } - - if (path != null) { - return new CIncludePathEntry(value.getName(), flags); + return CDataUtil.createCIncludePathEntry(name, flags); } break; } // case IPathEntry.CDT_CONTAINER: // return INDEX_CDT_CONTAINER; case IPathEntry.CDT_MACRO: - String name = value.getName(); if (name.length() != 0) { - String mValue = value.getValue(); - return new CMacroEntry(name, mValue, flags); + String value = pathEntryValue.getValue(); + return CDataUtil.createCMacroEntry(name, value, flags); } break; // case IPathEntry.CDT_OUTPUT: // return INDEX_CDT_OUTPUT; case IPathEntry.CDT_INCLUDE_FILE:{ - IPath path = value.getFullPath(); if (path != null) { - flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; - } else { - path = value.getLocation(); - } - - if (path != null) { - return new CIncludeFileEntry(value.getName(), flags); + return CDataUtil.createCIncludeFileEntry(name, flags); } break; } case IPathEntry.CDT_MACRO_FILE:{ - IPath path = value.getFullPath(); if (path != null) { - flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; - } else { - path = value.getLocation(); - } - - if (path != null) { - return new CMacroFileEntry(value.getName(), flags); + return CDataUtil.createCMacroFileEntry(name, flags); } break; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java index a3b11af68ef..1e57e2461ba 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java @@ -19,28 +19,28 @@ import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; -import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.cdt.ui.CUIPlugin; /** * A settings processor that imports and exports include paths. - * + * * @author Mike Kucera * @since 5.1 - * + * */ -public class IncludePathsSettingsProcessor extends SettingsProcessor { +public class IncludePathsSettingsProcessor extends SettingsProcessor { private static final String SECTION_NAME = "org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths"; //$NON-NLS-1$ private static final String INCLUDE_PATH_ELEMENT = "includepath"; //$NON-NLS-1$ private static final String WORKSPACE_PATH_ATTR = "workspace_path"; //$NON-NLS-1$ - - + + @Override public Image getIcon() { return CUIPlugin.getImageDescriptorRegistry().get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER)); @@ -50,7 +50,7 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor { public String getDisplayName() { return Messages.ProjectSettingsWizardPage_Processor_Includes; } - + @Override public String getSectionName() { return SECTION_NAME; @@ -60,11 +60,11 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor { protected int getSettingsType() { return ICSettingEntry.INCLUDE_PATH; } - + @Override protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting) throws SettingsImportExportException { char[] value = setting.getValue().toCharArray(); - + try { AttributesImpl attrib = null; if( (setting.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) > 0 ) { @@ -75,17 +75,17 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor { content.characters(value, 0, value.length); content.endElement(NONE, NONE, INCLUDE_PATH_ELEMENT); newline(content); - + } catch (SAXException e) { throw new SettingsImportExportException(e); } } - + @Override protected void readSettings(ICLanguageSetting setting, Element language) throws SettingsImportExportException { List includes = new ArrayList(); - + List includeNodes = XMLUtils.extractChildElements(language, INCLUDE_PATH_ELEMENT); for(Element includeElement : includeNodes) { String include = includeElement.getTextContent(); @@ -93,13 +93,13 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor { if(include != null && include.length() > 0) { if( includeElement.getAttribute(WORKSPACE_PATH_ATTR).equalsIgnoreCase(Boolean.TRUE.toString()) ) flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; - includes.add(new CIncludePathEntry(include, flags)); + includes.add(CDataUtil.createCIncludePathEntry(include, flags)); } } if(includes.isEmpty()) return; - + // need to do this or existing settings will disappear includes.addAll(setting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH)); setting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, includes); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java index 8813daeffc6..92563c83d9a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java @@ -22,29 +22,29 @@ import org.w3c.dom.Text; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; -import org.eclipse.cdt.core.settings.model.CMacroEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.cdt.ui.CUIPlugin; /** * A settings processor that imports and exports symbols. - * + * * @author Mike Kucera * @since 5.1 - * + * */ public class MacroSettingsProcessor extends SettingsProcessor { public static final String SECTION_NAME = "org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros"; //$NON-NLS-1$ - + private static final String MACRO_ELEMENT = "macro"; //$NON-NLS-1$ private static final String NAME_ELEMENT = "name"; //$NON-NLS-1$ private static final String VALUE_ELEMENT = "value"; //$NON-NLS-1$ - - + + @Override public Image getIcon() { return CUIPlugin.getImageDescriptorRegistry().get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO)); @@ -64,44 +64,44 @@ public class MacroSettingsProcessor extends SettingsProcessor { protected int getSettingsType() { return ICSettingEntry.MACRO; } - + @Override protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting) throws SettingsImportExportException { char[] name = setting.getName().toCharArray(); char[] value = setting.getValue().toCharArray(); - + try { content.startElement(NONE, NONE, MACRO_ELEMENT, null); newline(content); - + content.startElement(NONE, NONE, NAME_ELEMENT, null); content.characters(name, 0, name.length); content.endElement(NONE, NONE, NAME_ELEMENT); - + content.startElement(NONE, NONE, VALUE_ELEMENT, null); content.characters(value, 0, value.length); content.endElement(NONE, NONE, VALUE_ELEMENT); newline(content); - + content.endElement(NONE, NONE, MACRO_ELEMENT); newline(content); - + } catch(SAXException e) { throw new SettingsImportExportException(e); } } - - + + @Override protected void readSettings(ICLanguageSetting setting, Element language) throws SettingsImportExportException { List macros = new ArrayList(); - + List macrosNodes = XMLUtils.extractChildElements(language, MACRO_ELEMENT); - + for(Element macroElement : macrosNodes) { String name = null; String value = null; - + NodeList nodeList = macroElement.getChildNodes(); for(int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); @@ -125,21 +125,21 @@ public class MacroSettingsProcessor extends SettingsProcessor { throw new SettingsImportExportException("Unknown node: " + node.getNodeName()); //$NON-NLS-1$ } } - + if(name == null) throw new SettingsImportExportException("There must be one element"); //$NON-NLS-1$ if(value == null) throw new SettingsImportExportException("There must be one element"); //$NON-NLS-1$ - - macros.add(new CMacroEntry(name, value, 0)); + + macros.add(CDataUtil.createCMacroEntry(name, value, 0)); } - + if(macros.isEmpty()) return; - + // need to do this or existing settings will disappear macros.addAll(setting.getSettingEntriesList(ICSettingEntry.MACRO)); setting.setSettingEntries(ICSettingEntry.MACRO, macros); } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeFileTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeFileTab.java index c1e07d3c108..f0f2e21df56 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeFileTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeFileTab.java @@ -11,9 +11,9 @@ *******************************************************************************/ package org.eclipse.cdt.ui.newui; -import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; /** * @noextend This class is not intended to be subclassed by clients. @@ -25,7 +25,7 @@ public class ExpIncludeFileTab extends AbstractExportTab { @Override public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) { int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0; - return new CIncludeFileEntry(s2, flags); + return CDataUtil.createCIncludeFileEntry(s2, flags); } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java index 3482a3ef00e..2ccf13a0ad0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java @@ -10,26 +10,26 @@ *******************************************************************************/ package org.eclipse.cdt.ui.newui; -import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; /** * @noextend This class is not intended to be subclassed by clients. */ public class ExpIncludeTab extends AbstractExportTab { - + @Override public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) { int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0; - return new CIncludePathEntry(s2, flags); + return CDataUtil.createCIncludePathEntry(s2, flags); } @Override public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) { return doAdd(s1, s2, isWsp); } - + @Override public int getKind() { return ICSettingEntry.INCLUDE_PATH; } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java index a4bdbdd3aac..3228833b6bd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java @@ -10,9 +10,9 @@ *******************************************************************************/ package org.eclipse.cdt.ui.newui; -import org.eclipse.cdt.core.settings.model.CMacroEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; /** * @noextend This class is not intended to be subclassed by clients. @@ -22,14 +22,14 @@ public class ExpSymbolTab extends AbstractExportTab { // isWsp is ignored for symbols @Override public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) { - return new CMacroEntry(s1, s2, 0); + return CDataUtil.createCMacroEntry(s1, s2, 0); } @Override public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) { return doAdd(s1, s2, isWsp); } - + @Override public int getKind() { return ICSettingEntry.MACRO; } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java index a494da528a3..c253ef83ea1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java @@ -18,9 +18,9 @@ import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.internal.ui.newui.Messages; @@ -40,13 +40,13 @@ public class IncludeFileTab extends AbstractLangsListTab { @Override public void additionalTableSet() { columnToFit = new TableColumn(table, SWT.NONE); - columnToFit.setText(Messages.IncludeFileTab_0); - columnToFit.setToolTipText(Messages.IncludeFileTab_0); + columnToFit.setText(Messages.IncludeFileTab_0); + columnToFit.setToolTipText(Messages.IncludeFileTab_0); showBIButton.setSelection(true); table.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { - e.result = Messages.IncludeFileTab_0; + e.result = Messages.IncludeFileTab_0; } }); } @@ -68,7 +68,7 @@ public class IncludeFileTab extends AbstractLangsListTab { if (dlg.check2) { // isWsp flags = ICSettingEntry.VALUE_WORKSPACE_PATH; } - return new CIncludeFileEntry(dlg.text1, flags); + return CDataUtil.createCIncludeFileEntry(dlg.text1, flags); } return null; } @@ -78,7 +78,7 @@ public class IncludeFileTab extends AbstractLangsListTab { IncludeDialog dlg = new IncludeDialog( usercomp.getShell(), IncludeDialog.OLD_FILE, - Messages.IncludeFileTab_2, + Messages.IncludeFileTab_2, ent.getValue(), getResDesc().getConfiguration(), ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH, @@ -87,7 +87,7 @@ public class IncludeFileTab extends AbstractLangsListTab { int flags = 0; if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH; - return new CIncludeFileEntry(dlg.text1, flags); + return CDataUtil.createCIncludeFileEntry(dlg.text1, flags); } return null; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java index 40ada52f635..8eddee55c4d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java @@ -17,9 +17,9 @@ import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.internal.ui.newui.Messages; @@ -27,28 +27,28 @@ import org.eclipse.cdt.internal.ui.newui.Messages; * @noextend This class is not intended to be subclassed by clients. */ public class IncludeTab extends AbstractLangsListTab { - + @Override public void additionalTableSet() { columnToFit = new TableColumn(table, SWT.NONE); - columnToFit.setText(Messages.IncludeTab_0); - columnToFit.setToolTipText(Messages.IncludeTab_0); + columnToFit.setText(Messages.IncludeTab_0); + columnToFit.setToolTipText(Messages.IncludeTab_0); showBIButton.setSelection(true); table.getAccessible().addAccessibleListener( - new AccessibleAdapter() { + new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { - e.result = Messages.IncludeTab_0; + e.result = Messages.IncludeTab_0; } } ); } - + @Override public ICLanguageSettingEntry doAdd() { IncludeDialog dlg = new IncludeDialog( usercomp.getShell(), IncludeDialog.NEW_DIR, - Messages.IncludeTab_1, + Messages.IncludeTab_1, EMPTY_STR, getResDesc().getConfiguration(), 0); if (dlg.open() && dlg.text1.trim().length() > 0 ) { toAllCfgs = dlg.check1; @@ -57,7 +57,7 @@ public void additionalTableSet() { if (dlg.check2) { // isWsp flags = ICSettingEntry.VALUE_WORKSPACE_PATH; } - return new CIncludePathEntry(dlg.text1, flags); + return CDataUtil.createCIncludePathEntry(dlg.text1, flags); } return null; } @@ -66,21 +66,21 @@ public void additionalTableSet() { public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) { IncludeDialog dlg = new IncludeDialog( usercomp.getShell(), IncludeDialog.OLD_DIR, - Messages.IncludeTab_2, + Messages.IncludeTab_2, ent.getValue(), getResDesc().getConfiguration(), (ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH)); if (dlg.open()) { int flags = 0; if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH; - return new CIncludePathEntry(dlg.text1, flags); + return CDataUtil.createCIncludePathEntry(dlg.text1, flags); } return null; } - + @Override public int getKind() { return ICSettingEntry.INCLUDE_PATH; } - - + + @Override public void createControls(final Composite parent) { super.createControls(parent); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java index 08de5be87c6..6d93c850be2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java @@ -20,9 +20,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.cdt.core.model.util.CDTListComparator; -import org.eclipse.cdt.core.settings.model.CMacroEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.internal.ui.newui.Messages; @@ -33,18 +33,18 @@ public class SymbolTab extends AbstractLangsListTab { @Override public void additionalTableSet() { TableColumn tc = new TableColumn(table, SWT.LEFT); - tc.setText(Messages.SymbolTab_0); + tc.setText(Messages.SymbolTab_0); tc.setWidth(80); - tc.setToolTipText(Messages.SymbolTab_0); + tc.setToolTipText(Messages.SymbolTab_0); tc = new TableColumn(table, SWT.LEFT); - tc.setText(Messages.SymbolTab_1); + tc.setText(Messages.SymbolTab_1); tc.setWidth(130); - tc.setToolTipText(Messages.SymbolTab_1); + tc.setToolTipText(Messages.SymbolTab_1); table.getAccessible().addAccessibleListener( - new AccessibleAdapter() { + new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { - e.result = Messages.SymbolTab_0; + e.result = Messages.SymbolTab_0; } } ); @@ -54,11 +54,11 @@ public class SymbolTab extends AbstractLangsListTab { public ICLanguageSettingEntry doAdd() { SymbolDialog dlg = new SymbolDialog( usercomp.getShell(), true, - Messages.SymbolTab_2, EMPTY_STR, EMPTY_STR, getResDesc()); + Messages.SymbolTab_2, EMPTY_STR, EMPTY_STR, getResDesc()); if (dlg.open() && dlg.text1.trim().length() > 0 ) { toAllCfgs = dlg.check1; toAllLang = dlg.check3; - return new CMacroEntry(dlg.text1, dlg.text2, 0); + return CDataUtil.createCMacroEntry(dlg.text1, dlg.text2, 0); } return null; } @@ -67,16 +67,16 @@ public class SymbolTab extends AbstractLangsListTab { public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) { SymbolDialog dlg = new SymbolDialog( usercomp.getShell(), false, - Messages.SymbolTab_3, ent.getName(), + Messages.SymbolTab_3, ent.getName(), ent.getValue(), getResDesc()); if (dlg.open()) - return new CMacroEntry(dlg.text1, dlg.text2, 0); + return CDataUtil.createCMacroEntry(dlg.text1, dlg.text2, 0); return null; } - + @Override - public int getKind() { - return ICSettingEntry.MACRO; + public int getKind() { + return ICSettingEntry.MACRO; } // Specific version of "update()" for Symbols tab only @@ -84,21 +84,21 @@ public class SymbolTab extends AbstractLangsListTab { public void update() { if (lang != null) { int x = table.getSelectionIndex(); - if (x == -1) + if (x == -1) x = 0; shownEntries = getIncs(); Collections.sort(shownEntries, CDTListComparator.getInstance()); tv.setInput(shownEntries.toArray(new Object[shownEntries.size()])); if (table.getItemCount() > x) table.setSelection(x); - else if (table.getItemCount() > 0) + else if (table.getItemCount() > 0) table.setSelection(0); - } + } updateStringListModeControl(); updateButtons(); } - - + + @Override public void createControls(final Composite parent) { super.createControls(parent); diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/PerFileXLCScannerInfoCollector.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/PerFileXLCScannerInfoCollector.java index 01c66069930..d22938913a4 100644 --- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/PerFileXLCScannerInfoCollector.java +++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/PerFileXLCScannerInfoCollector.java @@ -35,6 +35,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo; @@ -196,7 +197,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I // if we didn't find the path, add it if(!symbolFound) { entriesChanged = true; - CMacroEntry newEntry = new CMacroEntry(symbol, discSymbols.get(symbol), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED); + CMacroEntry newEntry = CDataUtil.createCMacroEntry(symbol, discSymbols.get(symbol), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED); newEntries.add(newEntry); } } @@ -216,7 +217,6 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I newEntries.add(entry); } - boolean entriesChanged = false; // look for settings corresponding to each path we discovered @@ -234,7 +234,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I // if we didn't find the path, add it if(!pathFound) { entriesChanged = true; - CIncludePathEntry newEntry = new CIncludePathEntry(path, ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED); + CIncludePathEntry newEntry = CDataUtil.createCIncludePathEntry(path.toString(), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED); newEntries.add(newEntry); } }