mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-08 09:35:23 +02:00
Fix for bug 35960: search for duplicate file names.
This commit is contained in:
parent
219e0985f1
commit
c9469ad6ff
13 changed files with 472 additions and 162 deletions
|
@ -3,6 +3,31 @@
|
||||||
'setCurrentThread': check if the old current thread is not null.
|
'setCurrentThread': check if the old current thread is not null.
|
||||||
* CDebugTarget.java
|
* CDebugTarget.java
|
||||||
|
|
||||||
|
2003-10-17 Mikhail Khodjaiants
|
||||||
|
Core support of the 'Search for duplicate source files' option.
|
||||||
|
* ICSourceLocation.java
|
||||||
|
* ICSourceLocator.java
|
||||||
|
* CDirectorySourceLocation.java
|
||||||
|
* CProjectSourceLocation.java
|
||||||
|
* CSourceLocator.java
|
||||||
|
* CSourceManager.java
|
||||||
|
|
||||||
|
2003-10-17 Mikhail Khodjaiants
|
||||||
|
If the target is suspended by a line breakpoint the source manager tries to retrieve
|
||||||
|
the file resource from the breakpoint marker.
|
||||||
|
* CSourceManager.java
|
||||||
|
* CDebugTarget.java
|
||||||
|
|
||||||
|
2003-10-15 Mikhail Khodjaiants
|
||||||
|
Improving the source search algorithms.
|
||||||
|
* CDirectorySourceLocation.java
|
||||||
|
* CProjectSourceLocation.java
|
||||||
|
* CSourceLocator.java
|
||||||
|
|
||||||
|
2003-10-14 Mikhail Khodjaiants
|
||||||
|
Improved the source search algorithm.
|
||||||
|
* CProjectSourceLocation.java
|
||||||
|
|
||||||
2003-10-13 Mikhail Khodjaiants
|
2003-10-13 Mikhail Khodjaiants
|
||||||
Fix for bug 43372: changed the source lookup procedures to avoid the usage of 'getCanonicalPath'.
|
Fix for bug 43372: changed the source lookup procedures to avoid the usage of 'getCanonicalPath'.
|
||||||
* CDirectorySourceLocation.java
|
* CDirectorySourceLocation.java
|
||||||
|
|
|
@ -24,7 +24,7 @@ public interface ICSourceLocation extends IAdaptable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns an object representing the source code
|
* Returns an object representing the source code
|
||||||
* for a type with the specified name, or <code>null</code>
|
* for a file with the specified name, or <code>null</code>
|
||||||
* if none could be found. The source element
|
* if none could be found. The source element
|
||||||
* returned is implementation specific - for example, a
|
* returned is implementation specific - for example, a
|
||||||
* resource, a local file, a zip file entry, etc.
|
* resource, a local file, a zip file entry, etc.
|
||||||
|
@ -43,7 +43,7 @@ public interface ICSourceLocation extends IAdaptable
|
||||||
* @return a memento for this source location
|
* @return a memento for this source location
|
||||||
* @exception CoreException if unable to create a memento
|
* @exception CoreException if unable to create a memento
|
||||||
*/
|
*/
|
||||||
public String getMemento() throws CoreException;
|
String getMemento() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this source location from the given memento.
|
* Initializes this source location from the given memento.
|
||||||
|
@ -52,5 +52,19 @@ public interface ICSourceLocation extends IAdaptable
|
||||||
* @exception CoreException if unable to initialize this source
|
* @exception CoreException if unable to initialize this source
|
||||||
* location
|
* location
|
||||||
*/
|
*/
|
||||||
public void initializeFrom( String memento ) throws CoreException;
|
void initializeFrom( String memento ) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether to search for all source elements, or just the first match.
|
||||||
|
*
|
||||||
|
* @return whether to search for all source elements, or just the first match
|
||||||
|
*/
|
||||||
|
boolean searchForDuplicateFiles();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the 'search for duplicate source files' flag.
|
||||||
|
*
|
||||||
|
* @param search - a value to set
|
||||||
|
*/
|
||||||
|
void setSearchForDuplicateFiles( boolean search );
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,4 +71,18 @@ public interface ICSourceLocator extends ISourceLocator
|
||||||
* @return source element
|
* @return source element
|
||||||
*/
|
*/
|
||||||
Object findSourceElement( String fileName );
|
Object findSourceElement( String fileName );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether to search for all source elements, or just the first match.
|
||||||
|
*
|
||||||
|
* @return whether to search for all source elements, or just the first match
|
||||||
|
*/
|
||||||
|
boolean searchForDuplicateFiles();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the 'search for duplicate source files' flag.
|
||||||
|
*
|
||||||
|
* @param search - a value to set
|
||||||
|
*/
|
||||||
|
void setSearchForDuplicateFiles( boolean search );
|
||||||
}
|
}
|
|
@ -442,6 +442,13 @@ public class CDebugTarget extends CDebugElement
|
||||||
ISourceLocator locator = getLaunch().getSourceLocator();
|
ISourceLocator locator = getLaunch().getSourceLocator();
|
||||||
if ( locator instanceof IAdaptable )
|
if ( locator instanceof IAdaptable )
|
||||||
{
|
{
|
||||||
|
ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class );
|
||||||
|
if ( clocator instanceof IAdaptable )
|
||||||
|
{
|
||||||
|
CSourceManager sm = (CSourceManager)((IAdaptable)clocator).getAdapter( CSourceManager.class );
|
||||||
|
if ( sm != null )
|
||||||
|
sm.setDebugTarget( this );
|
||||||
|
}
|
||||||
IResourceChangeListener listener = (IResourceChangeListener)((IAdaptable)locator).getAdapter( IResourceChangeListener.class );
|
IResourceChangeListener listener = (IResourceChangeListener)((IAdaptable)locator).getAdapter( IResourceChangeListener.class );
|
||||||
if ( listener != null )
|
if ( listener != null )
|
||||||
CCorePlugin.getWorkspace().addResourceChangeListener( listener );
|
CCorePlugin.getWorkspace().addResourceChangeListener( listener );
|
||||||
|
@ -2342,13 +2349,14 @@ public class CDebugTarget extends CDebugElement
|
||||||
public void setCurrentThread( IThread thread ) throws DebugException
|
public void setCurrentThread( IThread thread ) throws DebugException
|
||||||
{
|
{
|
||||||
if ( !isSuspended() || !isAvailable() || thread == null || !(thread instanceof CThread) )
|
if ( !isSuspended() || !isAvailable() || thread == null || !(thread instanceof CThread) )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CThread oldThread = (CThread)getCurrentThread();
|
CThread oldThread = (CThread)getCurrentThread();
|
||||||
if ( !thread.equals( oldThread ) )
|
if ( !oldThread.equals( thread ) )
|
||||||
{
|
{
|
||||||
if ( oldThread != null )
|
|
||||||
oldThread.setCurrent( false );
|
oldThread.setCurrent( false );
|
||||||
getCDITarget().setCurrentThread( ((CThread)thread).getCDIThread() );
|
getCDITarget().setCurrentThread( ((CThread)thread).getCDIThread() );
|
||||||
((CThread)thread).setCurrent( true );
|
((CThread)thread).setCurrent( true );
|
||||||
|
@ -2776,6 +2784,26 @@ public class CDebugTarget extends CDebugElement
|
||||||
return fRunningInfo;
|
return fRunningInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IFile getCurrentBreakpointFile()
|
||||||
|
{
|
||||||
|
Object info = getCurrentStateInfo();
|
||||||
|
if ( info instanceof ICDIBreakpointHit )
|
||||||
|
{
|
||||||
|
ICDIBreakpoint cdiBreakpoint = ((ICDIBreakpointHit)info).getBreakpoint();
|
||||||
|
if ( cdiBreakpoint != null )
|
||||||
|
{
|
||||||
|
IBreakpoint breakpoint = findBreakpoint( cdiBreakpoint );
|
||||||
|
if ( breakpoint instanceof ICLineBreakpoint )
|
||||||
|
{
|
||||||
|
IResource resource = ((ICLineBreakpoint)breakpoint).getMarker().getResource();
|
||||||
|
if ( resource instanceof IFile )
|
||||||
|
return (IFile)resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected void setRunningInfo( RunningInfo info )
|
protected void setRunningInfo( RunningInfo info )
|
||||||
{
|
{
|
||||||
fRunningInfo = info;
|
fRunningInfo = info;
|
||||||
|
@ -2801,6 +2829,7 @@ public class CDebugTarget extends CDebugElement
|
||||||
}
|
}
|
||||||
setRunningInfo( info );
|
setRunningInfo( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private boolean applyDeferredBreakpoints()
|
private boolean applyDeferredBreakpoints()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
@ -56,6 +57,8 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
|
||||||
*/
|
*/
|
||||||
private IPath fAssociation = null;
|
private IPath fAssociation = null;
|
||||||
|
|
||||||
|
private boolean fSearchForDuplicateFiles = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CDirectorySourceLocation.
|
* Constructor for CDirectorySourceLocation.
|
||||||
*/
|
*/
|
||||||
|
@ -177,11 +180,16 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try for a file in another workspace project
|
// Try for a file in another workspace project
|
||||||
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( filePath );
|
IFile[] wsFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( filePath );
|
||||||
if ( f != null && f.exists() )
|
LinkedList list = new LinkedList();
|
||||||
{
|
for ( int j = 0; j < wsFiles.length; ++j )
|
||||||
return f;
|
if ( wsFiles[j].exists() )
|
||||||
}
|
if ( !searchForDuplicateFiles() )
|
||||||
|
return wsFiles[j];
|
||||||
|
else
|
||||||
|
list.add( wsFiles[j] );
|
||||||
|
if ( list.size() > 0 )
|
||||||
|
return ( list.size() == 1 ) ? list.getFirst() : list;
|
||||||
|
|
||||||
file = filePath.toFile();
|
file = filePath.toFile();
|
||||||
if ( file.exists() )
|
if ( file.exists() )
|
||||||
|
@ -201,11 +209,17 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
|
||||||
if ( file.exists() )
|
if ( file.exists() )
|
||||||
{
|
{
|
||||||
path = new Path( file.getAbsolutePath() ); // can't use getCanonicalPath because of links
|
path = new Path( file.getAbsolutePath() ); // can't use getCanonicalPath because of links
|
||||||
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
|
IFile[] wsFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( path );
|
||||||
if ( f != null && f.exists() )
|
LinkedList list = new LinkedList();
|
||||||
{
|
for ( int j = 0; j < wsFiles.length; ++j )
|
||||||
return f;
|
if ( wsFiles[j].exists() )
|
||||||
}
|
if ( !searchForDuplicateFiles() )
|
||||||
|
return wsFiles[j];
|
||||||
|
else
|
||||||
|
list.add( wsFiles[j] );
|
||||||
|
if ( list.size() > 0 )
|
||||||
|
return ( list.size() == 1 ) ? list.getFirst() : list;
|
||||||
|
else
|
||||||
return createExternalFileStorage( path );
|
return createExternalFileStorage( path );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,4 +369,20 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
|
||||||
String pathString = path.removeLastSegments( path.segmentCount() - segCount ).toOSString();
|
String pathString = path.removeLastSegments( path.segmentCount() - segCount ).toOSString();
|
||||||
return prefixString.equalsIgnoreCase( pathString );
|
return prefixString.equalsIgnoreCase( pathString );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#setSearchForDuplicateFiles(boolean)
|
||||||
|
*/
|
||||||
|
public void setSearchForDuplicateFiles( boolean search )
|
||||||
|
{
|
||||||
|
fSearchForDuplicateFiles = search;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#searchForDuplicateFiles()
|
||||||
|
*/
|
||||||
|
public boolean searchForDuplicateFiles()
|
||||||
|
{
|
||||||
|
return fSearchForDuplicateFiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.text.MessageFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
@ -23,6 +22,7 @@ import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
import org.eclipse.cdt.debug.core.CDebugUtils;
|
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceProxy;
|
import org.eclipse.core.resources.IResourceProxy;
|
||||||
|
@ -31,6 +31,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -62,6 +63,8 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
|
|
||||||
private boolean fGenerated = true;
|
private boolean fGenerated = true;
|
||||||
|
|
||||||
|
private boolean fSearchForDuplicateFiles = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CProjectSourceLocation.
|
* Constructor for CProjectSourceLocation.
|
||||||
*/
|
*/
|
||||||
|
@ -76,7 +79,6 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
{
|
{
|
||||||
setProject( project );
|
setProject( project );
|
||||||
fGenerated = true;
|
fGenerated = true;
|
||||||
initializeFolders();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +88,6 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
{
|
{
|
||||||
setProject( project );
|
setProject( project );
|
||||||
fGenerated = generated;
|
fGenerated = generated;
|
||||||
initializeFolders();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -151,17 +152,24 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
private Object doFindSourceElement( String name )
|
private Object doFindSourceElement( String name )
|
||||||
{
|
{
|
||||||
File file = new File( name );
|
File file = new File( name );
|
||||||
return ( file.isAbsolute() ) ? findFileByAbsolutePath( name ) :
|
return ( file.isAbsolute() ) ? findFileByAbsolutePath( file ) : findFileByRelativePath( name );
|
||||||
findFileByRelativePath( name );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object findFileByAbsolutePath( String name )
|
private Object findFileByAbsolutePath( File file )
|
||||||
{
|
{
|
||||||
File file = new File( name );
|
LinkedList list = new LinkedList();
|
||||||
Object result = null;
|
if ( file.exists() )
|
||||||
if ( file.isAbsolute() && file.exists() )
|
{
|
||||||
result = findFile( file );
|
IPath path = new Path( file.getAbsolutePath() );
|
||||||
return result;
|
IFile[] wsFiles = CDebugCorePlugin.getWorkspace().getRoot().findFilesForLocation( path );
|
||||||
|
for ( int i = 0; i < wsFiles.length; ++i )
|
||||||
|
if ( wsFiles[i].getProject().equals( getProject() ) && wsFiles[i].exists() )
|
||||||
|
if ( !searchForDuplicateFiles() )
|
||||||
|
return wsFiles[i];
|
||||||
|
else
|
||||||
|
list.add( wsFiles[i] );
|
||||||
|
}
|
||||||
|
return ( list.size() > 0 ) ? ( ( list.size() == 1 ) ? list.getFirst() : list ) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object findFileByRelativePath( String fileName )
|
private Object findFileByRelativePath( String fileName )
|
||||||
|
@ -170,66 +178,22 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
LinkedList list = new LinkedList();
|
LinkedList list = new LinkedList();
|
||||||
for ( int i = 0; i < folders.length; ++i )
|
for ( int i = 0; i < folders.length; ++i )
|
||||||
{
|
{
|
||||||
if ( list.size() > 0 && !searchForDuplicateFileNames() )
|
if ( list.size() > 0 && !searchForDuplicateFiles() )
|
||||||
break;
|
break;
|
||||||
IPath path = folders[i].getLocation().append( fileName );
|
IPath path = folders[i].getLocation().append( fileName );
|
||||||
Object result = findFile( new File( path.toOSString() ) );
|
File file = new File( path.toOSString() );
|
||||||
if ( result instanceof List )
|
if ( file.exists() )
|
||||||
list.addAll( (List)result );
|
|
||||||
else if ( result != null )
|
|
||||||
list.add( result );
|
|
||||||
}
|
|
||||||
if ( list.size() == 1 || (list.size() > 0 && !searchForDuplicateFileNames()) )
|
|
||||||
return list.getFirst();
|
|
||||||
if ( list.size() > 0 )
|
|
||||||
return list;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object findFile( final File file )
|
|
||||||
{
|
|
||||||
if ( file != null )
|
|
||||||
{
|
|
||||||
final String name = file.getName();
|
|
||||||
IResource[] folders = getFolders();
|
|
||||||
final LinkedList list = new LinkedList();
|
|
||||||
for ( int i = 0; i < folders.length; ++i )
|
|
||||||
{
|
|
||||||
// The workspace resources are case-sensitive, so we can not just
|
|
||||||
// append the file name to the folder name and check if the result exists.
|
|
||||||
if ( list.size() > 0 && !searchForDuplicateFileNames() )
|
|
||||||
break;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
folders[i].accept(
|
|
||||||
new IResourceProxyVisitor()
|
|
||||||
{
|
|
||||||
public boolean visit( IResourceProxy proxy ) throws CoreException
|
|
||||||
{
|
|
||||||
// use equalsIgnoreCase to make it work for Wondows
|
|
||||||
if ( proxy.getType() == IResource.FILE && proxy.getName().equalsIgnoreCase( name ) )
|
|
||||||
{
|
|
||||||
IResource resource = proxy.requestResource();
|
|
||||||
File file1 = new File( resource.getLocation().toOSString() );
|
|
||||||
if ( file1.exists() && file1.equals( file ) )
|
|
||||||
list.addLast( resource );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
IResource.NONE );
|
|
||||||
}
|
|
||||||
catch( CoreException e )
|
|
||||||
{
|
{
|
||||||
|
IFile[] wsFiles = CDebugCorePlugin.getWorkspace().getRoot().findFilesForLocation( path );
|
||||||
|
for ( int j = 0; j < wsFiles.length; ++j )
|
||||||
|
if ( wsFiles[j].exists() )
|
||||||
|
if ( !searchForDuplicateFiles() )
|
||||||
|
return wsFiles[j];
|
||||||
|
else
|
||||||
|
list.add( wsFiles[j] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( list.size() == 1 || (list.size() > 0 && !searchForDuplicateFileNames()) )
|
return ( list.size() > 0 ) ? ( ( list.size() == 1 ) ? list.getFirst() : list ) : null;
|
||||||
return list.getFirst();
|
|
||||||
if ( list.size() > 0 )
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object cacheLookup( String name )
|
private Object cacheLookup( String name )
|
||||||
|
@ -308,7 +272,6 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
if ( isGeneric == null || isGeneric.trim().length() == 0 )
|
if ( isGeneric == null || isGeneric.trim().length() == 0 )
|
||||||
isGeneric = Boolean.FALSE.toString();
|
isGeneric = Boolean.FALSE.toString();
|
||||||
setGenerated( isGeneric.equals( Boolean.TRUE.toString() ) );
|
setGenerated( isGeneric.equals( Boolean.TRUE.toString() ) );
|
||||||
initializeFolders();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch( ParserConfigurationException e )
|
catch( ParserConfigurationException e )
|
||||||
|
@ -403,12 +366,26 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
|
|
||||||
protected IResource[] getFolders()
|
protected IResource[] getFolders()
|
||||||
{
|
{
|
||||||
|
if ( fFolders == null )
|
||||||
|
initializeFolders();
|
||||||
return fFolders;
|
return fFolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean searchForDuplicateFileNames()
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#searchForDuplicateFiles()
|
||||||
|
*/
|
||||||
|
public boolean searchForDuplicateFiles()
|
||||||
{
|
{
|
||||||
// for now
|
return fSearchForDuplicateFiles;
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#setSearchForDuplicateFiles(boolean)
|
||||||
|
*/
|
||||||
|
public void setSearchForDuplicateFiles( boolean search )
|
||||||
|
{
|
||||||
|
fCache.clear();
|
||||||
|
fNotFoundCache.clear();
|
||||||
|
fSearchForDuplicateFiles = search;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
@ -14,6 +13,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
@ -21,7 +21,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.apache.xerces.dom.DocumentImpl;
|
import org.apache.xerces.dom.DocumentImpl;
|
||||||
import org.eclipse.cdt.core.resources.FileStorage;
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
import org.eclipse.cdt.debug.core.CDebugUtils;
|
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||||
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
||||||
|
@ -36,10 +35,8 @@ import org.eclipse.core.resources.IResourceChangeEvent;
|
||||||
import org.eclipse.core.resources.IResourceChangeListener;
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.model.IPersistableSourceLocator;
|
import org.eclipse.debug.core.model.IPersistableSourceLocator;
|
||||||
|
@ -67,6 +64,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
private static final String ATTR_CLASS = "class";
|
private static final String ATTR_CLASS = "class";
|
||||||
private static final String ATTR_MEMENTO = "memento";
|
private static final String ATTR_MEMENTO = "memento";
|
||||||
private static final String ATTR_PROJECT_NAME = "projectName";
|
private static final String ATTR_PROJECT_NAME = "projectName";
|
||||||
|
private static final String ATTR_DUPLICATE_FILES = "duplicateFiles";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The project associated with this locator.
|
* The project associated with this locator.
|
||||||
|
@ -83,6 +81,12 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
*/
|
*/
|
||||||
private List fReferencedProjects = new ArrayList( 10 );
|
private List fReferencedProjects = new ArrayList( 10 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The flag specifies whether to search for all source elements,
|
||||||
|
* or just the first match.
|
||||||
|
*/
|
||||||
|
private boolean fDuplicateFiles = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CSourceLocator.
|
* Constructor for CSourceLocator.
|
||||||
*/
|
*/
|
||||||
|
@ -116,14 +120,12 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
|
|
||||||
protected Object getInput( IStackFrameInfo info )
|
protected Object getInput( IStackFrameInfo info )
|
||||||
{
|
{
|
||||||
Object result = null;
|
LinkedList list = new LinkedList();
|
||||||
if ( info != null )
|
if ( info != null )
|
||||||
{
|
{
|
||||||
|
Object result = null;
|
||||||
String fileName = info.getFile();
|
String fileName = info.getFile();
|
||||||
if ( fileName != null && fileName.length() > 0 )
|
if ( fileName != null && fileName.length() > 0 )
|
||||||
{
|
|
||||||
result = findFileByAbsolutePath( fileName );
|
|
||||||
if ( result == null )
|
|
||||||
{
|
{
|
||||||
ICSourceLocation[] locations = getSourceLocations();
|
ICSourceLocation[] locations = getSourceLocations();
|
||||||
for ( int i = 0; i < locations.length; ++i )
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
|
@ -137,12 +139,18 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
if ( result != null )
|
if ( result != null )
|
||||||
|
{
|
||||||
|
if ( result instanceof List )
|
||||||
|
list.addAll( (List)result );
|
||||||
|
else
|
||||||
|
list.add( result );
|
||||||
|
if ( !searchForDuplicateFiles() )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return ( list.size() > 0 ) ? ( ( list.size() == 1 ) ? list.getFirst() : list ) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -165,7 +173,10 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( locations[i].findSourceElement( resource.getLocation().toOSString() ) != null )
|
Object result = locations[i].findSourceElement( resource.getLocation().toOSString() );
|
||||||
|
if ( result instanceof IFile && ((IFile)result).equals( resource ) )
|
||||||
|
return true;
|
||||||
|
if ( result instanceof List && ((List)result).contains( resource ) )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch( CoreException e )
|
catch( CoreException e )
|
||||||
|
@ -248,29 +259,6 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object findFileByAbsolutePath( String fileName )
|
|
||||||
{
|
|
||||||
File file = new File( fileName );
|
|
||||||
if ( file.isAbsolute() && file.exists() )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Path path = new Path( file.getCanonicalPath() );
|
|
||||||
// Try for a file in another workspace project
|
|
||||||
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
|
|
||||||
if ( f != null && f.exists() )
|
|
||||||
{
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
return new FileStorage( path );
|
|
||||||
}
|
|
||||||
catch( IOException e )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#findSourceElement(String)
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#findSourceElement(String)
|
||||||
*/
|
*/
|
||||||
|
@ -278,9 +266,6 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
{
|
{
|
||||||
Object result = null;
|
Object result = null;
|
||||||
if ( fileName != null && fileName.length() > 0 )
|
if ( fileName != null && fileName.length() > 0 )
|
||||||
{
|
|
||||||
result = findFileByAbsolutePath( fileName );
|
|
||||||
if ( result == null )
|
|
||||||
{
|
{
|
||||||
ICSourceLocation[] locations = getSourceLocations();
|
ICSourceLocation[] locations = getSourceLocations();
|
||||||
for ( int i = 0; i < locations.length; ++i )
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
|
@ -297,7 +282,6 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +297,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
ICSourceLocation[] locations = getSourceLocations();
|
ICSourceLocation[] locations = getSourceLocations();
|
||||||
saveDisabledGenericSourceLocations( locations, doc, node );
|
saveDisabledGenericSourceLocations( locations, doc, node );
|
||||||
saveAdditionalSourceLocations( locations, doc, node );
|
saveAdditionalSourceLocations( locations, doc, node );
|
||||||
|
node.setAttribute( ATTR_DUPLICATE_FILES, new Boolean( searchForDuplicateFiles() ).toString() );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return CDebugUtils.serializeDocument( doc, " " );
|
return CDebugUtils.serializeDocument( doc, " " );
|
||||||
|
@ -365,6 +349,9 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
// To support old launch configuration
|
// To support old launch configuration
|
||||||
addOldLocations( root, sourceLocations );
|
addOldLocations( root, sourceLocations );
|
||||||
setSourceLocations( (ICSourceLocation[])sourceLocations.toArray( new ICSourceLocation[sourceLocations.size()] ) );
|
setSourceLocations( (ICSourceLocation[])sourceLocations.toArray( new ICSourceLocation[sourceLocations.size()] ) );
|
||||||
|
|
||||||
|
setSearchForDuplicateFiles( Boolean.valueOf( root.getAttribute( ATTR_DUPLICATE_FILES ) ).booleanValue() );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch( ParserConfigurationException e )
|
catch( ParserConfigurationException e )
|
||||||
|
@ -725,4 +712,20 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
fReferencedProjects = newRefs;
|
fReferencedProjects = newRefs;
|
||||||
setSourceLocations( (ICSourceLocation[])newLocations.toArray( new ICSourceLocation[newLocations.size()] ) );
|
setSourceLocations( (ICSourceLocation[])newLocations.toArray( new ICSourceLocation[newLocations.size()] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#searchForDuplicateFiles()
|
||||||
|
*/
|
||||||
|
public boolean searchForDuplicateFiles()
|
||||||
|
{
|
||||||
|
return fDuplicateFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchForDuplicateFiles( boolean search )
|
||||||
|
{
|
||||||
|
fDuplicateFiles = search;
|
||||||
|
ICSourceLocation[] locations = getSourceLocations();
|
||||||
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
|
locations[i].setSearchForDuplicateFiles( search );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceChangeListener;
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
|
@ -40,6 +41,7 @@ public class CSourceManager implements ICSourceLocator,
|
||||||
private int fMode = ISourceMode.MODE_SOURCE;
|
private int fMode = ISourceMode.MODE_SOURCE;
|
||||||
private int fRealMode = fMode;
|
private int fRealMode = fMode;
|
||||||
private ILaunch fLaunch = null;
|
private ILaunch fLaunch = null;
|
||||||
|
private CDebugTarget fDebugTarget = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CSourceManager.
|
* Constructor for CSourceManager.
|
||||||
|
@ -132,6 +134,8 @@ public class CSourceManager implements ICSourceLocator,
|
||||||
*/
|
*/
|
||||||
public Object getAdapter( Class adapter )
|
public Object getAdapter( Class adapter )
|
||||||
{
|
{
|
||||||
|
if ( adapter.equals( CSourceManager.class ) )
|
||||||
|
return this;
|
||||||
if ( adapter.equals( IResourceChangeListener.class ) &&
|
if ( adapter.equals( IResourceChangeListener.class ) &&
|
||||||
fSourceLocator instanceof IResourceChangeListener )
|
fSourceLocator instanceof IResourceChangeListener )
|
||||||
return fSourceLocator;
|
return fSourceLocator;
|
||||||
|
@ -148,6 +152,11 @@ public class CSourceManager implements ICSourceLocator,
|
||||||
|
|
||||||
if ( getMode() == ISourceMode.MODE_SOURCE && getSourceLocator() != null )
|
if ( getMode() == ISourceMode.MODE_SOURCE && getSourceLocator() != null )
|
||||||
{
|
{
|
||||||
|
// if the target is suspended by a line breakpoint the source manager
|
||||||
|
// tries to retrieve the file resource from the breakpoint marker.
|
||||||
|
if ( getDebugTarget() != null )
|
||||||
|
result = getDebugTarget().getCurrentBreakpointFile();
|
||||||
|
if ( result == null )
|
||||||
result = getSourceLocator().getSourceElement( stackFrame );
|
result = getSourceLocator().getSourceElement( stackFrame );
|
||||||
}
|
}
|
||||||
if ( result == null &&
|
if ( result == null &&
|
||||||
|
@ -256,4 +265,31 @@ public class CSourceManager implements ICSourceLocator,
|
||||||
{
|
{
|
||||||
return ( getCSourceLocator() != null ) ? getCSourceLocator().getProject() : null;
|
return ( getCSourceLocator() != null ) ? getCSourceLocator().getProject() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDebugTarget( CDebugTarget target )
|
||||||
|
{
|
||||||
|
fDebugTarget = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CDebugTarget getDebugTarget()
|
||||||
|
{
|
||||||
|
return fDebugTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#setSearchForDuplicateFiles(boolean)
|
||||||
|
*/
|
||||||
|
public void setSearchForDuplicateFiles( boolean search )
|
||||||
|
{
|
||||||
|
if ( getCSourceLocator() != null )
|
||||||
|
getCSourceLocator().setSearchForDuplicateFiles( search );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#searchForDuplicateFiles()
|
||||||
|
*/
|
||||||
|
public boolean searchForDuplicateFiles()
|
||||||
|
{
|
||||||
|
return ( getCSourceLocator() != null ) ? getCSourceLocator().searchForDuplicateFiles() : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,18 @@
|
||||||
Fix for PR 45957: Memory view: last column does not show updates.
|
Fix for PR 45957: Memory view: last column does not show updates.
|
||||||
* MemoryPresentation.java
|
* MemoryPresentation.java
|
||||||
|
|
||||||
|
2003-10-17 Mikhail Khodjaiants
|
||||||
|
UI support of the 'Search for duplicate source files' option.
|
||||||
|
* icons/full/obj16/prj_file_obj.gif: new
|
||||||
|
* icons/full/obj16/ext_file_obj.gif: new
|
||||||
|
* CDebugImages.java
|
||||||
|
* CUISourceLocator.java
|
||||||
|
* SourceLookupBlock.java
|
||||||
|
* SourcePropertyPage.java
|
||||||
|
|
||||||
|
2003-10-17 Mikhail Khodjaiants
|
||||||
|
* CDebugEditor.java: changed the message displayed when the source file not found.
|
||||||
|
|
||||||
2003-10-14 Mikhail Khodjaiants
|
2003-10-14 Mikhail Khodjaiants
|
||||||
* DebugTextHover.java: check if the result of 'evaluateExpression' is not null before trim it.
|
* DebugTextHover.java: check if the result of 'evaluateExpression' is not null before trim it.
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,8 @@ public class CDebugImages
|
||||||
public static final String IMG_OBJS_LOADED_SHARED_LIBRARY = NAME_PREFIX + "library_syms_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_LOADED_SHARED_LIBRARY = NAME_PREFIX + "library_syms_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_SHARED_LIBRARY = NAME_PREFIX + "library_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_SHARED_LIBRARY = NAME_PREFIX + "library_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_SIGNAL = NAME_PREFIX + "signal_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_SIGNAL = NAME_PREFIX + "signal_obj.gif"; //$NON-NLS-1$
|
||||||
|
public static final String IMG_OBJS_WORKSPACE_SOURCE_FILE = NAME_PREFIX + "prj_file_obj.gif"; //$NON-NLS-1$
|
||||||
|
public static final String IMG_OBJS_EXTERNAL_SOURCE_FILE = NAME_PREFIX + "ext_file_obj.gif"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif"; //$NON-NLS-1$
|
public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$
|
public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$
|
||||||
|
@ -155,6 +157,8 @@ public class CDebugImages
|
||||||
public static final ImageDescriptor DESC_OBJS_LOADED_SHARED_LIBRARY = createManaged( T_OBJ, IMG_OBJS_LOADED_SHARED_LIBRARY );
|
public static final ImageDescriptor DESC_OBJS_LOADED_SHARED_LIBRARY = createManaged( T_OBJ, IMG_OBJS_LOADED_SHARED_LIBRARY );
|
||||||
public static final ImageDescriptor DESC_OBJS_SHARED_LIBRARY = createManaged( T_OBJ, IMG_OBJS_SHARED_LIBRARY );
|
public static final ImageDescriptor DESC_OBJS_SHARED_LIBRARY = createManaged( T_OBJ, IMG_OBJS_SHARED_LIBRARY );
|
||||||
public static final ImageDescriptor DESC_OBJS_SIGNAL = createManaged( T_OBJ, IMG_OBJS_SIGNAL );
|
public static final ImageDescriptor DESC_OBJS_SIGNAL = createManaged( T_OBJ, IMG_OBJS_SIGNAL );
|
||||||
|
public static final ImageDescriptor DESC_OBJS_WORKSPACE_SOURCE_FILE = createManaged( T_OBJ, IMG_OBJS_WORKSPACE_SOURCE_FILE );
|
||||||
|
public static final ImageDescriptor DESC_OBJS_EXTERNAL_SOURCE_FILE = createManaged( T_OBJ, IMG_OBJS_EXTERNAL_SOURCE_FILE );
|
||||||
public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_SOURCE_LOCATION ); //$NON-NLS-1$
|
public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_SOURCE_LOCATION ); //$NON-NLS-1$
|
||||||
public static final ImageDescriptor DESC_WIZBAN_ADD_PRJ_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_PRJ_SOURCE_LOCATION ); //$NON-NLS-1$
|
public static final ImageDescriptor DESC_WIZBAN_ADD_PRJ_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_PRJ_SOURCE_LOCATION ); //$NON-NLS-1$
|
||||||
public static final ImageDescriptor DESC_WIZBAN_ADD_DIR_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_DIR_SOURCE_LOCATION ); //$NON-NLS-1$
|
public static final ImageDescriptor DESC_WIZBAN_ADD_DIR_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_DIR_SOURCE_LOCATION ); //$NON-NLS-1$
|
||||||
|
|
|
@ -5,14 +5,23 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.ui.sourcelookup;
|
package org.eclipse.cdt.debug.ui.sourcelookup;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.resources.FileStorage;
|
||||||
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator;
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.SelectionButtonDialogField;
|
||||||
import org.eclipse.cdt.debug.internal.ui.editors.FileNotFoundElement;
|
import org.eclipse.cdt.debug.internal.ui.editors.FileNotFoundElement;
|
||||||
import org.eclipse.cdt.debug.internal.ui.editors.NoSymbolOrSourceElement;
|
import org.eclipse.cdt.debug.internal.ui.editors.NoSymbolOrSourceElement;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResourceChangeListener;
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -22,6 +31,14 @@ import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
import org.eclipse.debug.core.model.IPersistableSourceLocator;
|
import org.eclipse.debug.core.model.IPersistableSourceLocator;
|
||||||
import org.eclipse.debug.core.model.IStackFrame;
|
import org.eclipse.debug.core.model.IStackFrame;
|
||||||
|
import org.eclipse.jface.viewers.ArrayContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.dialogs.ListDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -32,6 +49,62 @@ import org.eclipse.debug.core.model.IStackFrame;
|
||||||
*/
|
*/
|
||||||
public class CUISourceLocator implements IAdaptable
|
public class CUISourceLocator implements IAdaptable
|
||||||
{
|
{
|
||||||
|
public class SourceSelectionDialog extends ListDialog
|
||||||
|
{
|
||||||
|
private SelectionButtonDialogField fAlwaysUseThisFileButton = new SelectionButtonDialogField( SWT.CHECK );
|
||||||
|
|
||||||
|
public SourceSelectionDialog( Shell parent )
|
||||||
|
{
|
||||||
|
super( parent );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.dialogs.ListDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||||
|
*/
|
||||||
|
protected Control createDialogArea( Composite parent )
|
||||||
|
{
|
||||||
|
Composite comp = ControlFactory.createComposite( parent, 1 );
|
||||||
|
super.createDialogArea( comp );
|
||||||
|
Composite comp1 = ControlFactory.createComposite( comp, 1 );
|
||||||
|
fAlwaysUseThisFileButton.setLabelText( "Always map to the selection" );
|
||||||
|
fAlwaysUseThisFileButton.doFillIntoGrid( comp1, 1 );
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean alwaysMapToSelection()
|
||||||
|
{
|
||||||
|
return fAlwaysUseThisFileButton.isSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SourceElementLabelProvider extends LabelProvider
|
||||||
|
{
|
||||||
|
protected CDebugImageDescriptorRegistry fDebugImageRegistry = CDebugUIPlugin.getImageDescriptorRegistry();
|
||||||
|
|
||||||
|
public SourceElementLabelProvider()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText(Object element)
|
||||||
|
{
|
||||||
|
if ( element instanceof IFile )
|
||||||
|
return ((IFile)element).getFullPath().toString();
|
||||||
|
if ( element instanceof FileStorage )
|
||||||
|
return ((FileStorage)element).getFullPath().toOSString();
|
||||||
|
return super.getText(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage( Object element )
|
||||||
|
{
|
||||||
|
if ( element instanceof IFile )
|
||||||
|
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_WORKSPACE_SOURCE_FILE );
|
||||||
|
if ( element instanceof FileStorage )
|
||||||
|
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_EXTERNAL_SOURCE_FILE );
|
||||||
|
return super.getImage( element );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The project being debugged.
|
* The project being debugged.
|
||||||
*/
|
*/
|
||||||
|
@ -42,6 +115,9 @@ public class CUISourceLocator implements IAdaptable
|
||||||
*/
|
*/
|
||||||
private CSourceManager fSourceLocator;
|
private CSourceManager fSourceLocator;
|
||||||
|
|
||||||
|
private HashMap fFramesToSource = null;
|
||||||
|
private HashMap fNamesToSource = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CUISourceLocator.
|
* Constructor for CUISourceLocator.
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +129,26 @@ public class CUISourceLocator implements IAdaptable
|
||||||
|
|
||||||
public Object getSourceElement( IStackFrame stackFrame )
|
public Object getSourceElement( IStackFrame stackFrame )
|
||||||
{
|
{
|
||||||
Object res = fSourceLocator.getSourceElement( stackFrame );
|
Object res = cacheLookup( stackFrame );
|
||||||
|
if ( res == null )
|
||||||
|
{
|
||||||
|
res = fSourceLocator.getSourceElement( stackFrame );
|
||||||
|
if ( res instanceof List )
|
||||||
|
{
|
||||||
|
List list = (List)res;
|
||||||
|
if ( list.size() != 0 )
|
||||||
|
{
|
||||||
|
SourceSelectionDialog dialog = createSourceSelectionDialog( list );
|
||||||
|
dialog.open();
|
||||||
|
Object[] objs = dialog.getResult();
|
||||||
|
res = ( objs != null && objs.length > 0 ) ? objs[0] : null;
|
||||||
|
if ( res != null )
|
||||||
|
cacheSourceElement( stackFrame, res, dialog.alwaysMapToSelection() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
res = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ( res == null )
|
if ( res == null )
|
||||||
{
|
{
|
||||||
IStackFrameInfo frameInfo = (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class );
|
IStackFrameInfo frameInfo = (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class );
|
||||||
|
@ -104,4 +199,60 @@ public class CUISourceLocator implements IAdaptable
|
||||||
CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null );
|
CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SourceSelectionDialog createSourceSelectionDialog( List list )
|
||||||
|
{
|
||||||
|
SourceSelectionDialog dialog = new SourceSelectionDialog( CDebugUIPlugin.getActiveWorkbenchShell() );
|
||||||
|
dialog.setInput( list.toArray() );
|
||||||
|
dialog.setContentProvider( new ArrayContentProvider() );
|
||||||
|
dialog.setLabelProvider( new SourceElementLabelProvider() );
|
||||||
|
dialog.setTitle( "Selection needed" );
|
||||||
|
dialog.setMessage( "Debugger has found multiple files with the same name.\nPlease select one associated with the selected stack frame." );
|
||||||
|
dialog.setInitialSelections( new Object[] { list.get( 0 ) } );
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cacheSourceElement( IStackFrame frame, Object sourceElement, boolean alwaysMapToSelection )
|
||||||
|
{
|
||||||
|
if ( alwaysMapToSelection )
|
||||||
|
{
|
||||||
|
String name = getFileName( frame );
|
||||||
|
if ( name != null )
|
||||||
|
{
|
||||||
|
if ( fNamesToSource == null )
|
||||||
|
fNamesToSource = new HashMap();
|
||||||
|
fNamesToSource.put( name, sourceElement );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( fFramesToSource == null )
|
||||||
|
fFramesToSource = new HashMap();
|
||||||
|
fFramesToSource.put( frame, sourceElement );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object cacheLookup( IStackFrame frame )
|
||||||
|
{
|
||||||
|
String name = getFileName( frame );
|
||||||
|
if ( name != null && fNamesToSource != null )
|
||||||
|
{
|
||||||
|
Object result = fNamesToSource.get( name );
|
||||||
|
if ( result != null )
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return ( fFramesToSource != null ) ? fFramesToSource.get( frame ) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFileName( IStackFrame frame )
|
||||||
|
{
|
||||||
|
IStackFrameInfo frameInfo = (IStackFrameInfo)frame.getAdapter( IStackFrameInfo.class );
|
||||||
|
if ( frameInfo != null )
|
||||||
|
{
|
||||||
|
String name = frameInfo.getFile();
|
||||||
|
if ( name != null && name.trim().length() > 0 )
|
||||||
|
return name.trim();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.debug.internal.ui.dialogfields.IDialogFieldListener;
|
||||||
import org.eclipse.cdt.debug.internal.ui.dialogfields.IListAdapter;
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.IListAdapter;
|
||||||
import org.eclipse.cdt.debug.internal.ui.dialogfields.LayoutUtil;
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.LayoutUtil;
|
||||||
import org.eclipse.cdt.debug.internal.ui.dialogfields.ListDialogField;
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.ListDialogField;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.SelectionButtonDialogField;
|
||||||
import org.eclipse.cdt.debug.internal.ui.dialogfields.Separator;
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.Separator;
|
||||||
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
|
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -158,7 +159,7 @@ public class SourceLookupBlock
|
||||||
private Shell fShell = null;
|
private Shell fShell = null;
|
||||||
private CheckedListDialogField fGeneratedSourceListField;
|
private CheckedListDialogField fGeneratedSourceListField;
|
||||||
private SourceListDialogField fAddedSourceListField;
|
private SourceListDialogField fAddedSourceListField;
|
||||||
// private SelectionButtonDialogField fSearchForDuplicateFiles;
|
private SelectionButtonDialogField fSearchForDuplicateFiles;
|
||||||
private ILaunchConfigurationDialog fLaunchConfigurationDialog = null;
|
private ILaunchConfigurationDialog fLaunchConfigurationDialog = null;
|
||||||
private boolean fIsDirty = false;
|
private boolean fIsDirty = false;
|
||||||
private ICSourceLocator fLocator = null;
|
private ICSourceLocator fLocator = null;
|
||||||
|
@ -228,10 +229,17 @@ public class SourceLookupBlock
|
||||||
fAddedSourceListField.setUpButtonIndex( 2 );
|
fAddedSourceListField.setUpButtonIndex( 2 );
|
||||||
fAddedSourceListField.setDownButtonIndex( 3 );
|
fAddedSourceListField.setDownButtonIndex( 3 );
|
||||||
fAddedSourceListField.setRemoveButtonIndex( 5 );
|
fAddedSourceListField.setRemoveButtonIndex( 5 );
|
||||||
/*
|
|
||||||
fSearchForDuplicateFiles = new SelectionButtonDialogField( SWT.CHECK );
|
fSearchForDuplicateFiles = new SelectionButtonDialogField( SWT.CHECK );
|
||||||
fSearchForDuplicateFiles.setLabelText( "Search for duplicate files" );
|
fSearchForDuplicateFiles.setLabelText( "Search for duplicate source files" );
|
||||||
*/
|
fSearchForDuplicateFiles.setDialogFieldListener(
|
||||||
|
new IDialogFieldListener()
|
||||||
|
{
|
||||||
|
public void dialogFieldChanged( DialogField field )
|
||||||
|
{
|
||||||
|
doCheckStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createControl( Composite parent )
|
public void createControl( Composite parent )
|
||||||
|
@ -277,9 +285,9 @@ public class SourceLookupBlock
|
||||||
viewer.setColumnProperties( new String[]{ CP_LOCATION, CP_ASSOCIATION } );
|
viewer.setColumnProperties( new String[]{ CP_LOCATION, CP_ASSOCIATION } );
|
||||||
viewer.setCellModifier( createCellModifier() );
|
viewer.setCellModifier( createCellModifier() );
|
||||||
|
|
||||||
new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) );
|
// new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) );
|
||||||
|
|
||||||
// fSearchForDuplicateFiles.doFillIntoGrid( fControl, 3 );
|
fSearchForDuplicateFiles.doFillIntoGrid( fControl, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICellModifier createCellModifier()
|
private ICellModifier createCellModifier()
|
||||||
|
@ -333,6 +341,7 @@ public class SourceLookupBlock
|
||||||
ICSourceLocation[] locations = fLocator.getSourceLocations();
|
ICSourceLocation[] locations = fLocator.getSourceLocations();
|
||||||
initializeGeneratedLocations( fLocator.getProject(), locations );
|
initializeGeneratedLocations( fLocator.getProject(), locations );
|
||||||
resetAdditionalLocations( locations );
|
resetAdditionalLocations( locations );
|
||||||
|
fSearchForDuplicateFiles.setSelection( fLocator.searchForDuplicateFiles() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,6 +500,7 @@ public class SourceLookupBlock
|
||||||
locations = CSourceLocator.getDefaultSourceLocations( getProject() );
|
locations = CSourceLocator.getDefaultSourceLocations( getProject() );
|
||||||
resetGeneratedLocations( locations );
|
resetGeneratedLocations( locations );
|
||||||
resetAdditionalLocations( locations );
|
resetAdditionalLocations( locations );
|
||||||
|
fSearchForDuplicateFiles.setSelection( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IProject getProject()
|
public IProject getProject()
|
||||||
|
@ -521,4 +531,9 @@ public class SourceLookupBlock
|
||||||
return locations[i];
|
return locations[i];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean searchForDuplicateFiles()
|
||||||
|
{
|
||||||
|
return ( fSearchForDuplicateFiles != null ) ? fSearchForDuplicateFiles.isSelected() : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.eclipse.cdt.debug.ui.sourcelookup;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -107,7 +106,7 @@ public class SourcePropertyPage extends PropertyPage
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
setSourceLocations( fBlock.getSourceLocations() );
|
setAttributes( fBlock );
|
||||||
}
|
}
|
||||||
catch( DebugException e )
|
catch( DebugException e )
|
||||||
{
|
{
|
||||||
|
@ -118,7 +117,7 @@ public class SourcePropertyPage extends PropertyPage
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSourceLocations( ICSourceLocation[] locations ) throws DebugException
|
private void setAttributes( SourceLookupBlock block ) throws DebugException
|
||||||
{
|
{
|
||||||
ICDebugTarget target = getDebugTarget();
|
ICDebugTarget target = getDebugTarget();
|
||||||
if ( target != null )
|
if ( target != null )
|
||||||
|
@ -128,7 +127,8 @@ public class SourcePropertyPage extends PropertyPage
|
||||||
ICSourceLocator locator = (ICSourceLocator)((IAdaptable)target.getLaunch().getSourceLocator()).getAdapter( ICSourceLocator.class );
|
ICSourceLocator locator = (ICSourceLocator)((IAdaptable)target.getLaunch().getSourceLocator()).getAdapter( ICSourceLocator.class );
|
||||||
if ( locator != null )
|
if ( locator != null )
|
||||||
{
|
{
|
||||||
locator.setSourceLocations( locations );
|
locator.setSourceLocations( block.getSourceLocations() );
|
||||||
|
locator.setSearchForDuplicateFiles( block.searchForDuplicateFiles() );
|
||||||
if ( target.getLaunch().getSourceLocator() instanceof IPersistableSourceLocator )
|
if ( target.getLaunch().getSourceLocator() instanceof IPersistableSourceLocator )
|
||||||
{
|
{
|
||||||
ILaunchConfiguration configuration = target.getLaunch().getLaunchConfiguration();
|
ILaunchConfiguration configuration = target.getLaunch().getLaunchConfiguration();
|
||||||
|
|
Loading…
Add table
Reference in a new issue