mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Update the necessary classes to use the new
ResolverModel.
This commit is contained in:
parent
895266aebe
commit
40f9982534
15 changed files with 61 additions and 137 deletions
|
@ -112,17 +112,17 @@ public class CModelTests extends TestCase {
|
||||||
testProject=CProjectHelper.createCProject("naturetest", "none");
|
testProject=CProjectHelper.createCProject("naturetest", "none");
|
||||||
if (testProject==null)
|
if (testProject==null)
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
assertTrue("hasCNature works", CoreModel.getDefault().hasCNature(testProject.getProject()));
|
assertTrue("hasCNature works", CoreModel.hasCNature(testProject.getProject()));
|
||||||
assertTrue("hasCCNature works without ccnature", !(CoreModel.getDefault().hasCCNature(testProject.getProject())));
|
assertTrue("hasCCNature works without ccnature", !(CoreModel.hasCCNature(testProject.getProject())));
|
||||||
|
|
||||||
|
|
||||||
CCProjectNature.addCCNature(testProject.getProject(), monitor);
|
CCProjectNature.addCCNature(testProject.getProject(), monitor);
|
||||||
assertTrue("hasCCNature works", (CoreModel.getDefault().hasCCNature(testProject.getProject())));
|
assertTrue("hasCCNature works", (CoreModel.hasCCNature(testProject.getProject())));
|
||||||
|
|
||||||
CCProjectNature.removeCCNature(testProject.getProject(), monitor);
|
CCProjectNature.removeCCNature(testProject.getProject(), monitor);
|
||||||
CCProjectNature.removeCNature(testProject.getProject(), monitor);
|
CCProjectNature.removeCNature(testProject.getProject(), monitor);
|
||||||
assertTrue("hasCNature works without cnature", !CoreModel.getDefault().hasCNature(testProject.getProject()));
|
assertTrue("hasCNature works without cnature", !CoreModel.hasCNature(testProject.getProject()));
|
||||||
assertTrue("hasCCNature works without ccnature or cnature", !(CoreModel.getDefault().hasCCNature(testProject.getProject())));
|
assertTrue("hasCCNature works without ccnature or cnature", !(CoreModel.hasCCNature(testProject.getProject())));
|
||||||
try{
|
try{
|
||||||
testProject.getProject().delete(true,true,monitor);
|
testProject.getProject().delete(true,true,monitor);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ public class CModelTests extends TestCase {
|
||||||
assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
|
assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
|
||||||
assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
|
assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
|
||||||
assertTrue("isObject", !CoreModel.getDefault().isObject(file));
|
assertTrue("isObject", !CoreModel.getDefault().isObject(file));
|
||||||
assertTrue("isTranslationUnit", !CoreModel.getDefault().isTranslationUnit(file));
|
assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
|
||||||
|
|
||||||
|
|
||||||
file = testProject.getProject().getFile("exetest.c");
|
file = testProject.getProject().getFile("exetest.c");
|
||||||
|
@ -171,7 +171,7 @@ public class CModelTests extends TestCase {
|
||||||
assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
|
assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
|
||||||
assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
|
assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
|
||||||
assertTrue("isObject", !CoreModel.getDefault().isObject(file));
|
assertTrue("isObject", !CoreModel.getDefault().isObject(file));
|
||||||
assertTrue("isTranslationUnit", CoreModel.getDefault().isTranslationUnit(file));
|
assertTrue("isTranslationUnit", CoreModel.isTranslationUnit(file));
|
||||||
|
|
||||||
file = testProject.getProject().getFile("exetest.o");
|
file = testProject.getProject().getFile("exetest.o");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -187,7 +187,7 @@ public class CModelTests extends TestCase {
|
||||||
assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
|
assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
|
||||||
assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
|
assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
|
||||||
assertTrue("isObject", CoreModel.getDefault().isObject(file));
|
assertTrue("isObject", CoreModel.getDefault().isObject(file));
|
||||||
assertTrue("isTranslationUnit", !CoreModel.getDefault().isTranslationUnit(file));
|
assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
|
||||||
|
|
||||||
file = testProject.getProject().getFile("liblibtest_g.so");
|
file = testProject.getProject().getFile("liblibtest_g.so");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -203,7 +203,7 @@ public class CModelTests extends TestCase {
|
||||||
assertTrue("isSharedLib", CoreModel.getDefault().isSharedLib(file));
|
assertTrue("isSharedLib", CoreModel.getDefault().isSharedLib(file));
|
||||||
assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
|
assertTrue("isArchive", !CoreModel.getDefault().isArchive(file));
|
||||||
assertTrue("isObject", !CoreModel.getDefault().isObject(file));
|
assertTrue("isObject", !CoreModel.getDefault().isObject(file));
|
||||||
assertTrue("isTranslationUnit", !CoreModel.getDefault().isTranslationUnit(file));
|
assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
|
||||||
|
|
||||||
file = testProject.getProject().getFile("liblibtest_g.a");
|
file = testProject.getProject().getFile("liblibtest_g.a");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -222,7 +222,7 @@ public class CModelTests extends TestCase {
|
||||||
assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
|
assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file));
|
||||||
assertTrue("isArchive", CoreModel.getDefault().isArchive(file));
|
assertTrue("isArchive", CoreModel.getDefault().isArchive(file));
|
||||||
assertTrue("isObject", !CoreModel.getDefault().isObject(file));
|
assertTrue("isObject", !CoreModel.getDefault().isObject(file));
|
||||||
assertTrue("isTranslationUnit", !CoreModel.getDefault().isTranslationUnit(file));
|
assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,9 +237,9 @@ public class CModelTests extends TestCase {
|
||||||
* Some simple tests for isValidTranslationUnitName
|
* Some simple tests for isValidTranslationUnitName
|
||||||
*/
|
*/
|
||||||
public void testIsValidTranslationUnitName() throws CoreException {
|
public void testIsValidTranslationUnitName() throws CoreException {
|
||||||
assertTrue("Invalid C file", !CoreModel.getDefault().isValidTranslationUnitName("notcfile"));
|
assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "notcfile"));
|
||||||
assertTrue("Invalid C file", !CoreModel.getDefault().isValidTranslationUnitName("not.c.file"));
|
assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "not.c.file"));
|
||||||
assertTrue("Invalid C file", !CoreModel.getDefault().isValidTranslationUnitName("not.ca"));
|
assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "not.ca"));
|
||||||
assertTrue("Valid C file", CoreModel.getDefault().isValidTranslationUnitName("areal.c"));
|
assertTrue("Valid C file", CoreModel.isValidTranslationUnitName(null, "areal.c"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2004-05-25 Alain Magloire
|
||||||
|
Update the necessary classes to use the new
|
||||||
|
ResolverModel.
|
||||||
|
|
||||||
2004-05-25 Alain Magloire
|
2004-05-25 Alain Magloire
|
||||||
|
|
||||||
Major Patch from Sam Robb
|
Major Patch from Sam Robb
|
||||||
|
|
|
@ -3,14 +3,11 @@ package org.eclipse.cdt.core.model;
|
||||||
/*
|
/*
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCProjectNature;
|
import org.eclipse.cdt.core.CCProjectNature;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.filetype.ICFileType;
|
import org.eclipse.cdt.core.filetype.ICFileType;
|
||||||
import org.eclipse.cdt.core.filetype.ICFileTypeAssociation;
|
|
||||||
import org.eclipse.cdt.core.filetype.ICFileTypeResolver;
|
|
||||||
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
||||||
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
||||||
import org.eclipse.cdt.internal.core.model.CModel;
|
import org.eclipse.cdt.internal.core.model.CModel;
|
||||||
|
@ -170,84 +167,27 @@ public class CoreModel {
|
||||||
/**
|
/**
|
||||||
* Return true if name is a valid name for a translation unit.
|
* Return true if name is a valid name for a translation unit.
|
||||||
*/
|
*/
|
||||||
public static boolean isValidTranslationUnitName(String name) {
|
public static boolean isValidTranslationUnitName(IProject project, String name) {
|
||||||
ICFileTypeResolver resolver = CCorePlugin.getDefault().getFileTypeResolver();
|
ICFileType type = CCorePlugin.getDefault().getFileType(project, name);
|
||||||
ICFileType type = resolver.getFileType(name);
|
|
||||||
return type.isTranslationUnit();
|
return type.isTranslationUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if name is a valid name for a translation unit.
|
* Return true if name is a valid name for a translation unit.
|
||||||
*/
|
*/
|
||||||
public static boolean isValidHeaderUnitName(String name) {
|
public static boolean isValidHeaderUnitName(IProject project, String name) {
|
||||||
ICFileTypeResolver resolver = CCorePlugin.getDefault().getFileTypeResolver();
|
ICFileType type = CCorePlugin.getDefault().getFileType(project, name);
|
||||||
ICFileType type = resolver.getFileType(name);
|
|
||||||
return type.isHeader();
|
return type.isHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if name is a valid name for a translation unit.
|
* Return true if name is a valid name for a translation unit.
|
||||||
*/
|
*/
|
||||||
public static boolean isValidSourceUnitName(String name) {
|
public static boolean isValidSourceUnitName(IProject project, String name) {
|
||||||
ICFileTypeResolver resolver = CCorePlugin.getDefault().getFileTypeResolver();
|
ICFileType type = CCorePlugin.getDefault().getFileType(project, name);
|
||||||
ICFileType type = resolver.getFileType(name);
|
|
||||||
return type.isSource();
|
return type.isSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the list of headers extensions.
|
|
||||||
*/
|
|
||||||
public static String[] getHeaderExtensions() {
|
|
||||||
ICFileTypeResolver resolver = CCorePlugin.getDefault().getFileTypeResolver();
|
|
||||||
ICFileTypeAssociation[] associations = resolver.getFileTypeAssociations();
|
|
||||||
ArrayList list = new ArrayList(associations.length);
|
|
||||||
for (int i = 0; i < associations.length; i++) {
|
|
||||||
ICFileType type = associations[i].getType();
|
|
||||||
if (type.isHeader()) {
|
|
||||||
list.add(associations[i].getPattern());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] exts = new String[list.size()];
|
|
||||||
list.toArray(exts);
|
|
||||||
return exts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the list of source extensions.
|
|
||||||
*/
|
|
||||||
public static String[] getSourceExtensions() {
|
|
||||||
ICFileTypeResolver resolver = CCorePlugin.getDefault().getFileTypeResolver();
|
|
||||||
ICFileTypeAssociation[] associations = resolver.getFileTypeAssociations();
|
|
||||||
ArrayList list = new ArrayList(associations.length);
|
|
||||||
for (int i = 0; i < associations.length; i++) {
|
|
||||||
ICFileType type = associations[i].getType();
|
|
||||||
if (type.isSource()) {
|
|
||||||
list.add(associations[i].getPattern());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] exts = new String[list.size()];
|
|
||||||
list.toArray(exts);
|
|
||||||
return exts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the list of headers and sources extensions
|
|
||||||
*/
|
|
||||||
public static String[] getTranslationUnitExtensions() {
|
|
||||||
ICFileTypeResolver resolver = CCorePlugin.getDefault().getFileTypeResolver();
|
|
||||||
ICFileTypeAssociation[] associations = resolver.getFileTypeAssociations();
|
|
||||||
ArrayList list = new ArrayList(associations.length);
|
|
||||||
for (int i = 0; i < associations.length; i++) {
|
|
||||||
ICFileType type = associations[i].getType();
|
|
||||||
if (type.isTranslationUnit()) {
|
|
||||||
list.add(associations[i].getPattern());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] exts = new String[list.size()];
|
|
||||||
list.toArray(exts);
|
|
||||||
return exts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if project has C nature.
|
* Return true if project has C nature.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -80,7 +80,8 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
}
|
}
|
||||||
case IResource.FILE: {
|
case IResource.FILE: {
|
||||||
String filename = member.getName();
|
String filename = member.getName();
|
||||||
if (CoreModel.isValidTranslationUnitName(filename) && root.isOnSourceEntry(member)) {
|
if (CoreModel.isValidTranslationUnitName(cproject.getProject(), filename) &&
|
||||||
|
root.isOnSourceEntry(member)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (root.isOnSourceEntry(member)) {
|
if (root.isOnSourceEntry(member)) {
|
||||||
|
|
|
@ -135,7 +135,13 @@ public class CModelBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// pick the language
|
// pick the language
|
||||||
ParserLanguage language = hasCppNature ? ParserLanguage.CPP : ParserLanguage.C;
|
ParserLanguage language;
|
||||||
|
if (hasCppNature) {
|
||||||
|
language = ParserLanguage.CPP;
|
||||||
|
} else {
|
||||||
|
// for C project try to guess.
|
||||||
|
language = translationUnit.isCXXLanguage() ? ParserLanguage.CPP : ParserLanguage.C;
|
||||||
|
}
|
||||||
|
|
||||||
// create the parser
|
// create the parser
|
||||||
IParser parser = null;
|
IParser parser = null;
|
||||||
|
|
|
@ -266,6 +266,14 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
if (cproject == null) {
|
if (cproject == null) {
|
||||||
cproject = create(file.getProject());
|
cproject = create(file.getProject());
|
||||||
}
|
}
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
// FIXME-alain: Quick hack 'til we fix the CDescriptor
|
||||||
|
// This should/must be remove
|
||||||
|
// ".cdtproject" is a special file for CProjects.
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
if (file.getName().equals(".cdtproject")) { // $NON-NLS-1$
|
||||||
|
return null;
|
||||||
|
}
|
||||||
boolean checkIfBinary = false;
|
boolean checkIfBinary = false;
|
||||||
ICElement celement = null;
|
ICElement celement = null;
|
||||||
try {
|
try {
|
||||||
|
@ -284,7 +292,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
cfolder = cfolder.getCContainer(segments[j]);
|
cfolder = cfolder.getCContainer(segments[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CoreModel.isValidTranslationUnitName(fileName)) {
|
if (CoreModel.isValidTranslationUnitName(cproject.getProject(), fileName)) {
|
||||||
celement = cfolder.getTranslationUnit(fileName);
|
celement = cfolder.getTranslationUnit(fileName);
|
||||||
} else if (cproject.isOnOutputEntry(file)) {
|
} else if (cproject.isOnOutputEntry(file)) {
|
||||||
IBinaryFile bin = createBinaryFile(file);
|
IBinaryFile bin = createBinaryFile(file);
|
||||||
|
|
|
@ -106,7 +106,7 @@ class CProjectInfo extends OpenableInfo {
|
||||||
case IResource.FILE: {
|
case IResource.FILE: {
|
||||||
String filename = member.getName();
|
String filename = member.getName();
|
||||||
if (srcIsProject) {
|
if (srcIsProject) {
|
||||||
if (CoreModel.isValidTranslationUnitName(filename)
|
if (CoreModel.isValidTranslationUnitName(cproject.getProject(), filename)
|
||||||
&& !CoreModelUtil.isExcluded(member, exclusionPatterns)) {
|
&& !CoreModelUtil.isExcluded(member, exclusionPatterns)) {
|
||||||
continue;
|
continue;
|
||||||
} else if (!CoreModelUtil.isExcluded(member, exclusionPatterns)) {
|
} else if (!CoreModelUtil.isExcluded(member, exclusionPatterns)) {
|
||||||
|
|
|
@ -607,7 +607,7 @@ public class DeltaProcessor {
|
||||||
|
|
||||||
String filename = resource.getName();
|
String filename = resource.getName();
|
||||||
|
|
||||||
if (CoreModel.isValidHeaderUnitName(filename)) {
|
if (CoreModel.isValidHeaderUnitName(resource.getProject(), filename)) {
|
||||||
indexManager.updateDependencies(resource);
|
indexManager.updateDependencies(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,8 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
||||||
ICElement celement = null;
|
ICElement celement = null;
|
||||||
if (child.isDirectory()) {
|
if (child.isDirectory()) {
|
||||||
celement = new IncludeReference(this, fIncludeEntry, new Path(child.getAbsolutePath()));
|
celement = new IncludeReference(this, fIncludeEntry, new Path(child.getAbsolutePath()));
|
||||||
} else if (CoreModel.isValidTranslationUnitName(names[i]) && child.isFile()) {
|
} else if (CoreModel.isValidTranslationUnitName(getCProject().getProject(), names[i]) &&
|
||||||
|
child.isFile()) {
|
||||||
celement = new ExternalTranslationUnit(this, path.append(names[i]));
|
celement = new ExternalTranslationUnit(this, path.append(names[i]));
|
||||||
}
|
}
|
||||||
if (celement != null) {
|
if (celement != null) {
|
||||||
|
|
|
@ -102,8 +102,9 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathEntry[] getResolvedPathEntries(ICProject cproject) throws CModelException {
|
public IPathEntry[] getResolvedPathEntries(ICProject cproject) throws CModelException {
|
||||||
boolean markers = cproject.getProject().getWorkspace().isTreeLocked();
|
//boolean markers = cproject.getProject().getWorkspace().isTreeLocked();
|
||||||
return getResolvedPathEntries(cproject, !markers);
|
//return getResolvedPathEntries(cproject, !markers);
|
||||||
|
return getResolvedPathEntries(cproject, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathEntry[] getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException {
|
public IPathEntry[] getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException {
|
||||||
|
|
|
@ -532,14 +532,16 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#isHeaderUnit()
|
* @see org.eclipse.cdt.core.model.ITranslationUnit#isHeaderUnit()
|
||||||
*/
|
*/
|
||||||
public boolean isHeaderUnit() {
|
public boolean isHeaderUnit() {
|
||||||
return CoreModel.isValidHeaderUnitName(getPath().lastSegment());
|
IProject project = getCProject().getProject();
|
||||||
|
return CoreModel.isValidHeaderUnitName(project, getPath().lastSegment());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#isSourceUnit()
|
* @see org.eclipse.cdt.core.model.ITranslationUnit#isSourceUnit()
|
||||||
*/
|
*/
|
||||||
public boolean isSourceUnit() {
|
public boolean isSourceUnit() {
|
||||||
return CoreModel.isValidSourceUnitName(getPath().lastSegment());
|
IProject project = getCProject().getProject();
|
||||||
|
return CoreModel.isValidSourceUnitName(project, getPath().lastSegment());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -662,22 +662,6 @@ public class CCorePlugin extends Plugin {
|
||||||
return new DefaultPathEntryStore(project);
|
return new DefaultPathEntryStore(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the file type object corresponding to the provided
|
|
||||||
* file name, using the workspace resolver.
|
|
||||||
*
|
|
||||||
* If no file type object exists, a default file type object is
|
|
||||||
* returned.
|
|
||||||
*
|
|
||||||
* @param fileName Name of the file to resolve type info for.
|
|
||||||
*
|
|
||||||
* @return File type object for the provided file name, in the
|
|
||||||
* context of the workspace
|
|
||||||
*/
|
|
||||||
public ICFileType getFileType(String fileName) {
|
|
||||||
return getFileTypeResolver().getFileType(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file type object corresponding to the provided
|
* Returns the file type object corresponding to the provided
|
||||||
* file name.
|
* file name.
|
||||||
|
@ -695,17 +679,6 @@ public class CCorePlugin extends Plugin {
|
||||||
return getFileTypeResolver(project).getFileType(fileName);
|
return getFileTypeResolver(project).getFileType(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the file type resolver for the workspace.
|
|
||||||
*
|
|
||||||
* @param project Project to get file type resolver for.
|
|
||||||
*
|
|
||||||
* @return File type resolver for the project.
|
|
||||||
*/
|
|
||||||
public ICFileTypeResolver getFileTypeResolver() {
|
|
||||||
return getResolverModel().getResolver();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the file type resolver for the specified project.
|
* Return the file type resolver for the specified project.
|
||||||
* Specifying a null project returns the file type resolver
|
* Specifying a null project returns the file type resolver
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class TypeInfoLabelProvider extends LabelProvider {
|
||||||
ITypeReference ref = typeRef.getResolvedReference();
|
ITypeReference ref = typeRef.getResolvedReference();
|
||||||
if (ref != null) {
|
if (ref != null) {
|
||||||
path = ref.getPath();
|
path = ref.getPath();
|
||||||
if (CoreModel.isValidHeaderUnitName(path.lastSegment())) {
|
if (CoreModel.isValidHeaderUnitName(typeRef.getEnclosingProject(), path.lastSegment())) {
|
||||||
return HEADER_ICON;
|
return HEADER_ICON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class UndoManager implements IUndoManager {
|
||||||
IResource resource= delta.getResource();
|
IResource resource= delta.getResource();
|
||||||
if (resource.getType() == IResource.FILE && delta.getKind() == IResourceDelta.CHANGED &&
|
if (resource.getType() == IResource.FILE && delta.getKind() == IResourceDelta.CHANGED &&
|
||||||
(delta.getFlags() & IResourceDelta.CONTENT) != 0) {
|
(delta.getFlags() & IResourceDelta.CONTENT) != 0) {
|
||||||
if(CoreModel.getDefault().isValidTranslationUnitName(resource.getName())) {
|
if(CoreModel.isValidTranslationUnitName(resource.getProject(), resource.getName())) {
|
||||||
ITranslationUnit unit= (ITranslationUnit)CoreModel.getDefault().create((IFile)resource);
|
ITranslationUnit unit= (ITranslationUnit)CoreModel.getDefault().create((IFile)resource);
|
||||||
if (unit != null && unit.exists()) {
|
if (unit != null && unit.exists()) {
|
||||||
flush();
|
flush();
|
||||||
|
|
|
@ -112,25 +112,13 @@ public class CElementSorter extends ViewerSorter {
|
||||||
} else if (element instanceof ICContainer) {
|
} else if (element instanceof ICContainer) {
|
||||||
return CCONTAINERS;
|
return CCONTAINERS;
|
||||||
} else if (element instanceof ITranslationUnit) {
|
} else if (element instanceof ITranslationUnit) {
|
||||||
IResource res = null;
|
ITranslationUnit tu = (ITranslationUnit)element;
|
||||||
res = ((ITranslationUnit)element).getUnderlyingResource();
|
if (CoreModel.isValidHeaderUnitName(tu.getCProject().getProject(), tu.getElementName())) {
|
||||||
if (res != null) {
|
|
||||||
String ext = res.getFileExtension();
|
|
||||||
if (ext != null) {
|
|
||||||
String[] headers = CoreModel.getDefault().getHeaderExtensions();
|
|
||||||
for (int i = 0; i < headers.length; i++) {
|
|
||||||
if (ext.equals(headers[i])) {
|
|
||||||
return TRANSLATIONUNIT_HEADERS;
|
return TRANSLATIONUNIT_HEADERS;
|
||||||
}
|
}
|
||||||
}
|
if (CoreModel.isValidSourceUnitName(tu.getCProject().getProject(), tu.getElementName())) {
|
||||||
String[] sources = CoreModel.getDefault().getSourceExtensions();
|
|
||||||
for (int i = 0; i < sources.length; i++) {
|
|
||||||
if (ext.equals(sources[i])) {
|
|
||||||
return TRANSLATIONUNIT_SOURCE;
|
return TRANSLATIONUNIT_SOURCE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRANSLATIONUNITS;
|
return TRANSLATIONUNITS;
|
||||||
} else if (element instanceof IInclude) {
|
} else if (element instanceof IInclude) {
|
||||||
return INCLUDES;
|
return INCLUDES;
|
||||||
|
|
Loading…
Add table
Reference in a new issue