1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Commit for Leo Treggiari -- Bug 80820 Two problems for converting 1.2 projects using 3rd party tool integrations

If there is no match for an option in the project being converted, ignore the option and continue converting the configuration
Patch tool lookup in converters to handle the case where the location of the definition fools the manifest reader and effectively hides the tool
This commit is contained in:
Sean Evoy 2004-12-13 17:37:51 +00:00
parent e7908d52e2
commit 3abb569374
5 changed files with 98 additions and 109 deletions

View file

@ -52,8 +52,10 @@ public class ManagedProjectUpdateTests extends TestCase {
private IProject[] createVersionProjects(String version){ private IProject[] createVersionProjects(String version){
File file = getVersionProjectsDir(version); File file = getVersionProjectsDir(version);
if(file == null) if(file == null) {
fail("Test project directory " + file.getName() + " is missing.");
return null; return null;
}
File projectZips[] = file.listFiles(new FileFilter(){ File projectZips[] = file.listFiles(new FileFilter(){
public boolean accept(File pathname){ public boolean accept(File pathname){
@ -80,8 +82,10 @@ public class ManagedProjectUpdateTests extends TestCase {
catch(Exception e){ catch(Exception e){
} }
} }
if(projectList.size() == 0) if(projectList.size() == 0) {
fail("No projects found in test project directory " + file.getName() + ". The .zip file may be missing or corrupt.");
return null; return null;
}
return (IProject[])projectList.toArray(new IProject[projectList.size()]); return (IProject[])projectList.toArray(new IProject[projectList.size()]);
} }

View file

@ -218,6 +218,7 @@ class UpdateManagedProject12 {
convertToolRef(toolChain, (Element) toolRefNodes.item(refIndex), monitor); convertToolRef(toolChain, (Element) toolRefNodes.item(refIndex), monitor);
} }
catch(CoreException e){ catch(CoreException e){
// TODO: Need error dialog!
newProject.removeConfiguration(newConfigId); newProject.removeConfiguration(newConfigId);
throw e; throw e;
} }
@ -233,7 +234,7 @@ class UpdateManagedProject12 {
String optId = null; String optId = null;
String[] idTokens = oldId.split(REGEXP_SEPARATOR); String[] idTokens = oldId.split(REGEXP_SEPARATOR);
Vector oldIdVector = new Vector(Arrays.asList(idTokens)); Vector oldIdVector = new Vector(Arrays.asList(idTokens));
if (isBuiltInOption(oldIdVector)) { if (isBuiltInOption(oldIdVector)) {
// New ID will be in form gnu.[c|c++|both].[compiler|link|lib].option.{1.2_component} // New ID will be in form gnu.[c|c++|both].[compiler|link|lib].option.{1.2_component}
Vector newIdVector = new Vector(idTokens.length + 2); Vector newIdVector = new Vector(idTokens.length + 2);
@ -314,7 +315,6 @@ class UpdateManagedProject12 {
// ignore this exception too // ignore this exception too
} }
// Construct the new ID // Construct the new ID
optId = new String(); optId = new String();
for (int rebuildIndex = 0; rebuildIndex < newIdVector.size(); ++ rebuildIndex) { for (int rebuildIndex = 0; rebuildIndex < newIdVector.size(); ++ rebuildIndex) {
@ -350,8 +350,7 @@ class UpdateManagedProject12 {
return curOption.getId(); return curOption.getId();
} }
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1, return optId;
ConverterMessages.getFormattedString("UpdateManagedProject12.3",optId), null)); //$NON-NLS-1$
} }
protected static void convertOptionRef(IToolChain toolChain, ITool tool, Element optRef) protected static void convertOptionRef(IToolChain toolChain, ITool tool, Element optRef)
@ -362,51 +361,47 @@ class UpdateManagedProject12 {
optId = getNewOptionId(toolChain, tool, optId); optId = getNewOptionId(toolChain, tool, optId);
// Get the option from the new tool // Get the option from the new tool
IOption newOpt = tool.getOptionById(optId); IOption newOpt = tool.getOptionById(optId);
if (newOpt == null) { if (newOpt != null) { // Ignore options that don't have a match
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1, IConfiguration configuration = toolChain.getParent();
ConverterMessages.getFormattedString("UpdateManagedProject12.4",optId), null)); //$NON-NLS-1$
} try {
switch (newOpt.getValueType()) {
IConfiguration configuration = toolChain.getParent(); case IOption.BOOLEAN:
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
try { configuration.setOption(tool, newOpt, bool.booleanValue());
switch (newOpt.getValueType()) { break;
case IOption.BOOLEAN: case IOption.STRING:
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE)); case IOption.ENUMERATED:
configuration.setOption(tool, newOpt, bool.booleanValue()); // This is going to be the human readable form of the enumerated value
break; String name = (String) optRef.getAttribute(IOption.DEFAULT_VALUE);
case IOption.STRING: // Convert it to the ID
case IOption.ENUMERATED: String idValue = newOpt.getEnumeratedId(name);
// This is going to be the human readable form of the enumerated value configuration.setOption(tool, newOpt, idValue != null ? idValue : name);
String name = (String) optRef.getAttribute(IOption.DEFAULT_VALUE); break;
// Convert it to the ID case IOption.STRING_LIST:
String idValue = newOpt.getEnumeratedId(name); case IOption.INCLUDE_PATH:
configuration.setOption(tool, newOpt, idValue != null ? idValue : name); case IOption.PREPROCESSOR_SYMBOLS:
break; case IOption.LIBRARIES:
case IOption.STRING_LIST: case IOption.OBJECTS:
case IOption.INCLUDE_PATH: Vector values = new Vector();
case IOption.PREPROCESSOR_SYMBOLS: NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
case IOption.LIBRARIES: for (int i = 0; i < nodes.getLength(); ++i) {
case IOption.OBJECTS: Node node = nodes.item(i);
Vector values = new Vector(); if (node.getNodeType() == Node.ELEMENT_NODE) {
NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE); Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
for (int i = 0; i < nodes.getLength(); ++i) { if (!isBuiltIn.booleanValue()) {
Node node = nodes.item(i); values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
if (node.getNodeType() == Node.ELEMENT_NODE) { }
Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
if (!isBuiltIn.booleanValue()) {
values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
} }
} }
} configuration.setOption(tool, newOpt, (String[])values.toArray(new String[values.size()]));
configuration.setOption(tool, newOpt, (String[])values.toArray(new String[values.size()])); break;
break; }
} catch (BuildException e) {
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
ConverterMessages.getFormattedString("UpdateManagedProject12.5",e.getMessage()), e)); //$NON-NLS-1$
} }
} catch (BuildException e) { }
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
ConverterMessages.getFormattedString("UpdateManagedProject12.5",e.getMessage()), e)); //$NON-NLS-1$
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -582,17 +577,15 @@ class UpdateManagedProject12 {
ITool parent = curTool.getSuperClass(); ITool parent = curTool.getSuperClass();
String curToolId = curTool.getId(); String curToolId = curTool.getId();
while (parent != null) {
String parentId = parent.getId();
if(parentId.equals(toolId))
break;
parent = parent.getSuperClass();
}
if(parent == null) if(parent == null)
continue; continue;
parent = parent.getSuperClass();
if(parent == null)
continue;
String parentId = parent.getId();
if(!parentId.equals(toolId))
continue;
try{ try{
Integer.decode(curToolId.substring(curToolId.lastIndexOf('.')+1)); //$NON-NLS-1$ Integer.decode(curToolId.substring(curToolId.lastIndexOf('.')+1)); //$NON-NLS-1$
} }
@ -611,9 +604,7 @@ class UpdateManagedProject12 {
protected static void convertToolRef(IToolChain toolChain, Element oldToolRef, IProgressMonitor monitor) protected static void convertToolRef(IToolChain toolChain, Element oldToolRef, IProgressMonitor monitor)
throws CoreException { throws CoreException {
String toolId = oldToolRef.getAttribute(IToolReference.ID); String toolId = oldToolRef.getAttribute(IToolReference.ID);
toolId = getNewToolId(toolChain, toolId); toolId = getNewToolId(toolChain, toolId);
IConfiguration configuration = toolChain.getParent(); IConfiguration configuration = toolChain.getParent();
// Get the new tool out of the configuration // Get the new tool out of the configuration

View file

@ -286,17 +286,15 @@ class UpdateManagedProject20 {
ITool parent = curTool.getSuperClass(); ITool parent = curTool.getSuperClass();
String curToolId = curTool.getId(); String curToolId = curTool.getId();
if(parent == null) while (parent != null) {
continue; String parentId = parent.getId();
if(parentId.equals(toolId))
parent = parent.getSuperClass(); break;
parent = parent.getSuperClass();
}
if(parent == null) if(parent == null)
continue; continue;
String parentId = parent.getId();
if(!parentId.equals(toolId))
continue;
try{ try{
Integer.decode(curToolId.substring(curToolId.lastIndexOf('.')+1)); //$NON-NLS-1$ Integer.decode(curToolId.substring(curToolId.lastIndexOf('.')+1)); //$NON-NLS-1$
} }
@ -374,56 +372,52 @@ class UpdateManagedProject20 {
if(option == null) if(option == null)
option = tool.getOptionById(optId); option = tool.getOptionById(optId);
if(option == null){ if (option != null) { // Ignore options that don't have a match
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1, try{
ConverterMessages.getFormattedString("UpdateManagedProject20.7",optId), null)); //$NON-NLS-1$ int type = option.getValueType();
}
switch(type){
try{ case IOption.BOOLEAN:{
int type = option.getValueType(); if(optRef.hasAttribute(IOption.DEFAULT_VALUE)){
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
switch(type){ configuration.setOption(tool,option,bool.booleanValue());
case IOption.BOOLEAN:{ }
if(optRef.hasAttribute(IOption.DEFAULT_VALUE)){ break;
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
configuration.setOption(tool,option,bool.booleanValue());
} }
break; case IOption.ENUMERATED:
} case IOption.STRING:{
case IOption.ENUMERATED: if(optRef.hasAttribute(IOption.DEFAULT_VALUE))
case IOption.STRING:{ configuration.setOption(tool,option,optRef.getAttribute(IOption.DEFAULT_VALUE));
if(optRef.hasAttribute(IOption.DEFAULT_VALUE)) break;
configuration.setOption(tool,option,optRef.getAttribute(IOption.DEFAULT_VALUE)); }
break; case IOption.STRING_LIST:
} case IOption.INCLUDE_PATH:
case IOption.STRING_LIST: case IOption.PREPROCESSOR_SYMBOLS:
case IOption.INCLUDE_PATH: case IOption.LIBRARIES:
case IOption.PREPROCESSOR_SYMBOLS: case IOption.OBJECTS:{
case IOption.LIBRARIES: Vector values = new Vector();
case IOption.OBJECTS:{ NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
Vector values = new Vector(); for (int j = 0; j < nodes.getLength(); ++j) {
NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE); Node node = nodes.item(j);
for (int j = 0; j < nodes.getLength(); ++j) { if (node.getNodeType() == Node.ELEMENT_NODE) {
Node node = nodes.item(j); Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
if (node.getNodeType() == Node.ELEMENT_NODE) { if (!isBuiltIn.booleanValue()) {
Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN)); values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
if (!isBuiltIn.booleanValue()) { }
values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
} }
} }
configuration.setOption(tool,option,(String[])values.toArray(new String[values.size()]));
break;
} }
configuration.setOption(tool,option,(String[])values.toArray(new String[values.size()])); default:
break; break;
} }
default: }
break; catch(BuildException e){
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
ConverterMessages.getFormattedString("UpdateManagedProject20.8",e.getMessage()), e)); //$NON-NLS-1$
} }
} }
catch(BuildException e){
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
ConverterMessages.getFormattedString("UpdateManagedProject20.8",e.getMessage()), e)); //$NON-NLS-1$
}
} }
} }