1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 375814 - Implement the Eclipse variables to obtain CDT configuration

name and description for the specified project
This commit is contained in:
Anton Gorenkov 2012-04-02 10:23:31 -07:00 committed by Sergey Prigogin
parent 22ea1c7683
commit f1a62f0fe3
6 changed files with 109 additions and 2 deletions

View file

@ -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

View file

@ -588,6 +588,22 @@
description="%cdt_pathentry_var.description">
</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

View file

@ -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

View file

@ -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();
}
}

View file

@ -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);
}

View file

@ -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();
}
}