[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Source Lookup changes
|
The content of the 'Source' launch configuration
tab and the 'Source Lookup' property page has been changed. This has been done
to provide more flexible way to manage the source locations of the
launch configuration..
By default the list of source locations includes
the main project and all referenced projects. User can enable/disable some of
these projects and/or add additional source locations.
When a project is added as a reference to the
main project the source locator updates automatically.
This should work with old launch
configurations.
Mikhail Khodjaiants
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v
retrieving revision 1.166
diff -u -r1.166 ChangeLog
--- ChangeLog 30 Jun 2003 02:59:06 -0000 1.166
+++ ChangeLog 17 Jul 2003 19:48:47 -0000
@@ -1,3 +1,12 @@
+2003-07-17 Mikhail Khodjaiants
+ Automatically update the list of source locations when the list of the referenced
+ projects is modified.
+ * CheckedListDialogField.java
+ * AddDirectorySourceLocationBlock.java
+ * AddProjectSourceLocationBlock.java
+ * CUISourceLocator.java
+ * SourceLookupBlock.java
+
2003-06-29 Mikhail Khodjaiants
Fix for PR 39101: No hilight when changing the value of register.
* RegistersView.java
Index: src/org/eclipse/cdt/debug/internal/ui/dialogfields/CheckedListDialogField.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/CheckedListDialogField.java,v
retrieving revision 1.2
diff -u -r1.2 CheckedListDialogField.java
--- src/org/eclipse/cdt/debug/internal/ui/dialogfields/CheckedListDialogField.java 9 Feb 2003 21:22:13 -0000 1.2
+++ src/org/eclipse/cdt/debug/internal/ui/dialogfields/CheckedListDialogField.java 17 Jul 2003 19:48:50 -0000
@@ -141,8 +141,15 @@
* Sets the checked state of an element. no dialog changed listener informed
*/
public void setCheckedWithoutUpdate(Object object, boolean state) {
- if (!fCheckElements.contains(object)) {
- fCheckElements.add(object);
+ if (state) {
+ if (!fCheckElements.contains(object)) {
+ fCheckElements.add(object);
+ }
+ }
+ else {
+ if (fCheckElements.contains(object)) {
+ fCheckElements.remove(object);
+ }
}
if (fTable != null) {
((CheckboxTableViewer)fTable).setChecked(object, state);
Index: src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java,v
retrieving revision 1.1
diff -u -r1.1 AddDirectorySourceLocationBlock.java
--- src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java 30 Dec 2002 00:07:15 -0000 1.1
+++ src/org/eclipse/cdt/debug/internal/ui/wizards/AddDirectorySourceLocationBlock.java 17 Jul 2003 19:48:51 -0000
@@ -6,7 +6,7 @@
package org.eclipse.cdt.debug.internal.ui.wizards;
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
-import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
+import org.eclipse.cdt.debug.core.sourcelookup.SourceLocationFactory;
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
import org.eclipse.cdt.debug.internal.ui.SWTUtil;
import org.eclipse.core.runtime.IPath;
@@ -177,7 +177,7 @@
if ( isLocationPathValid() )
{
Path association = ( isAssociationPathValid() ) ? new Path( getAssociationPath() ) : null;
- return new CDirectorySourceLocation( new Path( getLocationPath() ), association );
+ return SourceLocationFactory.createDirectorySourceLocation( new Path( getLocationPath() ), association );
}
return null;
}
Index: src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java,v
retrieving revision 1.1
diff -u -r1.1 AddProjectSourceLocationBlock.java
--- src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java 30 Dec 2002 00:07:15 -0000 1.1
+++ src/org/eclipse/cdt/debug/internal/ui/wizards/AddProjectSourceLocationBlock.java 17 Jul 2003 19:48:51 -0000
@@ -6,7 +6,7 @@
package org.eclipse.cdt.debug.internal.ui.wizards;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
-import org.eclipse.cdt.debug.internal.core.sourcelookup.CProjectSourceLocation;
+import org.eclipse.cdt.debug.core.sourcelookup.SourceLocationFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -92,7 +92,7 @@
{
if ( !((IStructuredSelection)fViewer.getSelection()).isEmpty() )
{
- return new CProjectSourceLocation( (IProject)((IStructuredSelection)fViewer.getSelection()).getFirstElement() );
+ return SourceLocationFactory.createProjectSourceLocation( (IProject)((IStructuredSelection)fViewer.getSelection()).getFirstElement(), false );
}
}
return null;
Index: src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java,v
retrieving revision 1.9
diff -u -r1.9 CUISourceLocator.java
--- src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java 25 Apr 2003 19:38:51 -0000 1.9
+++ src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java 17 Jul 2003 19:48:51 -0000
@@ -16,6 +16,7 @@
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
@@ -121,6 +122,8 @@
{
if ( adapter.equals( ICSourceLocator.class ) )
return fSourceLocator;
+ if ( adapter.equals( IResourceChangeListener.class ) && fSourceLocator instanceof IAdaptable )
+ return ((IAdaptable)fSourceLocator).getAdapter( IResourceChangeListener.class );
if ( adapter.equals( ISourceMode.class ) )
return fSourceLocator;
}
Index: src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java,v
retrieving revision 1.8
diff -u -r1.8 SourceLookupBlock.java
--- src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java 4 Mar 2003 17:40:09 -0000 1.8
+++ src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java 17 Jul 2003 19:48:51 -0000
@@ -5,28 +5,39 @@
*/
package org.eclipse.cdt.debug.ui.sourcelookup;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
+import org.eclipse.cdt.debug.core.sourcelookup.SourceLocationFactory;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
+import org.eclipse.cdt.debug.internal.ui.dialogfields.CheckedListDialogField;
import org.eclipse.cdt.debug.internal.ui.dialogfields.DialogField;
+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.Separator;
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -95,19 +106,6 @@
}
}
- private class SourceLookupAdapter implements IListAdapter
- {
- public void customButtonPressed( DialogField field, int index )
- {
- doButtonPressed( index );
- }
-
- public void selectionChanged( DialogField field )
- {
- doSelectionChanged();
- }
- }
-
private static class SourceLookupLabelProvider extends LabelProvider implements ITableLabelProvider
{
public Image getColumnImage( Object element, int columnIndex )
@@ -156,7 +154,9 @@
private Composite fControl = null;
private Shell fShell = null;
- private SourceListDialogField fSourceListField;
+ private CheckedListDialogField fGeneratedSourceListField;
+ private SourceListDialogField fAddedSourceListField;
+// private SelectionButtonDialogField fSearchForDuplicateFiles;
private ILaunchConfigurationDialog fLaunchConfigurationDialog = null;
private boolean fIsDirty = false;
private ICSourceLocator fLocator = null;
@@ -167,7 +167,13 @@
*/
public SourceLookupBlock()
{
- String[] buttonLabels = new String[]
+ String[] generatedSourceButtonLabels = new String[]
+ {
+ /* 0 */ "Select All",
+ /* 1 */ "Deselect All",
+ };
+
+ String[] addedSourceButtonLabels = new String[]
{
/* 0 */ "Add...",
/* 1 */ null,
@@ -175,17 +181,55 @@
/* 3 */ "Down",
/* 4 */ null,
/* 5 */ "Remove",
- /* 6 */ null,
- /* 7 */ "Restore Defaults",
};
- SourceLookupAdapter adapter = new SourceLookupAdapter();
-
- fSourceListField = new SourceListDialogField( adapter, buttonLabels, new SourceLookupLabelProvider() );
- fSourceListField.setLabelText( "Source Locations" );
- fSourceListField.setUpButtonIndex( 2 );
- fSourceListField.setDownButtonIndex( 3 );
- fSourceListField.setRemoveButtonIndex( 5 );
+ IListAdapter generatedSourceAdapter = new IListAdapter()
+ {
+ public void customButtonPressed( DialogField field, int index )
+ {
+ doGeneratedSourceButtonPressed( index );
+ }
+
+ public void selectionChanged( DialogField field )
+ {
+ doGeneratedSourceSelectionChanged();
+ }
+ };
+
+ fGeneratedSourceListField = new CheckedListDialogField( generatedSourceAdapter, generatedSourceButtonLabels, new SourceLookupLabelProvider() );
+ fGeneratedSourceListField.setLabelText( "Generic Source Locations" );
+ fGeneratedSourceListField.setCheckAllButtonIndex( 0 );
+ fGeneratedSourceListField.setUncheckAllButtonIndex( 1 );
+ fGeneratedSourceListField.setDialogFieldListener( new IDialogFieldListener()
+ {
+ public void dialogFieldChanged( DialogField field )
+ {
+ doCheckStateChanged();
+ }
+
+ } );
+ IListAdapter addedSourceAdapter = new IListAdapter()
+ {
+ public void customButtonPressed( DialogField field, int index )
+ {
+ doAddedSourceButtonPressed( index );
+ }
+
+ public void selectionChanged( DialogField field )
+ {
+ doAddedSourceSelectionChanged();
+ }
+ };
+
+ fAddedSourceListField = new SourceListDialogField( addedSourceAdapter, addedSourceButtonLabels, new SourceLookupLabelProvider() );
+ fAddedSourceListField.setLabelText( "Additional Source Locations" );
+ fAddedSourceListField.setUpButtonIndex( 2 );
+ fAddedSourceListField.setDownButtonIndex( 3 );
+ fAddedSourceListField.setRemoveButtonIndex( 5 );
+/*
+ fSearchForDuplicateFiles = new SelectionButtonDialogField( SWT.CHECK );
+ fSearchForDuplicateFiles.setLabelText( "Search for duplicate files" );
+*/
}
public void createControl( Composite parent )
@@ -202,17 +246,38 @@
PixelConverter converter = new PixelConverter( fControl );
- fSourceListField.doFillIntoGrid( fControl, 3 );
- LayoutUtil.setHorizontalSpan( fSourceListField.getLabelControl( null ), 2 );
- LayoutUtil.setWidthHint( fSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) );
- LayoutUtil.setHorizontalGrabbing( fSourceListField.getListControl( null ) );
+ fGeneratedSourceListField.doFillIntoGrid( fControl, 3 );
+ LayoutUtil.setHorizontalSpan( fGeneratedSourceListField.getLabelControl( null ), 2 );
+ LayoutUtil.setWidthHint( fGeneratedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) );
+ LayoutUtil.setHorizontalGrabbing( fGeneratedSourceListField.getListControl( null ) );
+ ((CheckboxTableViewer)fGeneratedSourceListField.getTableViewer()).
+ addCheckStateListener( new ICheckStateListener()
+ {
+ public void checkStateChanged( CheckStateChangedEvent event )
+ {
+ if ( event.getElement() instanceof IProjectSourceLocation )
+ doCheckStateChanged();
+ }
+
+ } );
+
+ new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) );
+
+ fAddedSourceListField.doFillIntoGrid( fControl, 3 );
+ LayoutUtil.setHorizontalSpan( fAddedSourceListField.getLabelControl( null ), 2 );
+ LayoutUtil.setWidthHint( fAddedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) );
+ LayoutUtil.setHorizontalGrabbing( fAddedSourceListField.getListControl( null ) );
- TableViewer viewer = fSourceListField.getTableViewer();
+ TableViewer viewer = fAddedSourceListField.getTableViewer();
Table table = viewer.getTable();
CellEditor cellEditor = new TextCellEditor( table );
viewer.setCellEditors( new CellEditor[]{ null, cellEditor } );
viewer.setColumnProperties( new String[]{ CP_LOCATION, CP_ASSOCIATION } );
viewer.setCellModifier( createCellModifier() );
+
+ new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) );
+
+// fSearchForDuplicateFiles.doFillIntoGrid( fControl, 3 );
}
private ICellModifier createCellModifier()
@@ -245,7 +310,7 @@
if ( association.isValidPath( (String)value ) )
{
((CDirectorySourceLocation)entry).setAssociation( association );
- getSourceListField().refresh();
+ getAddedSourceListField().refresh();
updateLaunchConfigurationDialog();
}
}
@@ -261,22 +326,61 @@
public void initialize( ICSourceLocator locator )
{
fLocator = locator;
- ICSourceLocation[] locations = new ICSourceLocation[0];
if ( fLocator != null )
- locations = fLocator.getSourceLocations();
- resetLocations( locations );
+ {
+ ICSourceLocation[] locations = fLocator.getSourceLocations();
+ initializeGeneratedLocations( fLocator.getProject(), locations );
+ resetAdditionalLocations( locations );
+ }
+ }
+
+ private void initializeGeneratedLocations( IProject project, ICSourceLocation[] locations )
+ {
+ fGeneratedSourceListField.removeAllElements();
+ if ( project == null && project.exists() && project.isOpen() )
+ return;
+ List list = getReferencedProjects( project );
+ IProject[] refs = (IProject[])list.toArray( new IProject[list.size()] );
+ ICSourceLocation loc = getLocationForProject( project, locations );
+ boolean checked = ( loc != null );
+ if ( loc == null )
+ loc = SourceLocationFactory.createProjectSourceLocation( project, true );
+ fGeneratedSourceListField.addElement( loc );
+ fGeneratedSourceListField.setChecked( loc, checked );
+
+ for ( int i = 0; i < refs.length; ++i )
+ {
+ loc = getLocationForProject( refs[i], locations );
+ checked = ( loc != null );
+ if ( loc == null )
+ loc = SourceLocationFactory.createProjectSourceLocation( refs[i], true );
+ fGeneratedSourceListField.addElement( loc );
+ fGeneratedSourceListField.setChecked( loc, checked );
+ }
}
- private void resetLocations( ICSourceLocation[] locations )
+ private void resetGeneratedLocations( ICSourceLocation[] locations )
{
- fSourceListField.removeAllElements();
+ fGeneratedSourceListField.checkAll( false );
for ( int i = 0; i < locations.length; ++i )
{
- fSourceListField.addElement( locations[i] );
+ if ( locations[i] instanceof IProjectSourceLocation &&
+ ((IProjectSourceLocation)locations[i]).isGeneric() )
+ fGeneratedSourceListField.setChecked( locations[i], true );
}
}
- protected void doButtonPressed( int index )
+ private void resetAdditionalLocations( ICSourceLocation[] locations )
+ {
+ fAddedSourceListField.removeAllElements();
+ for ( int i = 0; i < locations.length; ++i )
+ {
+ if ( !( locations[i] instanceof IProjectSourceLocation ) || !((IProjectSourceLocation)locations[i]).isGeneric() )
+ fAddedSourceListField.addElement( locations[i] );
+ }
+ }
+
+ protected void doAddedSourceButtonPressed( int index )
{
switch( index )
{
@@ -284,11 +388,9 @@
if ( addSourceLocation() )
fIsDirty = true;
break;
- case 7:
- restoreDefaults();
- case 2:
- case 3:
- case 5:
+ case 2: // Up
+ case 3: // Down
+ case 5: // Remove
fIsDirty = true;
break;
}
@@ -296,13 +398,45 @@
updateLaunchConfigurationDialog();
}
- protected void doSelectionChanged()
+ protected void doAddedSourceSelectionChanged()
+ {
+ }
+
+ protected void doCheckStateChanged()
+ {
+ fIsDirty = true;
+ updateLaunchConfigurationDialog();
+ }
+
+ protected void doGeneratedSourceButtonPressed( int index )
+ {
+ switch( index )
+ {
+ case 0: // Select All
+ case 1: // Deselect All
+ fIsDirty = true;
+ break;
+ }
+ if ( isDirty() )
+ updateLaunchConfigurationDialog();
+ }
+
+ protected void doGeneratedSourceSelectionChanged()
{
}
public ICSourceLocation[] getSourceLocations()
{
- return (ICSourceLocation[])fSourceListField.getElements().toArray( new ICSourceLocation[fSourceListField.getElements().size()] );
+ ArrayList list = new ArrayList( getGeneratedSourceListField().getElements().size() + getAddedSourceListField().getElements().size() );
+ Iterator it = getGeneratedSourceListField().getElements().iterator();
+ while( it.hasNext() )
+ {
+ IProjectSourceLocation location = (IProjectSourceLocation)it.next();
+ if ( getGeneratedSourceListField().isChecked( location ) )
+ list.add( location );
+ }
+ list.addAll( getAddedSourceListField().getElements() );
+ return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
}
private boolean addSourceLocation()
@@ -311,7 +445,7 @@
WizardDialog dialog = new WizardDialog( fControl.getShell(), wizard );
if ( dialog.open() == Window.OK )
{
- fSourceListField.addElement( wizard.getSourceLocation() );
+ fAddedSourceListField.addElement( wizard.getSourceLocation() );
return true;
}
return false;
@@ -344,7 +478,7 @@
protected Object getSelection()
{
- List list = fSourceListField.getSelectedElements();
+ List list = fAddedSourceListField.getSelectedElements();
return ( list.size() > 0 ) ? list.get( 0 ) : null;
}
@@ -353,7 +487,8 @@
ICSourceLocation[] locations = new ICSourceLocation[0];
if ( getProject() != null )
locations = CSourceLocator.getDefaultSourceLocations( getProject() );
- resetLocations( locations );
+ resetGeneratedLocations( locations );
+ resetAdditionalLocations( locations );
}
public IProject getProject()
@@ -366,8 +501,42 @@
fProject = project;
}
- public SourceListDialogField getSourceListField()
+ public SourceListDialogField getAddedSourceListField()
+ {
+ return fAddedSourceListField;
+ }
+
+ public CheckedListDialogField getGeneratedSourceListField()
+ {
+ return fGeneratedSourceListField;
+ }
+
+ private ICSourceLocation getLocationForProject( IProject project, ICSourceLocation[] locations )
{
- return fSourceListField;
+ for ( int i = 0; i < locations.length; ++i )
+ if ( locations[i] instanceof IProjectSourceLocation &&
+ project.equals( ((IProjectSourceLocation)locations[i]).getProject() ) )
+ return locations[i];
+ return null;
+ }
+
+ private List getReferencedProjects( IProject project )
+ {
+ ArrayList list = new ArrayList( 10 );
+ if ( project != null && project.exists() && project.isOpen() )
+ {
+ IProject[] refs = new IProject[0];
+ try
+ {
+ refs = project.getReferencedProjects();
+ }
+ catch( CoreException e )
+ {
+ }
+ list.addAll( Arrays.asList( refs ) );
+ for ( int i = 0; i < refs.length; ++i )
+ list.addAll( getReferencedProjects( refs[i] ) );
+ }
+ return list;
}
}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.213
diff -u -r1.213 ChangeLog
--- ChangeLog 30 Jun 2003 21:14:48 -0000 1.213
+++ ChangeLog 17 Jul 2003 19:47:50 -0000
@@ -1,3 +1,15 @@
+2003-07-17 Mikhail Khodjaiants
+ Automatically update the list of source locations when the list of the referenced
+ projects is modified.
+ * ICSourceLocator.java: added new method - 'getProject'
+ * IProjectSourceLocation.java: added new method - 'isGeneric'
+ * SourceLocationFactory.java: new class factory for source locations.
+ * CSourceLocator.java
+ * CDirectorySourceLocation.java
+ * CProjectSourceLocation.java
+ * CSourceManager.java
+ * CDebugTarget.java
+
2003-06-30 Mikhail Khodjaiants
Fix for PR 39372: Breakpoints don't get activated when symbols are loaded.
Index: src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java,v
retrieving revision 1.8
diff -u -r1.8 ICSourceLocator.java
--- src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java 20 Feb 2003 20:43:02 -0000 1.8
+++ src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java 17 Jul 2003 19:47:53 -0000
@@ -5,6 +5,7 @@
*/
package org.eclipse.cdt.debug.core.sourcelookup;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.debug.core.model.IStackFrame;
@@ -18,6 +19,13 @@
*/
public interface ICSourceLocator extends ISourceLocator
{
+ /**
+ * Returns the project this source locator is associated with or <code>null</code>.
+ *
+ * @return project this source locator is associated with or <code>null</code>
+ */
+ IProject getProject();
+
/**
* Returns the line number of the instruction pointer in the specified
* stack frame that corresponds to a line in an associated source element,
Index: src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java,v
retrieving revision 1.1
diff -u -r1.1 IProjectSourceLocation.java
--- src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java 29 Dec 2002 23:55:53 -0000 1.1
+++ src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java 17 Jul 2003 19:47:53 -0000
@@ -16,4 +16,6 @@
public interface IProjectSourceLocation extends ICSourceLocation
{
IProject getProject();
+
+ boolean isGeneric();
}
Index: src/org/eclipse/cdt/debug/core/sourcelookup/SourceLocationFactory.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/core/sourcelookup/SourceLocationFactory.java
diff -N src/org/eclipse/cdt/debug/core/sourcelookup/SourceLocationFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/core/sourcelookup/SourceLocationFactory.java 17 Jul 2003 19:47:53 -0000
@@ -0,0 +1,40 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.core.sourcelookup;
+
+import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
+import org.eclipse.cdt.debug.internal.core.sourcelookup.CProjectSourceLocation;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Enter type comment.
+ *
+ * @since Jul 14, 2003
+ */
+public class SourceLocationFactory
+{
+ public static IProjectSourceLocation createProjectSourceLocation( IProject project )
+ {
+ return new CProjectSourceLocation( project );
+ }
+
+ public static IProjectSourceLocation createProjectSourceLocation( IProject project, boolean generated )
+ {
+ return new CProjectSourceLocation( project, generated );
+ }
+
+ public static IDirectorySourceLocation createDirectorySourceLocation( IPath directory )
+ {
+ return new CDirectorySourceLocation( directory );
+ }
+
+ public static IDirectorySourceLocation createDirectorySourceLocation( IPath directory, IPath association )
+ {
+ return new CDirectorySourceLocation( directory, association );
+ }
+}
Index: src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java,v
retrieving revision 1.103
diff -u -r1.103 CDebugTarget.java
--- src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java 27 May 2003 19:00:30 -0000 1.103
+++ src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java 17 Jul 2003 19:47:54 -0000
@@ -87,6 +87,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
@@ -303,6 +304,7 @@
initializeBreakpoints();
initializeRegisters();
initializeMemoryManager();
+ initializeSourceManager();
getLaunch().addDebugTarget( this );
fireCreationEvent();
}
@@ -398,6 +400,17 @@
fMemoryManager = new CMemoryManager( this );
}
+ protected void initializeSourceManager()
+ {
+ ISourceLocator locator = getLaunch().getSourceLocator();
+ if ( locator instanceof IAdaptable )
+ {
+ IResourceChangeListener listener = (IResourceChangeListener)((IAdaptable)locator).getAdapter( IResourceChangeListener.class );
+ if ( listener != null )
+ CCorePlugin.getWorkspace().addResourceChangeListener( listener );
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
*/
@@ -1183,6 +1196,7 @@
disposeSignalManager();
disposeRegisterManager();
disposeDisassemblyManager();
+ disposeSourceManager();
removeAllExpressions();
try
{
@@ -2574,5 +2588,16 @@
public IRegisterGroup[] getRegisterGroups() throws DebugException
{
return getRegisterManager().getRegisterGroups();
+ }
+
+ protected void disposeSourceManager()
+ {
+ ISourceLocator locator = getSourceLocator();
+ if ( locator instanceof IAdaptable )
+ {
+ IResourceChangeListener listener = (IResourceChangeListener)((IAdaptable)locator).getAdapter( IResourceChangeListener.class );
+ if ( listener != null )
+ CCorePlugin.getWorkspace().removeResourceChangeListener( listener );
+ }
}
}
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java,v
retrieving revision 1.8
diff -u -r1.8 CDirectorySourceLocation.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java 28 Mar 2003 22:22:35 -0000 1.8
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java 17 Jul 2003 19:47:54 -0000
@@ -307,4 +307,27 @@
{
return string == null || string.length() == 0;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof IDirectorySourceLocation )
+ {
+ IPath dir = ((IDirectorySourceLocation)obj).getDirectory();
+ IPath association = ((IDirectorySourceLocation)obj).getAssociation();
+ if ( dir == null )
+ return false;
+ boolean result = dir.equals( getDirectory() );
+ if ( result )
+ {
+ if ( association == null && getAssociation() == null )
+ return true;
+ if ( association != null )
+ return association.equals( getAssociation() );
+ }
+ }
+ return false;
+ }
}
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java,v
retrieving revision 1.8
diff -u -r1.8 CProjectSourceLocation.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java 20 Feb 2003 20:36:18 -0000 1.8
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java 17 Jul 2003 19:47:55 -0000
@@ -47,6 +47,7 @@
{
private static final String ELEMENT_NAME = "cProjectSourceLocation";
private static final String ATTR_PROJECT = "project";
+ private static final String ATTR_GENERIC = "generic";
/**
* The project associated with this source location
@@ -57,6 +58,8 @@
private HashSet fNotFoundCache = new HashSet( 20 );
+ private boolean fGenerated = true;
+
/**
* Constructor for CProjectSourceLocation.
*/
@@ -70,6 +73,16 @@
public CProjectSourceLocation( IProject project )
{
setProject( project );
+ fGenerated = true;
+ }
+
+ /**
+ * Constructor for CProjectSourceLocation.
+ */
+ public CProjectSourceLocation( IProject project, boolean generated )
+ {
+ setProject( project );
+ fGenerated = generated;
}
/* (non-Javadoc)
@@ -240,7 +253,7 @@
Element node = doc.createElement( ELEMENT_NAME );
doc.appendChild( node );
node.setAttribute( ATTR_PROJECT, getProject().getName() );
-
+ node.setAttribute( ATTR_GENERIC, new Boolean( isGeneric() ).toString() );
try
{
return CDebugUtils.serializeDocument( doc, " " );
@@ -277,6 +290,10 @@
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( name );
setProject( project );
}
+ String isGeneric = root.getAttribute( ATTR_GENERIC );
+ if ( isGeneric == null || isGeneric.trim().length() == 0 )
+ isGeneric = Boolean.FALSE.toString();
+ setGenerated( isGeneric.equals( Boolean.TRUE.toString() ) );
return;
}
catch( ParserConfigurationException e )
@@ -310,5 +327,28 @@
private boolean isEmpty( String string )
{
return string == null || string.length() == 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation#isGenerated()
+ */
+ public boolean isGeneric()
+ {
+ return fGenerated;
+ }
+
+ public void setGenerated( boolean b )
+ {
+ fGenerated = b;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof IProjectSourceLocation )
+ return getProject().getName().equals( ((IProjectSourceLocation)obj).getProject().getName() );
+ return false;
}
}
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java,v
retrieving revision 1.11
diff -u -r1.11 CSourceLocator.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java 28 Mar 2003 22:22:35 -0000 1.11
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java 17 Jul 2003 19:47:55 -0000
@@ -10,6 +10,8 @@
import java.io.StringReader;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -20,14 +22,19 @@
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.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
+import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
+import org.eclipse.cdt.debug.core.sourcelookup.SourceLocationFactory;
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -50,40 +57,38 @@
* @since Aug 19, 2002
*/
-public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocator
+public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocator, IResourceChangeListener
{
- private static final String ELEMENT_NAME = "cSourceLocator";
- private static final String CHILD_NAME = "cSourceLocation";
+ private static final String SOURCE_LOCATOR_NAME = "cSourceLocator";
+ private static final String DISABLED_GENERIC_PROJECT_NAME = "disabledGenericProject";
+ private static final String ADDITIONAL_SOURCE_LOCATION_NAME = "additionalSourceLocation";
+ private static final String SOURCE_LOCATION_NAME = "cSourceLocation";
private static final String ATTR_CLASS = "class";
private static final String ATTR_MEMENTO = "memento";
+ private static final String ATTR_PROJECT_NAME = "projectName";
/**
- * The array of source locations associated with this locator.
+ * The project associated with this locator.
*/
- private ICSourceLocation[] fSourceLocations;
+ private IProject fProject = null;
/**
- * Constructor for CSourceLocator.
+ * The array of source locations associated with this locator.
*/
- public CSourceLocator()
- {
- setSourceLocations( new ICSourceLocation[0] );
- }
+ private ICSourceLocation[] fSourceLocations;
/**
- * Constructor for CSourceLocator.
+ * The array of projects referenced by main project.
*/
- public CSourceLocator( IProject project )
- {
- fSourceLocations = getDefaultSourceLocations( project );
- }
+ private List fReferencedProjects = new ArrayList( 10 );
/**
* Constructor for CSourceLocator.
*/
- public CSourceLocator( ICSourceLocation[] locations )
+ public CSourceLocator( IProject project )
{
- fSourceLocations = locations;
+ setProject( project );
+ setReferencedProjects();
}
/* (non-Javadoc)
@@ -200,7 +205,7 @@
ArrayList list = new ArrayList();
if ( project != null && project.exists() )
{
- list.add( new CProjectSourceLocation( project ) );
+ list.add( SourceLocationFactory.createProjectSourceLocation( project ) );
addReferencedSourceLocations( list, project );
}
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
@@ -217,7 +222,7 @@
{
if ( projects[i].exists() && !containsProject( list, projects[i] ) )
{
- list.add( new CProjectSourceLocation( projects[i] ) );
+ list.add( SourceLocationFactory.createProjectSourceLocation( projects[i] ) );
addReferencedSourceLocations( list, projects[i] );
}
}
@@ -293,17 +298,13 @@
public String getMemento() throws CoreException
{
Document doc = new DocumentImpl();
- Element node = doc.createElement( ELEMENT_NAME );
+ Element node = doc.createElement( SOURCE_LOCATOR_NAME );
doc.appendChild( node );
ICSourceLocation[] locations = getSourceLocations();
- for ( int i = 0; i < locations.length; i++ )
- {
- Element child = doc.createElement( CHILD_NAME );
- child.setAttribute( ATTR_CLASS, locations[i].getClass().getName() );
- child.setAttribute( ATTR_MEMENTO, locations[i].getMemento() );
- node.appendChild( child );
- }
+ saveDisabledGenericSourceLocations( locations, doc, node );
+ saveAdditionalSourceLocations( locations, doc, node );
+
try
{
return CDebugUtils.serializeDocument( doc, " " );
@@ -321,15 +322,7 @@
*/
public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException
{
- IProject project = getProject( configuration );
- if ( project != null )
- {
- setSourceLocations( getDefaultSourceLocations( project ) );
- }
- else
- {
- setSourceLocations( new ICSourceLocation[0] );
- }
+ setSourceLocations( getDefaultSourceLocations() );
}
/* (non-Javadoc)
@@ -346,63 +339,22 @@
InputSource source = new InputSource( reader );
root = parser.parse( source ).getDocumentElement();
- if ( !root.getNodeName().equalsIgnoreCase( ELEMENT_NAME ) )
+ if ( !root.getNodeName().equalsIgnoreCase( SOURCE_LOCATOR_NAME ) )
{
abort( "Unable to restore C/C++ source locator - invalid format.", null );
}
List sourceLocations = new ArrayList();
- ClassLoader classLoader = CDebugCorePlugin.getDefault() .getDescriptor().getPluginClassLoader();
-
- NodeList list = root.getChildNodes();
- int length = list.getLength();
- for ( int i = 0; i < length; ++i )
- {
- Node node = list.item( i );
- short type = node.getNodeType();
- if ( type == Node.ELEMENT_NODE )
- {
- Element entry = (Element)node;
- if ( entry.getNodeName().equalsIgnoreCase( CHILD_NAME ) )
- {
- String className = entry.getAttribute( ATTR_CLASS );
- String data = entry.getAttribute( ATTR_MEMENTO );
- if ( isEmpty( className ) )
- {
- abort( "Unable to restore C/C++ source locator - invalid format.", null );
- }
- Class clazz = null;
- try
- {
- clazz = classLoader.loadClass( className );
- }
- catch( ClassNotFoundException e )
- {
- abort( MessageFormat.format( "Unable to restore source location - class not found {0}", new String[] { className } ), e );
- }
-
- ICSourceLocation location = null;
- try
- {
- location = (ICSourceLocation)clazz.newInstance();
- }
- catch( IllegalAccessException e )
- {
- abort( "Unable to restore source location.", e );
- }
- catch( InstantiationException e )
- {
- abort( "Unable to restore source location.", e );
- }
- location.initializeFrom( data );
- sourceLocations.add( location );
- }
- else
- {
- abort( "Unable to restore C/C++ source locator - invalid format.", null );
- }
- }
- }
+
+ // Add locations based on referenced projects
+ IProject project = getProject();
+ if ( project != null && project.exists() && project.isOpen() )
+ sourceLocations.addAll( Arrays.asList( getDefaultSourceLocations() ) );
+
+ removeDisabledLocations( root, sourceLocations );
+ addAdditionalLocations( root, sourceLocations );
+ // To support old launch configuration
+ addOldLocations( root, sourceLocations );
setSourceLocations( (ICSourceLocation[])sourceLocations.toArray( new ICSourceLocation[sourceLocations.size()] ) );
return;
}
@@ -421,6 +373,154 @@
abort( "Exception occurred initializing source locator.", ex );
}
+ private void removeDisabledLocations( Element root, List sourceLocations ) throws CoreException
+ {
+ NodeList list = root.getChildNodes();
+ int length = list.getLength();
+ HashSet disabledProjects = new HashSet( length );
+ for ( int i = 0; i < length; ++i )
+ {
+ Node node = list.item( i );
+ short type = node.getNodeType();
+ if ( type == Node.ELEMENT_NODE )
+ {
+ Element entry = (Element)node;
+ if ( entry.getNodeName().equalsIgnoreCase( DISABLED_GENERIC_PROJECT_NAME ) )
+ {
+ String projectName = entry.getAttribute( ATTR_PROJECT_NAME );
+ if ( isEmpty( projectName ) )
+ {
+ CDebugCorePlugin.log( "Unable to restore C/C++ source locator - invalid format." );
+ }
+ disabledProjects.add( projectName.trim() );
+ }
+ }
+ }
+ Iterator it = sourceLocations.iterator();
+ while( it.hasNext() )
+ {
+ ICSourceLocation location = (ICSourceLocation)it.next();
+ if ( location instanceof IProjectSourceLocation &&
+ disabledProjects.contains( ((IProjectSourceLocation)location).getProject().getName() ) )
+ it.remove();
+ }
+ }
+
+ private void addAdditionalLocations( Element root, List sourceLocations ) throws CoreException
+ {
+ ClassLoader classLoader = CDebugCorePlugin.getDefault() .getDescriptor().getPluginClassLoader();
+
+ NodeList list = root.getChildNodes();
+ int length = list.getLength();
+ for ( int i = 0; i < length; ++i )
+ {
+ Node node = list.item( i );
+ short type = node.getNodeType();
+ if ( type == Node.ELEMENT_NODE )
+ {
+ Element entry = (Element)node;
+ if ( entry.getNodeName().equalsIgnoreCase( ADDITIONAL_SOURCE_LOCATION_NAME ) )
+ {
+ String className = entry.getAttribute( ATTR_CLASS );
+ String data = entry.getAttribute( ATTR_MEMENTO );
+ if ( isEmpty( className ) )
+ {
+ CDebugCorePlugin.log( "Unable to restore C/C++ source locator - invalid format." );
+ continue;
+ }
+ Class clazz = null;
+ try
+ {
+ clazz = classLoader.loadClass( className );
+ }
+ catch( ClassNotFoundException e )
+ {
+ CDebugCorePlugin.log( MessageFormat.format( "Unable to restore source location - class not found {0}", new String[] { className } ) );
+ continue;
+ }
+
+ ICSourceLocation location = null;
+ try
+ {
+ location = (ICSourceLocation)clazz.newInstance();
+ }
+ catch( IllegalAccessException e )
+ {
+ CDebugCorePlugin.log( "Unable to restore source location." );
+ continue;
+ }
+ catch( InstantiationException e )
+ {
+ CDebugCorePlugin.log( "Unable to restore source location." );
+ continue;
+ }
+ location.initializeFrom( data );
+ sourceLocations.add( location );
+ }
+ }
+ }
+ }
+
+ private void addOldLocations( Element root, List sourceLocations ) throws CoreException
+ {
+ ClassLoader classLoader = CDebugCorePlugin.getDefault() .getDescriptor().getPluginClassLoader();
+
+ NodeList list = root.getChildNodes();
+ int length = list.getLength();
+ for ( int i = 0; i < length; ++i )
+ {
+ Node node = list.item( i );
+ short type = node.getNodeType();
+ if ( type == Node.ELEMENT_NODE )
+ {
+ Element entry = (Element)node;
+ if ( entry.getNodeName().equalsIgnoreCase( SOURCE_LOCATION_NAME ) )
+ {
+ String className = entry.getAttribute( ATTR_CLASS );
+ String data = entry.getAttribute( ATTR_MEMENTO );
+ if ( isEmpty( className ) )
+ {
+ CDebugCorePlugin.log( "Unable to restore C/C++ source locator - invalid format." );
+ continue;
+ }
+ Class clazz = null;
+ try
+ {
+ clazz = classLoader.loadClass( className );
+ }
+ catch( ClassNotFoundException e )
+ {
+ CDebugCorePlugin.log( MessageFormat.format( "Unable to restore source location - class not found {0}", new String[] { className } ) );
+ continue;
+ }
+
+ ICSourceLocation location = null;
+ try
+ {
+ location = (ICSourceLocation)clazz.newInstance();
+ }
+ catch( IllegalAccessException e )
+ {
+ CDebugCorePlugin.log( "Unable to restore source location." );
+ continue;
+ }
+ catch( InstantiationException e )
+ {
+ CDebugCorePlugin.log( "Unable to restore source location." );
+ continue;
+ }
+ location.initializeFrom( data );
+ if ( !sourceLocations.contains( location ) )
+ {
+ if ( location instanceof CProjectSourceLocation )
+ ((CProjectSourceLocation)location).setGenerated( isReferencedProject( ((CProjectSourceLocation)location).getProject() ) );
+ sourceLocations.add( location );
+ }
+ }
+ }
+ }
+ }
+
/**
* Throws an internal error exception
*/
@@ -437,21 +537,209 @@
private boolean isEmpty( String string )
{
- return string == null || string.length() == 0;
+ return string == null || string.trim().length() == 0;
}
- private IProject getProject( ILaunchConfiguration configuration )
+ public void resourceChanged( IResourceChangeEvent event )
{
- IProject project = null;
- try
+ if ( event.getSource() instanceof IWorkspace && event.getDelta() != null )
+ {
+ IResourceDelta[] deltas = event.getDelta().getAffectedChildren();
+ if ( deltas != null )
+ {
+ ArrayList list = new ArrayList( deltas.length );
+ for ( int i = 0; i < deltas.length; ++i )
+ if ( deltas[i].getResource() instanceof IProject )
+ list.add( deltas[i].getResource() );
+ resetSourceLocations( list );
+ }
+ }
+ }
+
+ private void saveDisabledGenericSourceLocations( ICSourceLocation[] locations, Document doc, Element node )
+ {
+ IProject project = getProject();
+ if ( project != null && project.exists() && project.isOpen() )
+ {
+ try
+ {
+ IProject[] refs = project.getReferencedProjects();
+ HashSet names = new HashSet( refs.length + 1 );
+ names.add( project.getName() );
+ for ( int i = 0; i < refs.length; ++i )
+ {
+ names.add( refs[i].getName() );
+ }
+ for ( int i = 0; i < locations.length; ++i )
+ if ( locations[i] instanceof IProjectSourceLocation &&
+ ((IProjectSourceLocation)locations[i]).isGeneric() )
+ names.remove( ((IProjectSourceLocation)locations[i]).getProject().getName() );
+
+ Iterator it = names.iterator();
+ while ( it.hasNext() )
+ {
+ Element child = doc.createElement( DISABLED_GENERIC_PROJECT_NAME );
+ child.setAttribute( ATTR_PROJECT_NAME, (String)it.next() );
+ node.appendChild( child );
+ }
+ }
+ catch( CoreException e )
+ {
+ CDebugCorePlugin.log( e );
+ }
+ }
+ }
+
+ private void saveAdditionalSourceLocations( ICSourceLocation[] locations, Document doc, Element node )
+ {
+ for ( int i = 0; i < locations.length; i++ )
+ {
+ if ( locations[i] instanceof IProjectSourceLocation &&
+ ((IProjectSourceLocation)locations[i]).isGeneric() )
+ continue;
+ Element child = doc.createElement( SOURCE_LOCATION_NAME );
+ child.setAttribute( ATTR_CLASS, locations[i].getClass().getName() );
+ try
+ {
+ child.setAttribute( ATTR_MEMENTO, locations[i].getMemento() );
+ }
+ catch( CoreException e )
+ {
+ CDebugCorePlugin.log( e );
+ continue;
+ }
+ node.appendChild( child );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getProject()
+ */
+ public IProject getProject()
+ {
+ return fProject;
+ }
+
+ protected void setProject( IProject project )
+ {
+ fProject = project;
+ }
+
+ private boolean isReferencedProject( IProject ref )
+ {
+ if ( getProject() != null )
+ {
+ try
+ {
+ return Arrays.asList( getProject().getReferencedProjects() ).contains( ref );
+ }
+ catch( CoreException e )
+ {
+ CDebugCorePlugin.log( e );
+ }
+ }
+ return false;
+ }
+
+ private void setReferencedProjects()
+ {
+ fReferencedProjects.clear();
+ fReferencedProjects = getReferencedProjects( getProject() );
+ }
+
+ private List getReferencedProjects( IProject project )
+ {
+ ArrayList list = new ArrayList( 10 );
+ if ( project != null && project.exists() && project.isOpen() )
+ {
+ IProject[] refs = new IProject[0];
+ try
+ {
+ refs = project.getReferencedProjects();
+ }
+ catch( CoreException e )
+ {
+ }
+ list.addAll( Arrays.asList( refs ) );
+ for ( int i = 0; i < refs.length; ++i )
+ list.addAll( getReferencedProjects( refs[i] ) );
+ }
+ return list;
+ }
+
+ protected ICSourceLocation[] getDefaultSourceLocations()
+ {
+ Iterator it = fReferencedProjects.iterator();
+ ArrayList list = new ArrayList( fReferencedProjects.size() );
+ if ( getProject() != null && getProject().exists() && getProject().isOpen() )
+ list.add( SourceLocationFactory.createProjectSourceLocation( getProject() ) );
+ while( it.hasNext() )
+ {
+ IProject project = (IProject)it.next();
+ if ( project != null && project.exists() && project.isOpen() )
+ list.add( SourceLocationFactory.createProjectSourceLocation( project ) );
+ }
+ return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
+ }
+
+ private void resetSourceLocations( List affectedProjects )
+ {
+ if ( affectedProjects.size() != 0 && getProject() != null )
{
- String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "" );
- if ( !isEmpty( projectName ) )
- project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
+ if ( !getProject().exists() || !getProject().isOpen() )
+ {
+ removeGenericSourceLocations();
+ }
+ else
+ {
+ updateGenericSourceLocations( affectedProjects );
+ }
}
- catch( CoreException e )
+ }
+
+ private void removeGenericSourceLocations()
+ {
+ fReferencedProjects.clear();
+ ICSourceLocation[] locations = getSourceLocations();
+ ArrayList newLocations = new ArrayList( locations.length );
+ for ( int i = 0; i < locations.length; ++i )
+ if ( !(locations[i] instanceof IProjectSourceLocation) || !((IProjectSourceLocation)locations[i]).isGeneric() )
+ newLocations.add( locations[i] );
+ setSourceLocations( (ICSourceLocation[])newLocations.toArray( new ICSourceLocation[newLocations.size()] ) );
+ }
+
+ private void updateGenericSourceLocations( List affectedProjects )
+ {
+ List newRefs = getReferencedProjects( getProject() );
+ ICSourceLocation[] locations = getSourceLocations();
+ ArrayList newLocations = new ArrayList( locations.length );
+ for ( int i = 0; i < locations.length; ++i )
+ {
+ if ( !(locations[i] instanceof IProjectSourceLocation) || !((IProjectSourceLocation)locations[i]).isGeneric() )
+ {
+ newLocations.add( locations[i] );
+ }
+ else
+ {
+ IProject project = ((IProjectSourceLocation)locations[i]).getProject();
+ if ( project.exists() && project.isOpen() )
+ {
+ if ( newRefs.contains( project ) || project.equals( getProject() ) )
+ {
+ newLocations.add( locations[i] );
+ newRefs.remove( project );
+ }
+ }
+ }
+ }
+ Iterator it = newRefs.iterator();
+ while( it.hasNext() )
{
+ IProject project = (IProject)it.next();
+ if ( !fReferencedProjects.contains( project ) )
+ newLocations.add( SourceLocationFactory.createProjectSourceLocation( project ) );
}
- return project;
+ fReferencedProjects = newRefs;
+ setSourceLocations( (ICSourceLocation[])newLocations.toArray( new ICSourceLocation[newLocations.size()] ) );
}
}
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java,v
retrieving revision 1.8
diff -u -r1.8 CSourceManager.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java 18 Feb 2003 19:24:08 -0000 1.8
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java 17 Jul 2003 19:47:55 -0000
@@ -15,7 +15,9 @@
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.ILaunch;
@@ -130,6 +132,9 @@
*/
public Object getAdapter( Class adapter )
{
+ if ( adapter.equals( IResourceChangeListener.class ) &&
+ fSourceLocator instanceof IResourceChangeListener )
+ return fSourceLocator;
return null;
}
@@ -242,5 +247,13 @@
if ( fSourceLocator instanceof IPersistableSourceLocator )
return (IPersistableSourceLocator)fSourceLocator;
return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getProject()
+ */
+ public IProject getProject()
+ {
+ return ( getCSourceLocator() != null ) ? getCSourceLocator().getProject() : null;
}
}