1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 10:45:37 +02:00

Moved the 'getReferencedProject' method to 'CDebugUtils'.

Added the cycle checking.
This commit is contained in:
Mikhail Khodjaiants 2003-07-30 20:22:31 +00:00
parent 5aae8a1f5d
commit 022ba9b789
5 changed files with 65 additions and 46 deletions

View file

@ -1,3 +1,8 @@
2003-07-30 Mikhail Khodjaiants
Moved the 'getReferencedProject' method to 'CDebugUtils'. Added the cycle checking.
* CDebugUtils.java
* CSourceLocator.java
2003-07-28 Mikhail Khodjaiants 2003-07-28 Mikhail Khodjaiants
Minimize the number of the "evaluate expression" requests when changing the value of the floating point types. Minimize the number of the "evaluate expression" requests when changing the value of the floating point types.
* CDebugUtils.java * CDebugUtils.java

View file

@ -8,7 +8,9 @@ package org.eclipse.cdt.debug.core;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import org.apache.xml.serialize.Method; import org.apache.xml.serialize.Method;
import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.OutputFormat;
@ -405,4 +407,53 @@ public class CDebugUtils
} }
return false; return false;
} }
public static 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 )
{
}
for ( int i = 0; i < refs.length; ++i )
{
if ( !project.equals( refs[i] ) && refs[i] != null && refs[i].exists() && refs[i].isOpen() )
{
list.add( refs[i] );
getReferencedProjects( project, refs[i], list );
}
}
}
return list;
}
private static void getReferencedProjects( IProject root, IProject project, List list )
{
if ( project != null && project.exists() && project.isOpen() )
{
IProject[] refs = new IProject[0];
try
{
refs = project.getReferencedProjects();
}
catch( CoreException e )
{
}
for ( int i = 0; i < refs.length; ++i )
{
if ( !list.contains( refs[i] ) && refs[i] != null &&
!refs[i].equals( root ) && refs[i].exists() && refs[i].isOpen() )
{
list.add( refs[i] );
getReferencedProjects( root, refs[i], list );
}
}
}
}
} }

View file

@ -562,7 +562,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
IProject project = getProject(); IProject project = getProject();
if ( project != null && project.exists() && project.isOpen() ) if ( project != null && project.exists() && project.isOpen() )
{ {
List list = getReferencedProjects( project ); List list = CDebugUtils.getReferencedProjects( project );
HashSet names = new HashSet( list.size() + 1 ); HashSet names = new HashSet( list.size() + 1 );
names.add( project.getName() ); names.add( project.getName() );
Iterator it = list.iterator(); Iterator it = list.iterator();
@ -639,27 +639,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
private void setReferencedProjects() private void setReferencedProjects()
{ {
fReferencedProjects.clear(); fReferencedProjects.clear();
fReferencedProjects = getReferencedProjects( getProject() ); fReferencedProjects = CDebugUtils.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() protected ICSourceLocation[] getDefaultSourceLocations()
@ -705,7 +685,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
private void updateGenericSourceLocations( List affectedProjects ) private void updateGenericSourceLocations( List affectedProjects )
{ {
List newRefs = getReferencedProjects( getProject() ); List newRefs = CDebugUtils.getReferencedProjects( getProject() );
ICSourceLocation[] locations = getSourceLocations(); ICSourceLocation[] locations = getSourceLocations();
ArrayList newLocations = new ArrayList( locations.length ); ArrayList newLocations = new ArrayList( locations.length );
for ( int i = 0; i < locations.length; ++i ) for ( int i = 0; i < locations.length; ++i )

View file

@ -1,3 +1,7 @@
2003-07-30 Mikhail Khodjaiants
Moved the 'getReferencedProject' method to 'CDebugUtils'. Added the cycle checking.
* SourceLookupBlock.java
2003-07-29 Mikhail Khodjaiants 2003-07-29 Mikhail Khodjaiants
Fix for PR 40911: Double clicking on breakpoint with no source causes internal error. Fix for PR 40911: Double clicking on breakpoint with no source causes internal error.
* CDTDebugModelPresentation.java: check if the resource associated with breakpoint is a file. * CDTDebugModelPresentation.java: check if the resource associated with breakpoint is a file.

View file

@ -6,10 +6,10 @@
package org.eclipse.cdt.debug.ui.sourcelookup; package org.eclipse.cdt.debug.ui.sourcelookup;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
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.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
@ -28,7 +28,6 @@ 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.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;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.JFaceResources;
@ -342,7 +341,7 @@ public class SourceLookupBlock
fGeneratedSourceListField.removeAllElements(); fGeneratedSourceListField.removeAllElements();
if ( project == null && project.exists() && project.isOpen() ) if ( project == null && project.exists() && project.isOpen() )
return; return;
List list = getReferencedProjects( project ); List list = CDebugUtils.getReferencedProjects( project );
IProject[] refs = (IProject[])list.toArray( new IProject[list.size()] ); IProject[] refs = (IProject[])list.toArray( new IProject[list.size()] );
ICSourceLocation loc = getLocationForProject( project, locations ); ICSourceLocation loc = getLocationForProject( project, locations );
boolean checked = ( loc != null && ((IProjectSourceLocation)loc).isGeneric() ); boolean checked = ( loc != null && ((IProjectSourceLocation)loc).isGeneric() );
@ -522,24 +521,4 @@ public class SourceLookupBlock
return locations[i]; return locations[i];
return null; 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;
}
} }