Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2018-11-20 21:20:39 +0000
committerJonah Graham2018-11-20 21:20:39 +0000
commit48d2271a58a68743e428d3096d2bca054d04e310 (patch)
tree235ba23e71c393ad22d1d57fc8fdfec14754c4ee /core/org.eclipse.cdt.core
parent3cf0297769e5cfb91823e93ce570120a75fe01ce (diff)
downloadorg.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.gz
org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.xz
org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.zip
Bug 540373: Normalize newlines with .gitattributes
There is also a new script to verify completeness of .gitattributes: releng/scripts/verify_gitattributes.sh Change-Id: I2ce270852ab54b66b6c474a6ec94203fe5bba78b
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java136
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/IWorkingDirectoryTracker.java56
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsStorage.java530
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java578
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java872
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java28
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java232
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsSerializableStorage.java454
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java330
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java158
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java316
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java116
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java56
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java90
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/StandardAttributes.java60
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java334
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java330
-rw-r--r--core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd238
-rw-r--r--core/org.eclipse.cdt.core/schema/toolChainProvider.exsd264
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java548
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamProgressMonitor.java216
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java128
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java88
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java66
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java78
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java666
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/LRUCache.java98
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java718
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/IEnvironmentChangeListener.java54
30 files changed, 3924 insertions, 3924 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java
index fb9be5d5ae4..0d2a44c9b6d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java
@@ -1,69 +1,69 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - initial API and implementation
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.List;
-
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-/**
- * Interface to express ability (of a configuration description) to handle Language Settings
- * Providers.
- * @see ILanguageSettingsProvider
- *
- * @since 5.4
- *
- */
-public interface ILanguageSettingsProvidersKeeper {
- /**
- * Sets the list of language settings providers. Language settings providers are
- * used to supply language settings {@link ICLanguageSettingEntry} such as include paths
- * or preprocessor macros.
- *
- * @param providers - the list of providers to assign to the owner (configuration description).
- * This method clones the internal list or otherwise ensures immutability of the internal
- * list before actual addition to the project model. That is to ensure that there is no
- * back-door access and all changes in the list done by this method which fires notifications
- * to the registered listeners about the accompanied changes in settings entries, see
- * {@link LanguageSettingsManager#registerLanguageSettingsChangeListener(ILanguageSettingsChangeListener)}.
- */
- public void setLanguageSettingProviders(List<? extends ILanguageSettingsProvider> providers);
-
- /**
- * Returns the list of language settings providers. Language settings providers are
- * used to supply language settings {@link ICLanguageSettingEntry} such as include paths
- * or preprocessor macros.
- *
- * @return the list of providers to assign to the owner (configuration description). This
- * returns immutable list. Use {@link #setLanguageSettingProviders(List)} to change.
- * This method does not return {@code null}.
- */
- public List<ILanguageSettingsProvider> getLanguageSettingProviders();
-
- /**
- * Sets the list of IDs of default language settings providers.
- * <br><br>
- * The method is intended to be used by MBS to set the list from tool-chain definition.
- * The default list from the tool-chain is used, for example, while resetting
- * configuration providers to default in UI.
- *
- * @param ids - default provider IDs specified in the tool-chain.
- */
- public void setDefaultLanguageSettingsProvidersIds(String[] ids);
-
- /**
- * Retrieve the list of IDs of default language settings providers.
- * Normally the list would come from the tool-chain definition.
- *
- * @return default provider IDs or {@code null} if default providers are not defined.
- */
- public String[] getDefaultLanguageSettingsProvidersIds();
-
-}
+package org.eclipse.cdt.core.language.settings.providers;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+/**
+ * Interface to express ability (of a configuration description) to handle Language Settings
+ * Providers.
+ * @see ILanguageSettingsProvider
+ *
+ * @since 5.4
+ *
+ */
+public interface ILanguageSettingsProvidersKeeper {
+ /**
+ * Sets the list of language settings providers. Language settings providers are
+ * used to supply language settings {@link ICLanguageSettingEntry} such as include paths
+ * or preprocessor macros.
+ *
+ * @param providers - the list of providers to assign to the owner (configuration description).
+ * This method clones the internal list or otherwise ensures immutability of the internal
+ * list before actual addition to the project model. That is to ensure that there is no
+ * back-door access and all changes in the list done by this method which fires notifications
+ * to the registered listeners about the accompanied changes in settings entries, see
+ * {@link LanguageSettingsManager#registerLanguageSettingsChangeListener(ILanguageSettingsChangeListener)}.
+ */
+ public void setLanguageSettingProviders(List<? extends ILanguageSettingsProvider> providers);
+
+ /**
+ * Returns the list of language settings providers. Language settings providers are
+ * used to supply language settings {@link ICLanguageSettingEntry} such as include paths
+ * or preprocessor macros.
+ *
+ * @return the list of providers to assign to the owner (configuration description). This
+ * returns immutable list. Use {@link #setLanguageSettingProviders(List)} to change.
+ * This method does not return {@code null}.
+ */
+ public List<ILanguageSettingsProvider> getLanguageSettingProviders();
+
+ /**
+ * Sets the list of IDs of default language settings providers.
+ * <br><br>
+ * The method is intended to be used by MBS to set the list from tool-chain definition.
+ * The default list from the tool-chain is used, for example, while resetting
+ * configuration providers to default in UI.
+ *
+ * @param ids - default provider IDs specified in the tool-chain.
+ */
+ public void setDefaultLanguageSettingsProvidersIds(String[] ids);
+
+ /**
+ * Retrieve the list of IDs of default language settings providers.
+ * Normally the list would come from the tool-chain definition.
+ *
+ * @return default provider IDs or {@code null} if default providers are not defined.
+ */
+ public String[] getDefaultLanguageSettingsProvidersIds();
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/IWorkingDirectoryTracker.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/IWorkingDirectoryTracker.java
index 6bf62071aa3..4f64bc39cd2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/IWorkingDirectoryTracker.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/IWorkingDirectoryTracker.java
@@ -1,28 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2012 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.net.URI;
-
-/**
- * Interface for console parsers able to track current working directory for build.
- *
- * @since 5.4
- */
-public interface IWorkingDirectoryTracker {
- /**
- * Returns current working directory for the current build command as determined from
- * build output.
- *
- * @return URI of current working directory or {@code null}.
- */
- public URI getWorkingDirectoryURI();
-}
+/*******************************************************************************
+ * Copyright (c) 2012, 2012 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.language.settings.providers;
+
+import java.net.URI;
+
+/**
+ * Interface for console parsers able to track current working directory for build.
+ *
+ * @since 5.4
+ */
+public interface IWorkingDirectoryTracker {
+ /**
+ * Returns current working directory for the current build command as determined from
+ * build output.
+ *
+ * @return URI of current working directory or {@code null}.
+ */
+ public URI getWorkingDirectoryURI();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsStorage.java
index 992ee4e7097..a3e0e76468c 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsStorage.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsStorage.java
@@ -1,266 +1,266 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2014 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - initial API and implementation
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.internal.core.WeakHashSet;
-import org.eclipse.cdt.internal.core.WeakHashSetSynchronized;
-
-/**
- * The class representing the (in-memory) storage for language settings entries {@link ICLanguageSettingEntry}.
- *
- * @since 5.4
- */
-public class LanguageSettingsStorage implements Cloneable {
- /** Storage to keep settings entries. */
- protected Map<String, // languageId
- Map<String, // resource project path
- List<ICLanguageSettingEntry>>> fStorage = new HashMap<String, Map<String, List<ICLanguageSettingEntry>>>();
-
- /**
- * Pool of LSE lists 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<List<ICLanguageSettingEntry>> listPool = new WeakHashSetSynchronized<List<ICLanguageSettingEntry>>();
-
- /**
- * Returns the list of setting entries for the given resource and language.
- * <br> Note that this list is <b>unmodifiable</b>.
- *
- * @param rcProjectPath - path to the resource relative to the project.
- * @param languageId - language id.
- *
- * @return the list of setting entries or {@code null} if no settings defined.
- */
- public List<ICLanguageSettingEntry> getSettingEntries(String rcProjectPath, String languageId) {
- List<ICLanguageSettingEntry> entries = null;
- Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
- if (langMap!=null) {
- entries = langMap.get(rcProjectPath);
- }
- return entries;
- }
-
- /**
- * Some providers may collect entries in pretty much random order. For the intent of
- * predictability, UI usability and efficient storage the entries are sorted by kinds
- * and secondary by name for kinds where the secondary order is not significant.
- *
- * @param entries - list of entries to sort.
- * @return - sorted entries.
- */
- private List<ICLanguageSettingEntry> sortEntries(List<? extends ICLanguageSettingEntry> entries) {
- List<ICLanguageSettingEntry> sortedEntries = new ArrayList<>(entries);
- Collections.sort(sortedEntries, new Comparator<ICLanguageSettingEntry>() {
- /**
- * This comparator sorts by kinds first and the macros are sorted additionally by name.
- */
- @Override
- public int compare(ICLanguageSettingEntry entry0, ICLanguageSettingEntry entry1) {
- int kind0 = entry0.getKind();
- int kind1 = entry1.getKind();
- if (kind0 == ICSettingEntry.MACRO && kind1 == ICSettingEntry.MACRO) {
- return entry0.getName().compareTo(entry1.getName());
- }
-
- return kind0 - kind1;
- }});
-
- return sortedEntries;
- }
-
- /**
- * Sets language settings entries for the resource and language.
- *
- * @param rcProjectPath - path to the resource relative to the project. If {@code null} the entries are
- * considered to be being defined as default entries for resources.
- * @param languageId - language id. If {@code null}, then entries are considered
- * to be defined for the language scope.
- * @param entries - language settings entries to set.
- */
- public void setSettingEntries(String rcProjectPath, String languageId,
- List<? extends ICLanguageSettingEntry> entries) {
- synchronized (fStorage) {
- if (entries!=null) {
- Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
- if (langMap == null) {
- langMap = new HashMap<String, List<ICLanguageSettingEntry>>();
- fStorage.put(languageId, langMap);
- }
- List<ICLanguageSettingEntry> sortedEntries = getPooledList(sortEntries(entries), false);
- langMap.put(rcProjectPath, sortedEntries);
- } else {
- // reduct the empty maps in the tables
- Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
- if (langMap != null) {
- langMap.remove(rcProjectPath);
- if (langMap.isEmpty()) {
- fStorage.remove(languageId);
- }
- }
- }
- }
- }
-
- /**
- * @return {@code true} if the storage is empty or {@code false} otherwise.
- */
- public boolean isEmpty() {
- return fStorage.isEmpty();
- }
-
- /**
- * Clear all the entries for all resources and all languages.
- */
- public void clear() {
- synchronized (fStorage) {
- fStorage.clear();
- }
- }
-
- /**
- * @return set of all languages associated with the entries.
- * Note that the storage can keep default entries for the language scope
- * of the provider, so the set can contain {@code null}.
- */
- public Set<String> getLanguages() {
- return new HashSet<String>(fStorage.keySet());
- }
-
- /**
- * Returns set of paths for all resources associated with entries for given language.
- * The paths are project relative.
- *
- * @param languageId - language ID.
- * @return the set of resource paths associated with entries for the given language or empty set.
- * Note that the storage can keep default entries for resources, so the set can contain {@code null}.
- */
- public Set<String> getResourcePaths(String languageId) {
- Map<String, List<ICLanguageSettingEntry>> rcPathsMap = fStorage.get(languageId);
- if (rcPathsMap == null) {
- return new HashSet<String>();
- }
- return new HashSet<String>(rcPathsMap.keySet());
- }
-
- /**
- * Find and return the equal list of entries from the pool.
- *
- * @param entries - list of entries to pool.
- * @param copy - specify {@code true} to copy the list in order to prevent
- * back-door modification on the original list changes.
- * @return returns the list of entries from the pool.
- */
- private static List<ICLanguageSettingEntry> getPooledList(List<ICLanguageSettingEntry> entries, boolean copy) {
- if (entries == null)
- return null;
-
- List<ICLanguageSettingEntry> pooledList = listPool.get(entries);
- if (pooledList != null) {
- return pooledList;
- }
-
- if (entries.size() == 0) {
- return getPooledEmptyList();
- }
-
- if (copy) {
- entries = new ArrayList<ICLanguageSettingEntry>(entries);
- }
- pooledList = Collections.unmodifiableList(entries);
- return listPool.add(pooledList);
- }
-
- /**
- * Find and return the equal list of entries from the pool to conserve the memory.
- *
- * @param entries - list of entries to pool.
- * @return returns the list of entries from the pool.
- */
- public static List<ICLanguageSettingEntry> getPooledList(List<ICLanguageSettingEntry> entries) {
- return getPooledList(entries, true);
- }
-
- /**
- * @return Returns the empty immutable list which is pooled. Use this call rather than creating
- * new empty array to ensure that faster shallow operator '==' can be used instead of equals()
- * which goes deep on HashMaps.
- */
- public static List<ICLanguageSettingEntry> getPooledEmptyList() {
- List<ICLanguageSettingEntry> pooledEmptyList = Collections.emptyList();
- return listPool.add(pooledEmptyList);
- }
-
- /**
- * Clone storage for the entries. Copies references for lists of entries as a whole.
- * Note that that is OK as the lists kept in storage are unmodifiable and pooled.
- */
- @Override
- public LanguageSettingsStorage clone() throws CloneNotSupportedException {
- LanguageSettingsStorage storageClone = (LanguageSettingsStorage) super.clone();
- storageClone.fStorage = new HashMap<String, Map<String, List<ICLanguageSettingEntry>>>();
- synchronized (fStorage) {
- Set<Entry<String, Map<String, List<ICLanguageSettingEntry>>>> entrySetLang = fStorage.entrySet();
- for (Entry<String, Map<String, List<ICLanguageSettingEntry>>> entryLang : entrySetLang) {
- String langId = entryLang.getKey();
- Map<String, List<ICLanguageSettingEntry>> mapRc = entryLang.getValue();
- Map<String, List<ICLanguageSettingEntry>> mapRcClone = new HashMap<String, List<ICLanguageSettingEntry>>();
- Set<Entry<String, List<ICLanguageSettingEntry>>> entrySetRc = mapRc.entrySet();
- for (Entry<String, List<ICLanguageSettingEntry>> entryRc : entrySetRc) {
- String rcProjectPath = entryRc.getKey();
- List<ICLanguageSettingEntry> lsEntries = entryRc.getValue();
- // don't need to clone entries, they are from the LSE lists pool
- mapRcClone.put(rcProjectPath, lsEntries);
- }
- storageClone.fStorage.put(langId, mapRcClone);
- }
- }
- return storageClone;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fStorage == null) ? 0 : fStorage.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- LanguageSettingsStorage other = (LanguageSettingsStorage) obj;
- if (fStorage == null) {
- if (other.fStorage != null)
- return false;
- } else if (!fStorage.equals(other.fStorage))
- return false;
- return true;
- }
-
-}
+package org.eclipse.cdt.core.language.settings.providers;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.internal.core.WeakHashSet;
+import org.eclipse.cdt.internal.core.WeakHashSetSynchronized;
+
+/**
+ * The class representing the (in-memory) storage for language settings entries {@link ICLanguageSettingEntry}.
+ *
+ * @since 5.4
+ */
+public class LanguageSettingsStorage implements Cloneable {
+ /** Storage to keep settings entries. */
+ protected Map<String, // languageId
+ Map<String, // resource project path
+ List<ICLanguageSettingEntry>>> fStorage = new HashMap<String, Map<String, List<ICLanguageSettingEntry>>>();
+
+ /**
+ * Pool of LSE lists 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<List<ICLanguageSettingEntry>> listPool = new WeakHashSetSynchronized<List<ICLanguageSettingEntry>>();
+
+ /**
+ * Returns the list of setting entries for the given resource and language.
+ * <br> Note that this list is <b>unmodifiable</b>.
+ *
+ * @param rcProjectPath - path to the resource relative to the project.
+ * @param languageId - language id.
+ *
+ * @return the list of setting entries or {@code null} if no settings defined.
+ */
+ public List<ICLanguageSettingEntry> getSettingEntries(String rcProjectPath, String languageId) {
+ List<ICLanguageSettingEntry> entries = null;
+ Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
+ if (langMap!=null) {
+ entries = langMap.get(rcProjectPath);
+ }
+ return entries;
+ }
+
+ /**
+ * Some providers may collect entries in pretty much random order. For the intent of
+ * predictability, UI usability and efficient storage the entries are sorted by kinds
+ * and secondary by name for kinds where the secondary order is not significant.
+ *
+ * @param entries - list of entries to sort.
+ * @return - sorted entries.
+ */
+ private List<ICLanguageSettingEntry> sortEntries(List<? extends ICLanguageSettingEntry> entries) {
+ List<ICLanguageSettingEntry> sortedEntries = new ArrayList<>(entries);
+ Collections.sort(sortedEntries, new Comparator<ICLanguageSettingEntry>() {
+ /**
+ * This comparator sorts by kinds first and the macros are sorted additionally by name.
+ */
+ @Override
+ public int compare(ICLanguageSettingEntry entry0, ICLanguageSettingEntry entry1) {
+ int kind0 = entry0.getKind();
+ int kind1 = entry1.getKind();
+ if (kind0 == ICSettingEntry.MACRO && kind1 == ICSettingEntry.MACRO) {
+ return entry0.getName().compareTo(entry1.getName());
+ }
+
+ return kind0 - kind1;
+ }});
+
+ return sortedEntries;
+ }
+
+ /**
+ * Sets language settings entries for the resource and language.
+ *
+ * @param rcProjectPath - path to the resource relative to the project. If {@code null} the entries are
+ * considered to be being defined as default entries for resources.
+ * @param languageId - language id. If {@code null}, then entries are considered
+ * to be defined for the language scope.
+ * @param entries - language settings entries to set.
+ */
+ public void setSettingEntries(String rcProjectPath, String languageId,
+ List<? extends ICLanguageSettingEntry> entries) {
+ synchronized (fStorage) {
+ if (entries!=null) {
+ Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
+ if (langMap == null) {
+ langMap = new HashMap<String, List<ICLanguageSettingEntry>>();
+ fStorage.put(languageId, langMap);
+ }
+ List<ICLanguageSettingEntry> sortedEntries = getPooledList(sortEntries(entries), false);
+ langMap.put(rcProjectPath, sortedEntries);
+ } else {
+ // reduct the empty maps in the tables
+ Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
+ if (langMap != null) {
+ langMap.remove(rcProjectPath);
+ if (langMap.isEmpty()) {
+ fStorage.remove(languageId);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @return {@code true} if the storage is empty or {@code false} otherwise.
+ */
+ public boolean isEmpty() {
+ return fStorage.isEmpty();
+ }
+
+ /**
+ * Clear all the entries for all resources and all languages.
+ */
+ public void clear() {
+ synchronized (fStorage) {
+ fStorage.clear();
+ }
+ }
+
+ /**
+ * @return set of all languages associated with the entries.
+ * Note that the storage can keep default entries for the language scope
+ * of the provider, so the set can contain {@code null}.
+ */
+ public Set<String> getLanguages() {
+ return new HashSet<String>(fStorage.keySet());
+ }
+
+ /**
+ * Returns set of paths for all resources associated with entries for given language.
+ * The paths are project relative.
+ *
+ * @param languageId - language ID.
+ * @return the set of resource paths associated with entries for the given language or empty set.
+ * Note that the storage can keep default entries for resources, so the set can contain {@code null}.
+ */
+ public Set<String> getResourcePaths(String languageId) {
+ Map<String, List<ICLanguageSettingEntry>> rcPathsMap = fStorage.get(languageId);
+ if (rcPathsMap == null) {
+ return new HashSet<String>();
+ }
+ return new HashSet<String>(rcPathsMap.keySet());
+ }
+
+ /**
+ * Find and return the equal list of entries from the pool.
+ *
+ * @param entries - list of entries to pool.
+ * @param copy - specify {@code true} to copy the list in order to prevent
+ * back-door modification on the original list changes.
+ * @return returns the list of entries from the pool.
+ */
+ private static List<ICLanguageSettingEntry> getPooledList(List<ICLanguageSettingEntry> entries, boolean copy) {
+ if (entries == null)
+ return null;
+
+ List<ICLanguageSettingEntry> pooledList = listPool.get(entries);
+ if (pooledList != null) {
+ return pooledList;
+ }
+
+ if (entries.size() == 0) {
+ return getPooledEmptyList();
+ }
+
+ if (copy) {
+ entries = new ArrayList<ICLanguageSettingEntry>(entries);
+ }
+ pooledList = Collections.unmodifiableList(entries);
+ return listPool.add(pooledList);
+ }
+
+ /**
+ * Find and return the equal list of entries from the pool to conserve the memory.
+ *
+ * @param entries - list of entries to pool.
+ * @return returns the list of entries from the pool.
+ */
+ public static List<ICLanguageSettingEntry> getPooledList(List<ICLanguageSettingEntry> entries) {
+ return getPooledList(entries, true);
+ }
+
+ /**
+ * @return Returns the empty immutable list which is pooled. Use this call rather than creating
+ * new empty array to ensure that faster shallow operator '==' can be used instead of equals()
+ * which goes deep on HashMaps.
+ */
+ public static List<ICLanguageSettingEntry> getPooledEmptyList() {
+ List<ICLanguageSettingEntry> pooledEmptyList = Collections.emptyList();
+ return listPool.add(pooledEmptyList);
+ }
+
+ /**
+ * Clone storage for the entries. Copies references for lists of entries as a whole.
+ * Note that that is OK as the lists kept in storage are unmodifiable and pooled.
+ */
+ @Override
+ public LanguageSettingsStorage clone() throws CloneNotSupportedException {
+ LanguageSettingsStorage storageClone = (LanguageSettingsStorage) super.clone();
+ storageClone.fStorage = new HashMap<String, Map<String, List<ICLanguageSettingEntry>>>();
+ synchronized (fStorage) {
+ Set<Entry<String, Map<String, List<ICLanguageSettingEntry>>>> entrySetLang = fStorage.entrySet();
+ for (Entry<String, Map<String, List<ICLanguageSettingEntry>>> entryLang : entrySetLang) {
+ String langId = entryLang.getKey();
+ Map<String, List<ICLanguageSettingEntry>> mapRc = entryLang.getValue();
+ Map<String, List<ICLanguageSettingEntry>> mapRcClone = new HashMap<String, List<ICLanguageSettingEntry>>();
+ Set<Entry<String, List<ICLanguageSettingEntry>>> entrySetRc = mapRc.entrySet();
+ for (Entry<String, List<ICLanguageSettingEntry>> entryRc : entrySetRc) {
+ String rcProjectPath = entryRc.getKey();
+ List<ICLanguageSettingEntry> lsEntries = entryRc.getValue();
+ // don't need to clone entries, they are from the LSE lists pool
+ mapRcClone.put(rcProjectPath, lsEntries);
+ }
+ storageClone.fStorage.put(langId, mapRcClone);
+ }
+ }
+ return storageClone;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fStorage == null) ? 0 : fStorage.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ LanguageSettingsStorage other = (LanguageSettingsStorage) obj;
+ if (fStorage == null) {
+ if (other.fStorage != null)
+ return false;
+ } else if (!fStorage.equals(other.fStorage))
+ return false;
+ return true;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java
index ab7b58ea514..6159f1641e2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java
@@ -1,289 +1,289 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - initial API and implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.internal.core.LocalProjectScope;
-import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider;
-import org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider;
-import org.eclipse.cdt.internal.core.model.PathEntryManager;
-import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * Collection of utilities for legacy support of older Scanner Discovery functionality.
- * This class is temporary and not intended to be used by clients.
- *
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- *
- * @since 5.4
- */
-public class ScannerDiscoveryLegacySupport {
- /** ID of User language settings provider (from org.eclipse.cdt.ui) */
- public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$
- /** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */
- public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"; //$NON-NLS-1$
-
- /**
- * ID of ScannerInfo language settings provider wrapping ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point
- * @since 5.5
- */
- public static final String SI_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$
-
- /**
- * ID of language settings provider wrapping {@link org.eclipse.cdt.core.resources.ScannerProvider} of {@link PathEntryManager} for 3.X projects
- * @since 5.5
- */
- public static final String PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.PathEntryScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$
-
- private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$
- private static boolean DISABLE_LSP_DEFAULT_PROJECT = false;
- private static boolean DISABLE_LSP_DEFAULT_WORKSPACE = false;
- private static final String PREFERENCES_QUALIFIER_CCORE = CCorePlugin.PLUGIN_ID;
-
- private static Map<String, String> legacyProfiles = null;
-
- /**
- * Get preferences node for org.eclipse.cdt.core.
- *
- * @param project - project to get preferences or {@code null} for workspace preferences
- * @return
- */
- private static Preferences getPreferences(IProject project) {
- if (project == null) {
- return InstanceScope.INSTANCE.getNode(PREFERENCES_QUALIFIER_CCORE);
- } else {
- return new LocalProjectScope(project).getNode(PREFERENCES_QUALIFIER_CCORE);
- }
- }
-
- /**
- * Checks if Language Settings functionality is defined for given project in preferences.
- *
- * @param project - project to check the preference or {@code null} for workspace preference
- * @return {@code true} if functionality is defined
- *
- * @noreference This method is temporary and not intended to be referenced by clients.
- *
- * @since 5.5
- */
- public static boolean isLanguageSettingsProvidersFunctionalityDefined(IProject project) {
- Preferences pref = getPreferences(project);
- String value = pref.get(DISABLE_LSP_PREFERENCE, null);
- return value != null;
- }
-
- /**
- * Checks if Language Settings functionality is enabled for given project.
- * Note that disabling on workspace level will disable it for all projects.
- *
- * @param project - project to check the preference or {@code null} for workspace preference
- * @return {@code true} if functionality is enabled
- *
- * @noreference This method is temporary and not intended to be referenced by clients.
- */
- public static boolean isLanguageSettingsProvidersFunctionalityEnabled(IProject project) {
- boolean isEnabledInWorkspace = !getPreferences(null).getBoolean(DISABLE_LSP_PREFERENCE, DISABLE_LSP_DEFAULT_WORKSPACE);
- if (isEnabledInWorkspace && project != null) {
- return !getPreferences(project).getBoolean(DISABLE_LSP_PREFERENCE, DISABLE_LSP_DEFAULT_PROJECT);
- }
- return isEnabledInWorkspace;
- }
-
- /**
- * Enable/disable Language Settings functionality for the given project.
- *
- * @param project or {@code null} for workspace preference
- * @param value {@code true} to enable or {@code false} to disable the functionality.
- *
- * @noreference This method is temporary and not intended to be referenced by clients.
- */
- public static void setLanguageSettingsProvidersFunctionalityEnabled(IProject project, boolean value) {
- Preferences pref = getPreferences(project);
- if (value == isLanguageSettingsProvidersFunctionalityEnabled(project))
- return;
- pref.putBoolean(DISABLE_LSP_PREFERENCE, !value);
- // Scanner info provider have changed - clear the cached copy (http://bugs.eclipse.org/413357).
- CCorePlugin.getDefault().resetCachedScannerInfoProvider(project);
- try {
- pref.flush();
- } catch (BackingStoreException e) {
- CCorePlugin.log(e);
- }
- }
-
- /**
- * Check if legacy Scanner Discovery in MBS should be active.
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- */
- public static boolean isMbsLanguageSettingsProviderOn(ICConfigurationDescription cfgDescription) {
- if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
- for (ILanguageSettingsProvider lsp : lsProviders) {
- if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(lsp.getId())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Check if legacy Scanner Discovery should be active.
- * which is not intended to be referenced by clients.
- */
- private static boolean isLegacyProviderOn(ICConfigurationDescription cfgDescription) {
- if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
- for (ILanguageSettingsProvider lsp : lsProviders) {
- String id = lsp.getId();
- if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id) || SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id) || PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- */
- public static boolean isLegacyScannerDiscoveryOn(ICConfigurationDescription cfgDescription) {
- IProject project = null;
- if (cfgDescription != null) {
- ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
- if (prjDescription != null) {
- project = prjDescription.getProject();
- }
- }
- return !isLanguageSettingsProvidersFunctionalityEnabled(project) || isLegacyProviderOn(cfgDescription);
- }
-
- /**
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- */
- public static boolean isLegacyScannerDiscoveryOn(IProject project) {
- ICConfigurationDescription cfgDescription = null;
- ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project);
- if (prjDescription != null) {
- cfgDescription = prjDescription.getActiveConfiguration();
- }
- return !isLanguageSettingsProvidersFunctionalityEnabled(project) || isLegacyProviderOn(cfgDescription);
- }
-
- /**
- * Return list containing User provider and one of wrapper providers to support legacy projects (backward compatibility).
- *
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- * @since 5.5
- */
- public static String[] getDefaultProviderIdsLegacy(ICConfigurationDescription cfgDescription) {
- boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
- String legacyProviderId;
- if (useScannerInfoProviderExtension) {
- legacyProviderId = SI_LANGUAGE_SETTINGS_PROVIDER_ID;
- } else if (CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription)) {
- legacyProviderId = MBS_LANGUAGE_SETTINGS_PROVIDER_ID;
- } else {
- legacyProviderId = PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID;
- }
-
- return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, ReferencedProjectsLanguageSettingsProvider.ID, legacyProviderId};
- }
-
- /**
- * Checks if the provider is applicable for configuration from backward compatibility point of view
- *
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- * @since 5.5
- */
- public static boolean isProviderCompatible(String providerId, ICConfigurationDescription cfgDescription) {
- if (cfgDescription != null) {
- boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
- if (SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
- return useScannerInfoProviderExtension;
- }
-
- boolean isNewStyleCfg = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription);
- if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
- return !useScannerInfoProviderExtension && isNewStyleCfg;
- }
-
- if (PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
- return !useScannerInfoProviderExtension && !isNewStyleCfg;
- }
- }
-
- return true;
- }
-
- /**
- * If not defined yet, define property that controls if language settings providers functionality enabled for a given project.
- * Workspace preference is checked and the project property is set to match it.
- *
- * @param project - project to define enablement.
- * @since 5.5
- */
- public static void defineLanguageSettingsEnablement(IProject project) {
- if (project != null && ! ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
- boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null);
- ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled);
- }
- }
-
- /**
- * Returns the values of scanner discovery profiles (scannerConfigDiscoveryProfileId) which were deprecated
- * and replaced with language settings providers in plugin.xml.
- * This (temporary) function serves as fail-safe switch during the transition.
- *
- * @param id - can be id of either org.eclipse.cdt.managedbuilder.internal.core.InputType
- * or org.eclipse.cdt.managedbuilder.internal.core.ToolChain.
- * @return legacy scannerConfigDiscoveryProfileId.
- */
- @SuppressWarnings("nls")
- public static String getDeprecatedLegacyProfiles(String id) {
- if (legacyProfiles == null) {
- legacyProfiles = new HashMap<String, String>();
-
- // InputTypes
- legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
- legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
- legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC");
- legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP");
- legacyProfiles.put("cdt.managedbuild.tool.xlc.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile");
- legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile");
- legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP");
-
- // Toolchains
- }
-
- return legacyProfiles.get(id);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - initial API and implementation
+ * Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.language.settings.providers;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.internal.core.LocalProjectScope;
+import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider;
+import org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider;
+import org.eclipse.cdt.internal.core.model.PathEntryManager;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * Collection of utilities for legacy support of older Scanner Discovery functionality.
+ * This class is temporary and not intended to be used by clients.
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ *
+ * @since 5.4
+ */
+public class ScannerDiscoveryLegacySupport {
+ /** ID of User language settings provider (from org.eclipse.cdt.ui) */
+ public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$
+ /** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */
+ public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"; //$NON-NLS-1$
+
+ /**
+ * ID of ScannerInfo language settings provider wrapping ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point
+ * @since 5.5
+ */
+ public static final String SI_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$
+
+ /**
+ * ID of language settings provider wrapping {@link org.eclipse.cdt.core.resources.ScannerProvider} of {@link PathEntryManager} for 3.X projects
+ * @since 5.5
+ */
+ public static final String PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.PathEntryScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$
+
+ private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$
+ private static boolean DISABLE_LSP_DEFAULT_PROJECT = false;
+ private static boolean DISABLE_LSP_DEFAULT_WORKSPACE = false;
+ private static final String PREFERENCES_QUALIFIER_CCORE = CCorePlugin.PLUGIN_ID;
+
+ private static Map<String, String> legacyProfiles = null;
+
+ /**
+ * Get preferences node for org.eclipse.cdt.core.
+ *
+ * @param project - project to get preferences or {@code null} for workspace preferences
+ * @return
+ */
+ private static Preferences getPreferences(IProject project) {
+ if (project == null) {
+ return InstanceScope.INSTANCE.getNode(PREFERENCES_QUALIFIER_CCORE);
+ } else {
+ return new LocalProjectScope(project).getNode(PREFERENCES_QUALIFIER_CCORE);
+ }
+ }
+
+ /**
+ * Checks if Language Settings functionality is defined for given project in preferences.
+ *
+ * @param project - project to check the preference or {@code null} for workspace preference
+ * @return {@code true} if functionality is defined
+ *
+ * @noreference This method is temporary and not intended to be referenced by clients.
+ *
+ * @since 5.5
+ */
+ public static boolean isLanguageSettingsProvidersFunctionalityDefined(IProject project) {
+ Preferences pref = getPreferences(project);
+ String value = pref.get(DISABLE_LSP_PREFERENCE, null);
+ return value != null;
+ }
+
+ /**
+ * Checks if Language Settings functionality is enabled for given project.
+ * Note that disabling on workspace level will disable it for all projects.
+ *
+ * @param project - project to check the preference or {@code null} for workspace preference
+ * @return {@code true} if functionality is enabled
+ *
+ * @noreference This method is temporary and not intended to be referenced by clients.
+ */
+ public static boolean isLanguageSettingsProvidersFunctionalityEnabled(IProject project) {
+ boolean isEnabledInWorkspace = !getPreferences(null).getBoolean(DISABLE_LSP_PREFERENCE, DISABLE_LSP_DEFAULT_WORKSPACE);
+ if (isEnabledInWorkspace && project != null) {
+ return !getPreferences(project).getBoolean(DISABLE_LSP_PREFERENCE, DISABLE_LSP_DEFAULT_PROJECT);
+ }
+ return isEnabledInWorkspace;
+ }
+
+ /**
+ * Enable/disable Language Settings functionality for the given project.
+ *
+ * @param project or {@code null} for workspace preference
+ * @param value {@code true} to enable or {@code false} to disable the functionality.
+ *
+ * @noreference This method is temporary and not intended to be referenced by clients.
+ */
+ public static void setLanguageSettingsProvidersFunctionalityEnabled(IProject project, boolean value) {
+ Preferences pref = getPreferences(project);
+ if (value == isLanguageSettingsProvidersFunctionalityEnabled(project))
+ return;
+ pref.putBoolean(DISABLE_LSP_PREFERENCE, !value);
+ // Scanner info provider have changed - clear the cached copy (http://bugs.eclipse.org/413357).
+ CCorePlugin.getDefault().resetCachedScannerInfoProvider(project);
+ try {
+ pref.flush();
+ } catch (BackingStoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+
+ /**
+ * Check if legacy Scanner Discovery in MBS should be active.
+ * @noreference This is internal helper method to support compatibility with previous versions
+ * which is not intended to be referenced by clients.
+ */
+ public static boolean isMbsLanguageSettingsProviderOn(ICConfigurationDescription cfgDescription) {
+ if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
+ List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ for (ILanguageSettingsProvider lsp : lsProviders) {
+ if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(lsp.getId())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if legacy Scanner Discovery should be active.
+ * which is not intended to be referenced by clients.
+ */
+ private static boolean isLegacyProviderOn(ICConfigurationDescription cfgDescription) {
+ if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
+ List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ for (ILanguageSettingsProvider lsp : lsProviders) {
+ String id = lsp.getId();
+ if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id) || SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id) || PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @noreference This is internal helper method to support compatibility with previous versions
+ * which is not intended to be referenced by clients.
+ */
+ public static boolean isLegacyScannerDiscoveryOn(ICConfigurationDescription cfgDescription) {
+ IProject project = null;
+ if (cfgDescription != null) {
+ ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
+ if (prjDescription != null) {
+ project = prjDescription.getProject();
+ }
+ }
+ return !isLanguageSettingsProvidersFunctionalityEnabled(project) || isLegacyProviderOn(cfgDescription);
+ }
+
+ /**
+ * @noreference This is internal helper method to support compatibility with previous versions
+ * which is not intended to be referenced by clients.
+ */
+ public static boolean isLegacyScannerDiscoveryOn(IProject project) {
+ ICConfigurationDescription cfgDescription = null;
+ ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project);
+ if (prjDescription != null) {
+ cfgDescription = prjDescription.getActiveConfiguration();
+ }
+ return !isLanguageSettingsProvidersFunctionalityEnabled(project) || isLegacyProviderOn(cfgDescription);
+ }
+
+ /**
+ * Return list containing User provider and one of wrapper providers to support legacy projects (backward compatibility).
+ *
+ * @noreference This is internal helper method to support compatibility with previous versions
+ * which is not intended to be referenced by clients.
+ * @since 5.5
+ */
+ public static String[] getDefaultProviderIdsLegacy(ICConfigurationDescription cfgDescription) {
+ boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
+ String legacyProviderId;
+ if (useScannerInfoProviderExtension) {
+ legacyProviderId = SI_LANGUAGE_SETTINGS_PROVIDER_ID;
+ } else if (CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription)) {
+ legacyProviderId = MBS_LANGUAGE_SETTINGS_PROVIDER_ID;
+ } else {
+ legacyProviderId = PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID;
+ }
+
+ return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, ReferencedProjectsLanguageSettingsProvider.ID, legacyProviderId};
+ }
+
+ /**
+ * Checks if the provider is applicable for configuration from backward compatibility point of view
+ *
+ * @noreference This is internal helper method to support compatibility with previous versions
+ * which is not intended to be referenced by clients.
+ * @since 5.5
+ */
+ public static boolean isProviderCompatible(String providerId, ICConfigurationDescription cfgDescription) {
+ if (cfgDescription != null) {
+ boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
+ if (SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
+ return useScannerInfoProviderExtension;
+ }
+
+ boolean isNewStyleCfg = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription);
+ if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
+ return !useScannerInfoProviderExtension && isNewStyleCfg;
+ }
+
+ if (PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
+ return !useScannerInfoProviderExtension && !isNewStyleCfg;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * If not defined yet, define property that controls if language settings providers functionality enabled for a given project.
+ * Workspace preference is checked and the project property is set to match it.
+ *
+ * @param project - project to define enablement.
+ * @since 5.5
+ */
+ public static void defineLanguageSettingsEnablement(IProject project) {
+ if (project != null && ! ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
+ boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null);
+ ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled);
+ }
+ }
+
+ /**
+ * Returns the values of scanner discovery profiles (scannerConfigDiscoveryProfileId) which were deprecated
+ * and replaced with language settings providers in plugin.xml.
+ * This (temporary) function serves as fail-safe switch during the transition.
+ *
+ * @param id - can be id of either org.eclipse.cdt.managedbuilder.internal.core.InputType
+ * or org.eclipse.cdt.managedbuilder.internal.core.ToolChain.
+ * @return legacy scannerConfigDiscoveryProfileId.
+ */
+ @SuppressWarnings("nls")
+ public static String getDeprecatedLegacyProfiles(String id) {
+ if (legacyProfiles == null) {
+ legacyProfiles = new HashMap<String, String>();
+
+ // InputTypes
+ legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
+ legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
+ legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC");
+ legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP");
+ legacyProfiles.put("cdt.managedbuild.tool.xlc.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile");
+ legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile");
+ legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP");
+
+ // Toolchains
+ }
+
+ return legacyProfiles.get(id);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java
index 1cb99ec7ee5..be3ed312b7b 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java
@@ -1,437 +1,437 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2014 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
- * Markus Schorn (Wind River Systems)
- * Anton Leherbauer (Wind River Systems)
+/*******************************************************************************
+ * Copyright (c) 2000, 2014 QNX Software Systems 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:
+ * QNX Software Systems - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ * Anton Leherbauer (Wind River Systems)
*******************************************************************************/
-package org.eclipse.cdt.core.model;
-
-import java.net.URI;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Common protocol for all elements provided by the C model.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICElement extends IAdaptable {
- /** @since 5.6 */
- public static final ICElement[] EMPTY_ARRAY = {};
-
- /**
- * IResource from 10-20
- */
-
- /**
- * Constant representing a C Root workspace (IWorkspaceRoot object).
- * A C element with this type can be safely cast to <code>ICModel</code>.
- */
- static final int C_MODEL = 10;
-
- /**
- * Constant representing a C project (IProject object).
- * A C element with this type can be safely cast to <code>ICProject</code>.
- */
- static final int C_PROJECT = 11;
-
- /**
- * Constant representing a folder (ICContainer object).
- * A C element with this type can be safely cast to <code>ICContainer</code>.
- */
- static final int C_CCONTAINER = 12;
-
- static final int C_BINARY = 14;
-
- static final int C_ARCHIVE = 18;
- /**
- * Virtual container serving as a place holder.
- */
- static final int C_VCONTAINER = 30;
-
- /**
- * Constant representing a C/C++ children of a Translation Unit
- */
- static final int C_UNIT = 60;
-
- /**
- * Namespace.
- */
- static final int C_NAMESPACE = 61;
-
- /**
- * Using.
- */
- static final int C_USING = 62;
-
- /**
- * Enumeration.
- */
- static final int C_ENUMERATION = 63;
-
- /**
- * Declaration of a class without the definition.
- * class C;
- */
- static final int C_CLASS_DECLARATION = 64;
-
- /**
- * Constant representing a class structure.
- */
- static final int C_CLASS = 65;
-
- /**
- * Declaration of a structure without the definition.
- * struct C;
- */
- static final int C_STRUCT_DECLARATION = 66;
-
- /**
- * Constant representing a struct structure.
- */
- static final int C_STRUCT = 67;
-
- /**
- * Declaration of a union without the definition.
- * struct C;
- */
- static final int C_UNION_DECLARATION = 68;
-
- /**
- * Constant representing a union structure.
- */
- static final int C_UNION = 69;
-
- /**
- * A method definition part of a structure(class, struct, union).
- */
- static final int C_METHOD = 70;
-
- /**
- * A method declaration part of a structure(class, struct, union).
- */
- static final int C_METHOD_DECLARATION = 71;
-
- /**
- * A Field definition part of a structure(class, struct, union).
- */
- static final int C_FIELD = 72;
-
- /**
- * a C/C++ function prototype.
- */
- static final int C_FUNCTION_DECLARATION = 73;
-
- /**
- * a C/C++ function definition.
- */
- static final int C_FUNCTION = 74;
-
- /**
- * Preprocessor #include directive.
- */
- static final int C_INCLUDE = 75;
-
- /**
- * Global variable.
- */
- static final int C_VARIABLE = 76;
-
- /**
- * variable Declaration.
- */
- static final int C_VARIABLE_DECLARATION = 77;
-
- /**
- * Local Variable.
- */
- static final int C_VARIABLE_LOCAL = 78;
-
- /**
- * A preprocessor macro.
- */
- static final int C_MACRO = 79;
-
- /**
- * a Typedef.
- */
- static final int C_TYPEDEF = 80;
-
- /**
- * Enumerator.
- */
- static final int C_ENUMERATOR = 81;
-
- /**
- * C++ template class declaration without a definition.
- */
- static final int C_TEMPLATE_CLASS_DECLARATION = 82;
-
- /**
- * C++ template class with definition.
- */
- static final int C_TEMPLATE_CLASS = 83;
-
- /**
- * C++ template struct.
- */
- static final int C_TEMPLATE_STRUCT_DECLARATION = 84;
-
- /**
- * C++ template struct.
- */
- static final int C_TEMPLATE_STRUCT = 85;
-
- /**
- * C++ template union.
- */
- static final int C_TEMPLATE_UNION_DECLARATION = 86;
-
- /**
- * C++ template union.
- */
- static final int C_TEMPLATE_UNION = 87;
-
- /**
- * C++ template function declaration.
- */
- static final int C_TEMPLATE_FUNCTION_DECLARATION = 88;
-
- /**
- * C++ template function.
- */
- static final int C_TEMPLATE_FUNCTION = 89;
-
- /**
- * C++ template method.
- */
- static final int C_TEMPLATE_METHOD_DECLARATION = 90;
-
- /**
- * C++ template method.
- */
- static final int C_TEMPLATE_METHOD = 91;
-
- /**
- * C++ template variable.
- */
- static final int C_TEMPLATE_VARIABLE = 92;
-
- /**
- * An unknown ICElement. Mainly used to determine what elements are not yet implemented.
- * i.e. the new DOM Parser supports open declaration on labels, while the old parser did not
- */
- static final int C_UNKNOWN_DECLARATION = 93;
-
- /**
- * Assembly label.
- *
- * @since 5.0
- */
- static final int ASM_LABEL= 94;
-
- /**
- * @deprecated use {@link IMethodDeclaration#isConstructor()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int C_CLASS_CTOR = 0x100;
-
- /**
- * @deprecated use {@link IMethodDeclaration#isDestructor()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int C_CLASS_DTOR = 0x200;
-
- /**
- * @deprecated use {@link IDeclaration#isStatic()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int C_STORAGE_STATIC = 0x400;
-
- /**
- * @deprecated not used anymore
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int C_STORAGE_EXTERN = 0x800;
-
- /**
- * @deprecated use {@link IMember#getVisibility()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int CPP_PRIVATE = 0x1000;
-
- /**
- * @deprecated use {@link IMember#getVisibility()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int CPP_PUBLIC = 0x2000;
-
- /**
- * @deprecated use {@link IMember#getVisibility()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int CPP_PROTECTED = 0x4000;
- /**
- * @deprecated use {@link IMethodDeclaration#isFriend()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int CPP_FRIEND = 0x8000;
-
- /**
- * Returns whether this C element exists in the model.
- *
- * @return {@code true} if this element exists in the C model
- */
- boolean exists();
-
- /**
- * Returns the first ancestor of this C element that has the given type.
- * Returns {@code null} if no such an ancestor can be found.
- * This is a handle-only method.
- *
- * @param ancestorType the given type
- * @return the first ancestor of this C element that has the given type, {@code null} if no such
- * an ancestor can be found
- * @since 2.0
- */
- ICElement getAncestor(int ancestorType);
-
- /**
- * Returns the name of this element.
- *
- * @return the element name
- */
- String getElementName();
-
- /**
- * Returns this element's kind encoded as an integer.
- * This is a handle-only method.
- *
- * @return the kind of element; one of the constants declared in {@link ICElement}
- */
- int getElementType();
-
- /**
- * Returns the C model.
- *
- * @return the C model
- */
- ICModel getCModel();
-
- /**
- * Returns the C project this element is contained in, or {@code null} if this element
- * is not contained in any C project
- *
- * @return the containing C project, or {@code null} if this element is
- * not contained in a C project
- */
- ICProject getCProject();
-
- /**
- * Returns the element directly containing this element,
- * or {@code null} if this element has no parent.
- *
- * @return the parent element, or {@code null} if this element has no parent
- */
- ICElement getParent();
-
- /**
- * Returns the path to the innermost resource enclosing this element.
- * If this element is not included in an external archive,
- * the path returned is the full, absolute path to the underlying resource,
- * relative to the workbench.
- * If this element is included in an external archive,
- * the path returned is the absolute path to the archive in the file system.
- * This is a handle-only method.
- */
- IPath getPath();
-
- /**
- * Returns an absolute URI corresponding to the innermost file enclosing this element.
- *
- * @since 5.0
- * @return the URI corresponding to the location
- */
- URI getLocationURI();
-
- /**
- * Returns the underlying resource that contains this element, or {@code null} if this element
- * is not contained in a resource.
- *
- * @return the underlying resource, or {@code null} if none
- */
- IResource getUnderlyingResource();
-
- /**
- * Returns the corresponding resource for this element, or {@code null} if this element
- * does not have a corresponding resource.
- *
- * @return the corresponding resource, or {@code null} if none
- */
- IResource getResource();
-
- /**
- * Returns whether this C element is read-only. An element is read-only
- * if its structure cannot be modified by the C model.
- *
- * @return {@code true} if this element is read-only
- */
- boolean isReadOnly();
-
- /**
- * Returns whether the structure of this element is known. For example, for a
- * translation unit that could not be parsed, {@code false} is returned.
- * If the structure of an element is unknown, navigations will return reasonable
- * defaults. For example, {@code getChildren} will return an empty collection.
- * <p>
- * Note: This does not imply anything about consistency with the
- * underlying resource/buffer contents.
- *
- * @return {@code true} if the structure of this element is known
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource
- */
- boolean isStructureKnown() throws CModelException;
-
- /**
- * Accept a visitor and walk the ICElement tree with it.
- *
- * @param visitor
- * @throws CModelException
- */
- void accept(ICElementVisitor visitor) throws CoreException;
-
- /**
- * Returns a string representation of this element handle. The format of the
- * string is not specified; however, the identifier is stable across
- * workspace sessions, and can be used to recreate this handle via the
- * <code>CoreModel.create(String)</code> method.
- * <p>
- * Some element types, like binaries, do not support handle identifiers and
- * return {@code null}.
- *
- * @return the string handle identifier, or {@code null} if the element type is not supported
- * @see CoreModel#create(java.lang.String)
- *
- * @since 5.0
- */
- String getHandleIdentifier();
-}
+package org.eclipse.cdt.core.model;
+
+import java.net.URI;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Common protocol for all elements provided by the C model.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ICElement extends IAdaptable {
+ /** @since 5.6 */
+ public static final ICElement[] EMPTY_ARRAY = {};
+
+ /**
+ * IResource from 10-20
+ */
+
+ /**
+ * Constant representing a C Root workspace (IWorkspaceRoot object).
+ * A C element with this type can be safely cast to <code>ICModel</code>.
+ */
+ static final int C_MODEL = 10;
+
+ /**
+ * Constant representing a C project (IProject object).
+ * A C element with this type can be safely cast to <code>ICProject</code>.
+ */
+ static final int C_PROJECT = 11;
+
+ /**
+ * Constant representing a folder (ICContainer object).
+ * A C element with this type can be safely cast to <code>ICContainer</code>.
+ */
+ static final int C_CCONTAINER = 12;
+
+ static final int C_BINARY = 14;
+
+ static final int C_ARCHIVE = 18;
+ /**
+ * Virtual container serving as a place holder.
+ */
+ static final int C_VCONTAINER = 30;
+
+ /**
+ * Constant representing a C/C++ children of a Translation Unit
+ */
+ static final int C_UNIT = 60;
+
+ /**
+ * Namespace.
+ */
+ static final int C_NAMESPACE = 61;
+
+ /**
+ * Using.
+ */
+ static final int C_USING = 62;
+
+ /**
+ * Enumeration.
+ */
+ static final int C_ENUMERATION = 63;
+
+ /**
+ * Declaration of a class without the definition.
+ * class C;
+ */
+ static final int C_CLASS_DECLARATION = 64;
+
+ /**
+ * Constant representing a class structure.
+ */
+ static final int C_CLASS = 65;
+
+ /**
+ * Declaration of a structure without the definition.
+ * struct C;
+ */
+ static final int C_STRUCT_DECLARATION = 66;
+
+ /**
+ * Constant representing a struct structure.
+ */
+ static final int C_STRUCT = 67;
+
+ /**
+ * Declaration of a union without the definition.
+ * struct C;
+ */
+ static final int C_UNION_DECLARATION = 68;
+
+ /**
+ * Constant representing a union structure.
+ */
+ static final int C_UNION = 69;
+
+ /**
+ * A method definition part of a structure(class, struct, union).
+ */
+ static final int C_METHOD = 70;
+
+ /**
+ * A method declaration part of a structure(class, struct, union).
+ */
+ static final int C_METHOD_DECLARATION = 71;
+
+ /**
+ * A Field definition part of a structure(class, struct, union).
+ */
+ static final int C_FIELD = 72;
+
+ /**
+ * a C/C++ function prototype.
+ */
+ static final int C_FUNCTION_DECLARATION = 73;
+
+ /**
+ * a C/C++ function definition.
+ */
+ static final int C_FUNCTION = 74;
+
+ /**
+ * Preprocessor #include directive.
+ */
+ static final int C_INCLUDE = 75;
+
+ /**
+ * Global variable.
+ */
+ static final int C_VARIABLE = 76;
+
+ /**
+ * variable Declaration.
+ */
+ static final int C_VARIABLE_DECLARATION = 77;
+
+ /**
+ * Local Variable.
+ */
+ static final int C_VARIABLE_LOCAL = 78;
+
+ /**
+ * A preprocessor macro.
+ */
+ static final int C_MACRO = 79;
+
+ /**
+ * a Typedef.
+ */
+ static final int C_TYPEDEF = 80;
+
+ /**
+ * Enumerator.
+ */
+ static final int C_ENUMERATOR = 81;
+
+ /**
+ * C++ template class declaration without a definition.
+ */
+ static final int C_TEMPLATE_CLASS_DECLARATION = 82;
+
+ /**
+ * C++ template class with definition.
+ */
+ static final int C_TEMPLATE_CLASS = 83;
+
+ /**
+ * C++ template struct.
+ */
+ static final int C_TEMPLATE_STRUCT_DECLARATION = 84;
+
+ /**
+ * C++ template struct.
+ */
+ static final int C_TEMPLATE_STRUCT = 85;
+
+ /**
+ * C++ template union.
+ */
+ static final int C_TEMPLATE_UNION_DECLARATION = 86;
+
+ /**
+ * C++ template union.
+ */
+ static final int C_TEMPLATE_UNION = 87;
+
+ /**
+ * C++ template function declaration.
+ */
+ static final int C_TEMPLATE_FUNCTION_DECLARATION = 88;
+
+ /**
+ * C++ template function.
+ */
+ static final int C_TEMPLATE_FUNCTION = 89;
+
+ /**
+ * C++ template method.
+ */
+ static final int C_TEMPLATE_METHOD_DECLARATION = 90;
+
+ /**
+ * C++ template method.
+ */
+ static final int C_TEMPLATE_METHOD = 91;
+
+ /**
+ * C++ template variable.
+ */
+ static final int C_TEMPLATE_VARIABLE = 92;
+
+ /**
+ * An unknown ICElement. Mainly used to determine what elements are not yet implemented.
+ * i.e. the new DOM Parser supports open declaration on labels, while the old parser did not
+ */
+ static final int C_UNKNOWN_DECLARATION = 93;
+
+ /**
+ * Assembly label.
+ *
+ * @since 5.0
+ */
+ static final int ASM_LABEL= 94;
+
+ /**
+ * @deprecated use {@link IMethodDeclaration#isConstructor()}
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ @Deprecated
+ static final int C_CLASS_CTOR = 0x100;
+
+ /**
+ * @deprecated use {@link IMethodDeclaration#isDestructor()}
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ @Deprecated
+ static final int C_CLASS_DTOR = 0x200;
+
+ /**
+ * @deprecated use {@link IDeclaration#isStatic()}
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ @Deprecated
+ static final int C_STORAGE_STATIC = 0x400;
+
+ /**
+ * @deprecated not used anymore
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ @Deprecated
+ static final int C_STORAGE_EXTERN = 0x800;
+
+ /**
+ * @deprecated use {@link IMember#getVisibility()}
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ @Deprecated
+ static final int CPP_PRIVATE = 0x1000;
+
+ /**
+ * @deprecated use {@link IMember#getVisibility()}
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ @Deprecated
+ static final int CPP_PUBLIC = 0x2000;
+
+ /**
+ * @deprecated use {@link IMember#getVisibility()}
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ @Deprecated
+ static final int CPP_PROTECTED = 0x4000;
+ /**
+ * @deprecated use {@link IMethodDeclaration#isFriend()}
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ @Deprecated
+ static final int CPP_FRIEND = 0x8000;
+
+ /**
+ * Returns whether this C element exists in the model.
+ *
+ * @return {@code true} if this element exists in the C model
+ */
+ boolean exists();
+
+ /**
+ * Returns the first ancestor of this C element that has the given type.
+ * Returns {@code null} if no such an ancestor can be found.
+ * This is a handle-only method.
+ *
+ * @param ancestorType the given type
+ * @return the first ancestor of this C element that has the given type, {@code null} if no such
+ * an ancestor can be found
+ * @since 2.0
+ */
+ ICElement getAncestor(int ancestorType);
+
+ /**
+ * Returns the name of this element.
+ *
+ * @return the element name
+ */
+ String getElementName();
+
+ /**
+ * Returns this element's kind encoded as an integer.
+ * This is a handle-only method.
+ *
+ * @return the kind of element; one of the constants declared in {@link ICElement}
+ */
+ int getElementType();
+
+ /**
+ * Returns the C model.
+ *
+ * @return the C model
+ */
+ ICModel getCModel();
+
+ /**
+ * Returns the C project this element is contained in, or {@code null} if this element
+ * is not contained in any C project
+ *
+ * @return the containing C project, or {@code null} if this element is
+ * not contained in a C project
+ */
+ ICProject getCProject();
+
+ /**
+ * Returns the element directly containing this element,
+ * or {@code null} if this element has no parent.
+ *
+ * @return the parent element, or {@code null} if this element has no parent
+ */
+ ICElement getParent();
+
+ /**
+ * Returns the path to the innermost resource enclosing this element.
+ * If this element is not included in an external archive,
+ * the path returned is the full, absolute path to the underlying resource,
+ * relative to the workbench.
+ * If this element is included in an external archive,
+ * the path returned is the absolute path to the archive in the file system.
+ * This is a handle-only method.
+ */
+ IPath getPath();
+
+ /**
+ * Returns an absolute URI corresponding to the innermost file enclosing this element.
+ *
+ * @since 5.0
+ * @return the URI corresponding to the location
+ */
+ URI getLocationURI();
+
+ /**
+ * Returns the underlying resource that contains this element, or {@code null} if this element
+ * is not contained in a resource.
+ *
+ * @return the underlying resource, or {@code null} if none
+ */
+ IResource getUnderlyingResource();
+
+ /**
+ * Returns the corresponding resource for this element, or {@code null} if this element
+ * does not have a corresponding resource.
+ *
+ * @return the corresponding resource, or {@code null} if none
+ */
+ IResource getResource();
+
+ /**
+ * Returns whether this C element is read-only. An element is read-only
+ * if its structure cannot be modified by the C model.
+ *
+ * @return {@code true} if this element is read-only
+ */
+ boolean isReadOnly();
+
+ /**
+ * Returns whether the structure of this element is known. For example, for a
+ * translation unit that could not be parsed, {@code false} is returned.
+ * If the structure of an element is unknown, navigations will return reasonable
+ * defaults. For example, {@code getChildren} will return an empty collection.
+ * <p>
+ * Note: This does not imply anything about consistency with the
+ * underlying resource/buffer contents.
+ *
+ * @return {@code true} if the structure of this element is known
+ * @exception CModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+ boolean isStructureKnown() throws CModelException;
+
+ /**
+ * Accept a visitor and walk the ICElement tree with it.
+ *
+ * @param visitor
+ * @throws CModelException
+ */
+ void accept(ICElementVisitor visitor) throws CoreException;
+
+ /**
+ * Returns a string representation of this element handle. The format of the
+ * string is not specified; however, the identifier is stable across
+ * workspace sessions, and can be used to recreate this handle via the
+ * <code>CoreModel.create(String)</code> method.
+ * <p>
+ * Some element types, like binaries, do not support handle identifiers and
+ * return {@code null}.
+ *
+ * @return the string handle identifier, or {@code null} if the element type is not supported
+ * @see CoreModel#create(java.lang.String)
+ *
+ * @since 5.0
+ */
+ String getHandleIdentifier();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java
index 74fef6b7267..298098dd9e0 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java
@@ -1,15 +1,15 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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
*******************************************************************************/
-package org.eclipse.cdt.core.settings.model;
-
-public interface ICFileDescription extends ICResourceDescription {
- ICLanguageSetting getLanguageSetting();
-}
+package org.eclipse.cdt.core.settings.model;
+
+public interface ICFileDescription extends ICResourceDescription {
+ ICLanguageSetting getLanguageSetting();
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java
index 5aef3614481..282be48054b 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java
@@ -1,116 +1,116 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-
-
-/**
- * Contains the delta of changes that occurred as a result of modifying
- * language settings entries {@link ICLanguageSettingEntry}. The delta is
- * associated with a configuration description.
- *
- * <p>
- * <strong>EXPERIMENTAL</strong>. This class interface is not stable yet as
- * it is not currently clear how it may need to be used in future. Only bare
- * minimum is provided here at this point (CDT 8.1, Juno).
- * There is no guarantee that this API will work or that it will remain the same.
- * Please do not use this API without consulting with the CDT team.
- * </p>
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public class LanguageSettingsDelta {
- // maps are ordered by providers
- private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> oldLanguageSettingsState;
- private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> newLanguageSettingsState;
-
- private Set<String> paths = null;
-
- /**
- * Constructor.
- *
- * @param oldState - old language settings storage state.
- * @param newState - new language settings storage state.
- */
- public LanguageSettingsDelta(LinkedHashMap<String, LanguageSettingsStorage> oldState, LinkedHashMap<String, LanguageSettingsStorage> newState) {
- oldLanguageSettingsState = oldState;
- newLanguageSettingsState = newState;
- }
-
- /**
- * @return resource paths affected by changes represented by this delta.
- */
- public Set<String> getAffectedResourcePaths() {
- if (paths != null) {
- return paths;
- }
-
- paths = new TreeSet<String>();
-
- LanguageSettingsStorage oldCombinedStorage = combineStorage(oldLanguageSettingsState);
- LanguageSettingsStorage newCombinedStorage = combineStorage(newLanguageSettingsState);
-
- for (String lang : oldCombinedStorage.getLanguages()) {
- for (String path : oldCombinedStorage.getResourcePaths(lang)) {
- if (oldCombinedStorage.getSettingEntries(path, lang) != newCombinedStorage.getSettingEntries(path, lang)) {
- if (path == null) {
- // add path of the project
- path = ""; //$NON-NLS-1$
- }
- paths.add(path);
- }
- }
- }
-
- for (String lang : newCombinedStorage.getLanguages()) {
- for (String path : newCombinedStorage.getResourcePaths(lang)) {
- if (newCombinedStorage.getSettingEntries(path, lang) != oldCombinedStorage.getSettingEntries(path, lang)) {
- if (path == null) {
- // add path of the project
- path = ""; //$NON-NLS-1$
- }
- paths.add(path);
- }
- }
- }
-
- return paths;
- }
-
- /**
- * Language settings entries from different providers can overlap. This method resolves all overlapping
- * ones combining entries into one aggregate storage.
- */
- private LanguageSettingsStorage combineStorage(LinkedHashMap<String, LanguageSettingsStorage> state) {
- LanguageSettingsStorage combinedStore = new LanguageSettingsStorage();
- for (LanguageSettingsStorage providerStore : state.values()) {
- for (String lang : providerStore.getLanguages()) {
- for (String path : providerStore.getResourcePaths(lang)) {
- // provider (store) higher on the list overrides others below
- if (combinedStore.getSettingEntries(path, lang) == null) {
- List<ICLanguageSettingEntry> entries = providerStore.getSettingEntries(path, lang);
- combinedStore.setSettingEntries(path, lang, entries);
- }
- }
- }
- }
-
- return combinedStore;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.language.settings.providers;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+
+/**
+ * Contains the delta of changes that occurred as a result of modifying
+ * language settings entries {@link ICLanguageSettingEntry}. The delta is
+ * associated with a configuration description.
+ *
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class interface is not stable yet as
+ * it is not currently clear how it may need to be used in future. Only bare
+ * minimum is provided here at this point (CDT 8.1, Juno).
+ * There is no guarantee that this API will work or that it will remain the same.
+ * Please do not use this API without consulting with the CDT team.
+ * </p>
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class LanguageSettingsDelta {
+ // maps are ordered by providers
+ private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> oldLanguageSettingsState;
+ private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> newLanguageSettingsState;
+
+ private Set<String> paths = null;
+
+ /**
+ * Constructor.
+ *
+ * @param oldState - old language settings storage state.
+ * @param newState - new language settings storage state.
+ */
+ public LanguageSettingsDelta(LinkedHashMap<String, LanguageSettingsStorage> oldState, LinkedHashMap<String, LanguageSettingsStorage> newState) {
+ oldLanguageSettingsState = oldState;
+ newLanguageSettingsState = newState;
+ }
+
+ /**
+ * @return resource paths affected by changes represented by this delta.
+ */
+ public Set<String> getAffectedResourcePaths() {
+ if (paths != null) {
+ return paths;
+ }
+
+ paths = new TreeSet<String>();
+
+ LanguageSettingsStorage oldCombinedStorage = combineStorage(oldLanguageSettingsState);
+ LanguageSettingsStorage newCombinedStorage = combineStorage(newLanguageSettingsState);
+
+ for (String lang : oldCombinedStorage.getLanguages()) {
+ for (String path : oldCombinedStorage.getResourcePaths(lang)) {
+ if (oldCombinedStorage.getSettingEntries(path, lang) != newCombinedStorage.getSettingEntries(path, lang)) {
+ if (path == null) {
+ // add path of the project
+ path = ""; //$NON-NLS-1$
+ }
+ paths.add(path);
+ }
+ }
+ }
+
+ for (String lang : newCombinedStorage.getLanguages()) {
+ for (String path : newCombinedStorage.getResourcePaths(lang)) {
+ if (newCombinedStorage.getSettingEntries(path, lang) != oldCombinedStorage.getSettingEntries(path, lang)) {
+ if (path == null) {
+ // add path of the project
+ path = ""; //$NON-NLS-1$
+ }
+ paths.add(path);
+ }
+ }
+ }
+
+ return paths;
+ }
+
+ /**
+ * Language settings entries from different providers can overlap. This method resolves all overlapping
+ * ones combining entries into one aggregate storage.
+ */
+ private LanguageSettingsStorage combineStorage(LinkedHashMap<String, LanguageSettingsStorage> state) {
+ LanguageSettingsStorage combinedStore = new LanguageSettingsStorage();
+ for (LanguageSettingsStorage providerStore : state.values()) {
+ for (String lang : providerStore.getLanguages()) {
+ for (String path : providerStore.getResourcePaths(lang)) {
+ // provider (store) higher on the list overrides others below
+ if (combinedStore.getSettingEntries(path, lang) == null) {
+ List<ICLanguageSettingEntry> entries = providerStore.getSettingEntries(path, lang);
+ combinedStore.setSettingEntries(path, lang, entries);
+ }
+ }
+ }
+ }
+
+ return combinedStore;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsSerializableStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsSerializableStorage.java
index 5e5cbeea774..a74154de47a 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsSerializableStorage.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsSerializableStorage.java
@@ -1,228 +1,228 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - initial API and implementation
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
-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.core.settings.model.util.LanguageSettingEntriesSerializer;
-import org.eclipse.cdt.internal.core.XmlUtil;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * The class representing persistent storage for language settings entries {@link ICLanguageSettingEntry}.
- */
-public class LanguageSettingsSerializableStorage extends LanguageSettingsStorage {
- private static final String ELEM_LANGUAGE = "language"; //$NON-NLS-1$
- private static final String ATTR_LANGUAGE_ID = "id"; //$NON-NLS-1$
- private static final String ELEM_RESOURCE = "resource"; //$NON-NLS-1$
- private static final String ATTR_PROJECT_PATH = "project-relative-path"; //$NON-NLS-1$
-
- private static final String ELEM_ENTRY = LanguageSettingsExtensionManager.ELEM_ENTRY;
- private static final String ATTR_ENTRY_KIND = LanguageSettingsExtensionManager.ATTR_ENTRY_KIND;
- private static final String ATTR_ENTRY_NAME = LanguageSettingsExtensionManager.ATTR_ENTRY_NAME;
- private static final String ATTR_ENTRY_VALUE = LanguageSettingsExtensionManager.ATTR_ENTRY_VALUE;
- private static final String ELEM_ENTRY_FLAG = LanguageSettingsExtensionManager.ELEM_ENTRY_FLAG;
-
- /**
- * Serialize the provider entries under parent XML element.
- *
- * @param elementProvider - element where to serialize the entries.
- */
- public void serializeEntries(Element elementProvider) {
- synchronized (fStorage) {
- for (Entry<String, Map<String, List<ICLanguageSettingEntry>>> entryLang : fStorage.entrySet()) {
- serializeLanguage(elementProvider, entryLang.getKey(), entryLang.getValue());
- }
- }
- }
-
- /**
- * Serialize the provider entries for a given language list.
- */
- private void serializeLanguage(Element parentElement, String langId, Map<String, List<ICLanguageSettingEntry>> langMap) {
- if (langId!=null) {
- Element elementLanguage = XmlUtil.appendElement(parentElement, ELEM_LANGUAGE, new String[] {ATTR_LANGUAGE_ID, langId});
- parentElement = elementLanguage;
- }
- for (Entry<String, List<ICLanguageSettingEntry>> entryRc : langMap.entrySet()) {
- serializeResource(parentElement, entryRc.getKey(), entryRc.getValue());
- }
- }
-
- /**
- * Serialize the provider entries for a given resource list.
- */
- private void serializeResource(Element parentElement, String rcProjectPath, List<ICLanguageSettingEntry> rcList) {
- if (rcProjectPath!=null) {
- Element elementRc = XmlUtil.appendElement(parentElement, ELEM_RESOURCE, new String[] {ATTR_PROJECT_PATH, rcProjectPath});
- parentElement = elementRc;
- }
- serializeSettingEntries(parentElement, rcList);
- }
-
- /**
- * Serialize given settings entries.
- */
- private void serializeSettingEntries(Element parentElement, List<ICLanguageSettingEntry> settingEntries) {
- for (ICLanguageSettingEntry entry : settingEntries) {
- Element elementSettingEntry = XmlUtil.appendElement(parentElement, ELEM_ENTRY, new String[] {
- ATTR_ENTRY_KIND, LanguageSettingEntriesSerializer.kindToString(entry.getKind()),
- ATTR_ENTRY_NAME, entry.getName(),
- });
- switch (entry.getKind()) {
- case ICSettingEntry.MACRO:
- elementSettingEntry.setAttribute(ATTR_ENTRY_VALUE, entry.getValue());
- break;
-// case ICLanguageSettingEntry.LIBRARY_FILE:
-// // YAGNI: sourceAttachment fields may need to be covered
-// break;
- }
- int flags = entry.getFlags();
- if (flags != 0) {
- // Element elementFlag =
- XmlUtil.appendElement(elementSettingEntry, ELEM_ENTRY_FLAG, new String[] {
- ATTR_ENTRY_VALUE, LanguageSettingEntriesSerializer.composeFlagsString(entry.getFlags())
- });
- }
- }
- }
-
- /**
- * Load provider entries from XML provider element.
- *
- * @param providerNode - parent XML element "provider" where entries are defined.
- */
- public void loadEntries(Element providerNode) {
- List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>();
- NodeList nodes = providerNode.getChildNodes();
- for (int i=0;i<nodes.getLength();i++) {
- Node elementNode = nodes.item(i);
- if (elementNode.getNodeType() != Node.ELEMENT_NODE)
- continue;
-
- if (ELEM_LANGUAGE.equals(elementNode.getNodeName())) {
- loadLanguageElement(elementNode, null);
- } else if (ELEM_RESOURCE.equals(elementNode.getNodeName())) {
- loadResourceElement(elementNode, null, null);
- } else if (ELEM_ENTRY.equals(elementNode.getNodeName())) {
- ICLanguageSettingEntry entry = loadSettingEntry(elementNode);
- if (entry!=null) {
- settings.add(entry);
- }
- }
- }
- // set settings
- if (settings.size() > 0) {
- setSettingEntries(null, null, settings);
- }
- }
-
- /**
- * Load a setting entry from XML element.
- */
- private ICLanguageSettingEntry loadSettingEntry(Node parentElement) {
- String settingKind = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_KIND);
- String settingName = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_NAME);
-
- NodeList flagNodes = parentElement.getChildNodes();
- int flags = 0;
- for (int i=0;i<flagNodes.getLength();i++) {
- Node flagNode = flagNodes.item(i);
- if (flagNode.getNodeType() != Node.ELEMENT_NODE || !ELEM_ENTRY_FLAG.equals(flagNode.getNodeName()))
- continue;
-
- String settingFlags = XmlUtil.determineAttributeValue(flagNode, ATTR_ENTRY_VALUE);
- int bitFlag = LanguageSettingEntriesSerializer.composeFlags(settingFlags);
- flags |= bitFlag;
-
- }
-
- String settingValue = null;
- int kind = LanguageSettingEntriesSerializer.stringToKind(settingKind);
- if (kind == ICSettingEntry.MACRO)
- settingValue = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_VALUE);
- ICLanguageSettingEntry entry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, settingName, settingValue, null, flags);
- return entry;
- }
-
- /**
- * Load entries defined in language element.
- */
- private void loadLanguageElement(Node parentNode, String cfgId) {
- String langId = XmlUtil.determineAttributeValue(parentNode, ATTR_LANGUAGE_ID);
- if (langId.length() == 0) {
- langId=null;
- }
-
- List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>();
- NodeList nodes = parentNode.getChildNodes();
- for (int i=0;i<nodes.getLength();i++) {
- Node elementNode = nodes.item(i);
- if (elementNode.getNodeType() != Node.ELEMENT_NODE)
- continue;
-
- if (ELEM_RESOURCE.equals(elementNode.getNodeName())) {
- loadResourceElement(elementNode, cfgId, langId);
- } else if (ELEM_ENTRY.equals(elementNode.getNodeName())) {
- ICLanguageSettingEntry entry = loadSettingEntry(elementNode);
- if (entry!=null) {
- settings.add(entry);
- }
- }
- }
- // set settings
- if (settings.size() > 0) {
- setSettingEntries(null, langId, settings);
- }
- }
-
- /**
- * Load entries defined in resource element.
- */
- private void loadResourceElement(Node parentNode, String cfgId, String langId) {
- String rcProjectPath = XmlUtil.determineAttributeValue(parentNode, ATTR_PROJECT_PATH);
-
- List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>();
- NodeList nodes = parentNode.getChildNodes();
- for (int i=0;i<nodes.getLength();i++) {
- Node elementNode = nodes.item(i);
- if (elementNode.getNodeType() != Node.ELEMENT_NODE)
- continue;
-
- if (ELEM_ENTRY.equals(elementNode.getNodeName())) {
- ICLanguageSettingEntry entry = loadSettingEntry(elementNode);
- if (entry!=null) {
- settings.add(entry);
- }
- }
- }
-
- // set settings
- if (settings.size() > 0) {
- setSettingEntries(rcProjectPath, langId, settings);
- }
- }
-
- @Override
- public LanguageSettingsSerializableStorage clone() throws CloneNotSupportedException {
- return (LanguageSettingsSerializableStorage) super.clone();
- }
-
-}
+package org.eclipse.cdt.internal.core.language.settings.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
+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.core.settings.model.util.LanguageSettingEntriesSerializer;
+import org.eclipse.cdt.internal.core.XmlUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * The class representing persistent storage for language settings entries {@link ICLanguageSettingEntry}.
+ */
+public class LanguageSettingsSerializableStorage extends LanguageSettingsStorage {
+ private static final String ELEM_LANGUAGE = "language"; //$NON-NLS-1$
+ private static final String ATTR_LANGUAGE_ID = "id"; //$NON-NLS-1$
+ private static final String ELEM_RESOURCE = "resource"; //$NON-NLS-1$
+ private static final String ATTR_PROJECT_PATH = "project-relative-path"; //$NON-NLS-1$
+
+ private static final String ELEM_ENTRY = LanguageSettingsExtensionManager.ELEM_ENTRY;
+ private static final String ATTR_ENTRY_KIND = LanguageSettingsExtensionManager.ATTR_ENTRY_KIND;
+ private static final String ATTR_ENTRY_NAME = LanguageSettingsExtensionManager.ATTR_ENTRY_NAME;
+ private static final String ATTR_ENTRY_VALUE = LanguageSettingsExtensionManager.ATTR_ENTRY_VALUE;
+ private static final String ELEM_ENTRY_FLAG = LanguageSettingsExtensionManager.ELEM_ENTRY_FLAG;
+
+ /**
+ * Serialize the provider entries under parent XML element.
+ *
+ * @param elementProvider - element where to serialize the entries.
+ */
+ public void serializeEntries(Element elementProvider) {
+ synchronized (fStorage) {
+ for (Entry<String, Map<String, List<ICLanguageSettingEntry>>> entryLang : fStorage.entrySet()) {
+ serializeLanguage(elementProvider, entryLang.getKey(), entryLang.getValue());
+ }
+ }
+ }
+
+ /**
+ * Serialize the provider entries for a given language list.
+ */
+ private void serializeLanguage(Element parentElement, String langId, Map<String, List<ICLanguageSettingEntry>> langMap) {
+ if (langId!=null) {
+ Element elementLanguage = XmlUtil.appendElement(parentElement, ELEM_LANGUAGE, new String[] {ATTR_LANGUAGE_ID, langId});
+ parentElement = elementLanguage;
+ }
+ for (Entry<String, List<ICLanguageSettingEntry>> entryRc : langMap.entrySet()) {
+ serializeResource(parentElement, entryRc.getKey(), entryRc.getValue());
+ }
+ }
+
+ /**
+ * Serialize the provider entries for a given resource list.
+ */
+ private void serializeResource(Element parentElement, String rcProjectPath, List<ICLanguageSettingEntry> rcList) {
+ if (rcProjectPath!=null) {
+ Element elementRc = XmlUtil.appendElement(parentElement, ELEM_RESOURCE, new String[] {ATTR_PROJECT_PATH, rcProjectPath});
+ parentElement = elementRc;
+ }
+ serializeSettingEntries(parentElement, rcList);
+ }
+
+ /**
+ * Serialize given settings entries.
+ */
+ private void serializeSettingEntries(Element parentElement, List<ICLanguageSettingEntry> settingEntries) {
+ for (ICLanguageSettingEntry entry : settingEntries) {
+ Element elementSettingEntry = XmlUtil.appendElement(parentElement, ELEM_ENTRY, new String[] {
+ ATTR_ENTRY_KIND, LanguageSettingEntriesSerializer.kindToString(entry.getKind()),
+ ATTR_ENTRY_NAME, entry.getName(),
+ });
+ switch (entry.getKind()) {
+ case ICSettingEntry.MACRO:
+ elementSettingEntry.setAttribute(ATTR_ENTRY_VALUE, entry.getValue());
+ break;
+// case ICLanguageSettingEntry.LIBRARY_FILE:
+// // YAGNI: sourceAttachment fields may need to be covered
+// break;
+ }
+ int flags = entry.getFlags();
+ if (flags != 0) {
+ // Element elementFlag =
+ XmlUtil.appendElement(elementSettingEntry, ELEM_ENTRY_FLAG, new String[] {
+ ATTR_ENTRY_VALUE, LanguageSettingEntriesSerializer.composeFlagsString(entry.getFlags())
+ });
+ }
+ }
+ }
+
+ /**
+ * Load provider entries from XML provider element.
+ *
+ * @param providerNode - parent XML element "provider" where entries are defined.
+ */
+ public void loadEntries(Element providerNode) {
+ List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>();
+ NodeList nodes = providerNode.getChildNodes();
+ for (int i=0;i<nodes.getLength();i++) {
+ Node elementNode = nodes.item(i);
+ if (elementNode.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+
+ if (ELEM_LANGUAGE.equals(elementNode.getNodeName())) {
+ loadLanguageElement(elementNode, null);
+ } else if (ELEM_RESOURCE.equals(elementNode.getNodeName())) {
+ loadResourceElement(elementNode, null, null);
+ } else if (ELEM_ENTRY.equals(elementNode.getNodeName())) {
+ ICLanguageSettingEntry entry = loadSettingEntry(elementNode);
+ if (entry!=null) {
+ settings.add(entry);
+ }
+ }
+ }
+ // set settings
+ if (settings.size() > 0) {
+ setSettingEntries(null, null, settings);
+ }
+ }
+
+ /**
+ * Load a setting entry from XML element.
+ */
+ private ICLanguageSettingEntry loadSettingEntry(Node parentElement) {
+ String settingKind = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_KIND);
+ String settingName = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_NAME);
+
+ NodeList flagNodes = parentElement.getChildNodes();
+ int flags = 0;
+ for (int i=0;i<flagNodes.getLength();i++) {
+ Node flagNode = flagNodes.item(i);
+ if (flagNode.getNodeType() != Node.ELEMENT_NODE || !ELEM_ENTRY_FLAG.equals(flagNode.getNodeName()))
+ continue;
+
+ String settingFlags = XmlUtil.determineAttributeValue(flagNode, ATTR_ENTRY_VALUE);
+ int bitFlag = LanguageSettingEntriesSerializer.composeFlags(settingFlags);
+ flags |= bitFlag;
+
+ }
+
+ String settingValue = null;
+ int kind = LanguageSettingEntriesSerializer.stringToKind(settingKind);
+ if (kind == ICSettingEntry.MACRO)
+ settingValue = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_VALUE);
+ ICLanguageSettingEntry entry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, settingName, settingValue, null, flags);
+ return entry;
+ }
+
+ /**
+ * Load entries defined in language element.
+ */
+ private void loadLanguageElement(Node parentNode, String cfgId) {
+ String langId = XmlUtil.determineAttributeValue(parentNode, ATTR_LANGUAGE_ID);
+ if (langId.length() == 0) {
+ langId=null;
+ }
+
+ List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>();
+ NodeList nodes = parentNode.getChildNodes();
+ for (int i=0;i<nodes.getLength();i++) {
+ Node elementNode = nodes.item(i);
+ if (elementNode.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+
+ if (ELEM_RESOURCE.equals(elementNode.getNodeName())) {
+ loadResourceElement(elementNode, cfgId, langId);
+ } else if (ELEM_ENTRY.equals(elementNode.getNodeName())) {
+ ICLanguageSettingEntry entry = loadSettingEntry(elementNode);
+ if (entry!=null) {
+ settings.add(entry);
+ }
+ }
+ }
+ // set settings
+ if (settings.size() > 0) {
+ setSettingEntries(null, langId, settings);
+ }
+ }
+
+ /**
+ * Load entries defined in resource element.
+ */
+ private void loadResourceElement(Node parentNode, String cfgId, String langId) {
+ String rcProjectPath = XmlUtil.determineAttributeValue(parentNode, ATTR_PROJECT_PATH);
+
+ List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>();
+ NodeList nodes = parentNode.getChildNodes();
+ for (int i=0;i<nodes.getLength();i++) {
+ Node elementNode = nodes.item(i);
+ if (elementNode.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+
+ if (ELEM_ENTRY.equals(elementNode.getNodeName())) {
+ ICLanguageSettingEntry entry = loadSettingEntry(elementNode);
+ if (entry!=null) {
+ settings.add(entry);
+ }
+ }
+ }
+
+ // set settings
+ if (settings.size() > 0) {
+ setSettingEntries(rcProjectPath, langId, settings);
+ }
+ }
+
+ @Override
+ public LanguageSettingsSerializableStorage clone() throws CloneNotSupportedException {
+ return (LanguageSettingsSerializableStorage) super.clone();
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java
index ee3ae24a027..8e390c88644 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java
@@ -1,165 +1,165 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2013 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IContainerEntry;
-import org.eclipse.cdt.core.model.IIncludeEntry;
-import org.eclipse.cdt.core.model.IIncludeFileEntry;
-import org.eclipse.cdt.core.model.ILibraryEntry;
-import org.eclipse.cdt.core.model.IMacroEntry;
-import org.eclipse.cdt.core.model.IMacroFileEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.core.model.IPathEntryContainer;
-import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
-import org.eclipse.cdt.core.resources.IPathEntryStore;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.internal.core.model.CModelManager;
-import org.eclipse.cdt.internal.core.model.DefaultPathEntryStore;
-import org.eclipse.cdt.internal.core.model.PathEntryManager;
-import org.eclipse.cdt.internal.core.model.PathEntryUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Wrapper class intended to provide backward compatibility with ScannerInfo supplied by {@link PathEntryManager}.
- */
-public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettingsBaseProvider {
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (cfgDescription == null) {
- return null;
- }
- ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
- if (prjDescription == null) {
- return null;
- }
-
- IProject project = prjDescription.getProject();
- ICProject cproject = CModelManager.getDefault().getCModel().getCProject(project);
- IPath projectPath = cproject.getPath();
-
- // using map of sets to support specific ordering of entries
- LinkedHashMap<Integer, Set<IPathEntry>> pathEntriesMap = new LinkedHashMap<Integer, Set<IPathEntry>>();
- pathEntriesMap.put(IPathEntry.CDT_INCLUDE, new LinkedHashSet<IPathEntry>());
- // keep macros sorted
- pathEntriesMap.put(IPathEntry.CDT_MACRO, new TreeSet<IPathEntry>(new Comparator<IPathEntry>() {
- @Override
- public int compare(IPathEntry macro1, IPathEntry macro2) {
- if (macro1 instanceof IMacroEntry && macro2 instanceof IMacroEntry) {
- return ((IMacroEntry)macro1).getMacroName().compareTo(((IMacroEntry)macro2).getMacroName());
- }
- return 0;
- }
- }));
- pathEntriesMap.put(IPathEntry.CDT_INCLUDE_FILE, new LinkedHashSet<IPathEntry>());
- pathEntriesMap.put(IPathEntry.CDT_MACRO_FILE, new LinkedHashSet<IPathEntry>());
- pathEntriesMap.put(IPathEntry.CDT_LIBRARY, new LinkedHashSet<IPathEntry>());
-
- IPathEntryStore pathEntryStore = new DefaultPathEntryStore(project);
- int typesMask = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO | IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE | IPathEntry.CDT_LIBRARY;
- try {
- IPathEntry[] storePathEntries = pathEntryStore.getRawPathEntries();
- for (IPathEntry storePathEntry : storePathEntries) {
- if (storePathEntry instanceof IContainerEntry) {
- try {
- IPathEntryContainer container = PathEntryManager.getDefault().getPathEntryContainer((IContainerEntry) storePathEntry, cproject);
- if (container != null) {
- IPathEntry[] pathEntries = null;
- if (container instanceof IPathEntryContainerExtension) {
- pathEntries = ((IPathEntryContainerExtension)container).getPathEntries(rc.getFullPath(), typesMask);
- } else {
- pathEntries = container.getPathEntries();
- }
- if (pathEntries != null) {
- for (IPathEntry pathEntry : pathEntries) {
- collectPathEntry(pathEntriesMap, projectPath, pathEntry);
- }
- }
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
- } else {
- collectPathEntry(pathEntriesMap, projectPath, storePathEntry);
- }
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
-
- Set<ICLanguageSettingEntry> lsEntries = new LinkedHashSet<ICLanguageSettingEntry>();
- for (Entry<Integer, Set<IPathEntry>> entrySet : pathEntriesMap.entrySet()) {
- Set<IPathEntry> pathEntries = entrySet.getValue();
- for (IPathEntry pathEntry : pathEntries) {
- ICLanguageSettingEntry lsEntry = toLanguageSettingsEntry(pathEntry);
- if (lsEntry != null) {
- lsEntries.add(lsEntry);
- }
- }
- }
-
- return LanguageSettingsSerializableStorage.getPooledList(new ArrayList<ICLanguageSettingEntry>(lsEntries));
- }
-
- private void collectPathEntry(LinkedHashMap<Integer, Set<IPathEntry>> pathEntriesMap, IPath projectPath, IPathEntry pathEntry) {
- switch (pathEntry.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE:
- case IPathEntry.CDT_MACRO:
- case IPathEntry.CDT_INCLUDE_FILE:
- case IPathEntry.CDT_MACRO_FILE:
- case IPathEntry.CDT_LIBRARY:
- IPathEntry resolvedPathEntry = PathEntryUtil.cloneEntryAndExpand(projectPath, pathEntry);
- Set<IPathEntry> set = pathEntriesMap.get(resolvedPathEntry.getEntryKind());
- if (set != null) {
- set.add(resolvedPathEntry);
- }
- }
- }
-
- private ICLanguageSettingEntry toLanguageSettingsEntry(IPathEntry pathEntry) {
- switch (pathEntry.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE:
- IIncludeEntry includeEntry = (IIncludeEntry)pathEntry;
- return CDataUtil.createCIncludePathEntry(includeEntry.getFullIncludePath().toOSString(), includeEntry.isSystemInclude() ? 0 : ICSettingEntry.LOCAL);
- case IPathEntry.CDT_MACRO:
- IMacroEntry macroEntry = (IMacroEntry) pathEntry;
- return CDataUtil.createCMacroEntry(macroEntry.getMacroName(), macroEntry.getMacroValue(), 0);
- case IPathEntry.CDT_INCLUDE_FILE:
- IIncludeFileEntry includeFileEntry = (IIncludeFileEntry) pathEntry;
- return CDataUtil.createCIncludeFileEntry(includeFileEntry.getFullIncludeFilePath().toOSString(), 0);
- case IPathEntry.CDT_MACRO_FILE:
- IMacroFileEntry macroFileEntry = (IMacroFileEntry) pathEntry;
- return CDataUtil.createCMacroFileEntry(macroFileEntry.getFullMacroFilePath().toOSString(), 0);
- case IPathEntry.CDT_LIBRARY:
- ILibraryEntry libraryEntry = (ILibraryEntry) pathEntry;
- return CDataUtil.createCLibraryFileEntry(libraryEntry.getFullLibraryPath().toOSString(), 0);
- }
- return null;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013, 2013 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.language.settings.providers;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IIncludeEntry;
+import org.eclipse.cdt.core.model.IIncludeFileEntry;
+import org.eclipse.cdt.core.model.ILibraryEntry;
+import org.eclipse.cdt.core.model.IMacroEntry;
+import org.eclipse.cdt.core.model.IMacroFileEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.IPathEntryContainer;
+import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.internal.core.model.CModelManager;
+import org.eclipse.cdt.internal.core.model.DefaultPathEntryStore;
+import org.eclipse.cdt.internal.core.model.PathEntryManager;
+import org.eclipse.cdt.internal.core.model.PathEntryUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Wrapper class intended to provide backward compatibility with ScannerInfo supplied by {@link PathEntryManager}.
+ */
+public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettingsBaseProvider {
+ @Override
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ if (cfgDescription == null) {
+ return null;
+ }
+ ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
+ if (prjDescription == null) {
+ return null;
+ }
+
+ IProject project = prjDescription.getProject();
+ ICProject cproject = CModelManager.getDefault().getCModel().getCProject(project);
+ IPath projectPath = cproject.getPath();
+
+ // using map of sets to support specific ordering of entries
+ LinkedHashMap<Integer, Set<IPathEntry>> pathEntriesMap = new LinkedHashMap<Integer, Set<IPathEntry>>();
+ pathEntriesMap.put(IPathEntry.CDT_INCLUDE, new LinkedHashSet<IPathEntry>());
+ // keep macros sorted
+ pathEntriesMap.put(IPathEntry.CDT_MACRO, new TreeSet<IPathEntry>(new Comparator<IPathEntry>() {
+ @Override
+ public int compare(IPathEntry macro1, IPathEntry macro2) {
+ if (macro1 instanceof IMacroEntry && macro2 instanceof IMacroEntry) {
+ return ((IMacroEntry)macro1).getMacroName().compareTo(((IMacroEntry)macro2).getMacroName());
+ }
+ return 0;
+ }
+ }));
+ pathEntriesMap.put(IPathEntry.CDT_INCLUDE_FILE, new LinkedHashSet<IPathEntry>());
+ pathEntriesMap.put(IPathEntry.CDT_MACRO_FILE, new LinkedHashSet<IPathEntry>());
+ pathEntriesMap.put(IPathEntry.CDT_LIBRARY, new LinkedHashSet<IPathEntry>());
+
+ IPathEntryStore pathEntryStore = new DefaultPathEntryStore(project);
+ int typesMask = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO | IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE | IPathEntry.CDT_LIBRARY;
+ try {
+ IPathEntry[] storePathEntries = pathEntryStore.getRawPathEntries();
+ for (IPathEntry storePathEntry : storePathEntries) {
+ if (storePathEntry instanceof IContainerEntry) {
+ try {
+ IPathEntryContainer container = PathEntryManager.getDefault().getPathEntryContainer((IContainerEntry) storePathEntry, cproject);
+ if (container != null) {
+ IPathEntry[] pathEntries = null;
+ if (container instanceof IPathEntryContainerExtension) {
+ pathEntries = ((IPathEntryContainerExtension)container).getPathEntries(rc.getFullPath(), typesMask);
+ } else {
+ pathEntries = container.getPathEntries();
+ }
+ if (pathEntries != null) {
+ for (IPathEntry pathEntry : pathEntries) {
+ collectPathEntry(pathEntriesMap, projectPath, pathEntry);
+ }
+ }
+ }
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ } else {
+ collectPathEntry(pathEntriesMap, projectPath, storePathEntry);
+ }
+ }
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+
+ Set<ICLanguageSettingEntry> lsEntries = new LinkedHashSet<ICLanguageSettingEntry>();
+ for (Entry<Integer, Set<IPathEntry>> entrySet : pathEntriesMap.entrySet()) {
+ Set<IPathEntry> pathEntries = entrySet.getValue();
+ for (IPathEntry pathEntry : pathEntries) {
+ ICLanguageSettingEntry lsEntry = toLanguageSettingsEntry(pathEntry);
+ if (lsEntry != null) {
+ lsEntries.add(lsEntry);
+ }
+ }
+ }
+
+ return LanguageSettingsSerializableStorage.getPooledList(new ArrayList<ICLanguageSettingEntry>(lsEntries));
+ }
+
+ private void collectPathEntry(LinkedHashMap<Integer, Set<IPathEntry>> pathEntriesMap, IPath projectPath, IPathEntry pathEntry) {
+ switch (pathEntry.getEntryKind()) {
+ case IPathEntry.CDT_INCLUDE:
+ case IPathEntry.CDT_MACRO:
+ case IPathEntry.CDT_INCLUDE_FILE:
+ case IPathEntry.CDT_MACRO_FILE:
+ case IPathEntry.CDT_LIBRARY:
+ IPathEntry resolvedPathEntry = PathEntryUtil.cloneEntryAndExpand(projectPath, pathEntry);
+ Set<IPathEntry> set = pathEntriesMap.get(resolvedPathEntry.getEntryKind());
+ if (set != null) {
+ set.add(resolvedPathEntry);
+ }
+ }
+ }
+
+ private ICLanguageSettingEntry toLanguageSettingsEntry(IPathEntry pathEntry) {
+ switch (pathEntry.getEntryKind()) {
+ case IPathEntry.CDT_INCLUDE:
+ IIncludeEntry includeEntry = (IIncludeEntry)pathEntry;
+ return CDataUtil.createCIncludePathEntry(includeEntry.getFullIncludePath().toOSString(), includeEntry.isSystemInclude() ? 0 : ICSettingEntry.LOCAL);
+ case IPathEntry.CDT_MACRO:
+ IMacroEntry macroEntry = (IMacroEntry) pathEntry;
+ return CDataUtil.createCMacroEntry(macroEntry.getMacroName(), macroEntry.getMacroValue(), 0);
+ case IPathEntry.CDT_INCLUDE_FILE:
+ IIncludeFileEntry includeFileEntry = (IIncludeFileEntry) pathEntry;
+ return CDataUtil.createCIncludeFileEntry(includeFileEntry.getFullIncludeFilePath().toOSString(), 0);
+ case IPathEntry.CDT_MACRO_FILE:
+ IMacroFileEntry macroFileEntry = (IMacroFileEntry) pathEntry;
+ return CDataUtil.createCMacroFileEntry(macroFileEntry.getFullMacroFilePath().toOSString(), 0);
+ case IPathEntry.CDT_LIBRARY:
+ ILibraryEntry libraryEntry = (ILibraryEntry) pathEntry;
+ return CDataUtil.createCLibraryFileEntry(libraryEntry.getFullLibraryPath().toOSString(), 0);
+ }
+ return null;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java
index 68dc700d0be..3fca1995de1 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java
@@ -1,79 +1,79 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2013 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
-import org.eclipse.cdt.core.model.CoreModelUtil;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.core.resources.IResource;
-
-/**
- * Language settings provider to provide entries exported from referenced projects.
- */
-public class ReferencedProjectsLanguageSettingsProvider extends LanguageSettingsBaseProvider {
- /** ID of the provider used in extension point from plugin.xml */
- public static final String ID = "org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider"; //$NON-NLS-1$
-
- final private ThreadLocal<Boolean> recursiveCallIndicator = new ThreadLocal<Boolean>() {
- @Override
- protected Boolean initialValue() {
- return false;
- }
- };
-
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (recursiveCallIndicator.get()) {
- // Recursive call indicates that the provider of a referenced project is called.
- // Only exported entries of the original configuration should be considered,
- // entries of referenced projects are not re-exported.
- return null;
- }
-
- if (cfgDescription == null) {
- return null;
- }
- ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
- if (prjDescription == null) {
- return null;
- }
-
- try {
- recursiveCallIndicator.set(true);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- ICConfigurationDescription[] refCfgDescriptions = CoreModelUtil.getReferencedConfigurationDescriptions(cfgDescription, false);
- for (ICConfigurationDescription refCfgDescription : refCfgDescriptions) {
- List<ICLanguageSettingEntry> refEntries = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, rc, languageId, ICSettingEntry.ALL);
- for (ICLanguageSettingEntry refEntry : refEntries) {
- int flags = refEntry.getFlags();
- if ((flags & ICSettingEntry.EXPORTED) == ICSettingEntry.EXPORTED) {
- // create a new entry with EXPORTED flag cleared
- ICLanguageSettingEntry entry = CDataUtil.createEntry(refEntry, flags & ~ICSettingEntry.EXPORTED);
- entries.add(entry);
- }
- }
- }
-
- return LanguageSettingsStorage.getPooledList(new ArrayList<ICLanguageSettingEntry>(entries));
- } finally {
- recursiveCallIndicator.set(false);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013, 2013 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.language.settings.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Language settings provider to provide entries exported from referenced projects.
+ */
+public class ReferencedProjectsLanguageSettingsProvider extends LanguageSettingsBaseProvider {
+ /** ID of the provider used in extension point from plugin.xml */
+ public static final String ID = "org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider"; //$NON-NLS-1$
+
+ final private ThreadLocal<Boolean> recursiveCallIndicator = new ThreadLocal<Boolean>() {
+ @Override
+ protected Boolean initialValue() {
+ return false;
+ }
+ };
+
+ @Override
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ if (recursiveCallIndicator.get()) {
+ // Recursive call indicates that the provider of a referenced project is called.
+ // Only exported entries of the original configuration should be considered,
+ // entries of referenced projects are not re-exported.
+ return null;
+ }
+
+ if (cfgDescription == null) {
+ return null;
+ }
+ ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
+ if (prjDescription == null) {
+ return null;
+ }
+
+ try {
+ recursiveCallIndicator.set(true);
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ ICConfigurationDescription[] refCfgDescriptions = CoreModelUtil.getReferencedConfigurationDescriptions(cfgDescription, false);
+ for (ICConfigurationDescription refCfgDescription : refCfgDescriptions) {
+ List<ICLanguageSettingEntry> refEntries = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, rc, languageId, ICSettingEntry.ALL);
+ for (ICLanguageSettingEntry refEntry : refEntries) {
+ int flags = refEntry.getFlags();
+ if ((flags & ICSettingEntry.EXPORTED) == ICSettingEntry.EXPORTED) {
+ // create a new entry with EXPORTED flag cleared
+ ICLanguageSettingEntry entry = CDataUtil.createEntry(refEntry, flags & ~ICSettingEntry.EXPORTED);
+ entries.add(entry);
+ }
+ }
+ }
+
+ return LanguageSettingsStorage.getPooledList(new ArrayList<ICLanguageSettingEntry>(entries));
+ } finally {
+ recursiveCallIndicator.set(false);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java
index 956b7919d1a..ea6cf1054d5 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java
@@ -1,158 +1,158 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2013 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
-import org.eclipse.cdt.core.AbstractCExtension;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
-import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoProvider;
-import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-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.core.settings.model.util.CExtensionUtil;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-/**
- * Wrapper class intended to provide backward compatibility with ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point
- */
-public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettingsBaseProvider {
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- IScannerInfoProvider scannerInfoProvider = getScannerInfoProvider(cfgDescription);
- if (scannerInfoProvider != null) {
- IScannerInfo si = scannerInfoProvider.getScannerInformation(rc);
- if (si != null) {
- if (si instanceof IExtendedScannerInfo) {
- addLocalIncludePaths(entries, (IExtendedScannerInfo) si);
- }
-
- addSystemIncludePaths(entries, si);
- addDefinedSymbols(entries, si);
-
- if (si instanceof IExtendedScannerInfo) {
- addIncludeFiles(entries, (IExtendedScannerInfo) si);
- addMacroFiles(entries, (IExtendedScannerInfo) si);
- }
-
- if (!entries.isEmpty()) {
- return LanguageSettingsSerializableStorage.getPooledList(entries);
- }
- }
- }
- return null;
- }
-
- /**
- * Return ScannerInfoProvider defined in configuration metadata in .cproject.
- *
- * @param cfgDescription - configuration description.
- * @return an instance of ScannerInfoProvider or {@code null}.
- */
- public IScannerInfoProvider getScannerInfoProvider(ICConfigurationDescription cfgDescription) {
- if (cfgDescription == null || cfgDescription.isPreferenceConfiguration()) {
- return null;
- }
-
- IScannerInfoProvider scannerInfoProvider = null;
- ICConfigExtensionReference[] refs = cfgDescription.get(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
- if (refs != null && refs.length > 0) {
- ICConfigExtensionReference ref = refs[0];
- try {
- AbstractCExtension cExtension = null;
- IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", false); //$NON-NLS-1$
- cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$
- cExtension.setExtensionReference(ref);
- cExtension.setProject(ref.getConfiguration().getProjectDescription().getProject());
- if (cExtension instanceof IScannerInfoProvider) {
- scannerInfoProvider = (IScannerInfoProvider) cExtension;
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
- }
- return scannerInfoProvider;
- }
-
- /**
- * Add local include paths to the list of entries.
- */
- private void addLocalIncludePaths(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
- String[] localIncludePaths = esi.getLocalIncludePath();
- if (localIncludePaths != null) {
- for (String path : localIncludePaths) {
- entries.add(CDataUtil.createCIncludePathEntry(path, ICSettingEntry.LOCAL));
- }
- }
- }
-
- /**
- * Add system include paths to the list of entries.
- */
- private void addSystemIncludePaths(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
- String[] includePaths = si.getIncludePaths();
- if (includePaths != null) {
- for (String path : includePaths) {
- entries.add(CDataUtil.createCIncludePathEntry(path, 0));
- }
- }
- }
-
- /**
- * Add defined macros to the list of entries.
- */
- private void addDefinedSymbols(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
- Map<String, String> definedSymbols = si.getDefinedSymbols();
- if (definedSymbols != null) {
- for (Entry<String, String> entry : new TreeMap<String, String>(definedSymbols).entrySet()) {
- String name = entry.getKey();
- String value = entry.getValue();
- entries.add(CDataUtil.createCMacroEntry(name, value, 0));
- }
- }
- }
-
- /**
- * Add include files to the list of entries.
- */
- private void addIncludeFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
- String[] includeFiles = esi.getIncludeFiles();
- if (includeFiles != null) {
- for (String path : includeFiles) {
- entries.add(CDataUtil.createCIncludeFileEntry(path, 0));
- }
- }
- }
-
- /**
- * Add macro files to the list of entries.
- */
- private void addMacroFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
- String[] macroFiles = esi.getMacroFiles();
- if (macroFiles != null) {
- for (String path : macroFiles) {
- entries.add(CDataUtil.createCMacroFileEntry(path, 0));
- }
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013, 2013 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.language.settings.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+
+import org.eclipse.cdt.core.AbstractCExtension;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
+import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+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.core.settings.model.util.CExtensionUtil;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * Wrapper class intended to provide backward compatibility with ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point
+ */
+public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettingsBaseProvider {
+ @Override
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ IScannerInfoProvider scannerInfoProvider = getScannerInfoProvider(cfgDescription);
+ if (scannerInfoProvider != null) {
+ IScannerInfo si = scannerInfoProvider.getScannerInformation(rc);
+ if (si != null) {
+ if (si instanceof IExtendedScannerInfo) {
+ addLocalIncludePaths(entries, (IExtendedScannerInfo) si);
+ }
+
+ addSystemIncludePaths(entries, si);
+ addDefinedSymbols(entries, si);
+
+ if (si instanceof IExtendedScannerInfo) {
+ addIncludeFiles(entries, (IExtendedScannerInfo) si);
+ addMacroFiles(entries, (IExtendedScannerInfo) si);
+ }
+
+ if (!entries.isEmpty()) {
+ return LanguageSettingsSerializableStorage.getPooledList(entries);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return ScannerInfoProvider defined in configuration metadata in .cproject.
+ *
+ * @param cfgDescription - configuration description.
+ * @return an instance of ScannerInfoProvider or {@code null}.
+ */
+ public IScannerInfoProvider getScannerInfoProvider(ICConfigurationDescription cfgDescription) {
+ if (cfgDescription == null || cfgDescription.isPreferenceConfiguration()) {
+ return null;
+ }
+
+ IScannerInfoProvider scannerInfoProvider = null;
+ ICConfigExtensionReference[] refs = cfgDescription.get(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
+ if (refs != null && refs.length > 0) {
+ ICConfigExtensionReference ref = refs[0];
+ try {
+ AbstractCExtension cExtension = null;
+ IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", false); //$NON-NLS-1$
+ cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$
+ cExtension.setExtensionReference(ref);
+ cExtension.setProject(ref.getConfiguration().getProjectDescription().getProject());
+ if (cExtension instanceof IScannerInfoProvider) {
+ scannerInfoProvider = (IScannerInfoProvider) cExtension;
+ }
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ return scannerInfoProvider;
+ }
+
+ /**
+ * Add local include paths to the list of entries.
+ */
+ private void addLocalIncludePaths(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
+ String[] localIncludePaths = esi.getLocalIncludePath();
+ if (localIncludePaths != null) {
+ for (String path : localIncludePaths) {
+ entries.add(CDataUtil.createCIncludePathEntry(path, ICSettingEntry.LOCAL));
+ }
+ }
+ }
+
+ /**
+ * Add system include paths to the list of entries.
+ */
+ private void addSystemIncludePaths(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
+ String[] includePaths = si.getIncludePaths();
+ if (includePaths != null) {
+ for (String path : includePaths) {
+ entries.add(CDataUtil.createCIncludePathEntry(path, 0));
+ }
+ }
+ }
+
+ /**
+ * Add defined macros to the list of entries.
+ */
+ private void addDefinedSymbols(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
+ Map<String, String> definedSymbols = si.getDefinedSymbols();
+ if (definedSymbols != null) {
+ for (Entry<String, String> entry : new TreeMap<String, String>(definedSymbols).entrySet()) {
+ String name = entry.getKey();
+ String value = entry.getValue();
+ entries.add(CDataUtil.createCMacroEntry(name, value, 0));
+ }
+ }
+ }
+
+ /**
+ * Add include files to the list of entries.
+ */
+ private void addIncludeFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
+ String[] includeFiles = esi.getIncludeFiles();
+ if (includeFiles != null) {
+ for (String path : includeFiles) {
+ entries.add(CDataUtil.createCIncludeFileEntry(path, 0));
+ }
+ }
+ }
+
+ /**
+ * Add macro files to the list of entries.
+ */
+ private void addMacroFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
+ String[] macroFiles = esi.getMacroFiles();
+ if (macroFiles != null) {
+ for (String path : macroFiles) {
+ entries.add(CDataUtil.createCMacroFileEntry(path, 0));
+ }
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java
index d294ae94ede..8a70bff4f2c 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java
@@ -1,59 +1,59 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2011 IBM 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:
- * Rational Software - initial implementation
+/*******************************************************************************
+ * Copyright (c) 2001, 2011 IBM 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:
+ * Rational Software - initial implementation
*******************************************************************************/
-package org.eclipse.cdt.internal.core.model;
-
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.cdt.core.model.ICModelStatus;
-import org.eclipse.cdt.core.model.CModelException;
-
-/**
- * An operation created as a result of a call to JavaCore.run(IWorkspaceRunnable, IProgressMonitor)
- * that encapsulates a user defined IWorkspaceRunnable.
- */
-public class BatchOperation extends CModelOperation {
- protected IWorkspaceRunnable runnable;
-
- public BatchOperation(IWorkspaceRunnable runnable) {
- this.runnable = runnable;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.core.JavaModelOperation#executeOperation()
- */
- @Override
- protected void executeOperation() throws CModelException {
- try {
- this.runnable.run(fMonitor);
- } catch (CoreException ce) {
- if (ce instanceof CModelException) {
- throw (CModelException)ce;
- }
- if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
- Throwable e= ce.getStatus().getException();
- if (e instanceof CModelException) {
- throw (CModelException) e;
- }
- }
- throw new CModelException(ce);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.core.JavaModelOperation#verify()
- */
- @Override
- protected ICModelStatus verify() {
- // cannot verify user defined operation
- return CModelStatus.VERIFIED_OK;
- }
-}
+package org.eclipse.cdt.internal.core.model;
+
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.cdt.core.model.ICModelStatus;
+import org.eclipse.cdt.core.model.CModelException;
+
+/**
+ * An operation created as a result of a call to JavaCore.run(IWorkspaceRunnable, IProgressMonitor)
+ * that encapsulates a user defined IWorkspaceRunnable.
+ */
+public class BatchOperation extends CModelOperation {
+ protected IWorkspaceRunnable runnable;
+
+ public BatchOperation(IWorkspaceRunnable runnable) {
+ this.runnable = runnable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.core.JavaModelOperation#executeOperation()
+ */
+ @Override
+ protected void executeOperation() throws CModelException {
+ try {
+ this.runnable.run(fMonitor);
+ } catch (CoreException ce) {
+ if (ce instanceof CModelException) {
+ throw (CModelException)ce;
+ }
+ if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
+ Throwable e= ce.getStatus().getException();
+ if (e instanceof CModelException) {
+ throw (CModelException) e;
+ }
+ }
+ throw new CModelException(ce);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.core.JavaModelOperation#verify()
+ */
+ @Override
+ protected ICModelStatus verify() {
+ // cannot verify user defined operation
+ return CModelStatus.VERIFIED_OK;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java
index 897abdd2173..c3491406ca8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java
@@ -1,28 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2014 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences.
- * 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:
- * Thomas Corbat (IFS) - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.dom.ast.cpp;
-
-import org.eclipse.cdt.core.dom.ast.IType;
-
-/**
- * Represents an alias template (14.5.7).
- * @since 5.5
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICPPAliasTemplate extends IType, ICPPTemplateDefinition {
- /**
- * Returns the aliased type.
- */
- public IType getType();
-}
+/*******************************************************************************
+ * Copyright (c) 2012, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Rapperswil, University of applied sciences.
+ * 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:
+ * Thomas Corbat (IFS) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IType;
+
+/**
+ * Represents an alias template (14.5.7).
+ * @since 5.5
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ICPPAliasTemplate extends IType, ICPPTemplateDefinition {
+ /**
+ * Returns the aliased type.
+ */
+ public IType getType();
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java
index 5ab56f46e1e..4082f1b0c04 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java
@@ -1,47 +1,47 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Tomasz Wesolowski
- * 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:
- * Tomasz Wesolowski - initial API and implementation
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Tomasz Wesolowski
+ * 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:
+ * Tomasz Wesolowski - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.dom.rewrite;
-
-import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
-import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
-import org.eclipse.cdt.core.dom.ast.INodeFactory;
-import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl;
-
-/**
- * This class handles the creation of {@link IASTDeclarator}s and {@link IASTDeclSpecifier}s
- * for a given type.
- *
- * @author Tomasz Wesolowski
- * @noextend This interface is not intended to be extended by clients.
- * @since 5.3
- */
-public abstract class DeclarationGenerator {
-
- public static DeclarationGenerator create(INodeFactory factory) {
- return new DeclarationGeneratorImpl(factory);
- }
-
- /**
- * Creates a new {@link IASTDeclSpecifier} for a given {@link IType}.
- * @param type the type to describe
- * @return the generated declaration specifier
- */
- public abstract IASTDeclSpecifier createDeclSpecFromType(IType type);
-
- /**
- * Creates a new {@link IASTDeclarator} for a given {@link IType}.
- * @param type the type to describe
- * @param name the name for the declarator
- * @return the generated declarator
- */
- public abstract IASTDeclarator createDeclaratorFromType(IType type, char[] name);
+package org.eclipse.cdt.core.dom.rewrite;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.INodeFactory;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl;
+
+/**
+ * This class handles the creation of {@link IASTDeclarator}s and {@link IASTDeclSpecifier}s
+ * for a given type.
+ *
+ * @author Tomasz Wesolowski
+ * @noextend This interface is not intended to be extended by clients.
+ * @since 5.3
+ */
+public abstract class DeclarationGenerator {
+
+ public static DeclarationGenerator create(INodeFactory factory) {
+ return new DeclarationGeneratorImpl(factory);
+ }
+
+ /**
+ * Creates a new {@link IASTDeclSpecifier} for a given {@link IType}.
+ * @param type the type to describe
+ * @return the generated declaration specifier
+ */
+ public abstract IASTDeclSpecifier createDeclSpecFromType(IType type);
+
+ /**
+ * Creates a new {@link IASTDeclarator} for a given {@link IType}.
+ * @param type the type to describe
+ * @param name the name for the declarator
+ * @return the generated declarator
+ */
+ public abstract IASTDeclarator createDeclaratorFromType(IType type, char[] name);
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java
index 4c86e4326eb..018730f8337 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java
@@ -8,14 +8,14 @@
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
*******************************************************************************/
-package org.eclipse.cdt.core.index;
+package org.eclipse.cdt.core.index;
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Path;
/**
* A location converter for converting project resource locations to be relative to a specified
@@ -33,13 +33,13 @@ public class ResourceContainerRelativeLocationConverter implements IIndexLocatio
public ResourceContainerRelativeLocationConverter(IContainer container) {
this.fullPath = container.getFullPath();
this.root = ResourcesPlugin.getWorkspace().getRoot();
- }
+ }
@Override
public IIndexFileLocation fromInternalFormat(String raw) {
IResource member= root.getFile(fullPath.append(raw));
return new IndexFileLocation(member.getLocationURI(), member.getFullPath().toString());
- }
+ }
@Override
public String toInternalFormat(IIndexFileLocation location) {
String sFullPath= location.getFullPath();
@@ -51,4 +51,4 @@ public class ResourceContainerRelativeLocationConverter implements IIndexLocatio
}
return null;
}
-}
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/StandardAttributes.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/StandardAttributes.java
index 1597a77dafa..bcca01f1b47 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/StandardAttributes.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/StandardAttributes.java
@@ -1,30 +1,30 @@
-/*******************************************************************************
- * Copyright (c) 2017 Institute for Software, HSR Hochschule fuer Technik
- * 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
- *******************************************************************************/
-package org.eclipse.cdt.core.parser;
-
-/**
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- * @since 6.3
- */
-@SuppressWarnings("nls")
-public class StandardAttributes {
- public static final String CARRIES_DEPENDENCY = "carries_dependency";
- public static final String DEPRECATED = "deprecated";
- public static final String FALLTHROUGH = "fallthrough";
- public static final String MAYBE_UNUSED = "maybe_unused";
- public static final String NODISCARD = "nodiscard";
- public static final String NORETURN = "noreturn";
-
- public static final char[] cCARRIES_DEPENDENCY = "carries_dependency".toCharArray();
- public static final char[] cDEPRECATED = "deprecated".toCharArray();
- public static final char[] cFALLTHROUGH = "fallthrough".toCharArray();
- public static final char[] cMAYBE_UNUSED = "maybe_unused".toCharArray();
- public static final char[] cNODISCARD = "nodiscard".toCharArray();
- public static final char[] cNORETURN = "noreturn".toCharArray();
-}
+/*******************************************************************************
+ * Copyright (c) 2017 Institute for Software, HSR Hochschule fuer Technik
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.core.parser;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @since 6.3
+ */
+@SuppressWarnings("nls")
+public class StandardAttributes {
+ public static final String CARRIES_DEPENDENCY = "carries_dependency";
+ public static final String DEPRECATED = "deprecated";
+ public static final String FALLTHROUGH = "fallthrough";
+ public static final String MAYBE_UNUSED = "maybe_unused";
+ public static final String NODISCARD = "nodiscard";
+ public static final String NORETURN = "noreturn";
+
+ public static final char[] cCARRIES_DEPENDENCY = "carries_dependency".toCharArray();
+ public static final char[] cDEPRECATED = "deprecated".toCharArray();
+ public static final char[] cFALLTHROUGH = "fallthrough".toCharArray();
+ public static final char[] cMAYBE_UNUSED = "maybe_unused".toCharArray();
+ public static final char[] cNODISCARD = "nodiscard".toCharArray();
+ public static final char[] cNORETURN = "noreturn".toCharArray();
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java
index 5f098d4fbe4..594cda3abbd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java
@@ -1,167 +1,167 @@
-/*******************************************************************************
- * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences.
- * 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:
- * Thomas Corbat (IFS) - Initial API and implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.dom.parser.cpp;
-
-import org.eclipse.cdt.core.dom.ILinkage;
-import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
-import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IScope;
-import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
-import org.eclipse.cdt.core.parser.util.ArrayUtil;
-import org.eclipse.cdt.internal.core.dom.Linkage;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
-import org.eclipse.core.runtime.PlatformObject;
-
-public class CPPAliasTemplate extends PlatformObject
- implements ICPPAliasTemplate, ICPPTemplateParameterOwner, ICPPInternalBinding {
- private final IASTName aliasName;
- private final IType aliasedType;
- private ICPPTemplateParameter[] templateParameters;
-
- public CPPAliasTemplate(IASTName aliasName, IType aliasedType) {
- this.aliasName = aliasName;
- this.aliasedType = aliasedType;
- aliasName.setBinding(this);
- }
-
- @Override
- public IType getType() {
- return aliasedType;
- }
-
- @Override
- public String getName() {
- return new String(getNameCharArray());
- }
-
- @Override
- public char[] getNameCharArray() {
- return aliasName.getSimpleID();
- }
-
- @Override
- public ILinkage getLinkage() {
- return Linkage.CPP_LINKAGE;
- }
-
- @Override
- public IBinding getOwner() {
- return CPPVisitor.findDeclarationOwner(aliasName, true);
- }
-
- @Override
- public IScope getScope() throws DOMException {
- return CPPVisitor.getContainingScope(aliasName.getParent());
- }
-
- @Override
- public boolean isSameType(IType type) {
- if (type == null) {
- return false;
- }
- IType aliasedType = getType();
- return type.isSameType(aliasedType);
- }
-
- @Override
- public Object clone() {
- IType t = null;
- try {
- t = (IType) super.clone();
- } catch (CloneNotSupportedException e) {
- // Not going to happen
- }
- return t;
- }
-
- @Override
- public String[] getQualifiedName() throws DOMException {
- return CPPVisitor.getQualifiedName(this);
- }
-
- @Override
- public char[][] getQualifiedNameCharArray() throws DOMException {
- return CPPVisitor.getQualifiedNameCharArray(this);
- }
-
- @Override
- public boolean isGloballyQualified() throws DOMException {
- return true;
- }
-
- @Override
- public ICPPTemplateParameter[] getTemplateParameters() {
- if (templateParameters == null) {
- ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(aliasName);
- if (template == null)
- return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
- ICPPASTTemplateParameter[] params = template.getTemplateParameters();
- IBinding p = null;
- ICPPTemplateParameter[] result = null;
- for (ICPPASTTemplateParameter param : params) {
- p= CPPTemplates.getTemplateParameterName(param).resolveBinding();
- if (p instanceof ICPPTemplateParameter) {
- result = ArrayUtil.append(ICPPTemplateParameter.class, result, (ICPPTemplateParameter) p);
- }
- }
- templateParameters = ArrayUtil.trim(ICPPTemplateParameter.class, result);
- }
- return templateParameters;
- }
-
- @Override
- public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) {
- int pos= templateParameter.getParameterPosition();
-
- ICPPASTTemplateParameter[] params = CPPTemplates.getTemplateDeclaration(aliasName).getTemplateParameters();
- if (pos < params.length) {
- final IASTName oName = CPPTemplates.getTemplateParameterName(params[pos]);
- return oName.resolvePreBinding();
- }
- return templateParameter;
- }
-
- @Override
- public IASTNode getDefinition() {
- return aliasName;
- }
-
- @Override
- public IASTNode[] getDeclarations() {
- return null;
- }
-
- @Override
- public void addDefinition(IASTNode node) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void addDeclaration(IASTNode node) {
- throw new UnsupportedOperationException();
- }
-
- /** For debugging only. */
- @Override
- public String toString() {
- return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
+ * Rapperswil, University of applied sciences.
+ * 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:
+ * Thomas Corbat (IFS) - Initial API and implementation
+ * Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
+import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.core.runtime.PlatformObject;
+
+public class CPPAliasTemplate extends PlatformObject
+ implements ICPPAliasTemplate, ICPPTemplateParameterOwner, ICPPInternalBinding {
+ private final IASTName aliasName;
+ private final IType aliasedType;
+ private ICPPTemplateParameter[] templateParameters;
+
+ public CPPAliasTemplate(IASTName aliasName, IType aliasedType) {
+ this.aliasName = aliasName;
+ this.aliasedType = aliasedType;
+ aliasName.setBinding(this);
+ }
+
+ @Override
+ public IType getType() {
+ return aliasedType;
+ }
+
+ @Override
+ public String getName() {
+ return new String(getNameCharArray());
+ }
+
+ @Override
+ public char[] getNameCharArray() {
+ return aliasName.getSimpleID();
+ }
+
+ @Override
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
+
+ @Override
+ public IBinding getOwner() {
+ return CPPVisitor.findDeclarationOwner(aliasName, true);
+ }
+
+ @Override
+ public IScope getScope() throws DOMException {
+ return CPPVisitor.getContainingScope(aliasName.getParent());
+ }
+
+ @Override
+ public boolean isSameType(IType type) {
+ if (type == null) {
+ return false;
+ }
+ IType aliasedType = getType();
+ return type.isSameType(aliasedType);
+ }
+
+ @Override
+ public Object clone() {
+ IType t = null;
+ try {
+ t = (IType) super.clone();
+ } catch (CloneNotSupportedException e) {
+ // Not going to happen
+ }
+ return t;
+ }
+
+ @Override
+ public String[] getQualifiedName() throws DOMException {
+ return CPPVisitor.getQualifiedName(this);
+ }
+
+ @Override
+ public char[][] getQualifiedNameCharArray() throws DOMException {
+ return CPPVisitor.getQualifiedNameCharArray(this);
+ }
+
+ @Override
+ public boolean isGloballyQualified() throws DOMException {
+ return true;
+ }
+
+ @Override
+ public ICPPTemplateParameter[] getTemplateParameters() {
+ if (templateParameters == null) {
+ ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(aliasName);
+ if (template == null)
+ return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
+ ICPPASTTemplateParameter[] params = template.getTemplateParameters();
+ IBinding p = null;
+ ICPPTemplateParameter[] result = null;
+ for (ICPPASTTemplateParameter param : params) {
+ p= CPPTemplates.getTemplateParameterName(param).resolveBinding();
+ if (p instanceof ICPPTemplateParameter) {
+ result = ArrayUtil.append(ICPPTemplateParameter.class, result, (ICPPTemplateParameter) p);
+ }
+ }
+ templateParameters = ArrayUtil.trim(ICPPTemplateParameter.class, result);
+ }
+ return templateParameters;
+ }
+
+ @Override
+ public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) {
+ int pos= templateParameter.getParameterPosition();
+
+ ICPPASTTemplateParameter[] params = CPPTemplates.getTemplateDeclaration(aliasName).getTemplateParameters();
+ if (pos < params.length) {
+ final IASTName oName = CPPTemplates.getTemplateParameterName(params[pos]);
+ return oName.resolvePreBinding();
+ }
+ return templateParameter;
+ }
+
+ @Override
+ public IASTNode getDefinition() {
+ return aliasName;
+ }
+
+ @Override
+ public IASTNode[] getDeclarations() {
+ return null;
+ }
+
+ @Override
+ public void addDefinition(IASTNode node) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void addDeclaration(IASTNode node) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** For debugging only. */
+ @Override
+ public String toString() {
+ return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java
index 0f595659952..2274469a4f1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java
@@ -1,166 +1,166 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2016 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences.
- * 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:
- * Thomas Corbat (IFS) - Initial API and implementation
- * Sergey Prigogin (Google)
+/*******************************************************************************
+ * Copyright (c) 2012, 2016 Institute for Software, HSR Hochschule fuer Technik
+ * Rapperswil, University of applied sciences.
+ * 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:
+ * Thomas Corbat (IFS) - Initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
-package org.eclipse.cdt.internal.core.dom.parser.cpp;
-
-import org.eclipse.cdt.core.dom.ILinkage;
-import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
-import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IScope;
-import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
-import org.eclipse.cdt.core.parser.util.CharArrayUtils;
-import org.eclipse.cdt.internal.core.dom.Linkage;
-import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
-
-public class CPPAliasTemplateInstance extends CPPSpecialization implements ICPPAliasTemplateInstance,
- ITypeContainer {
- private IType aliasedType;
- private ICPPTemplateArgument[] fArguments;
-
- public CPPAliasTemplateInstance(ICPPAliasTemplate aliasTemplate, IType aliasedType, IBinding owner,
- ICPPTemplateParameterMap argumentMap, ICPPTemplateArgument[] arguments) {
- super(aliasTemplate, owner, argumentMap);
- this.aliasedType = aliasedType;
- this.fArguments = arguments;
- }
-
- @Override
- public ICPPAliasTemplate getTemplateDefinition() {
- return (ICPPAliasTemplate) super.getSpecializedBinding();
- }
-
- @Override
- public boolean isSameType(IType other) {
- if (other == aliasedType)
- return true;
- if (aliasedType != null) {
- return aliasedType.isSameType(other);
- }
- return false;
- }
-
- @Override
- public IType getType() {
- return aliasedType;
- }
-
- @Override
- public void setType(IType type) {
- aliasedType = type;
- }
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- }
- return null;
- }
-
- @Override
- public String getName() {
- return new String(getNameCharArray());
- }
-
- @Override
- public char[] getNameCharArray() {
- char[] name = getTemplateDefinition().getNameCharArray();
- if (name != null) {
- return name;
- }
- return CharArrayUtils.EMPTY_CHAR_ARRAY;
- }
-
- @Override
- public ILinkage getLinkage() {
- return Linkage.CPP_LINKAGE;
- }
-
- @Override
- public IBinding getOwner() {
- if (getTemplateDefinition() != null) {
- return getTemplateDefinition().getOwner();
- }
- return null;
- }
-
- @Override
- public IScope getScope() throws DOMException {
- if (getTemplateDefinition() != null) {
- return getTemplateDefinition().getScope();
- }
- return null;
- }
-
- @Override
- public String[] getQualifiedName() {
- return CPPVisitor.getQualifiedName(this);
- }
-
- @Override
- public char[][] getQualifiedNameCharArray() {
- return CPPVisitor.getQualifiedNameCharArray(this);
- }
-
- @Override
- public boolean isGloballyQualified() throws DOMException {
- return getTemplateDefinition().isGloballyQualified();
- }
-
- @Override
- public IASTNode getDefinition() {
- if (getTemplateDefinition() instanceof ICPPInternalBinding) {
- return ((ICPPInternalBinding) getTemplateDefinition()).getDefinition();
- }
- return null;
- }
-
- @Override
- public IASTNode[] getDeclarations() {
- return null;
- }
-
- @Override
- public void addDefinition(IASTNode node) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void addDeclaration(IASTNode node) {
- throw new UnsupportedOperationException();
- }
-
- /** For debugging only. */
- @Override
- public String toString() {
- return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
- }
-
- @Override
- public ICPPTemplateArgument[] getTemplateArguments() {
- return fArguments;
- }
-
- @Override
- public boolean isExplicitSpecialization() {
- // Alias templates cannot have explicit specializations.
- return false;
- }
-}
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+
+public class CPPAliasTemplateInstance extends CPPSpecialization implements ICPPAliasTemplateInstance,
+ ITypeContainer {
+ private IType aliasedType;
+ private ICPPTemplateArgument[] fArguments;
+
+ public CPPAliasTemplateInstance(ICPPAliasTemplate aliasTemplate, IType aliasedType, IBinding owner,
+ ICPPTemplateParameterMap argumentMap, ICPPTemplateArgument[] arguments) {
+ super(aliasTemplate, owner, argumentMap);
+ this.aliasedType = aliasedType;
+ this.fArguments = arguments;
+ }
+
+ @Override
+ public ICPPAliasTemplate getTemplateDefinition() {
+ return (ICPPAliasTemplate) super.getSpecializedBinding();
+ }
+
+ @Override
+ public boolean isSameType(IType other) {
+ if (other == aliasedType)
+ return true;
+ if (aliasedType != null) {
+ return aliasedType.isSameType(other);
+ }
+ return false;
+ }
+
+ @Override
+ public IType getType() {
+ return aliasedType;
+ }
+
+ @Override
+ public void setType(IType type) {
+ aliasedType = type;
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ }
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return new String(getNameCharArray());
+ }
+
+ @Override
+ public char[] getNameCharArray() {
+ char[] name = getTemplateDefinition().getNameCharArray();
+ if (name != null) {
+ return name;
+ }
+ return CharArrayUtils.EMPTY_CHAR_ARRAY;
+ }
+
+ @Override
+ public ILinkage getLinkage() {
+ return Linkage.CPP_LINKAGE;
+ }
+
+ @Override
+ public IBinding getOwner() {
+ if (getTemplateDefinition() != null) {
+ return getTemplateDefinition().getOwner();
+ }
+ return null;
+ }
+
+ @Override
+ public IScope getScope() throws DOMException {
+ if (getTemplateDefinition() != null) {
+ return getTemplateDefinition().getScope();
+ }
+ return null;
+ }
+
+ @Override
+ public String[] getQualifiedName() {
+ return CPPVisitor.getQualifiedName(this);
+ }
+
+ @Override
+ public char[][] getQualifiedNameCharArray() {
+ return CPPVisitor.getQualifiedNameCharArray(this);
+ }
+
+ @Override
+ public boolean isGloballyQualified() throws DOMException {
+ return getTemplateDefinition().isGloballyQualified();
+ }
+
+ @Override
+ public IASTNode getDefinition() {
+ if (getTemplateDefinition() instanceof ICPPInternalBinding) {
+ return ((ICPPInternalBinding) getTemplateDefinition()).getDefinition();
+ }
+ return null;
+ }
+
+ @Override
+ public IASTNode[] getDeclarations() {
+ return null;
+ }
+
+ @Override
+ public void addDefinition(IASTNode node) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void addDeclaration(IASTNode node) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** For debugging only. */
+ @Override
+ public String toString() {
+ return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
+ }
+
+ @Override
+ public ICPPTemplateArgument[] getTemplateArguments() {
+ return fArguments;
+ }
+
+ @Override
+ public boolean isExplicitSpecialization() {
+ // Alias templates cannot have explicit specializations.
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd b/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd
index 3abc3226dcc..c2d7de5cf85 100644
--- a/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd
+++ b/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd
@@ -1,119 +1,119 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.cdt.core" id="CBuildConfigProvider" name="CBuildConfigProvider"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="provider"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="provider">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.ICBuildConfigurationProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="natureId" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.natures/@id"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.core" id="CBuildConfigProvider" name="CBuildConfigProvider"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="provider"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="provider">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.ICBuildConfigurationProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="natureId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.natures/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd b/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd
index 78c09ea5a12..b4962a3957e 100644
--- a/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd
+++ b/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd
@@ -1,132 +1,132 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.cdt.core" id="ToolChainProvider" name="Tool Chain Provider"/>
- </appInfo>
- <documentation>
- A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren&apos;t called unless there&apos;s a good chance they have toolchains to offer.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="provider"/>
- <element ref="type"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="provider">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.IToolChainProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="type">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.core" id="ToolChainProvider" name="Tool Chain Provider"/>
+ </appInfo>
+ <documentation>
+ A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren&apos;t called unless there&apos;s a good chance they have toolchains to offer.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="provider"/>
+ <element ref="type"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="provider">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.IToolChainProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="type">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java
index 3e9bd08818a..fab7d8ad5cf 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java
@@ -1,274 +1,274 @@
-/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems 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
- *******************************************************************************/
-package org.eclipse.cdt.core.build;
-
-import java.net.URI;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
-import org.eclipse.core.resources.IBuildConfiguration;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- * Toolchains are a collection of tools that take the source code and converts
- * it into an executable system.
- *
- * @since 6.0
- */
-public interface IToolChain extends IAdaptable {
-
- /**
- * Property: The OS the toolchain builds for.
- */
- static final String ATTR_OS = "os"; //$NON-NLS-1$
-
- /**
- * Property: The CPU architecture the toolchain supports.
- */
- static final String ATTR_ARCH = "arch"; //$NON-NLS-1$
-
- /**
- * Property: A package ID to reflect different version/package line up of
- * the platform this toolchain supports.
- */
- static final String ATTR_PACKAGE = "package"; //$NON-NLS-1$
-
- /**
- * The provider of the toolchain.
- *
- * @return toolchain provider
- */
- IToolChainProvider getProvider();
-
- /**
- * The ID of the toolchain
- *
- * @return toolchain ID
- */
- String getId();
-
- /**
- * The version of the toolchain
- *
- * @deprecated the version doesn't matter. id's for a given type must be unique.
- * @return toolchain version
- */
- @Deprecated
- String getVersion();
-
- /**
- * The user friendly name for the toolchain
- *
- * @return toolchain name
- */
- String getName();
-
- /**
- * The type id for the toolchain. The combination of type id and toolchain id
- * uniquely identify the toolchain in the system.
- *
- * @since 6.4
- */
- default String getTypeId() {
- // Subclasses really need to override this. There can be multiple providers for
- // a given toolchain type.
- return getProvider().getId();
- }
-
- /**
- * Returns an property of the toolchain. Used to determine applicability of
- * a toolchain for a given situation.
- *
- * @param key
- * key of the property
- * @return value of the property or null if the toolchain does not have that
- * property
- */
- String getProperty(String key);
-
- /**
- * Set a property on the toolchain.
- *
- * @param key
- * key of the property
- * @param value
- * value of the property
- */
- void setProperty(String key, String value);
-
- /**
- * Return the environment variables to be set when invoking the tools in the
- * toolchain.
- *
- * @return environment variables
- */
- IEnvironmentVariable[] getVariables();
-
- /**
- * Return the environment variable of the given name used when invoking the
- * toolchain.
- *
- * @param name
- * environment variable name
- * @return environment variable value
- */
- IEnvironmentVariable getVariable(String name);
-
- /**
- * Returns the error parser IDs use to create error markers for builds with
- * this toolchain.
- *
- * @return error parser IDs
- */
- String[] getErrorParserIds();
-
- /**
- * Returns the IDs for the binary parsers that can parse the build output of
- * the toolchain.
- *
- * @return binary parser IDs for this toolchain
- */
- String getBinaryParserId();
-
- /**
- * Get the scanner info for a given build config, command, base scanner
- * info, resource and build directory.
- *
- * @param buildConfig
- * the build configuration this scanner info applies to
- * @param command
- * the compile command that is used to build the resource
- * @param baseScannerInfo
- * base scanner info that this scanner info extends/replaces
- * @param resource
- * the resource this scanner info applies to, usually a source
- * file
- * @param buildDirectoryURI
- * where the build command is run to build this resource
- * @return scanner info for this resource
- * @since 6.1
- */
- default IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, List<String> command,
- IExtendedScannerInfo baseScannerInfo, IResource resource, URI buildDirectoryURI) {
- return null;
- }
-
- @Deprecated
- default IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, Path command, String[] args,
- IExtendedScannerInfo baseScannerInfo, IResource resource, URI buildDirectoryURI) {
- List<String> commandStrings = new ArrayList<>(args.length + 1);
- commandStrings.add(command.toString());
- commandStrings.addAll(Arrays.asList(args));
- return getScannerInfo(buildConfig, commandStrings, baseScannerInfo, resource, buildDirectoryURI);
- }
-
- /**
- * Return the default scanner info for this toolchain. This is used before
- * any build information is available to provide at least a minimal scanner
- * info based on the compiler built-ins.
- *
- * @param buildConfig
- * the build configuration this scanner info applies to
- * @param baseScannerInfo
- * base scanner info that this scanner info extends/replaces
- * @param language
- * the source language that selects the tool to provide scanner
- * info for
- * @param buildDirectoryURI
- * the build directory that would be used to run commands
- * @returns default scanner info for this language
- * @since 6.1
- */
- default IExtendedScannerInfo getDefaultScannerInfo(IBuildConfiguration buildConfig,
- IExtendedScannerInfo baseScannerInfo, ILanguage language, URI buildDirectoryURI) {
- return null;
- }
-
- /**
- * Returns the absolute path of the tool represented by the command
- *
- * @param command
- * the command as it usually appears on the command line
- * @return the absolute path to the tool for the command
- */
- Path getCommandPath(Path command);
-
- /**
- * Returns the list of compiler tools.
- *
- * @return list of compiler tools
- */
- String[] getCompileCommands();
-
- /**
- * Returns the list of compiler tools for a given language.
- *
- * @param language
- * the language for the commands
- * @return the compile commands for the language
- * @since 6.1
- */
- default String[] getCompileCommands(ILanguage language) {
- return new String[0];
- }
-
- /**
- * Returns the list of resources referenced in a compile command.
- *
- * @param command
- * the compile command
- * @param buildDirectoryURI
- * the directory the compile command runs in
- * @return the list of resources referenced in the compile command
- * @since 6.1
- */
- default IResource[] getResourcesFromCommand(List<String> command, URI buildDirectoryURI) {
- return new IResource[0];
- }
-
- @Deprecated
- default IResource[] getResourcesFromCommand(String[] command, URI buildDirectoryURI) {
- return getResourcesFromCommand(Arrays.asList(command), buildDirectoryURI);
- }
-
- /**
- * Strips the resources from the compile command. Use to produce the common
- * parts of the command shared by a number of resources.
- *
- * @param command
- * the original compile command
- * @param resources
- * the resources this command compiles for usually returned by
- * getResourcesFromCommand()
- * @return the stripped command
- * @since 6.1
- */
- default List<String> stripCommand(List<String> command, IResource[] resources) {
- return command;
- }
-
- /**
- * @since 6.1
- */
- default boolean matches(Map<String, String> properties) {
- for (Map.Entry<String, String> property : properties.entrySet()) {
- if (!property.getValue().equals(getProperty(property.getKey()))) {
- return false;
- }
- }
- return true;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2016 QNX Software Systems 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
+ *******************************************************************************/
+package org.eclipse.cdt.core.build;
+
+import java.net.URI;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
+import org.eclipse.core.resources.IBuildConfiguration;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * Toolchains are a collection of tools that take the source code and converts
+ * it into an executable system.
+ *
+ * @since 6.0
+ */
+public interface IToolChain extends IAdaptable {
+
+ /**
+ * Property: The OS the toolchain builds for.
+ */
+ static final String ATTR_OS = "os"; //$NON-NLS-1$
+
+ /**
+ * Property: The CPU architecture the toolchain supports.
+ */
+ static final String ATTR_ARCH = "arch"; //$NON-NLS-1$
+
+ /**
+ * Property: A package ID to reflect different version/package line up of
+ * the platform this toolchain supports.
+ */
+ static final String ATTR_PACKAGE = "package"; //$NON-NLS-1$
+
+ /**
+ * The provider of the toolchain.
+ *
+ * @return toolchain provider
+ */
+ IToolChainProvider getProvider();
+
+ /**
+ * The ID of the toolchain
+ *
+ * @return toolchain ID
+ */
+ String getId();
+
+ /**
+ * The version of the toolchain
+ *
+ * @deprecated the version doesn't matter. id's for a given type must be unique.
+ * @return toolchain version
+ */
+ @Deprecated
+ String getVersion();
+
+ /**
+ * The user friendly name for the toolchain
+ *
+ * @return toolchain name
+ */
+ String getName();
+
+ /**
+ * The type id for the toolchain. The combination of type id and toolchain id
+ * uniquely identify the toolchain in the system.
+ *
+ * @since 6.4
+ */
+ default String getTypeId() {
+ // Subclasses really need to override this. There can be multiple providers for
+ // a given toolchain type.
+ return getProvider().getId();
+ }
+
+ /**
+ * Returns an property of the toolchain. Used to determine applicability of
+ * a toolchain for a given situation.
+ *
+ * @param key
+ * key of the property
+ * @return value of the property or null if the toolchain does not have that
+ * property
+ */
+ String getProperty(String key);
+
+ /**
+ * Set a property on the toolchain.
+ *
+ * @param key
+ * key of the property
+ * @param value
+ * value of the property
+ */
+ void setProperty(String key, String value);
+
+ /**
+ * Return the environment variables to be set when invoking the tools in the
+ * toolchain.
+ *
+ * @return environment variables
+ */
+ IEnvironmentVariable[] getVariables();
+
+ /**
+ * Return the environment variable of the given name used when invoking the
+ * toolchain.
+ *
+ * @param name
+ * environment variable name
+ * @return environment variable value
+ */
+ IEnvironmentVariable getVariable(String name);
+
+ /**
+ * Returns the error parser IDs use to create error markers for builds with
+ * this toolchain.
+ *
+ * @return error parser IDs
+ */
+ String[] getErrorParserIds();
+
+ /**
+ * Returns the IDs for the binary parsers that can parse the build output of
+ * the toolchain.
+ *
+ * @return binary parser IDs for this toolchain
+ */
+ String getBinaryParserId();
+
+ /**
+ * Get the scanner info for a given build config, command, base scanner
+ * info, resource and build directory.
+ *
+ * @param buildConfig
+ * the build configuration this scanner info applies to
+ * @param command
+ * the compile command that is used to build the resource
+ * @param baseScannerInfo
+ * base scanner info that this scanner info extends/replaces
+ * @param resource
+ * the resource this scanner info applies to, usually a source
+ * file
+ * @param buildDirectoryURI
+ * where the build command is run to build this resource
+ * @return scanner info for this resource
+ * @since 6.1
+ */
+ default IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, List<String> command,
+ IExtendedScannerInfo baseScannerInfo, IResource resource, URI buildDirectoryURI) {
+ return null;
+ }
+
+ @Deprecated
+ default IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, Path command, String[] args,
+ IExtendedScannerInfo baseScannerInfo, IResource resource, URI buildDirectoryURI) {
+ List<String> commandStrings = new ArrayList<>(args.length + 1);
+ commandStrings.add(command.toString());
+ commandStrings.addAll(Arrays.asList(args));
+ return getScannerInfo(buildConfig, commandStrings, baseScannerInfo, resource, buildDirectoryURI);
+ }
+
+ /**
+ * Return the default scanner info for this toolchain. This is used before
+ * any build information is available to provide at least a minimal scanner
+ * info based on the compiler built-ins.
+ *
+ * @param buildConfig
+ * the build configuration this scanner info applies to
+ * @param baseScannerInfo
+ * base scanner info that this scanner info extends/replaces
+ * @param language
+ * the source language that selects the tool to provide scanner
+ * info for
+ * @param buildDirectoryURI
+ * the build directory that would be used to run commands
+ * @returns default scanner info for this language
+ * @since 6.1
+ */
+ default IExtendedScannerInfo getDefaultScannerInfo(IBuildConfiguration buildConfig,
+ IExtendedScannerInfo baseScannerInfo, ILanguage language, URI buildDirectoryURI) {
+ return null;
+ }
+
+ /**
+ * Returns the absolute path of the tool represented by the command
+ *
+ * @param command
+ * the command as it usually appears on the command line
+ * @return the absolute path to the tool for the command
+ */
+ Path getCommandPath(Path command);
+
+ /**
+ * Returns the list of compiler tools.
+ *
+ * @return list of compiler tools
+ */
+ String[] getCompileCommands();
+
+ /**
+ * Returns the list of compiler tools for a given language.
+ *
+ * @param language
+ * the language for the commands
+ * @return the compile commands for the language
+ * @since 6.1
+ */
+ default String[] getCompileCommands(ILanguage language) {
+ return new String[0];
+ }
+
+ /**
+ * Returns the list of resources referenced in a compile command.
+ *
+ * @param command
+ * the compile command
+ * @param buildDirectoryURI
+ * the directory the compile command runs in
+ * @return the list of resources referenced in the compile command
+ * @since 6.1
+ */
+ default IResource[] getResourcesFromCommand(List<String> command, URI buildDirectoryURI) {
+ return new IResource[0];
+ }
+
+ @Deprecated
+ default IResource[] getResourcesFromCommand(String[] command, URI buildDirectoryURI) {
+ return getResourcesFromCommand(Arrays.asList(command), buildDirectoryURI);
+ }
+
+ /**
+ * Strips the resources from the compile command. Use to produce the common
+ * parts of the command shared by a number of resources.
+ *
+ * @param command
+ * the original compile command
+ * @param resources
+ * the resources this command compiles for usually returned by
+ * getResourcesFromCommand()
+ * @return the stripped command
+ * @since 6.1
+ */
+ default List<String> stripCommand(List<String> command, IResource[] resources) {
+ return command;
+ }
+
+ /**
+ * @since 6.1
+ */
+ default boolean matches(Map<String, String> properties) {
+ for (Map.Entry<String, String> property : properties.entrySet()) {
+ if (!property.getValue().equals(getProperty(property.getKey()))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamProgressMonitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamProgressMonitor.java
index 551401d8e6a..aa7f7d2f31e 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamProgressMonitor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamProgressMonitor.java
@@ -1,109 +1,109 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
+/*******************************************************************************
+ * Copyright (c) 2000, 2012 QNX Software Systems 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:
+ * QNX Software Systems - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.internal.core;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Helper class to report progress of the build via {@link IProgressMonitor}
- */
-public class StreamProgressMonitor extends OutputStream {
-
- private IProgressMonitor monitor;
- private OutputStream console;
- private final int fTotalWork;
- private int halfWay;
- private int currentIncrement = 2;
- private int nextProgress = currentIncrement;
- private int worked = 0;
-
- public StreamProgressMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
- monitor = mon;
- console = cos;
- fTotalWork = totalWork;
- halfWay = fTotalWork / 2;
- monitor.beginTask("", fTotalWork); //$NON-NLS-1$
- }
-
- private void progressUpdate() {
- if (--nextProgress <= 0) {
- //we have exhausted the current increment, so report progress
- if (fTotalWork > worked) {
- monitor.worked(1);
- }
- worked++;
- if (worked >= halfWay) {
- //we have passed the current halfway point, so double the
- //increment and reset the halfway point.
- currentIncrement *= 2;
- halfWay += (fTotalWork - halfWay) / 2;
- }
- //reset the progress counter to another full increment
- nextProgress = currentIncrement;
- }
- }
- /**
- * @see java.io.OutputStream#close()
- */
- @Override
- public void close() throws IOException {
- if (console != null) {
- console.close();
- }
- monitor.done();
- }
-
- /**
- * @see java.io.OutputStream#flush()
- */
- @Override
- public void flush() throws IOException {
- if (console != null) {
- console.flush();
- }
- }
-
- /**
- * @see java.io.OutputStream#write(int)
- */
- @Override
- public synchronized void write(int b) throws IOException {
- if (console != null) {
- console.write(b);
- }
- progressUpdate();
- }
-
- /**
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- @Override
- public synchronized void write(byte[] b, int off, int len) throws IOException {
- if (b == null) {
- throw new NullPointerException();
- } else if (off != 0 || (len < 0) || (len > b.length)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return;
- }
- if (console != null) {
- console.write(b, off, len);
- }
- progressUpdate();
- }
-
- public int getWorkDone() {
- return worked;
- }
-}
+package org.eclipse.cdt.internal.core;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Helper class to report progress of the build via {@link IProgressMonitor}
+ */
+public class StreamProgressMonitor extends OutputStream {
+
+ private IProgressMonitor monitor;
+ private OutputStream console;
+ private final int fTotalWork;
+ private int halfWay;
+ private int currentIncrement = 2;
+ private int nextProgress = currentIncrement;
+ private int worked = 0;
+
+ public StreamProgressMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
+ monitor = mon;
+ console = cos;
+ fTotalWork = totalWork;
+ halfWay = fTotalWork / 2;
+ monitor.beginTask("", fTotalWork); //$NON-NLS-1$
+ }
+
+ private void progressUpdate() {
+ if (--nextProgress <= 0) {
+ //we have exhausted the current increment, so report progress
+ if (fTotalWork > worked) {
+ monitor.worked(1);
+ }
+ worked++;
+ if (worked >= halfWay) {
+ //we have passed the current halfway point, so double the
+ //increment and reset the halfway point.
+ currentIncrement *= 2;
+ halfWay += (fTotalWork - halfWay) / 2;
+ }
+ //reset the progress counter to another full increment
+ nextProgress = currentIncrement;
+ }
+ }
+ /**
+ * @see java.io.OutputStream#close()
+ */
+ @Override
+ public void close() throws IOException {
+ if (console != null) {
+ console.close();
+ }
+ monitor.done();
+ }
+
+ /**
+ * @see java.io.OutputStream#flush()
+ */
+ @Override
+ public void flush() throws IOException {
+ if (console != null) {
+ console.flush();
+ }
+ }
+
+ /**
+ * @see java.io.OutputStream#write(int)
+ */
+ @Override
+ public synchronized void write(int b) throws IOException {
+ if (console != null) {
+ console.write(b);
+ }
+ progressUpdate();
+ }
+
+ /**
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ @Override
+ public synchronized void write(byte[] b, int off, int len) throws IOException {
+ if (b == null) {
+ throw new NullPointerException();
+ } else if (off != 0 || (len < 0) || (len > b.length)) {
+ throw new IndexOutOfBoundsException();
+ } else if (len == 0) {
+ return;
+ }
+ if (console != null) {
+ console.write(b, off, len);
+ }
+ progressUpdate();
+ }
+
+ public int getWorkDone() {
+ return worked;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java
index 889fade0c6c..176312db830 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java
@@ -1,64 +1,64 @@
-/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.envvar;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.build.ICBuildConfiguration;
-import org.eclipse.cdt.core.build.IToolChain;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.core.resources.IBuildConfiguration;
-import org.eclipse.core.runtime.CoreException;
-
-public class ToolChainEnvironmentSupplier implements ICoreEnvironmentVariableSupplier {
-
- @Override
- public IEnvironmentVariable getVariable(String name, Object context) {
- if (context instanceof IBuildConfiguration) {
- ICBuildConfiguration config = ((IBuildConfiguration) context)
- .getAdapter(ICBuildConfiguration.class);
- if (config != null) {
- try {
- IToolChain toolChain = config.getToolChain();
- if (toolChain != null) {
- return toolChain.getVariable(name);
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- return null;
- }
- }
- }
- return null;
- }
-
- @Override
- public IEnvironmentVariable[] getVariables(Object context) {
- if (context instanceof IBuildConfiguration) {
- ICBuildConfiguration config = ((IBuildConfiguration) context)
- .getAdapter(ICBuildConfiguration.class);
- if (config != null) {
- try {
- IToolChain toolChain = config.getToolChain();
- if (toolChain != null) {
- return toolChain.getVariables();
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- return null;
- }
- }
- }
- return null;
- }
-
- @Override
- public boolean appendEnvironment(Object context) {
- return true;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2016 QNX Software Systems 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
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.envvar;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.core.resources.IBuildConfiguration;
+import org.eclipse.core.runtime.CoreException;
+
+public class ToolChainEnvironmentSupplier implements ICoreEnvironmentVariableSupplier {
+
+ @Override
+ public IEnvironmentVariable getVariable(String name, Object context) {
+ if (context instanceof IBuildConfiguration) {
+ ICBuildConfiguration config = ((IBuildConfiguration) context)
+ .getAdapter(ICBuildConfiguration.class);
+ if (config != null) {
+ try {
+ IToolChain toolChain = config.getToolChain();
+ if (toolChain != null) {
+ return toolChain.getVariable(name);
+ }
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public IEnvironmentVariable[] getVariables(Object context) {
+ if (context instanceof IBuildConfiguration) {
+ ICBuildConfiguration config = ((IBuildConfiguration) context)
+ .getAdapter(ICBuildConfiguration.class);
+ if (config != null) {
+ try {
+ IToolChain toolChain = config.getToolChain();
+ if (toolChain != null) {
+ return toolChain.getVariables();
+ }
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean appendEnvironment(Object context) {
+ return true;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java
index 265ee19d3a4..058b50fb320 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java
@@ -1,44 +1,44 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems 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:
- * Doug Schaefer - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.templateengine;
-
-import java.util.List;
-
-/**
- * @author Doug Schaefer
- * @since 5.4
- */
-public class TemplateCategory {
-
- private final String id;
- private String label;
- private List<String> parentCategoryIds;
-
- public TemplateCategory(String id, String label, List<String> parentCategoryIds) {
- this.id = id;
- this.label = label;
- this.parentCategoryIds = parentCategoryIds;
- }
-
- public String getId() {
- return id;
- }
-
- public String getLabel() {
- return label;
- }
-
- public List<String> getParentCategoryIds() {
- return parentCategoryIds;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems 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:
+ * Doug Schaefer - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.templateengine;
+
+import java.util.List;
+
+/**
+ * @author Doug Schaefer
+ * @since 5.4
+ */
+public class TemplateCategory {
+
+ private final String id;
+ private String label;
+ private List<String> parentCategoryIds;
+
+ public TemplateCategory(String id, String label, List<String> parentCategoryIds) {
+ this.id = id;
+ this.label = label;
+ this.parentCategoryIds = parentCategoryIds;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public List<String> getParentCategoryIds() {
+ return parentCategoryIds;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java
index 1e172ca620c..a6aa4c1d247 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java
@@ -1,33 +1,33 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems 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:
- * Doug Schaefer - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.templateengine;
-
-/**
- * @author Doug Schaefer
- * @since 5.4
- */
-public class TemplateEngine2 extends TemplateEngine {
-
- /**
- * Project type for new templates. Default if not set in extension.
- */
- public static final String NEW_TEMPLATE = "newTemplate"; //$NON-NLS-1$
-
- public static TemplateEngine2 getDefault() {
- return (TemplateEngine2)TemplateEngine.getDefault();
- }
-
- public TemplateCategory getCategory(String id) {
- return categoryMap.get(id);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems 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:
+ * Doug Schaefer - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.templateengine;
+
+/**
+ * @author Doug Schaefer
+ * @since 5.4
+ */
+public class TemplateEngine2 extends TemplateEngine {
+
+ /**
+ * Project type for new templates. Default if not set in extension.
+ */
+ public static final String NEW_TEMPLATE = "newTemplate"; //$NON-NLS-1$
+
+ public static TemplateEngine2 getDefault() {
+ return (TemplateEngine2)TemplateEngine.getDefault();
+ }
+
+ public TemplateCategory getCategory(String id) {
+ return categoryMap.get(id);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java
index 478e0cf2618..5a11b23ed4f 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java
@@ -1,39 +1,39 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems 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:
- * Doug Schaefer - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.templateengine;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Template info extended to include new stuff for new new project wizard UI.
- *
- * @author Doug Schaefer
- * @since 5.4
- */
-public class TemplateInfo2 extends TemplateInfo {
-
- private List<String> parentCategoryIds;
-
- public TemplateInfo2(String templateId, String projectTypeId, String filterPattern,
- String templatePath, String pluginId, Set<String> toolChainIdSet,
- Object extraPagesProvider, boolean isCategory, List<String> parentCategoryIds) {
- super(templateId, projectTypeId, filterPattern, templatePath, pluginId, toolChainIdSet,
- extraPagesProvider, isCategory);
- this.parentCategoryIds = parentCategoryIds;
- }
-
- public List<String> getParentCategoryIds() {
- return parentCategoryIds;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems 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:
+ * Doug Schaefer - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.templateengine;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Template info extended to include new stuff for new new project wizard UI.
+ *
+ * @author Doug Schaefer
+ * @since 5.4
+ */
+public class TemplateInfo2 extends TemplateInfo {
+
+ private List<String> parentCategoryIds;
+
+ public TemplateInfo2(String templateId, String projectTypeId, String filterPattern,
+ String templatePath, String pluginId, Set<String> toolChainIdSet,
+ Object extraPagesProvider, boolean isCategory, List<String> parentCategoryIds) {
+ super(templateId, projectTypeId, filterPattern, templatePath, pluginId, toolChainIdSet,
+ extraPagesProvider, isCategory);
+ this.parentCategoryIds = parentCategoryIds;
+ }
+
+ public List<String> getParentCategoryIds() {
+ return parentCategoryIds;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java
index 902f6e1ba54..80884db7c83 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java
@@ -1,333 +1,333 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Collections;
-import java.util.Map;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.cdt.utils.WindowsRegistry;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * A collection of cygwin-related utilities.
- */
-public class Cygwin {
- public static final String ENV_CYGWIN_HOME = "CYGWIN_HOME"; //$NON-NLS-1$
- private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
-
- private static final String CYGPATH = "cygpath"; //$NON-NLS-1$
- private static final String DEFAULT_ROOT = "C:\\cygwin"; //$NON-NLS-1$
- private static final String CYGWIN_DLL = "cygwin1.dll"; //$NON-NLS-1$
- private static final String REGISTRY_KEY_SETUP = "SOFTWARE\\Cygwin\\setup"; //$NON-NLS-1$
- private static final String REGISTRY_KEY_SETUP_WIN64 = "SOFTWARE\\Wow6432Node\\Cygwin\\setup"; //$NON-NLS-1$
- // note that in Cygwin 1.7 the mount point storage has been moved out of the registry
- private static final String REGISTRY_KEY_MOUNTS = "SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\"; //$NON-NLS-1$
- private static final String PATH_NAME = "native"; //$NON-NLS-1$
- private static final String ROOTPATTERN = "/"; //$NON-NLS-1$
- private static final char SLASH = '/';
- private static final char BACKSLASH = '\\';
-
- private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32);
-
- private static String envPathValueCached = null;
- private static String envCygwinHomeValueCached = null;
- private static String cygwinLocation = null;
- private static boolean isCygwinLocationCached = false;
-
- private final static Map<String/*envPath*/, String /*cygpathLocation*/> cygpathLocationCache = Collections.synchronizedMap(new LRUCache<String, String>(1,20));
- private final static Map<String/*command*/, String /*translatedPath*/> translatedPathsCache = Collections.synchronizedMap(new LRUCache<String, String>(10,500));
-
- /**
- * Find location of "cygpath" utility on the file system.
- */
- private static String findCygpathLocation(String envPath) {
- if (envPath == null) {
- // $PATH from user preferences
- IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
- if (varPath != null) {
- envPath = varPath.getValue();
- }
- }
-
- String cygpathLocation = cygpathLocationCache.get(envPath);
- if (cygpathLocation == null) {
- IPath loc = PathUtil.findProgramLocation(CYGPATH, envPath);
- cygpathLocation = loc != null ? loc.toOSString() : null;
- cygpathLocationCache.put(envPath, cygpathLocation);
- }
- return cygpathLocation;
- }
-
- /**
- * Check if cygwin path conversion utilities are available in the path.
- * Tells whether cygwin is installed in the path.
- *
- * @param envPath - list of directories to search for cygwin utilities separated
- * by path separator (format of environment variable $PATH)
- * or {@code null} to use current $PATH.
- * @return {@code true} if cygwin is available, {@code false} otherwise.
- */
- public static boolean isAvailable(String envPath) {
- return isWindowsPlatform && findCygpathLocation(envPath) != null;
- }
-
- /**
- * Check if cygwin path conversion utilities are available in $PATH.
- * Tells whether cygwin is installed in the path.
- *
- * @return {@code true} if cygwin is available, {@code false} otherwise.
- */
- public static boolean isAvailable() {
- return isWindowsPlatform && findCygpathLocation(null) != null;
- }
-
- /**
- * Run program (assuming cygpath) and return the translated path which is the first line of output.
- */
- private static String runCygpath(String[] args) throws IOException {
- String command = getCommand(args);
- String translatedPath = translatedPathsCache.get(command);
- if (translatedPath == null) {
- Process cygpathProcess = Runtime.getRuntime().exec(args);
- BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpathProcess.getInputStream()));
- String firstLine = null;
- try {
- firstLine = stdout.readLine();
- } finally {
- stdout.close();
- }
- if (firstLine == null) {
- throw new IOException("Unable read output from command=[" + command + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- translatedPath = firstLine.trim();
- translatedPathsCache.put(command, translatedPath);
- }
-
- return translatedPath;
- }
-
- /**
- * Construct a command from arguments array.
- */
- private static String getCommand(String[] args) {
- String command = ""; //$NON-NLS-1$
- for (String arg : args) {
- command = command + arg + ' ';
- }
- return command.trim();
- }
-
- /**
- * Conversion from Cygwin path to Windows path.
- * Note that there is no need to cache results, they are already cached internally.
- *
- * @param cygwinPath - cygwin path.
- * @param envPath - list of directories to search for cygwin utilities separated
- * by path separator (format of environment variable $PATH).
- * @return Windows style converted path. Note that that also converts cygwin links to their targets.
- *
- * @throws UnsupportedOperationException if Cygwin is unavailable.
- * @throws IOException on IO problem.
- */
- public static String cygwinToWindowsPath(String cygwinPath, String envPath) throws IOException, UnsupportedOperationException {
- if (cygwinPath == null || cygwinPath.trim().length() == 0)
- return cygwinPath;
-
- if (!isWindowsPlatform) {
- throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
- }
-
- String cygpathLocation = findCygpathLocation(envPath);
- if (cygpathLocation == null) {
- throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$
- }
-
- String windowsPath = runCygpath(new String[] {cygpathLocation, "-w", cygwinPath}); //$NON-NLS-1$
- return windowsPath;
- }
-
- /**
- * Conversion from Cygwin path to Windows path.
- * Note that there is no need to cache results, they are already cached internally.
- *
- * @param cygwinPath - cygwin path.
- * @return Windows style converted path. Note that that also converts cygwin links to their targets.
- *
- * @throws UnsupportedOperationException if Cygwin is unavailable.
- * @throws IOException on IO problem.
- */
- public static String cygwinToWindowsPath(String cygwinPath) throws IOException, UnsupportedOperationException {
- return cygwinToWindowsPath(cygwinPath, null);
- }
-
- /**
- * Conversion from Windows path to Cygwin path.
- * Note that there is no need to cache results, they are already cached internally.
- *
- * @param windowsPath - Windows path.
- * @param envPath - list of directories to search for cygwin utilities (value of environment variable $PATH).
- * @return Cygwin style converted path.
- *
- * @throws UnsupportedOperationException if Cygwin is unavailable.
- * @throws IOException on IO problem.
- */
- public static String windowsToCygwinPath(String windowsPath, String envPath) throws IOException, UnsupportedOperationException {
- if (windowsPath == null || windowsPath.trim().length() == 0)
- return windowsPath;
-
- if (!isWindowsPlatform) {
- throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
- }
-
- String cygpathLocation = findCygpathLocation(envPath);
- if (cygpathLocation == null) {
- throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$
- }
-
- String cygwinPath = runCygpath(new String[] {cygpathLocation, "-u", windowsPath}); //$NON-NLS-1$
- return cygwinPath;
- }
-
- /**
- * Conversion from Windows path to Cygwin path.
- * Note that there is no need to cache results, they are already cached internally.
- *
- * @param windowsPath - Windows path.
- * @return Cygwin style converted path.
- *
- * @throws UnsupportedOperationException if Cygwin is unavailable.
- * @throws IOException on IO problem.
- */
- public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException {
- return windowsToCygwinPath(windowsPath, null);
- }
-
- /**
- * Find location where Cygwin is installed. A number of locations is being checked,
- * such as environment variable $CYGWIN_HOME, $PATH, Windows registry et al.
- * <br><br>
- * If you use this do not cache results to ensure user preferences are accounted for.
- * Please rely on internal caching.
- *
- * @return Location of Cygwin root folder "/" on file system in Windows format.
- */
- public static String getCygwinHome() {
- if (!isWindowsPlatform) {
- return null;
- }
-
- IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
- String envPathValue = varPath != null ? varPath.getValue() : null;
- IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_CYGWIN_HOME, (ICConfigurationDescription) null, true);
- String envCygwinHomeValue = varCygwinHome != null ? varCygwinHome.getValue() : null;
-
- // isCygwinLocationCached is used to figure fact of caching when all cached objects are null
- if (isCygwinLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached) && CDataUtil.objectsEqual(envCygwinHomeValue, envCygwinHomeValueCached)) {
- return cygwinLocation;
- }
-
- cygwinLocation = findCygwinRoot(envPathValue, envCygwinHomeValue);
-
- envPathValueCached = envPathValue;
- envCygwinHomeValueCached = envCygwinHomeValue;
- isCygwinLocationCached = true;
-
- return cygwinLocation;
- }
-
- /**
- * Reads required value from registry. Looks in both
- * HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE
- *
- * @param key Registry key
- * @param name Registry value to read
- * @return corresponding string value or null if nothing found
- */
- private static String readValueFromRegistry(String key, String name) {
- WindowsRegistry registry = WindowsRegistry.getRegistry();
- if (registry != null) {
- String s = registry.getCurrentUserValue(key, name);
- if(s == null) {
- s = registry.getLocalMachineValue(key, name);
- }
-
- if (s != null) {
- return (s.replace(BACKSLASH, SLASH));
- }
- }
- return null;
- }
-
- /**
- * @return The absolute path to cygwin's root or null if not found
- */
- private static String findCygwinRoot(String envPathValue, String envCygwinHomeValue) {
- String rootValue = null;
-
- // Check $CYGWIN_HOME
- if (envCygwinHomeValue != null && !envCygwinHomeValue.isEmpty()) {
- IPath location = new Path(envCygwinHomeValue + "/bin/" + CYGWIN_DLL); //$NON-NLS-1$
- if (location.toFile().exists()) {
- // get rootValue from "rootValue\bin\cygwin1.dll"
- rootValue = location.removeLastSegments(2).toOSString();
- }
- }
-
- // Look in PATH values. Look for cygwin1.dll
- if(rootValue == null) {
- IPath location = PathUtil.findProgramLocation(CYGWIN_DLL, envPathValue);
- if (location != null) {
- // get rootValue from "rootValue\bin\cygwin1.dll"
- rootValue = location.removeLastSegments(2).toOSString();
- }
- }
-
- // Try to find the root dir in SOFTWARE\Cygwin\setup
- if(rootValue == null) {
- rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP, "rootdir"); //$NON-NLS-1$
- }
-
- // Try to find the root dir in SOFTWARE\Wow6432Node\Cygwin\setup
- if(rootValue == null) {
- rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP_WIN64, "rootdir"); //$NON-NLS-1$
- }
-
- // Try to find the root dir in SOFTWARE\Cygnus Solutions
- if (rootValue == null) {
- rootValue = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ROOTPATTERN, PATH_NAME);
- }
-
- // Try the default Cygwin install dir
- if(rootValue == null) {
- File file = new File(DEFAULT_ROOT);
- if (file.exists() && file.isDirectory())
- rootValue = DEFAULT_ROOT;
- }
-
- if(rootValue != null) {
- rootValue = rootValue.replace(BACKSLASH, SLASH);
- }
-
- return rootValue;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.utils.PathUtil;
+import org.eclipse.cdt.utils.WindowsRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * A collection of cygwin-related utilities.
+ */
+public class Cygwin {
+ public static final String ENV_CYGWIN_HOME = "CYGWIN_HOME"; //$NON-NLS-1$
+ private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
+
+ private static final String CYGPATH = "cygpath"; //$NON-NLS-1$
+ private static final String DEFAULT_ROOT = "C:\\cygwin"; //$NON-NLS-1$
+ private static final String CYGWIN_DLL = "cygwin1.dll"; //$NON-NLS-1$
+ private static final String REGISTRY_KEY_SETUP = "SOFTWARE\\Cygwin\\setup"; //$NON-NLS-1$
+ private static final String REGISTRY_KEY_SETUP_WIN64 = "SOFTWARE\\Wow6432Node\\Cygwin\\setup"; //$NON-NLS-1$
+ // note that in Cygwin 1.7 the mount point storage has been moved out of the registry
+ private static final String REGISTRY_KEY_MOUNTS = "SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\"; //$NON-NLS-1$
+ private static final String PATH_NAME = "native"; //$NON-NLS-1$
+ private static final String ROOTPATTERN = "/"; //$NON-NLS-1$
+ private static final char SLASH = '/';
+ private static final char BACKSLASH = '\\';
+
+ private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32);
+
+ private static String envPathValueCached = null;
+ private static String envCygwinHomeValueCached = null;
+ private static String cygwinLocation = null;
+ private static boolean isCygwinLocationCached = false;
+
+ private final static Map<String/*envPath*/, String /*cygpathLocation*/> cygpathLocationCache = Collections.synchronizedMap(new LRUCache<String, String>(1,20));
+ private final static Map<String/*command*/, String /*translatedPath*/> translatedPathsCache = Collections.synchronizedMap(new LRUCache<String, String>(10,500));
+
+ /**
+ * Find location of "cygpath" utility on the file system.
+ */
+ private static String findCygpathLocation(String envPath) {
+ if (envPath == null) {
+ // $PATH from user preferences
+ IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
+ if (varPath != null) {
+ envPath = varPath.getValue();
+ }
+ }
+
+ String cygpathLocation = cygpathLocationCache.get(envPath);
+ if (cygpathLocation == null) {
+ IPath loc = PathUtil.findProgramLocation(CYGPATH, envPath);
+ cygpathLocation = loc != null ? loc.toOSString() : null;
+ cygpathLocationCache.put(envPath, cygpathLocation);
+ }
+ return cygpathLocation;
+ }
+
+ /**
+ * Check if cygwin path conversion utilities are available in the path.
+ * Tells whether cygwin is installed in the path.
+ *
+ * @param envPath - list of directories to search for cygwin utilities separated
+ * by path separator (format of environment variable $PATH)
+ * or {@code null} to use current $PATH.
+ * @return {@code true} if cygwin is available, {@code false} otherwise.
+ */
+ public static boolean isAvailable(String envPath) {
+ return isWindowsPlatform && findCygpathLocation(envPath) != null;
+ }
+
+ /**
+ * Check if cygwin path conversion utilities are available in $PATH.
+ * Tells whether cygwin is installed in the path.
+ *
+ * @return {@code true} if cygwin is available, {@code false} otherwise.
+ */
+ public static boolean isAvailable() {
+ return isWindowsPlatform && findCygpathLocation(null) != null;
+ }
+
+ /**
+ * Run program (assuming cygpath) and return the translated path which is the first line of output.
+ */
+ private static String runCygpath(String[] args) throws IOException {
+ String command = getCommand(args);
+ String translatedPath = translatedPathsCache.get(command);
+ if (translatedPath == null) {
+ Process cygpathProcess = Runtime.getRuntime().exec(args);
+ BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpathProcess.getInputStream()));
+ String firstLine = null;
+ try {
+ firstLine = stdout.readLine();
+ } finally {
+ stdout.close();
+ }
+ if (firstLine == null) {
+ throw new IOException("Unable read output from command=[" + command + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ translatedPath = firstLine.trim();
+ translatedPathsCache.put(command, translatedPath);
+ }
+
+ return translatedPath;
+ }
+
+ /**
+ * Construct a command from arguments array.
+ */
+ private static String getCommand(String[] args) {
+ String command = ""; //$NON-NLS-1$
+ for (String arg : args) {
+ command = command + arg + ' ';
+ }
+ return command.trim();
+ }
+
+ /**
+ * Conversion from Cygwin path to Windows path.
+ * Note that there is no need to cache results, they are already cached internally.
+ *
+ * @param cygwinPath - cygwin path.
+ * @param envPath - list of directories to search for cygwin utilities separated
+ * by path separator (format of environment variable $PATH).
+ * @return Windows style converted path. Note that that also converts cygwin links to their targets.
+ *
+ * @throws UnsupportedOperationException if Cygwin is unavailable.
+ * @throws IOException on IO problem.
+ */
+ public static String cygwinToWindowsPath(String cygwinPath, String envPath) throws IOException, UnsupportedOperationException {
+ if (cygwinPath == null || cygwinPath.trim().length() == 0)
+ return cygwinPath;
+
+ if (!isWindowsPlatform) {
+ throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
+ }
+
+ String cygpathLocation = findCygpathLocation(envPath);
+ if (cygpathLocation == null) {
+ throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$
+ }
+
+ String windowsPath = runCygpath(new String[] {cygpathLocation, "-w", cygwinPath}); //$NON-NLS-1$
+ return windowsPath;
+ }
+
+ /**
+ * Conversion from Cygwin path to Windows path.
+ * Note that there is no need to cache results, they are already cached internally.
+ *
+ * @param cygwinPath - cygwin path.
+ * @return Windows style converted path. Note that that also converts cygwin links to their targets.
+ *
+ * @throws UnsupportedOperationException if Cygwin is unavailable.
+ * @throws IOException on IO problem.
+ */
+ public static String cygwinToWindowsPath(String cygwinPath) throws IOException, UnsupportedOperationException {
+ return cygwinToWindowsPath(cygwinPath, null);
+ }
+
+ /**
+ * Conversion from Windows path to Cygwin path.
+ * Note that there is no need to cache results, they are already cached internally.
+ *
+ * @param windowsPath - Windows path.
+ * @param envPath - list of directories to search for cygwin utilities (value of environment variable $PATH).
+ * @return Cygwin style converted path.
+ *
+ * @throws UnsupportedOperationException if Cygwin is unavailable.
+ * @throws IOException on IO problem.
+ */
+ public static String windowsToCygwinPath(String windowsPath, String envPath) throws IOException, UnsupportedOperationException {
+ if (windowsPath == null || windowsPath.trim().length() == 0)
+ return windowsPath;
+
+ if (!isWindowsPlatform) {
+ throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
+ }
+
+ String cygpathLocation = findCygpathLocation(envPath);
+ if (cygpathLocation == null) {
+ throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$
+ }
+
+ String cygwinPath = runCygpath(new String[] {cygpathLocation, "-u", windowsPath}); //$NON-NLS-1$
+ return cygwinPath;
+ }
+
+ /**
+ * Conversion from Windows path to Cygwin path.
+ * Note that there is no need to cache results, they are already cached internally.
+ *
+ * @param windowsPath - Windows path.
+ * @return Cygwin style converted path.
+ *
+ * @throws UnsupportedOperationException if Cygwin is unavailable.
+ * @throws IOException on IO problem.
+ */
+ public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException {
+ return windowsToCygwinPath(windowsPath, null);
+ }
+
+ /**
+ * Find location where Cygwin is installed. A number of locations is being checked,
+ * such as environment variable $CYGWIN_HOME, $PATH, Windows registry et al.
+ * <br><br>
+ * If you use this do not cache results to ensure user preferences are accounted for.
+ * Please rely on internal caching.
+ *
+ * @return Location of Cygwin root folder "/" on file system in Windows format.
+ */
+ public static String getCygwinHome() {
+ if (!isWindowsPlatform) {
+ return null;
+ }
+
+ IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
+ String envPathValue = varPath != null ? varPath.getValue() : null;
+ IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_CYGWIN_HOME, (ICConfigurationDescription) null, true);
+ String envCygwinHomeValue = varCygwinHome != null ? varCygwinHome.getValue() : null;
+
+ // isCygwinLocationCached is used to figure fact of caching when all cached objects are null
+ if (isCygwinLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached) && CDataUtil.objectsEqual(envCygwinHomeValue, envCygwinHomeValueCached)) {
+ return cygwinLocation;
+ }
+
+ cygwinLocation = findCygwinRoot(envPathValue, envCygwinHomeValue);
+
+ envPathValueCached = envPathValue;
+ envCygwinHomeValueCached = envCygwinHomeValue;
+ isCygwinLocationCached = true;
+
+ return cygwinLocation;
+ }
+
+ /**
+ * Reads required value from registry. Looks in both
+ * HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE
+ *
+ * @param key Registry key
+ * @param name Registry value to read
+ * @return corresponding string value or null if nothing found
+ */
+ private static String readValueFromRegistry(String key, String name) {
+ WindowsRegistry registry = WindowsRegistry.getRegistry();
+ if (registry != null) {
+ String s = registry.getCurrentUserValue(key, name);
+ if(s == null) {
+ s = registry.getLocalMachineValue(key, name);
+ }
+
+ if (s != null) {
+ return (s.replace(BACKSLASH, SLASH));
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return The absolute path to cygwin's root or null if not found
+ */
+ private static String findCygwinRoot(String envPathValue, String envCygwinHomeValue) {
+ String rootValue = null;
+
+ // Check $CYGWIN_HOME
+ if (envCygwinHomeValue != null && !envCygwinHomeValue.isEmpty()) {
+ IPath location = new Path(envCygwinHomeValue + "/bin/" + CYGWIN_DLL); //$NON-NLS-1$
+ if (location.toFile().exists()) {
+ // get rootValue from "rootValue\bin\cygwin1.dll"
+ rootValue = location.removeLastSegments(2).toOSString();
+ }
+ }
+
+ // Look in PATH values. Look for cygwin1.dll
+ if(rootValue == null) {
+ IPath location = PathUtil.findProgramLocation(CYGWIN_DLL, envPathValue);
+ if (location != null) {
+ // get rootValue from "rootValue\bin\cygwin1.dll"
+ rootValue = location.removeLastSegments(2).toOSString();
+ }
+ }
+
+ // Try to find the root dir in SOFTWARE\Cygwin\setup
+ if(rootValue == null) {
+ rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP, "rootdir"); //$NON-NLS-1$
+ }
+
+ // Try to find the root dir in SOFTWARE\Wow6432Node\Cygwin\setup
+ if(rootValue == null) {
+ rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP_WIN64, "rootdir"); //$NON-NLS-1$
+ }
+
+ // Try to find the root dir in SOFTWARE\Cygnus Solutions
+ if (rootValue == null) {
+ rootValue = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ROOTPATTERN, PATH_NAME);
+ }
+
+ // Try the default Cygwin install dir
+ if(rootValue == null) {
+ File file = new File(DEFAULT_ROOT);
+ if (file.exists() && file.isDirectory())
+ rootValue = DEFAULT_ROOT;
+ }
+
+ if(rootValue != null) {
+ rootValue = rootValue.replace(BACKSLASH, SLASH);
+ }
+
+ return rootValue;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/LRUCache.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/LRUCache.java
index 817613c6406..df63401266e 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/LRUCache.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/LRUCache.java
@@ -1,50 +1,50 @@
-/*******************************************************************************
- * Copyright (c) 2013 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core;
-
-import java.util.LinkedHashMap;
-import java.util.Map.Entry;
-
-/**
- * A simple cache with limited number of items in the cache. LRUCache discards the Least Recently Used items first.
- * Based on {@link LinkedHashMap}. Note that {@link LinkedHashMap} has built-in facility to support cache like that
- * which is described in its JavaDoc.
- */
-public class LRUCache<K, V> extends LinkedHashMap<K, V> {
- private int fLimit;
-
- /**
- * Constructs an empty LRUCache with the specified limit on the number of items in the cache.
- *
- * @param limit - the maximum number of items to keep in the cache.
- */
- public LRUCache(int limit) {
- super(limit, 0.75f, true);
- fLimit= limit;
- }
-
- /**
- * Constructs an empty LRUCache with the specified initial capacity and limit on the number of items in the cache.
- *
- * @param initialCapacity - initial capacity.
- * @param limit - the maximum number of items to keep in the cache.
- */
- public LRUCache(int initialCapacity, int limit) {
- super(initialCapacity, 0.75f, true);
- fLimit= limit;
- }
-
- @Override
- protected boolean removeEldestEntry(Entry<K, V> eldest) {
- return size() >= fLimit;
- }
+/*******************************************************************************
+ * Copyright (c) 2013 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.core;
+
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
+
+/**
+ * A simple cache with limited number of items in the cache. LRUCache discards the Least Recently Used items first.
+ * Based on {@link LinkedHashMap}. Note that {@link LinkedHashMap} has built-in facility to support cache like that
+ * which is described in its JavaDoc.
+ */
+public class LRUCache<K, V> extends LinkedHashMap<K, V> {
+ private int fLimit;
+
+ /**
+ * Constructs an empty LRUCache with the specified limit on the number of items in the cache.
+ *
+ * @param limit - the maximum number of items to keep in the cache.
+ */
+ public LRUCache(int limit) {
+ super(limit, 0.75f, true);
+ fLimit= limit;
+ }
+
+ /**
+ * Constructs an empty LRUCache with the specified initial capacity and limit on the number of items in the cache.
+ *
+ * @param initialCapacity - initial capacity.
+ * @param limit - the maximum number of items to keep in the cache.
+ */
+ public LRUCache(int initialCapacity, int limit) {
+ super(initialCapacity, 0.75f, true);
+ fLimit= limit;
+ }
+
+ @Override
+ protected boolean removeEldestEntry(Entry<K, V> eldest) {
+ return size() >= fLimit;
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java
index ad62fc2378b..e1cbceb5888 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java
@@ -1,359 +1,359 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.cdt.utils.WindowsRegistry;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * A collection of MinGW-related utility methods.
- */
-public class MinGW {
- public static final String ENV_MINGW_HOME = "MINGW_HOME"; //$NON-NLS-1$
- public static final String ENV_MSYS_HOME = "MSYS_HOME"; //$NON-NLS-1$
- private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
-
- private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32);
-
- private static String envPathValueCached = null;
- private static String envMinGWHomeValueCached = null;
- private static String minGWLocation = null;
- private static boolean isMinGWLocationCached = false;
-
- private static String envMinGWHomeValueCached_msys = null;
- private static String mSysLocation = null;
- private static boolean isMSysLocationCached = false;
-
- private final static Map<String/* envPath */, String/* mingwLocation */> mingwLocationCache = Collections
- .synchronizedMap(new WeakHashMap<String, String>(1));
-
- /**
- * @return The absolute path to MinGW root folder or {@code null} if not
- * found
- */
- private static String findMinGWRoot(String envPathValue, String envMinGWHomeValue) {
- String rootValue = null;
-
- // Check $MINGW_HOME
- if (envMinGWHomeValue != null && !envMinGWHomeValue.isEmpty()) {
- IPath mingwBinDir = new Path(envMinGWHomeValue + "\\bin"); //$NON-NLS-1$
- if (mingwBinDir.toFile().isDirectory()) {
- rootValue = mingwBinDir.removeLastSegments(1).toOSString();
- }
- }
-
- // Try the mingw directory in the platform install directory
- // CDT distributions like Wascana may distribute MinGW like that
- if (rootValue == null) {
- IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile());
- IPath mingwBinDir = installPath.append("mingw\\bin"); //$NON-NLS-1$
- if (mingwBinDir.toFile().isDirectory()) {
- rootValue = mingwBinDir.removeLastSegments(1).toOSString();
- }
- }
-
- // Look in PATH values. Look for mingw32-gcc.exe or
- // x86_64-w64-mingw32-gcc.exe
- if (rootValue == null) {
- rootValue = findMingwInPath(envPathValue);
- }
-
- // Look in MSYS2
- if (rootValue == null) {
- WindowsRegistry registry = WindowsRegistry.getRegistry();
- String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$
- String subkey;
- boolean on64bit = Platform.getOSArch().equals(Platform.ARCH_X86_64);
- String key32bit = null;
- for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) {
- String compKey = uninstallKey + '\\' + subkey;
- String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
- if (on64bit) {
- if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
- String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
- String mingwLocation = installLocation + "\\mingw64"; //$NON-NLS-1$
- File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- break;
- } else {
- mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$
- gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- break;
- }
- }
- } else if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
- key32bit = compKey;
- }
- } else {
- if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
- String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
- String mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$
- File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- break;
- }
- }
- }
- }
-
- if (on64bit && key32bit != null) {
- String installLocation = registry.getCurrentUserValue(key32bit, "InstallLocation"); //$NON-NLS-1$
- String mingwLocation = installLocation + "\\mingw64"; //$NON-NLS-1$
- File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- } else {
- mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$
- gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- }
- }
- }
- }
-
- // Try the default MinGW install dir
- if (rootValue == null) {
- IPath mingwBinDir = new Path("C:\\MinGW"); //$NON-NLS-1$
- if (mingwBinDir.toFile().isDirectory()) {
- rootValue = mingwBinDir.toOSString();
- }
- }
-
- return rootValue;
- }
-
- private static String findMingwInPath(String envPath) {
- if (envPath == null) {
- // $PATH from user preferences
- IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager()
- .getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
- if (varPath != null) {
- envPath = varPath.getValue();
- }
- }
-
- String mingwLocation = mingwLocationCache.get(envPath);
- // check if WeakHashMap contains the key as null may be the cached value
- if (mingwLocation == null && !mingwLocationCache.containsKey(envPath)) {
- // Check for MinGW-w64 on Windows 64 bit, see
- // http://mingw-w64.sourceforge.net/
- if (Platform.ARCH_X86_64.equals(Platform.getOSArch())) {
- IPath gcc64Loc = PathUtil.findProgramLocation("x86_64-w64-mingw32-gcc.exe", envPath); //$NON-NLS-1$
- if (gcc64Loc != null) {
- mingwLocation = gcc64Loc.removeLastSegments(2).toOSString();
- }
- }
-
- // Look for mingw32-gcc.exe
- if (mingwLocation == null) {
- IPath gccLoc = PathUtil.findProgramLocation("mingw32-gcc.exe", envPath); //$NON-NLS-1$
- if (gccLoc != null) {
- mingwLocation = gccLoc.removeLastSegments(2).toOSString();
- }
- }
- mingwLocationCache.put(envPath, mingwLocation);
- }
-
- return mingwLocation;
- }
-
- private static String findMSysRoot(String envMinGWHomeValue) {
- String msysHome = null;
-
- // Look in the install location parent dir
- IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile());
- IPath installMsysBin = installPath.append("msys\\bin"); //$NON-NLS-1$
- if (installMsysBin.toFile().isDirectory()) {
- msysHome = installMsysBin.removeLastSegments(1).toOSString();
- }
-
- // Look under $MINGW_HOME
- if (msysHome == null) {
- if (envMinGWHomeValue != null && !envMinGWHomeValue.isEmpty()) {
- IPath minGwMsysBin = new Path(envMinGWHomeValue + "\\msys\\1.0\\bin"); //$NON-NLS-1$
- if (minGwMsysBin.toFile().isDirectory()) {
- msysHome = minGwMsysBin.removeLastSegments(1).toOSString();
- }
- }
- }
-
- // Try under MSYS2
- if (msysHome == null) {
- // Give preference to msys64 on 64-bit platforms and ignore 64 on
- // 32-bit platforms
- WindowsRegistry registry = WindowsRegistry.getRegistry();
- String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$
- String subkey;
- boolean on64bit = Platform.getOSArch().equals(Platform.ARCH_X86_64);
- String key32bit = null;
- for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) {
- String compKey = uninstallKey + '\\' + subkey;
- String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
- if (on64bit) {
- if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
- String home = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
- if (new File(home).isDirectory()) {
- msysHome = home;
- break;
- }
- } else if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
- key32bit = compKey;
- }
- } else {
- if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
- String home = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
- if (new File(home).isDirectory()) {
- msysHome = home;
- break;
- }
- }
- }
- }
-
- if (on64bit && key32bit != null) {
- String home = registry.getCurrentUserValue(key32bit, "InstallLocation"); //$NON-NLS-1$
- if (new File(home).isDirectory()) {
- msysHome = home;
- }
- }
- }
-
- // Try under default MinGW dir
- if (msysHome == null) {
- IPath minGwMsysBin = new Path("C:\\MinGW\\msys\\1.0\\bin"); //$NON-NLS-1$
- if (minGwMsysBin.toFile().isDirectory()) {
- msysHome = minGwMsysBin.removeLastSegments(1).toOSString();
- }
- }
-
- // Try in default MSYS root folder
- if (msysHome == null) {
- IPath defaultMsysBin = new Path("C:\\msys\\1.0\\bin"); //$NON-NLS-1$
- if (defaultMsysBin.toFile().isDirectory()) {
- msysHome = defaultMsysBin.removeLastSegments(1).toOSString();
- }
- }
- return msysHome;
- }
-
- /**
- * Find location where MinGW is installed. A number of locations is being
- * checked, such as environment variable $MINGW_HOME, $PATH, Windows
- * registry et al. <br>
- * <br>
- * If you use this do not cache results to ensure user preferences are
- * accounted for. Please rely on internal caching.
- *
- * @return MinGW root ("/") path in Windows format.
- */
- public static String getMinGWHome() {
- if (!isWindowsPlatform) {
- return null;
- }
-
- IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager()
- .getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
- String envPathValue = varPath != null ? varPath.getValue() : null;
- IEnvironmentVariable varMinGWHome = CCorePlugin.getDefault().getBuildEnvironmentManager()
- .getVariable(ENV_MINGW_HOME, (ICConfigurationDescription) null, true);
- String envMinGWHomeValue = varMinGWHome != null ? varMinGWHome.getValue() : null;
-
- // isMinGWLocationCached is used to figure fact of caching when all
- // cached objects are null
- if (isMinGWLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached)
- && CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached)) {
- return minGWLocation;
- }
-
- minGWLocation = findMinGWRoot(envPathValue, envMinGWHomeValue);
- envPathValueCached = envPathValue;
- envMinGWHomeValueCached = envMinGWHomeValue;
- isMinGWLocationCached = true;
-
- return minGWLocation;
- }
-
- /**
- * Find location where MSys is installed. Environment variable $MSYS_HOME
- * and some predetermined locations are being checked. <br>
- * <br>
- * If you use this do not cache results to ensure user preferences are
- * accounted for. Please rely on internal caching.
- *
- * @return MSys root ("/") path in Windows format.
- */
- public static String getMSysHome() {
- if (!isWindowsPlatform) {
- return null;
- }
-
- // Use $MSYS_HOME if defined
- IEnvironmentVariable varMsysHome = CCorePlugin.getDefault().getBuildEnvironmentManager()
- .getVariable(ENV_MSYS_HOME, (ICConfigurationDescription) null, true);
- String msysHomeValue = varMsysHome != null ? varMsysHome.getValue() : null;
- if (msysHomeValue != null) {
- return msysHomeValue;
- }
-
- String envMinGWHomeValue = getMinGWHome();
-
- // isMSysLocationCached is used to figure whether it was cached when all
- // cached objects are null
- if (isMSysLocationCached && CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached_msys)) {
- return mSysLocation;
- }
-
- mSysLocation = findMSysRoot(envMinGWHomeValue);
- envMinGWHomeValueCached_msys = envMinGWHomeValue;
- isMSysLocationCached = true;
-
- return mSysLocation;
- }
-
- /**
- * Check if MinGW is available in the path.
- *
- * @param envPath
- * - list of directories to search for MinGW separated by path
- * separator (format of environment variable $PATH) or
- * {@code null} to use current $PATH.
- * @return {@code true} if MinGW is available, {@code false} otherwise.
- */
- public static boolean isAvailable(String envPath) {
- return isWindowsPlatform && findMingwInPath(envPath) != null;
- }
-
- /**
- * Check if MinGW is available in $PATH.
- *
- * @return {@code true} if MinGW is available, {@code false} otherwise.
- */
- public static boolean isAvailable() {
- return isWindowsPlatform && findMingwInPath(null) != null;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.utils.PathUtil;
+import org.eclipse.cdt.utils.WindowsRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * A collection of MinGW-related utility methods.
+ */
+public class MinGW {
+ public static final String ENV_MINGW_HOME = "MINGW_HOME"; //$NON-NLS-1$
+ public static final String ENV_MSYS_HOME = "MSYS_HOME"; //$NON-NLS-1$
+ private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
+
+ private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32);
+
+ private static String envPathValueCached = null;
+ private static String envMinGWHomeValueCached = null;
+ private static String minGWLocation = null;
+ private static boolean isMinGWLocationCached = false;
+
+ private static String envMinGWHomeValueCached_msys = null;
+ private static String mSysLocation = null;
+ private static boolean isMSysLocationCached = false;
+
+ private final static Map<String/* envPath */, String/* mingwLocation */> mingwLocationCache = Collections
+ .synchronizedMap(new WeakHashMap<String, String>(1));
+
+ /**
+ * @return The absolute path to MinGW root folder or {@code null} if not
+ * found
+ */
+ private static String findMinGWRoot(String envPathValue, String envMinGWHomeValue) {
+ String rootValue = null;
+
+ // Check $MINGW_HOME
+ if (envMinGWHomeValue != null && !envMinGWHomeValue.isEmpty()) {
+ IPath mingwBinDir = new Path(envMinGWHomeValue + "\\bin"); //$NON-NLS-1$
+ if (mingwBinDir.toFile().isDirectory()) {
+ rootValue = mingwBinDir.removeLastSegments(1).toOSString();
+ }
+ }
+
+ // Try the mingw directory in the platform install directory
+ // CDT distributions like Wascana may distribute MinGW like that
+ if (rootValue == null) {
+ IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile());
+ IPath mingwBinDir = installPath.append("mingw\\bin"); //$NON-NLS-1$
+ if (mingwBinDir.toFile().isDirectory()) {
+ rootValue = mingwBinDir.removeLastSegments(1).toOSString();
+ }
+ }
+
+ // Look in PATH values. Look for mingw32-gcc.exe or
+ // x86_64-w64-mingw32-gcc.exe
+ if (rootValue == null) {
+ rootValue = findMingwInPath(envPathValue);
+ }
+
+ // Look in MSYS2
+ if (rootValue == null) {
+ WindowsRegistry registry = WindowsRegistry.getRegistry();
+ String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$
+ String subkey;
+ boolean on64bit = Platform.getOSArch().equals(Platform.ARCH_X86_64);
+ String key32bit = null;
+ for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) {
+ String compKey = uninstallKey + '\\' + subkey;
+ String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
+ if (on64bit) {
+ if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
+ String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
+ String mingwLocation = installLocation + "\\mingw64"; //$NON-NLS-1$
+ File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
+ if (gccFile.canExecute()) {
+ rootValue = mingwLocation;
+ break;
+ } else {
+ mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$
+ gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
+ if (gccFile.canExecute()) {
+ rootValue = mingwLocation;
+ break;
+ }
+ }
+ } else if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
+ key32bit = compKey;
+ }
+ } else {
+ if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
+ String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
+ String mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$
+ File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
+ if (gccFile.canExecute()) {
+ rootValue = mingwLocation;
+ break;
+ }
+ }
+ }
+ }
+
+ if (on64bit && key32bit != null) {
+ String installLocation = registry.getCurrentUserValue(key32bit, "InstallLocation"); //$NON-NLS-1$
+ String mingwLocation = installLocation + "\\mingw64"; //$NON-NLS-1$
+ File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
+ if (gccFile.canExecute()) {
+ rootValue = mingwLocation;
+ } else {
+ mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$
+ gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
+ if (gccFile.canExecute()) {
+ rootValue = mingwLocation;
+ }
+ }
+ }
+ }
+
+ // Try the default MinGW install dir
+ if (rootValue == null) {
+ IPath mingwBinDir = new Path("C:\\MinGW"); //$NON-NLS-1$
+ if (mingwBinDir.toFile().isDirectory()) {
+ rootValue = mingwBinDir.toOSString();
+ }
+ }
+
+ return rootValue;
+ }
+
+ private static String findMingwInPath(String envPath) {
+ if (envPath == null) {
+ // $PATH from user preferences
+ IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager()
+ .getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
+ if (varPath != null) {
+ envPath = varPath.getValue();
+ }
+ }
+
+ String mingwLocation = mingwLocationCache.get(envPath);
+ // check if WeakHashMap contains the key as null may be the cached value
+ if (mingwLocation == null && !mingwLocationCache.containsKey(envPath)) {
+ // Check for MinGW-w64 on Windows 64 bit, see
+ // http://mingw-w64.sourceforge.net/
+ if (Platform.ARCH_X86_64.equals(Platform.getOSArch())) {
+ IPath gcc64Loc = PathUtil.findProgramLocation("x86_64-w64-mingw32-gcc.exe", envPath); //$NON-NLS-1$
+ if (gcc64Loc != null) {
+ mingwLocation = gcc64Loc.removeLastSegments(2).toOSString();
+ }
+ }
+
+ // Look for mingw32-gcc.exe
+ if (mingwLocation == null) {
+ IPath gccLoc = PathUtil.findProgramLocation("mingw32-gcc.exe", envPath); //$NON-NLS-1$
+ if (gccLoc != null) {
+ mingwLocation = gccLoc.removeLastSegments(2).toOSString();
+ }
+ }
+ mingwLocationCache.put(envPath, mingwLocation);
+ }
+
+ return mingwLocation;
+ }
+
+ private static String findMSysRoot(String envMinGWHomeValue) {
+ String msysHome = null;
+
+ // Look in the install location parent dir
+ IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile());
+ IPath installMsysBin = installPath.append("msys\\bin"); //$NON-NLS-1$
+ if (installMsysBin.toFile().isDirectory()) {
+ msysHome = installMsysBin.removeLastSegments(1).toOSString();
+ }
+
+ // Look under $MINGW_HOME
+ if (msysHome == null) {
+ if (envMinGWHomeValue != null && !envMinGWHomeValue.isEmpty()) {
+ IPath minGwMsysBin = new Path(envMinGWHomeValue + "\\msys\\1.0\\bin"); //$NON-NLS-1$
+ if (minGwMsysBin.toFile().isDirectory()) {
+ msysHome = minGwMsysBin.removeLastSegments(1).toOSString();
+ }
+ }
+ }
+
+ // Try under MSYS2
+ if (msysHome == null) {
+ // Give preference to msys64 on 64-bit platforms and ignore 64 on
+ // 32-bit platforms
+ WindowsRegistry registry = WindowsRegistry.getRegistry();
+ String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$
+ String subkey;
+ boolean on64bit = Platform.getOSArch().equals(Platform.ARCH_X86_64);
+ String key32bit = null;
+ for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) {
+ String compKey = uninstallKey + '\\' + subkey;
+ String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
+ if (on64bit) {
+ if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
+ String home = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
+ if (new File(home).isDirectory()) {
+ msysHome = home;
+ break;
+ }
+ } else if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
+ key32bit = compKey;
+ }
+ } else {
+ if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
+ String home = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
+ if (new File(home).isDirectory()) {
+ msysHome = home;
+ break;
+ }
+ }
+ }
+ }
+
+ if (on64bit && key32bit != null) {
+ String home = registry.getCurrentUserValue(key32bit, "InstallLocation"); //$NON-NLS-1$
+ if (new File(home).isDirectory()) {
+ msysHome = home;
+ }
+ }
+ }
+
+ // Try under default MinGW dir
+ if (msysHome == null) {
+ IPath minGwMsysBin = new Path("C:\\MinGW\\msys\\1.0\\bin"); //$NON-NLS-1$
+ if (minGwMsysBin.toFile().isDirectory()) {
+ msysHome = minGwMsysBin.removeLastSegments(1).toOSString();
+ }
+ }
+
+ // Try in default MSYS root folder
+ if (msysHome == null) {
+ IPath defaultMsysBin = new Path("C:\\msys\\1.0\\bin"); //$NON-NLS-1$
+ if (defaultMsysBin.toFile().isDirectory()) {
+ msysHome = defaultMsysBin.removeLastSegments(1).toOSString();
+ }
+ }
+ return msysHome;
+ }
+
+ /**
+ * Find location where MinGW is installed. A number of locations is being
+ * checked, such as environment variable $MINGW_HOME, $PATH, Windows
+ * registry et al. <br>
+ * <br>
+ * If you use this do not cache results to ensure user preferences are
+ * accounted for. Please rely on internal caching.
+ *
+ * @return MinGW root ("/") path in Windows format.
+ */
+ public static String getMinGWHome() {
+ if (!isWindowsPlatform) {
+ return null;
+ }
+
+ IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager()
+ .getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
+ String envPathValue = varPath != null ? varPath.getValue() : null;
+ IEnvironmentVariable varMinGWHome = CCorePlugin.getDefault().getBuildEnvironmentManager()
+ .getVariable(ENV_MINGW_HOME, (ICConfigurationDescription) null, true);
+ String envMinGWHomeValue = varMinGWHome != null ? varMinGWHome.getValue() : null;
+
+ // isMinGWLocationCached is used to figure fact of caching when all
+ // cached objects are null
+ if (isMinGWLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached)
+ && CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached)) {
+ return minGWLocation;
+ }
+
+ minGWLocation = findMinGWRoot(envPathValue, envMinGWHomeValue);
+ envPathValueCached = envPathValue;
+ envMinGWHomeValueCached = envMinGWHomeValue;
+ isMinGWLocationCached = true;
+
+ return minGWLocation;
+ }
+
+ /**
+ * Find location where MSys is installed. Environment variable $MSYS_HOME
+ * and some predetermined locations are being checked. <br>
+ * <br>
+ * If you use this do not cache results to ensure user preferences are
+ * accounted for. Please rely on internal caching.
+ *
+ * @return MSys root ("/") path in Windows format.
+ */
+ public static String getMSysHome() {
+ if (!isWindowsPlatform) {
+ return null;
+ }
+
+ // Use $MSYS_HOME if defined
+ IEnvironmentVariable varMsysHome = CCorePlugin.getDefault().getBuildEnvironmentManager()
+ .getVariable(ENV_MSYS_HOME, (ICConfigurationDescription) null, true);
+ String msysHomeValue = varMsysHome != null ? varMsysHome.getValue() : null;
+ if (msysHomeValue != null) {
+ return msysHomeValue;
+ }
+
+ String envMinGWHomeValue = getMinGWHome();
+
+ // isMSysLocationCached is used to figure whether it was cached when all
+ // cached objects are null
+ if (isMSysLocationCached && CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached_msys)) {
+ return mSysLocation;
+ }
+
+ mSysLocation = findMSysRoot(envMinGWHomeValue);
+ envMinGWHomeValueCached_msys = envMinGWHomeValue;
+ isMSysLocationCached = true;
+
+ return mSysLocation;
+ }
+
+ /**
+ * Check if MinGW is available in the path.
+ *
+ * @param envPath
+ * - list of directories to search for MinGW separated by path
+ * separator (format of environment variable $PATH) or
+ * {@code null} to use current $PATH.
+ * @return {@code true} if MinGW is available, {@code false} otherwise.
+ */
+ public static boolean isAvailable(String envPath) {
+ return isWindowsPlatform && findMingwInPath(envPath) != null;
+ }
+
+ /**
+ * Check if MinGW is available in $PATH.
+ *
+ * @return {@code true} if MinGW is available, {@code false} otherwise.
+ */
+ public static boolean isAvailable() {
+ return isWindowsPlatform && findMingwInPath(null) != null;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/IEnvironmentChangeListener.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/IEnvironmentChangeListener.java
index 6adea60095c..10340bb9375 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/IEnvironmentChangeListener.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/IEnvironmentChangeListener.java
@@ -1,27 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2013 Andrew Gvozdev and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.utils.envvar;
-
-
-/**
- * Interface for listeners to changes in environment variables defined by user
- * on CDT Environment page in Preferences.
- *
- * @since 5.5
- */
-public interface IEnvironmentChangeListener {
- /**
- * Indicates that environment variables have been changed.
- *
- * @param event - details of the event.
- */
- public void handleEvent(IEnvironmentChangeEvent event);
-}
+/*******************************************************************************
+ * Copyright (c) 2013, 2013 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils.envvar;
+
+
+/**
+ * Interface for listeners to changes in environment variables defined by user
+ * on CDT Environment page in Preferences.
+ *
+ * @since 5.5
+ */
+public interface IEnvironmentChangeListener {
+ /**
+ * Indicates that environment variables have been changed.
+ *
+ * @param event - details of the event.
+ */
+ public void handleEvent(IEnvironmentChangeEvent event);
+}

Back to the top