1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-21 16:05:25 +02:00

Don't bother checking to see if non-existent files are in the project.

This commit is contained in:
Ken Ryall 2009-05-19 17:19:53 +00:00
parent bd6747e339
commit b48b4d1acd

View file

@ -81,16 +81,16 @@ public class Executable extends PlatformObject {
return super.equals(arg0); return super.equals(arg0);
} }
private IPath path; private final IPath executablePath;
private IProject project; private final IProject project;
private String name; private final String name;
private IResource resource; private final IResource resource;
private Map<ITranslationUnit, String> remappedPaths; private final Map<ITranslationUnit, String> remappedPaths;
private ArrayList<ITranslationUnit> sourceFiles; private final ArrayList<ITranslationUnit> sourceFiles;
private boolean refreshSourceFiles; private boolean refreshSourceFiles;
public IPath getPath() { public IPath getPath() {
return path; return executablePath;
} }
public IProject getProject() { public IProject getProject() {
@ -98,7 +98,7 @@ public class Executable extends PlatformObject {
} }
public Executable(IPath path, IProject project, IResource resource) { public Executable(IPath path, IProject project, IResource resource) {
this.path = path; this.executablePath = path;
this.project = project; this.project = project;
this.name = new File(path.toOSString()).getName(); this.name = new File(path.toOSString()).getName();
this.resource = resource; this.resource = resource;
@ -113,7 +113,7 @@ public class Executable extends PlatformObject {
@Override @Override
public String toString() { public String toString() {
return path.toString(); return executablePath.toString();
} }
public String getName() { public String getName() {
@ -173,33 +173,38 @@ public class Executable extends PlatformObject {
// resolve // resolve
// them relative to the executable. // them relative to the executable.
boolean fileExists = false;
try { try {
File file = new File(filename); File file = new File(filename);
if (file.exists()) { fileExists = file.exists();
if (fileExists) {
filename = file.getCanonicalPath(); filename = file.getCanonicalPath();
} else if (filename.startsWith(".")) { //$NON-NLS-1$ } else if (filename.startsWith(".")) { //$NON-NLS-1$
file = new File(path.removeLastSegments(1).toOSString(), filename); file = new File(executablePath.removeLastSegments(1).toOSString(), filename);
filename = file.getCanonicalPath(); filename = file.getCanonicalPath();
} }
} catch (IOException e) { // Do nothing. } catch (IOException e) { // Do nothing.
} }
// See if this source file is already in the project.
// We check this to determine if we should create a
// TranslationUnit or ExternalTranslationUnit
IFile sourceFile = getProject().getFile(filename);
IPath path = new Path(filename);
IFile wkspFile = null; IFile wkspFile = null;
if (sourceFile.exists()) IFile sourceFile = getProject().getFile(filename);
wkspFile = sourceFile; IPath sourcePath = new Path(filename);
else { if (fileExists) {
IFile[] filesInWP = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(path); // See if this source file is already in the project.
// We check this to determine if we should create a
// TranslationUnit or ExternalTranslationUnit
for (int j = 0; j < filesInWP.length; j++) { if (sourceFile.exists())
if (filesInWP[j].isAccessible()) { wkspFile = sourceFile;
wkspFile = filesInWP[j]; else {
break; IFile[] filesInWP = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(sourcePath);
for (int j = 0; j < filesInWP.length; j++) {
if (filesInWP[j].isAccessible()) {
wkspFile = filesInWP[j];
break;
}
} }
} }
} }
@ -214,7 +219,7 @@ public class Executable extends PlatformObject {
if (wkspFile != null) if (wkspFile != null)
tu = new TranslationUnit(cproject, wkspFile, id); tu = new TranslationUnit(cproject, wkspFile, id);
else else
tu = new ExternalTranslationUnit(cproject, URIUtil.toURI(path), id); tu = new ExternalTranslationUnit(cproject, URIUtil.toURI(sourcePath), id);
sourceFiles.add(tu); sourceFiles.add(tu);