| author | Anton Gorenkov | 2012-04-02 13:23:31 (EDT) |
|---|---|---|
| committer | Sergey Prigogin | 2012-04-02 13:23:31 (EDT) |
| commit | f1a62f0fe3948a2a2f3b45cb315d67fbb0104442 (patch) (side-by-side diff) | |
| tree | 971cad594169a86ae8cf38193283501e91bbfb7f | |
| parent | 22ea1c7683acacf6bc378a64c3cbf0652395221b (diff) | |
| download | org.eclipse.cdt-f1a62f0fe3948a2a2f3b45cb315d67fbb0104442.zip org.eclipse.cdt-f1a62f0fe3948a2a2f3b45cb315d67fbb0104442.tar.gz org.eclipse.cdt-f1a62f0fe3948a2a2f3b45cb315d67fbb0104442.tar.bz2 | |
Bug 375814 - Implement the Eclipse variables to obtain CDT configuration
name and description for the specified project
6 files changed, 109 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/plugin.properties b/core/org.eclipse.cdt.core/plugin.properties index 58aae22..05f9ed7 100644 --- a/core/org.eclipse.cdt.core/plugin.properties +++ b/core/org.eclipse.cdt.core/plugin.properties @@ -104,7 +104,9 @@ cxxHeaderName=C++ Header File asmSourceName=Assembly Source File binaryFileName=Binary File -cdt_pathentry_var.description=CDT PathEntry Variable +cdt_pathentry_var.description=CDT PathEntry variable +config_name_var.description=The name of the active configuration for the project specified as an argument +config_description_var.description=The description of the active configuration for the project specified as an argument PDOMProviderName=PDOM Provider diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index c4e1a38..f58003a 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -589,6 +589,22 @@ </variable> </extension> <extension + point="org.eclipse.core.variables.dynamicVariables"> + <variable + name="config_name" + resolver="org.eclipse.cdt.internal.core.ConfigurationNameVariableResolver" + description="%config_name_var.description"> + </variable> + </extension> + <extension + point="org.eclipse.core.variables.dynamicVariables"> + <variable + name="config_description" + resolver="org.eclipse.cdt.internal.core.ConfigurationDescriptionVariableResolver" + description="%config_description_var.description"> + </variable> + </extension> + <extension point="org.eclipse.cdt.core.CBuildConsole"> <CBuildConsole class="org.eclipse.cdt.internal.core.SystemBuildConsole" diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties index 36637f2..1e13e84 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2010 QNX Software Systems and others. +# Copyright (c) 2000, 2010, 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 @@ -9,6 +9,7 @@ # QNX Software Systems - Initial API and implementation # Markus Schorn (Wind River Systems) # Anton Leherbauer (Wind River Systems) +# Anton Gorenkov ############################################################################### ACBuilder.ProblemsView.Location=line {0}, external location: {1} CBuilder.build_error= Build Error @@ -68,6 +69,9 @@ Util.unknownFormat=Unknown debug format PathEntryVariableResolver.0=CDT PathEntry variable not specified +ConfigurationInfoVariableResolver.noProjectName=Project name should be specified as variable argument for '${'{0}'}' variable +ConfigurationInfoVariableResolver.wrongProjectName=The "{0}" project referenced by the '${'{1}'}' variable does not exist + CTagsIndexMarker.fileMissing=CTags output file missing CTagsIndexMarker.CTagsMissing=CTags not installed or not in path DOMIndexerMarker.EmptyScannerInfo=File not indexed because it was not built diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConfigurationDescriptionVariableResolver.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConfigurationDescriptionVariableResolver.java new file mode 100644 index 0000000..4493c4d --- a/dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConfigurationDescriptionVariableResolver.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2012 Anton Gorenkov 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: + * Anton Gorenkov - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core; + +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; + +public class ConfigurationDescriptionVariableResolver extends ConfigurationInfoVariableResolver { + @Override + protected String fetchConfigurationInfo(ICConfigurationDescription configuration) { + return configuration.getDescription(); + } +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConfigurationInfoVariableResolver.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConfigurationInfoVariableResolver.java new file mode 100644 index 0000000..94db247 --- a/dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConfigurationInfoVariableResolver.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2012 Anton Gorenkov 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: + * Anton Gorenkov - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core; + +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.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.variables.IDynamicVariable; +import org.eclipse.core.variables.IDynamicVariableResolver; +import org.eclipse.osgi.util.NLS; + +public abstract class ConfigurationInfoVariableResolver implements IDynamicVariableResolver { + @Override + public String resolveValue(IDynamicVariable variable, String argument) throws CoreException { + if (argument == null) { + String message = NLS.bind(CCorePlugin.getResourceString("ConfigurationInfoVariableResolver.noProjectName"), //$NON-NLS-1$ + variable.getName()); + throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, message, null)); + } + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(argument); + if (!project.exists()) { + String message = NLS.bind(CCorePlugin.getResourceString("ConfigurationInfoVariableResolver.wrongProjectName"), //$NON-NLS-1$ + argument, variable.getName()); + throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, message, null)); + } + ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(project); + return fetchConfigurationInfo(projectDescription.getActiveConfiguration()); + } + + protected abstract String fetchConfigurationInfo(ICConfigurationDescription configuration); +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConfigurationNameVariableResolver.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConfigurationNameVariableResolver.java new file mode 100644 index 0000000..bd4dabe --- a/dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ConfigurationNameVariableResolver.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2012 Anton Gorenkov 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: + * Anton Gorenkov - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core; + +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; + +public class ConfigurationNameVariableResolver extends ConfigurationInfoVariableResolver { + @Override + protected String fetchConfigurationInfo(ICConfigurationDescription configuration) { + return configuration.getName(); + } +} |

