1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-07 10:33:26 +02:00

bug 272432: support template process for setting Enumerated options

Patch from Miwako Tokugawa was used for this change.
This commit is contained in:
Andrew Gvozdev 2010-11-04 19:53:56 +00:00
parent 5b51ec0206
commit 5f088e7a74
4 changed files with 41 additions and 5 deletions

View file

@ -23,7 +23,12 @@ public interface IBuildObject {
public String getId();
public String getName();
/**
* @return id of the object this class was based on during creation or id of the object itself.
*/
public String getBaseId();
/** @since 8.0 */
public Version getVersion();
/** @since 8.0 */

View file

@ -3697,6 +3697,32 @@ public class ManagedBuildManager extends AbstractCExtension {
return superId + "." + suffix; //$NON-NLS-1$
}
private static int isInt(String s) {
try {
return Integer.parseInt(s);
} catch (NumberFormatException e) {
return 0;
}
}
/**
* @return base id when the given id was generated by {@link #calculateChildId(String, String)}.
* @since 8.0
*/
public static String calculateBaseId(String id) {
int index = id.lastIndexOf('.');
if (index<0)
return id;
String lastSeg = id.substring(index+1,id.length());
if (isInt(lastSeg)>0) {
String baseId = id.substring(0,index);
return baseId;
}
return getIdFromIdAndVersion(id);
}
/**
* @return calculated relative path given the full path to a folder and a file
*/

View file

@ -19,6 +19,7 @@ public class BuildObject implements IBuildObject {
protected String id;
protected String name;
private String baseId=null;
protected Version version = null;
protected String managedBuildRevision = null;
@ -81,10 +82,13 @@ public class BuildObject implements IBuildObject {
}
/**
* @return Returns the Id without the version (if any).
* @return id of the object this class was based on. Note that this function
* assumes that id was generated by {@link ManagedBuildManager#calculateChildId(String, String)}.
*/
public String getBaseId() {
return ManagedBuildManager.getIdFromIdAndVersion(id);
if (baseId==null)
baseId = ManagedBuildManager.calculateBaseId(id);
return baseId;
}

View file

@ -33,7 +33,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
/**
* This class sets the Managed Build System Option Values.
* This class sets the Managed Build System Option Values. Note that this class
* handles both string options and enumerated options.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
@ -118,7 +119,7 @@ public class SetMBSStringOptionValue extends ProcessRunner {
String lowerId = id.toLowerCase();
int optionType;
for (int i = 0; i < options.length; i++) {
if (options[i].getId().toLowerCase().matches(lowerId)) {
if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
optionType = options[i].getValueType();
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], value);
@ -137,7 +138,7 @@ public class SetMBSStringOptionValue extends ProcessRunner {
String lowerId = id.toLowerCase();
int optionType;
for (int i = 0; i < options.length; i++) {
if (options[i].getId().toLowerCase().matches(lowerId)) {
if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
optionType = options[i].getValueType();
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], value);