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

Update MBS to use project-specific content types when available

This commit is contained in:
Leo Treggiari 2005-06-26 03:54:50 +00:00
parent 59725982d0
commit cb24633d18
10 changed files with 179 additions and 51 deletions

View file

@ -51,7 +51,7 @@ public class TestLinkerNameProvider implements IManagedOutputNameProvider {
fileName = fileName.substring(2,fileName.length()-1);
}
}
String[] exts = tool.getPrimaryOutputType().getOutputExtensions();
String[] exts = tool.getPrimaryOutputType().getOutputExtensions(tool);
if (exts != null && exts[0].length() > 0) {
fileName += IManagedBuilderMakefileGenerator.DOT + exts[0];
}

View file

@ -183,18 +183,20 @@ public interface IInputType extends IBuildObject {
* is specified and registered with Eclipse. Otherwise the
* sourceExtensions attribute will be used.
*
* @param tool the tool that contains the input-type
* @return String[]
*/
public String[] getSourceExtensions();
public String[] getSourceExtensions(ITool tool);
/**
* Answers <code>true</code> if the input type considers the file extension to be
* one associated with a source file.
*
* @param ext file extension of the source
* @param tool the tool that contains the input-type
* @param ext file extension of the source
* @return boolean
*/
public boolean isSourceExtension(String ext);
public boolean isSourceExtension(ITool tool, String ext);
/**
* Returns the Eclipse <code>IContentType</code> that describes the
@ -242,18 +244,20 @@ public interface IInputType extends IBuildObject {
* is specified and registered with Eclipse. Otherwise the
* dependencyExtensions attribute will be used.
*
* @param tool the tool that contains the input-type
* @return String[]
*/
public String[] getDependencyExtensions();
public String[] getDependencyExtensions(ITool tool);
/**
* Answers <code>true</code> if the input type considers the file extension to be
* one associated with a dependency file.
*
* @param ext file extension of the source
* @param tool the tool that contains the input-type
* @param ext file extension of the source
* @return boolean
*/
public boolean isDependencyExtension(String ext);
public boolean isDependencyExtension(ITool tool, String ext);
/**
* Returns the id of the option that is associated with this

View file

@ -93,18 +93,20 @@ public interface IOutputType extends IBuildObject {
* is specified and registered with Eclipse. Otherwise the
* outputs attribute will be used.
*
* @param tool the tool that contains the output-type
* @return String[]
*/
public String[] getOutputExtensions();
public String[] getOutputExtensions(ITool tool);
/**
* Answers <code>true</code> if the output type considers the file extension to be
* one associated with an output file.
*
* @param ext file extension
* @param tool the tool that contains the output-type
* @param ext file extension
* @return boolean
*/
public boolean isOutputExtension(String ext);
public boolean isOutputExtension(ITool tool, String ext);
/**
* Returns the id of the option that is associated with this

View file

@ -16,10 +16,15 @@ import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.content.*;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IInputOrder;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
@ -678,6 +683,22 @@ public class InputType extends BuildObject implements IInputType {
return (IPath[])ins.toArray(new IPath[ins.size()]);
}
/* (non-Javadoc)
* Returns the project that uses this IInputType
*/
public IProject getProject(ITool tool) {
IProject project = null;
IBuildObject toolParent = tool.getParent();
if (toolParent != null) {
if (toolParent instanceof IToolChain) {
return (IProject)((IToolChain)toolParent).getParent().getOwner();
} else if (toolParent instanceof IResourceConfiguration) {
return (IProject)((IResourceConfiguration)toolParent).getOwner();
}
}
return project;
}
/* (non-Javadoc)
* Memory-safe way to access the list of input orders
*/
@ -806,10 +827,26 @@ public class InputType extends BuildObject implements IInputType {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyExtensions()
*/
public String[] getDependencyExtensions() {
public String[] getDependencyExtensions(ITool tool) {
// Use content type if specified and registered with Eclipse
IContentType type = getDependencyContentType();
if (type != null) {
IContentTypeSettings settings = null;
IProject project = getProject(tool);
if (project != null) {
IScopeContext projectScope = new ProjectScope(project);
try {
settings = type.getSettings(projectScope);
} catch (Exception e) {}
if (settings != null) {
String[] specs = settings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
// TODO: There doesn't seem to be any way to distinguish between these 2 cases:
// 1. No project specific entries have been set so getFileSpecs returns an empty list
// 2. There are project specific entries and all of the "default" entries have been removed
// For now, we have to assume the first case.
if (specs.length > 0) return specs;
}
}
return type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
}
return getDependencyExtensionsAttribute();
@ -818,8 +855,8 @@ public class InputType extends BuildObject implements IInputType {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#isDependencyExtension()
*/
public boolean isDependencyExtension(String ext) {
String[] exts = getDependencyExtensions();
public boolean isDependencyExtension(ITool tool, String ext) {
String[] exts = getDependencyExtensions(tool);
for (int i=0; i<exts.length; i++) {
if (ext.equals(exts[i])) return true;
}
@ -1006,20 +1043,36 @@ public class InputType extends BuildObject implements IInputType {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#getSourceExtensions()
*/
public String[] getSourceExtensions() {
public String[] getSourceExtensions(ITool tool) {
// Use content type if specified and registered with Eclipse
IContentType type = getSourceContentType();
if (type != null) {
IContentTypeSettings settings = null;
IProject project = getProject(tool);
if (project != null) {
IScopeContext projectScope = new ProjectScope(project);
try {
settings = type.getSettings(projectScope);
} catch (Exception e) {}
if (settings != null) {
String[] specs = settings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
// TODO: There doesn't seem to be any way to distinguish between these 2 cases:
// 1. No project specific entries have been set so getFileSpecs returns an empty list
// 2. There are project specific entries and all of the "default" entries have been removed
// For now, we have to assume the first case.
if (specs.length > 0) return specs;
}
}
return type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
}
return getSourceExtensionsAttribute();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#isDependencyExtension()
* @see org.eclipse.cdt.core.build.managed.IInputType#isSourceExtension()
*/
public boolean isSourceExtension(String ext) {
String[] exts = getSourceExtensions();
public boolean isSourceExtension(ITool tool, String ext) {
String[] exts = getSourceExtensions(tool);
for (int i=0; i<exts.length; i++) {
if (ext.equals(exts[i])) return true;
}

View file

@ -10,14 +10,19 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.content.*;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@ -414,6 +419,22 @@ public class OutputType extends BuildObject implements IOutputType {
return parent;
}
/* (non-Javadoc)
* Returns the project that uses this IOutputType
*/
public IProject getProject(ITool tool) {
IProject project = null;
IBuildObject toolParent = tool.getParent();
if (toolParent != null) {
if (toolParent instanceof IToolChain) {
return (IProject)((IToolChain)toolParent).getParent().getOwner();
} else if (toolParent instanceof IResourceConfiguration) {
return (IProject)((IResourceConfiguration)toolParent).getOwner();
}
}
return project;
}
/*
* M O D E L A T T R I B U T E A C C E S S O R S
*/
@ -637,10 +658,26 @@ public class OutputType extends BuildObject implements IOutputType {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOuputType#getOutputExtensions()
*/
public String[] getOutputExtensions() {
public String[] getOutputExtensions(ITool tool) {
// Use content type if specified and registered with Eclipse
IContentType type = getOutputContentType();
if (type != null) {
IContentTypeSettings settings = null;
IProject project = getProject(tool);
if (project != null) {
IScopeContext projectScope = new ProjectScope(project);
try {
settings = type.getSettings(projectScope);
} catch (Exception e) {}
if (settings != null) {
String[] specs = settings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
// TODO: There doesn't seem to be any way to distinguish between these 2 cases:
// 1. No project specific entries have been set so getFileSpecs returns an empty list
// 2. There are project specific entries and all of the "default" entries have been removed
// For now, we have to assume the first case.
if (specs.length > 0) return specs;
}
}
return type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
}
return getOutputExtensionsAttribute();
@ -649,8 +686,8 @@ public class OutputType extends BuildObject implements IOutputType {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOutputType#isOutputExtension()
*/
public boolean isOutputExtension(String ext) {
String[] exts = getOutputExtensions();
public boolean isOutputExtension(ITool tool, String ext) {
String[] exts = getOutputExtensions(tool);
if (exts != null) {
for (int i=0; i<exts.length; i++) {
if (ext.equals(exts[i])) return true;

View file

@ -70,8 +70,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
public static final String DEFAULT_CBS_PATTERN = "${COMMAND}"; //$NON-NLS-1$
private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
private static final IOption[] EMPTY_OPTIONS = new IOption[0];
//private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
//private static final IOption[] EMPTY_OPTIONS = new IOption[0];
private static final String EMPTY_STRING = new String();
private static final String[] EMPTY_STRING_ARRAY = new String[0];
private static final String DEFAULT_ANNOUNCEMENT_PREFIX = "Tool.default.announcement"; //$NON-NLS-1$
@ -1341,7 +1341,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
// Find the primary input type
IInputType type = getPrimaryInputType();
if (type != null) {
String[] exts = type.getSourceExtensions();
String[] exts = type.getSourceExtensions(this);
// Use the first entry in the list
if (exts.length > 0) return exts[0];
}
@ -1358,7 +1358,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
public String[] getPrimaryInputExtensions() {
IInputType type = getPrimaryInputType();
if (type != null) {
String[] exts = type.getSourceExtensions();
String[] exts = type.getSourceExtensions(this);
// Use the first entry in the list
if (exts.length > 0) return exts;
}
@ -1379,7 +1379,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (types != null && types.length > 0) {
List allExts = new ArrayList();
for (int i=0; i<types.length; i++) {
String[] exts = types[i].getSourceExtensions();
String[] exts = types[i].getSourceExtensions(this);
for (int j=0; j<exts.length; j++) {
allExts.add(exts[j]);
}
@ -1419,7 +1419,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
IInputType[] types = getInputTypes();
if (types != null && types.length > 0) {
for (int i=0; i<types.length; i++) {
if (types[i].isSourceExtension(inputExtension)) {
if (types[i].isSourceExtension(this, inputExtension)) {
type = types[i];
break;
}
@ -1506,7 +1506,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (types != null && types.length > 0) {
List allExts = new ArrayList();
for (int i=0; i<types.length; i++) {
String[] exts = types[i].getDependencyExtensions();
String[] exts = types[i].getDependencyExtensions(this);
for (int j=0; j<exts.length; j++) {
allExts.add(exts[j]);
}
@ -1740,7 +1740,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
IInputType[] types = getInputTypes();
if (types != null) {
for (int i=0; i<types.length; i++) {
if (types[i].isSourceExtension(sourceExt)) {
if (types[i].isSourceExtension(this, sourceExt)) {
return ((InputType)types[i]).getDependencyGeneratorElement();
}
}
@ -1830,7 +1830,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (types != null && types.length > 0) {
List allExts = new ArrayList();
for (int i=0; i<types.length; i++) {
String[] exts = types[i].getOutputExtensions();
String[] exts = types[i].getOutputExtensions(this);
if (exts != null) {
for (int j=0; j<exts.length; j++) {
allExts.add(exts[j]);
@ -1882,8 +1882,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (types != null) {
for (i=0; i<types.length; i++) {
IInputType inputType = types[i].getPrimaryInputType();
if (inputType != null && inputType.isSourceExtension(inputExtension)) {
String[] exts = types[i].getOutputExtensions();
if (inputType != null && inputType.isSourceExtension(this, inputExtension)) {
String[] exts = types[i].getOutputExtensions(this);
if (exts != null && exts.length > 0) {
return exts[0];
}
@ -1893,7 +1893,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (getInputType(inputExtension) != null) {
// Return the first extension of the primary output type
IOutputType outType = getPrimaryOutputType();
String[] exts = outType.getOutputExtensions();
String[] exts = outType.getOutputExtensions(this);
if (exts != null && exts.length > 0) {
return exts[0];
}
@ -1924,7 +1924,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
IOutputType[] types = getOutputTypes();
if (types != null && types.length > 0) {
for (int i=0; i<types.length; i++) {
if (types[i].isOutputExtension(outputExtension)) {
if (types[i].isOutputExtension(this, outputExtension)) {
type = types[i];
break;
}
@ -2425,7 +2425,6 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
private void checkForMigrationSupport() {
String tmpId = null;
boolean isExists = false;
if ( getSuperClass() == null) {

View file

@ -83,7 +83,7 @@ public class GnuLinkOutputNameProvider implements IManagedOutputNameProvider {
fileName = outputPrefix + fileName;
}
// Add the primary output type extension
String[] exts = tool.getPrimaryOutputType().getOutputExtensions();
String[] exts = tool.getPrimaryOutputType().getOutputExtensions(tool);
if (exts != null && exts[0].length() > 0) {
fileName += IManagedBuilderMakefileGenerator.DOT + exts[0];
}

View file

@ -119,7 +119,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// What kind of resource change has occurred
if (resource.getType() == IResource.FILE) {
String ext = resource.getFileExtension();
boolean moved = false;
switch (delta.getKind()) {
case IResourceDelta.ADDED:
if (!generator.isGeneratedResource(resource)) {
@ -232,11 +231,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// String constants for makefile contents and messages
private static final String COMMENT = "MakefileGenerator.comment"; //$NON-NLS-1$
private static final String AUTO_DEP = COMMENT + ".autodeps"; //$NON-NLS-1$
private static final String MESSAGE = "ManagedMakeBuilder.message"; //$NON-NLS-1$
private static final String BUILD_ERROR = MESSAGE + ".error"; //$NON-NLS-1$
//private static final String AUTO_DEP = COMMENT + ".autodeps"; //$NON-NLS-1$
//private static final String MESSAGE = "ManagedMakeBuilder.message"; //$NON-NLS-1$
//private static final String BUILD_ERROR = MESSAGE + ".error"; //$NON-NLS-1$
private static final String DEP_INCL = COMMENT + ".module.dep.includes"; //$NON-NLS-1$
//private static final String DEP_INCL = COMMENT + ".module.dep.includes"; //$NON-NLS-1$
private static final String HEADER = COMMENT + ".header"; //$NON-NLS-1$
protected static final String MESSAGE_FINISH_BUILD = ManagedMakeMessages.getResourceString("MakefileGenerator.message.finish.build"); //$NON-NLS-1$
@ -244,7 +243,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
protected static final String MESSAGE_START_BUILD = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.build"); //$NON-NLS-1$
protected static final String MESSAGE_START_FILE = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.file"); //$NON-NLS-1$
protected static final String MESSAGE_NO_TARGET_TOOL = ManagedMakeMessages.getResourceString("MakefileGenerator.message.no.target"); //$NON-NLS-1$
private static final String MOD_INCL = COMMENT + ".module.make.includes"; //$NON-NLS-1$
//private static final String MOD_INCL = COMMENT + ".module.make.includes"; //$NON-NLS-1$
private static final String MOD_LIST = COMMENT + ".module.list"; //$NON-NLS-1$
private static final String MOD_VARS = COMMENT + ".module.variables"; //$NON-NLS-1$
private static final String MOD_RULES = COMMENT + ".build.rule"; //$NON-NLS-1$
@ -1601,7 +1600,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Generate a build rule for any tool that consumes the output of this tool
IOutputType[] outTypes = generatingTool.getOutputTypes();
for (int i=0; i<outTypes.length; i++) {
String[] outExts = outTypes[i].getOutputExtensions();
String[] outExts = outTypes[i].getOutputExtensions(generatingTool);
String outVariable = outTypes[i].getBuildVariable();
if (outExts != null) {
for (int j=0; j<outExts.length; j++) {
@ -1863,7 +1862,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
tool = buildTools[j];
}
// look for the extension in the map
StringBuffer bufferForExtension = new StringBuffer();
if (varName == null) {
varName = getSourceMacroName(ext).toString();
// Add the resource to the list of all resources associated with a variable.
@ -2347,7 +2345,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
boolean primaryOutput = (type == tool.getPrimaryOutputType());
//if (primaryOutput && ignorePrimary) continue;
String outputPrefix = type.getOutputPrefix();
String variable = type.getBuildVariable();
boolean multOfType = type.getMultipleOfType();
IOption option = tool.getOptionBySuperClassId(type.getOptionId());
IManagedOutputNameProvider nameProvider = type.getNameProvider();

View file

@ -42,8 +42,8 @@ import org.eclipse.core.runtime.Path;
*/
public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
private static final String EMPTY_STRING = new String();
private static final String OBJS_MACRO = "OBJS"; //$NON-NLS-1$
//private static final String EMPTY_STRING = new String();
//private static final String OBJS_MACRO = "OBJS"; //$NON-NLS-1$
private static final String DEPS_MACRO = "DEPS"; //$NON-NLS-1$
/*
@ -223,7 +223,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// it gives us an input resource for generating default names
// Determine the set of source input macros to use
HashSet handledInputExtensions = new HashSet();
String[] exts = type.getSourceExtensions();
String[] exts = type.getSourceExtensions(tool);
if (projResources != null) {
for (int j=0; j<projResources.length; j++) {
if (projResources[j].getType() == IResource.FILE) {
@ -232,7 +232,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// fix for NPE, bugzilla 99483
if(fileExt == null)
{
fileExt = "";
fileExt = ""; //$NON-NLS-1$
}
for (int k=0; k<exts.length; k++) {
@ -475,7 +475,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
String namePattern = type.getNamePattern();
if (namePattern == null || namePattern.length() == 0) {
namePattern = outputPrefix + IManagedBuilderMakefileGenerator.WILDCARD;
String outExt = (type.getOutputExtensions())[0];
String outExt = (type.getOutputExtensions(tool))[0];
if (outExt != null && outExt.length() > 0) {
namePattern += DOT + outExt;
}
@ -597,7 +597,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
switch (calcType) {
case IManagedDependencyGenerator.TYPE_COMMAND:
// iterate over all extensions that the tool knows how to handle
String[] extensionsList = type.getSourceExtensions();
String[] extensionsList = type.getSourceExtensions(tool);
for (int j=0; j<extensionsList.length; j++) {
String extensionName = extensionsList[j];

View file

@ -13,18 +13,26 @@ package org.eclipse.cdt.managedbuilder.projectconverter;
import java.io.File;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.content.IContentTypeSettings;
import org.eclipse.core.runtime.preferences.IScopeContext;
class UpdateManagedProject21 {
@ -46,10 +54,38 @@ class UpdateManagedProject21 {
monitor.beginTask(ConverterMessages.getFormattedString("UpdateManagedProject20.0", projectName), 1); //$NON-NLS-1$
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
UpdateManagedProjectManager.backupFile(file, "_21backup", monitor, project); //$NON-NLS-1$
// No physical conversion is need since the 3.0 model is a superset of the 2.1 model
// Just upgrade the version
// We need to upgrade the version
((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString());
info.setValid(true);
// Also we check for this special case. If the project is a C++ project, and it contains .c files, we add
// the .c extension to the project-specific list of C++ file extensions so that these projects build as they
// did in CDT 2.*. Otherwise the .c files will not be compiled by default since CDT 3.0 switched to using
// Eclipse content types.
if (CoreModel.hasCCNature(project)) {
IResource[] files = project.members();
for (int i=0; i<files.length; i++) {
String ext = files[i].getFileExtension();
if (ext != null && ext.equals("c")) { //$NON-NLS-1$
/*
* What to do here is not yet decided
try {
IContentTypeManager manager = Platform.getContentTypeManager();
IContentType contentType = manager.getContentType("org.eclipse.cdt.core.cxxSource"); //$NON-NLS-1$
IScopeContext projectScope = new ProjectScope(project);
IContentTypeSettings settings = contentType.getSettings(projectScope);
// TODO: we need to add the default extensions too...
settings.addFileSpec("c", IContentType.FILE_EXTENSION_SPEC); //$NON-NLS-1$
} catch (CoreException e) {
// TODO: Issue message??
}
*/
break;
}
}
}
// Save the updated file
// If the tree is locked spawn a job to this.