mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for PR 35960: the "Search for duplicate source files" option is added.
This commit is contained in:
parent
ab1e01699b
commit
d253f76e29
14 changed files with 331 additions and 37 deletions
|
@ -1,3 +1,12 @@
|
|||
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.
|
||||
|
|
|
@ -24,7 +24,7 @@ public interface ICSourceLocation extends IAdaptable
|
|||
{
|
||||
/**
|
||||
* 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
|
||||
* returned is implementation specific - for example, a
|
||||
* resource, a local file, a zip file entry, etc.
|
||||
|
@ -35,7 +35,7 @@ public interface ICSourceLocation extends IAdaptable
|
|||
* @exception CoreException if an exception occurs while searching for the specified source element
|
||||
*/
|
||||
Object findSourceElement( String name ) throws CoreException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a memento for this source location from which this
|
||||
* source location can be reconstructed.
|
||||
|
@ -43,7 +43,7 @@ public interface ICSourceLocation extends IAdaptable
|
|||
* @return a memento for this source location
|
||||
* @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.
|
||||
|
@ -52,5 +52,19 @@ public interface ICSourceLocation extends IAdaptable
|
|||
* @exception CoreException if unable to initialize this source
|
||||
* 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
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
|
|||
*/
|
||||
private IPath fAssociation = null;
|
||||
|
||||
private boolean fSearchForDuplicateFiles = false;
|
||||
|
||||
/**
|
||||
* Constructor for CDirectorySourceLocation.
|
||||
*/
|
||||
|
@ -182,12 +184,12 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
|
|||
LinkedList list = new LinkedList();
|
||||
for ( int j = 0; j < wsFiles.length; ++j )
|
||||
if ( wsFiles[j].exists() )
|
||||
if ( !searchForDuplicateFileNames() )
|
||||
if ( !searchForDuplicateFiles() )
|
||||
return wsFiles[j];
|
||||
else
|
||||
list.add( wsFiles[j] );
|
||||
if ( list.size() > 0 )
|
||||
return list;
|
||||
return ( list.size() == 1 ) ? list.getFirst() : list;
|
||||
|
||||
file = filePath.toFile();
|
||||
if ( file.exists() )
|
||||
|
@ -211,12 +213,12 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
|
|||
LinkedList list = new LinkedList();
|
||||
for ( int j = 0; j < wsFiles.length; ++j )
|
||||
if ( wsFiles[j].exists() )
|
||||
if ( !searchForDuplicateFileNames() )
|
||||
if ( !searchForDuplicateFiles() )
|
||||
return wsFiles[j];
|
||||
else
|
||||
list.add( wsFiles[j] );
|
||||
if ( list.size() > 0 )
|
||||
return list;
|
||||
return ( list.size() == 1 ) ? list.getFirst() : list;
|
||||
else
|
||||
return createExternalFileStorage( path );
|
||||
}
|
||||
|
@ -368,9 +370,19 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
|
|||
return prefixString.equalsIgnoreCase( pathString );
|
||||
}
|
||||
|
||||
protected boolean searchForDuplicateFileNames()
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#setSearchForDuplicateFiles(boolean)
|
||||
*/
|
||||
public void setSearchForDuplicateFiles( boolean search )
|
||||
{
|
||||
// for now
|
||||
return false;
|
||||
fSearchForDuplicateFiles = search;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#searchForDuplicateFiles()
|
||||
*/
|
||||
public boolean searchForDuplicateFiles()
|
||||
{
|
||||
return fSearchForDuplicateFiles;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,8 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
|||
private HashSet fNotFoundCache = new HashSet( 20 );
|
||||
|
||||
private boolean fGenerated = true;
|
||||
|
||||
private boolean fSearchForDuplicateFiles = false;
|
||||
|
||||
/**
|
||||
* Constructor for CProjectSourceLocation.
|
||||
|
@ -162,12 +164,12 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
|||
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 ( !searchForDuplicateFileNames() )
|
||||
if ( !searchForDuplicateFiles() )
|
||||
return wsFiles[i];
|
||||
else
|
||||
list.add( wsFiles[i] );
|
||||
}
|
||||
return ( list.size() > 0 ) ? list : null;
|
||||
return ( list.size() > 0 ) ? ( ( list.size() == 1 ) ? list.getFirst() : list ) : null;
|
||||
}
|
||||
|
||||
private Object findFileByRelativePath( String fileName )
|
||||
|
@ -176,7 +178,7 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
|||
LinkedList list = new LinkedList();
|
||||
for ( int i = 0; i < folders.length; ++i )
|
||||
{
|
||||
if ( list.size() > 0 && !searchForDuplicateFileNames() )
|
||||
if ( list.size() > 0 && !searchForDuplicateFiles() )
|
||||
break;
|
||||
IPath path = folders[i].getLocation().append( fileName );
|
||||
File file = new File( path.toOSString() );
|
||||
|
@ -185,13 +187,13 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
|||
IFile[] wsFiles = CDebugCorePlugin.getWorkspace().getRoot().findFilesForLocation( path );
|
||||
for ( int j = 0; j < wsFiles.length; ++j )
|
||||
if ( wsFiles[j].exists() )
|
||||
if ( !searchForDuplicateFileNames() )
|
||||
if ( !searchForDuplicateFiles() )
|
||||
return wsFiles[j];
|
||||
else
|
||||
list.add( wsFiles[j] );
|
||||
}
|
||||
}
|
||||
return ( list.size() > 0 ) ? list : null;
|
||||
return ( list.size() > 0 ) ? ( ( list.size() == 1 ) ? list.getFirst() : list ) : null;
|
||||
}
|
||||
|
||||
private Object cacheLookup( String name )
|
||||
|
@ -369,9 +371,21 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
|||
return fFolders;
|
||||
}
|
||||
|
||||
protected boolean searchForDuplicateFileNames()
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#searchForDuplicateFiles()
|
||||
*/
|
||||
public boolean searchForDuplicateFiles()
|
||||
{
|
||||
// for now
|
||||
return false;
|
||||
return fSearchForDuplicateFiles;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#setSearchForDuplicateFiles(boolean)
|
||||
*/
|
||||
public void setSearchForDuplicateFiles( boolean search )
|
||||
{
|
||||
fCache.clear();
|
||||
fNotFoundCache.clear();
|
||||
fSearchForDuplicateFiles = search;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
|
@ -63,6 +64,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
|||
private static final String ATTR_CLASS = "class";
|
||||
private static final String ATTR_MEMENTO = "memento";
|
||||
private static final String ATTR_PROJECT_NAME = "projectName";
|
||||
private static final String ATTR_DUPLICATE_FILES = "duplicateFiles";
|
||||
|
||||
/**
|
||||
* The project associated with this locator.
|
||||
|
@ -79,6 +81,12 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -112,9 +120,10 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
|||
|
||||
protected Object getInput( IStackFrameInfo info )
|
||||
{
|
||||
Object result = null;
|
||||
LinkedList list = new LinkedList();
|
||||
if ( info != null )
|
||||
{
|
||||
Object result = null;
|
||||
String fileName = info.getFile();
|
||||
if ( fileName != null && fileName.length() > 0 )
|
||||
{
|
||||
|
@ -130,11 +139,18 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
|||
// do nothing
|
||||
}
|
||||
if ( result != null )
|
||||
break;
|
||||
{
|
||||
if ( result instanceof List )
|
||||
list.addAll( (List)result );
|
||||
else
|
||||
list.add( result );
|
||||
if ( !searchForDuplicateFiles() )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return ( list.size() > 0 ) ? ( ( list.size() == 1 ) ? list.getFirst() : list ) : null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -281,7 +297,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
|||
ICSourceLocation[] locations = getSourceLocations();
|
||||
saveDisabledGenericSourceLocations( locations, doc, node );
|
||||
saveAdditionalSourceLocations( locations, doc, node );
|
||||
|
||||
node.setAttribute( ATTR_DUPLICATE_FILES, new Boolean( searchForDuplicateFiles() ).toString() );
|
||||
try
|
||||
{
|
||||
return CDebugUtils.serializeDocument( doc, " " );
|
||||
|
@ -333,6 +349,9 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
|||
// To support old launch configuration
|
||||
addOldLocations( root, sourceLocations );
|
||||
setSourceLocations( (ICSourceLocation[])sourceLocations.toArray( new ICSourceLocation[sourceLocations.size()] ) );
|
||||
|
||||
setSearchForDuplicateFiles( Boolean.valueOf( root.getAttribute( ATTR_DUPLICATE_FILES ) ).booleanValue() );
|
||||
|
||||
return;
|
||||
}
|
||||
catch( ParserConfigurationException e )
|
||||
|
@ -693,4 +712,20 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
|||
fReferencedProjects = newRefs;
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ public class CSourceManager implements ICSourceLocator,
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected ICSourceLocator getCSourceLocator()
|
||||
{
|
||||
if ( getSourceLocator() instanceof ICSourceLocator )
|
||||
|
@ -275,4 +275,21 @@ public class CSourceManager implements ICSourceLocator,
|
|||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
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.
|
||||
|
||||
|
|
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/ext_file_obj.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/ext_file_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 171 B |
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/prj_file_obj.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/prj_file_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 180 B |
|
@ -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_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_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_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_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_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_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$
|
||||
|
|
|
@ -5,14 +5,23 @@
|
|||
*/
|
||||
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.sourcelookup.ICSourceLocator;
|
||||
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.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.NoSymbolOrSourceElement;
|
||||
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.IResourceChangeListener;
|
||||
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.model.IPersistableSourceLocator;
|
||||
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 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.
|
||||
*/
|
||||
|
@ -41,7 +114,10 @@ public class CUISourceLocator implements IAdaptable
|
|||
* Underlying source locator.
|
||||
*/
|
||||
private CSourceManager fSourceLocator;
|
||||
|
||||
|
||||
private HashMap fFramesToSource = null;
|
||||
private HashMap fNamesToSource = null;
|
||||
|
||||
/**
|
||||
* Constructor for CUISourceLocator.
|
||||
*/
|
||||
|
@ -53,7 +129,26 @@ public class CUISourceLocator implements IAdaptable
|
|||
|
||||
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 )
|
||||
{
|
||||
IStackFrameInfo frameInfo = (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class );
|
||||
|
@ -104,4 +199,60 @@ public class CUISourceLocator implements IAdaptable
|
|||
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.LayoutUtil;
|
||||
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.wizards.AddSourceLocationWizard;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -158,7 +159,7 @@ public class SourceLookupBlock
|
|||
private Shell fShell = null;
|
||||
private CheckedListDialogField fGeneratedSourceListField;
|
||||
private SourceListDialogField fAddedSourceListField;
|
||||
// private SelectionButtonDialogField fSearchForDuplicateFiles;
|
||||
private SelectionButtonDialogField fSearchForDuplicateFiles;
|
||||
private ILaunchConfigurationDialog fLaunchConfigurationDialog = null;
|
||||
private boolean fIsDirty = false;
|
||||
private ICSourceLocator fLocator = null;
|
||||
|
@ -228,10 +229,17 @@ public class SourceLookupBlock
|
|||
fAddedSourceListField.setUpButtonIndex( 2 );
|
||||
fAddedSourceListField.setDownButtonIndex( 3 );
|
||||
fAddedSourceListField.setRemoveButtonIndex( 5 );
|
||||
/*
|
||||
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 )
|
||||
|
@ -277,9 +285,9 @@ public class SourceLookupBlock
|
|||
viewer.setColumnProperties( new String[]{ CP_LOCATION, CP_ASSOCIATION } );
|
||||
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()
|
||||
|
@ -333,6 +341,7 @@ public class SourceLookupBlock
|
|||
ICSourceLocation[] locations = fLocator.getSourceLocations();
|
||||
initializeGeneratedLocations( fLocator.getProject(), locations );
|
||||
resetAdditionalLocations( locations );
|
||||
fSearchForDuplicateFiles.setSelection( fLocator.searchForDuplicateFiles() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -491,6 +500,7 @@ public class SourceLookupBlock
|
|||
locations = CSourceLocator.getDefaultSourceLocations( getProject() );
|
||||
resetGeneratedLocations( locations );
|
||||
resetAdditionalLocations( locations );
|
||||
fSearchForDuplicateFiles.setSelection( false );
|
||||
}
|
||||
|
||||
public IProject getProject()
|
||||
|
@ -521,4 +531,9 @@ public class SourceLookupBlock
|
|||
return locations[i];
|
||||
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.model.ICDebugTarget;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -107,7 +106,7 @@ public class SourcePropertyPage extends PropertyPage
|
|||
{
|
||||
try
|
||||
{
|
||||
setSourceLocations( fBlock.getSourceLocations() );
|
||||
setAttributes( fBlock );
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
|
@ -118,7 +117,7 @@ public class SourcePropertyPage extends PropertyPage
|
|||
return true;
|
||||
}
|
||||
|
||||
private void setSourceLocations( ICSourceLocation[] locations ) throws DebugException
|
||||
private void setAttributes( SourceLookupBlock block ) throws DebugException
|
||||
{
|
||||
ICDebugTarget target = getDebugTarget();
|
||||
if ( target != null )
|
||||
|
@ -128,7 +127,8 @@ public class SourcePropertyPage extends PropertyPage
|
|||
ICSourceLocator locator = (ICSourceLocator)((IAdaptable)target.getLaunch().getSourceLocator()).getAdapter( ICSourceLocator.class );
|
||||
if ( locator != null )
|
||||
{
|
||||
locator.setSourceLocations( locations );
|
||||
locator.setSourceLocations( block.getSourceLocations() );
|
||||
locator.setSearchForDuplicateFiles( block.searchForDuplicateFiles() );
|
||||
if ( target.getLaunch().getSourceLocator() instanceof IPersistableSourceLocator )
|
||||
{
|
||||
ILaunchConfiguration configuration = target.getLaunch().getLaunchConfiguration();
|
||||
|
|
Loading…
Add table
Reference in a new issue