diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index f440c86b6fe..54bd26a9201 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,8 @@ +2003-10-28 Mikhail Khodjaiants + Search only in the parent folders if the given file path is absolute. + Return a list only if the number of resulting files is > 1. + * CDirectorySourceLocation.java + 2003-10-27 Mikhail Khodjaiants Renamed 'SourceLocationFactory' to 'SourceLookupFactory'. Added the 'createSourceLocator' method to 'SourceLookupFactory'. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java index d539140c551..9b14d11028a 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java @@ -91,7 +91,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation public Object findSourceElement( String name ) throws CoreException { Object result = null; - if ( getDirectory() != null ) + if ( !isEmpty( name ) && getDirectory() != null ) { File file = new File( name ); if ( file.isAbsolute() ) @@ -187,7 +187,8 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation return result; } } - return list; + if ( list.size() > 0 ) + return ( list.size() == 1 ) ? list.getFirst() : list; } return null; } @@ -200,17 +201,12 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation IPath filePath = new Path( name ); IPath path = new Path( folder.getAbsolutePath() ); IPath association = getAssociation(); - if ( isPrefix( path, filePath ) ) + if ( !isPrefix( path, filePath ) || path.segmentCount() + 1 != filePath.segmentCount() ) { - filePath = path.append( filePath.removeFirstSegments( path.segmentCount() ) ); - } - else if ( association != null && isPrefix( association, filePath ) ) - { - filePath = path.append( filePath.removeFirstSegments( association.segmentCount() ) ); - } - else - { - return null; + if ( association != null && isPrefix( association, filePath ) && association.segmentCount() + 1 == filePath.segmentCount() ) + filePath = path.append( filePath.removeFirstSegments( association.segmentCount() ) ); + else + return null; } // Try for a file in another workspace project @@ -226,7 +222,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation return ( list.size() == 1 ) ? list.getFirst() : list; file = filePath.toFile(); - if ( file.exists() ) + if ( file.exists() && file.isFile() ) { return createExternalFileStorage( filePath ); } @@ -257,7 +253,8 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation return result; } } - return list; + if ( list.size() > 0 ) + return ( list.size() == 1 ) ? list.getFirst() : list; } return null; } @@ -267,7 +264,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation IPath path = new Path( folder.getAbsolutePath() ); path = path.append( fileName ); File file = path.toFile(); - if ( file.exists() ) + if ( file.exists() && file.isFile() ) { path = new Path( file.getAbsolutePath() ); IFile[] wsFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( path ); @@ -458,6 +455,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation public void setSearchSubfolders( boolean search ) { + resetFolders(); fSearchSubfolders = search; } @@ -502,4 +500,12 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation list.addAll( getFileFolders( folders[i] ) ); return list; } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() + { + return ( getDirectory() != null ) ? getDirectory().toOSString() : ""; + } }