Skip to main content
summaryrefslogtreecommitdiffstats
path: root/qt
diff options
context:
space:
mode:
authorDoug Schaefer2016-03-15 19:58:01 +0000
committerDoug Schaefer2016-03-21 03:10:46 +0000
commit5a5de4b1db175e02c38f3e197589489f6d2bc653 (patch)
tree647325dace5fc0d3343deb9c4e12b93f06af2c25 /qt
parentc58c554e3a1d87147e26448f572c37f7e583fc31 (diff)
downloadorg.eclipse.cdt-5a5de4b1db175e02c38f3e197589489f6d2bc653.tar.gz
org.eclipse.cdt-5a5de4b1db175e02c38f3e197589489f6d2bc653.tar.xz
org.eclipse.cdt-5a5de4b1db175e02c38f3e197589489f6d2bc653.zip
Bug 489563 - API change for Language Settings Providers.
Use IBuildConfiguration instead of ICConfigurationDescription. Add adapters to convert back and forth between these. Create IBuildConfiguration objects when configuration descriptors are created. Clean up formating of the code involved. Change-Id: Iec5ca132dddbf990f116f96b4680ef5f7318e28b
Diffstat (limited to 'qt')
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java139
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePathsProvider.java66
2 files changed, 111 insertions, 94 deletions
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java
index 4216f8b1188..878dc1c784b 100644
--- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java
@@ -18,24 +18,25 @@ import java.util.List;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
-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.utils.spawner.ProcessFactory;
+import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IResource;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
- * Discovers and persists the list of Qt include paths for a particular installation of
- * Qt. The Qt installation is described by the path to qmake.
+ * Discovers and persists the list of Qt include paths for a particular
+ * installation of Qt. The Qt installation is described by the path to qmake.
* <p>
- * Qt uses a tool called qmake to generate makefiles for Qt projects. The tool has a
- * query mode that can be used to discover information about the Qt installation. Here
- * qmake is used to build a list of all installed Qt include paths.
+ * Qt uses a tool called qmake to generate makefiles for Qt projects. The tool
+ * has a query mode that can be used to discover information about the Qt
+ * installation. Here qmake is used to build a list of all installed Qt include
+ * paths.
* <p>
- * These paths are persisted into a file called language-settings.xml in the workspace
- * metadata area.
+ * These paths are persisted into a file called language-settings.xml in the
+ * workspace metadata area.
*
* @see QtIncludePathsProvider
*/
@@ -52,34 +53,34 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
private long qmakeModTime;
/**
- * The cached data is reloaded when the folder holding the include paths
- * is removed.
+ * The cached data is reloaded when the folder holding the include paths is
+ * removed.
*/
private String qtInstallHeadersPath;
/**
- * The cached data is reloaded when the folder containing the include folders is
- * modified.
+ * The cached data is reloaded when the folder containing the include
+ * folders is modified.
*/
private long qtInstallHeadersModTime;
- private static final String ATTR_QMAKE = "qmake";
- private static final String ATTR_QMAKE_MOD = "qmakeModification";
- private static final String ATTR_QT_INSTALL_HEADERS = "QT_INSTALL_HEADERS";
- private static final String ATTR_QT_INSTALL_HEADERS_MOD = "qtInstallHeadersModification";
+ private static final String ATTR_QMAKE = "qmake"; //$NON-NLS-1$
+ private static final String ATTR_QMAKE_MOD = "qmakeModification"; //$NON-NLS-1$
+ private static final String ATTR_QT_INSTALL_HEADERS = "QT_INSTALL_HEADERS"; //$NON-NLS-1$
+ private static final String ATTR_QT_INSTALL_HEADERS_MOD = "qtInstallHeadersModification"; //$NON-NLS-1$
/**
- * Create a new instance of the include path wrapper for the Qt installation for
- * the given qmake binary.
+ * Create a new instance of the include path wrapper for the Qt installation
+ * for the given qmake binary.
*/
public QtIncludePaths(String qmakePath) {
this.qmakePath = qmakePath;
}
/**
- * Create and load an instance of QtIncludePaths from data that was serialized into the
- * given XML element. Return null if an instance cannot be loaded or if the installation
- * is no longer valid.
+ * Create and load an instance of QtIncludePaths from data that was
+ * serialized into the given XML element. Return null if an instance cannot
+ * be loaded or if the installation is no longer valid.
*/
public static QtIncludePaths loadFrom(Node node) {
if (node.getNodeType() != Node.ELEMENT_NODE)
@@ -87,8 +88,7 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
Element element = (Element) node;
String qmakePath = element.getAttribute(ATTR_QMAKE);
- if (qmakePath == null
- || qmakePath.isEmpty())
+ if (qmakePath == null || qmakePath.isEmpty())
return null;
QtIncludePaths qtIncludePaths = new QtIncludePaths(qmakePath);
@@ -101,18 +101,16 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
}
/**
- * Return true if the receiver points to a valid Qt installation and false otherwise.
- * The installation is considered valid if an executable qmake binary exists at the
- * expected location.
+ * Return true if the receiver points to a valid Qt installation and false
+ * otherwise. The installation is considered valid if an executable qmake
+ * binary exists at the expected location.
*/
public boolean isValid() {
- if (qmakePath == null
- || qmakePath.isEmpty())
+ if (qmakePath == null || qmakePath.isEmpty())
return false;
File qmake = new File(qmakePath);
- return qmake.exists()
- && qmake.canExecute();
+ return qmake.exists() && qmake.canExecute();
}
@Override
@@ -120,8 +118,10 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
if (!(obj instanceof QtIncludePaths))
return super.equals(obj);
- // Include paths are equivalent when they point to the same qmake binary. All other
- // values are reloaded from that binary and do not need to be directly compared.
+ // Include paths are equivalent when they point to the same qmake
+ // binary. All other
+ // values are reloaded from that binary and do not need to be directly
+ // compared.
QtIncludePaths other = (QtIncludePaths) obj;
return qmakePath == null ? other.qmakePath == null : qmakePath.equals(other.qmakePath);
}
@@ -132,33 +132,32 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
}
/**
- * Return a current list of the include paths for this Qt installation. Return null if
- * no such paths can be found.
+ * Return a current list of the include paths for this Qt installation.
+ * Return null if no such paths can be found.
* <p>
- * Updates the cached results if needed. If the settings are updated then the new list
- * will be serialized into the workspace metadata area.
+ * Updates the cached results if needed. If the settings are updated then
+ * the new list will be serialized into the workspace metadata area.
*/
@Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription configDesc, IResource rc, String languageId) {
+ public List<ICLanguageSettingEntry> getSettingEntries(IBuildConfiguration config, IResource rc, String languageId) {
List<ICLanguageSettingEntry> entries = null;
File qmake = new File(qmakePath);
- if (!qmake.exists()
- || qmakeModTime != qmake.lastModified())
+ if (!qmake.exists() || qmakeModTime != qmake.lastModified())
entries = reload();
else {
File qtInstallHeadersDir = new File(qtInstallHeadersPath);
- if (!qtInstallHeadersDir.exists()
- || qtInstallHeadersModTime != qtInstallHeadersDir.lastModified())
+ if (!qtInstallHeadersDir.exists() || qtInstallHeadersModTime != qtInstallHeadersDir.lastModified())
entries = reload();
}
- // If the cache was not reloaded, then return the previously discovered entries.
+ // If the cache was not reloaded, then return the previously discovered
+ // entries.
if (entries == null)
- return super.getSettingEntries(configDesc, rc, languageId);
+ return super.getSettingEntries(config, rc, languageId);
// Otherwise store, persist, and return the newly discovered values.
- setSettingEntries(configDesc, rc, languageId, entries);
+ setSettingEntries(config, rc, languageId, entries);
serializeLanguageSettingsInBackground(null);
return entries;
}
@@ -170,8 +169,10 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
parentElement.setAttribute(ATTR_QT_INSTALL_HEADERS, qtInstallHeadersPath);
parentElement.setAttribute(ATTR_QT_INSTALL_HEADERS_MOD, Long.toString(qtInstallHeadersModTime));
- // The parent implementation tries to create a new child node (provider) that is used
- // as the part for later entries. This isn't needed in this case, we just want to
+ // The parent implementation tries to create a new child node (provider)
+ // that is used
+ // as the part for later entries. This isn't needed in this case, we
+ // just want to
// use the part that serializes the languages.
return parentElement;
}
@@ -182,25 +183,26 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
qtInstallHeadersPath = element.getAttribute(ATTR_QT_INSTALL_HEADERS);
qtInstallHeadersModTime = getLongAttribute(element, ATTR_QT_INSTALL_HEADERS_MOD);
- // The parent implementation tries to create a new child node (provider) that is used
- // as the part for later entries. This isn't needed in this case, we just want to
+ // The parent implementation tries to create a new child node (provider)
+ // that is used
+ // as the part for later entries. This isn't needed in this case, we
+ // just want to
// use the part that serializes the languages.
}
/**
- * Parse and return the given attribute as a long. Return 0 if the attribute does
- * not have a valid value.
+ * Parse and return the given attribute as a long. Return 0 if the attribute
+ * does not have a valid value.
*/
private static long getLongAttribute(Element element, String attr) {
String value = element.getAttribute(attr);
- if (value == null
- || value.isEmpty())
+ if (value == null || value.isEmpty())
return 0;
try {
return Long.parseLong(value);
- } catch(NumberFormatException e) {
- Activator.log("attribute name:" + attr + " value:" + value, e);
+ } catch (NumberFormatException e) {
+ Activator.log("attribute name:" + attr + " value:" + value, e); //$NON-NLS-1$ //$NON-NLS-2$
return 0;
}
}
@@ -209,33 +211,34 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
* Reload and return the entries if possible, return null otherwise.
*/
private List<ICLanguageSettingEntry> reload() {
- // All keys are reset and then updated as their values are discovered. This allows partial
+ // All keys are reset and then updated as their values are discovered.
+ // This allows partial
// success to skip over previously calculated values.
qmakeModTime = 0;
qtInstallHeadersPath = null;
qtInstallHeadersModTime = 0;
File qmake = new File(qmakePath);
- if (!qmake.exists()
- || !qmake.canExecute())
+ if (!qmake.exists() || !qmake.canExecute())
return Collections.emptyList();
qmakeModTime = qmake.lastModified();
- // Run `qmake -query QT_INSTALL_HEADERS` to get output like "/opt/qt-5.0.0/include".
+ // Run `qmake -query QT_INSTALL_HEADERS` to get output like
+ // "/opt/qt-5.0.0/include".
BufferedReader reader = null;
Process process = null;
try {
- process = ProcessFactory.getFactory().exec(new String[]{ qmakePath, "-query", "QT_INSTALL_HEADERS" });
+ process = ProcessFactory.getFactory().exec(new String[] { qmakePath, "-query", "QT_INSTALL_HEADERS" }); //$NON-NLS-1$ //$NON-NLS-2$
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
qtInstallHeadersPath = reader.readLine();
- } catch(IOException e) {
+ } catch (IOException e) {
Activator.log(e);
} finally {
try {
if (reader != null)
reader.close();
- } catch(IOException e) {
+ } catch (IOException e) {
/* ignore */
} finally {
if (process != null)
@@ -249,12 +252,11 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
File qtInstallHeadersDir = new File(qtInstallHeadersPath);
qtInstallHeadersModTime = qtInstallHeadersDir.lastModified();
- if (!qtInstallHeadersDir.exists()
- || !qtInstallHeadersDir.canRead()
- || !qtInstallHeadersDir.isDirectory())
+ if (!qtInstallHeadersDir.exists() || !qtInstallHeadersDir.canRead() || !qtInstallHeadersDir.isDirectory())
return Collections.emptyList();
- // Create an include path entry for all sub-folders in the QT_INSTALL_HEADERS location, including
+ // Create an include path entry for all sub-folders in the
+ // QT_INSTALL_HEADERS location, including
// the QT_INSTALL_HEADERS folder itself.
File[] files = qtInstallHeadersDir.listFiles(new FileFilter() {
@Override
@@ -265,7 +267,7 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(files.length + 1);
safeAdd(entries, qtInstallHeadersDir);
- for(File file : files)
+ for (File file : files)
safeAdd(entries, file);
return entries;
@@ -273,8 +275,9 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider {
private static void safeAdd(List<ICLanguageSettingEntry> entries, File file) {
try {
- entries.add(new CIncludePathEntry(file.getCanonicalPath(), ICSettingEntry.READONLY | ICSettingEntry.RESOLVED));
- } catch(IOException e) {
+ entries.add(
+ new CIncludePathEntry(file.getCanonicalPath(), ICSettingEntry.READONLY | ICSettingEntry.RESOLVED));
+ } catch (IOException e) {
Activator.log(e);
}
}
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePathsProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePathsProvider.java
index fa832c66d79..c9f1e63e8ea 100644
--- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePathsProvider.java
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePathsProvider.java
@@ -16,6 +16,7 @@ import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IResource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -24,8 +25,8 @@ import org.w3c.dom.NodeList;
/**
* This provider uses persistent cache to store the include paths for different
- * Qt installations. A Qt installation is uniquely identified by the path to
- * the qmake binary within the installation.
+ * Qt installations. A Qt installation is uniquely identified by the path to the
+ * qmake binary within the installation.
* <p>
* This result is shared among all Build Configurations that use the provider
* with the same value for the QMAKE environment variable.
@@ -33,17 +34,19 @@ import org.w3c.dom.NodeList;
public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider {
/**
- * The provider identifies Qt installations by the absolute path to the qmake binary. The
- * include paths relevant to the installations are computed and persisted in {@link QtIncludePaths}.
+ * The provider identifies Qt installations by the absolute path to the
+ * qmake binary. The include paths relevant to the installations are
+ * computed and persisted in {@link QtIncludePaths}.
*/
private final Map<String, QtIncludePaths> qtInstallHeaders = new HashMap<String, QtIncludePaths>();
/**
- * The build configuration stores the path to the qmake binary as an environment variable.
+ * The build configuration stores the path to the qmake binary as an
+ * environment variable.
*/
- private static final String ENVVAR_QMAKE = "QMAKE";
+ private static final String ENVVAR_QMAKE = "QMAKE"; //$NON-NLS-1$
- private static final String ELEMENT_QMAKE = "qmake";
+ private static final String ELEMENT_QMAKE = "qmake"; //$NON-NLS-1$
@Override
public boolean equals(Object obj) {
@@ -68,17 +71,19 @@ public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider
public void loadEntries(Element providerNode) {
super.loadEntries(providerNode);
- // Find and load all qmake child nodes. There will be one node for each Qt
- // installation that has been used. Qt installations that are no longer valid
- // are not loaded. This means they will be removed from the file the next time
+ // Find and load all qmake child nodes. There will be one node for each
+ // Qt
+ // installation that has been used. Qt installations that are no longer
+ // valid
+ // are not loaded. This means they will be removed from the file the
+ // next time
// that the language setting providers are serialized.
NodeList children = providerNode.getChildNodes();
for (int i = 0; i < children.getLength(); ++i) {
Node child = children.item(i);
if (ELEMENT_QMAKE.equals(child.getNodeName())) {
QtIncludePaths qtIncludePaths = QtIncludePaths.loadFrom(child);
- if (qtIncludePaths != null
- && qtIncludePaths.isValid())
+ if (qtIncludePaths != null && qtIncludePaths.isValid())
qtInstallHeaders.put(qtIncludePaths.getQMakePath(), qtIncludePaths);
}
}
@@ -86,14 +91,17 @@ public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider
@Override
public void serializeEntries(Element parent) {
- // NOTE: This creates its own XML structure where children of the provider node are qmake nodes.
- // Within each qmake node is a list of include paths for that installation. Calling the
- // base #serializeEntries here would try to write this instance's (empty) list of settings
- // to the file.
+ // NOTE: This creates its own XML structure where children of the
+ // provider node are qmake nodes.
+ // Within each qmake node is a list of include paths for that
+ // installation. Calling the
+ // base #serializeEntries here would try to write this instance's
+ // (empty) list of settings
+ // to the file.
// Each value is serialized into a new element in the XML document.
- Document document = parent instanceof Document ? (Document)parent : parent.getOwnerDocument();
- for(QtIncludePaths qtIncludePaths : qtInstallHeaders.values()) {
+ Document document = parent instanceof Document ? (Document) parent : parent.getOwnerDocument();
+ for (QtIncludePaths qtIncludePaths : qtInstallHeaders.values()) {
Element child = document.createElement(ELEMENT_QMAKE);
qtIncludePaths.serialize(child);
parent.appendChild(child);
@@ -101,19 +109,24 @@ public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider
}
/**
- * The given build configuration's QMAKE environment variable is used to identify the appropriate
- * Qt installation. The language settings are then either returned from the previously persisted
- * data or loaded, serialized, and returned.
+ * The given build configuration's QMAKE environment variable is used to
+ * identify the appropriate Qt installation. The language settings are then
+ * either returned from the previously persisted data or loaded, serialized,
+ * and returned.
*/
@Override
- public synchronized List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription configDesc, IResource rc, String languageId) {
+ public synchronized List<ICLanguageSettingEntry> getSettingEntries(IBuildConfiguration config, IResource rc,
+ String languageId) {
// Make sure the requested language is in scope for this provider.
if (!getLanguageScope().contains(languageId))
return null;
- // The value of the build configuration's QMAKE environment variable is used to select the
+ // The value of the build configuration's QMAKE environment variable is
+ // used to select the
// right version of qmake.
- IEnvironmentVariable qmake_var = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENVVAR_QMAKE, configDesc, true);
+ ICConfigurationDescription configDesc = config.getAdapter(ICConfigurationDescription.class);
+ IEnvironmentVariable qmake_var = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENVVAR_QMAKE,
+ configDesc, true);
if (qmake_var == null)
return null;
@@ -121,13 +134,14 @@ public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider
if (qmake == null)
return null;
- // The path to qmake is used as the key into the in-memory cache of header paths.
+ // The path to qmake is used as the key into the in-memory cache of
+ // header paths.
QtIncludePaths paths = qtInstallHeaders.get(qmake);
if (paths == null) {
paths = new QtIncludePaths(qmake);
qtInstallHeaders.put(qmake, paths);
}
- return paths.getSettingEntries(configDesc, null, languageId);
+ return paths.getSettingEntries(config, null, languageId);
}
}

Back to the top