From ef8512f6c93f7eb1b7885102a06896be495b5576 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Sun, 29 Dec 2002 23:55:53 +0000 Subject: [PATCH] Implementation of the 'Source Lookup' property page. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 8 +++++++ .../IDirectorySourceLocation.java | 20 +++++++++++++++++ .../sourcelookup/IProjectSourceLocation.java | 19 ++++++++++++++++ .../CDirectorySourceLocation.java | 22 +++++++++---------- .../sourcelookup/CProjectSourceLocation.java | 3 ++- .../core/sourcelookup/CSourceLocator.java | 18 +++++++++++---- 6 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDirectorySourceLocation.java create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index d06a7dae615..04658940d26 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,11 @@ +2002-12-18 Mikhail Khodjaiants + Implementation of the 'Source Lookup' property page. + * IDirectorySourceLocation.java: new interface + * IProjectSourceLocation.java: new interface + * CDirectorySourceLocation.java + * CProjectSourceLocation.java + * CSourceLocator.java + 2002-12-29 Mikhail Khodjaiants Fix in the 'supportsBreakpoints' method of CDebugTarget * CDebugTarget.java: No need to check if the breakpoint file belongs to the source locator. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDirectorySourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDirectorySourceLocation.java new file mode 100644 index 00000000000..5b12c6c2304 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDirectorySourceLocation.java @@ -0,0 +1,20 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.core.sourcelookup; + +import org.eclipse.core.runtime.IPath; + +/** + * + * Enter type comment. + * + * @since Dec 24, 2002 + */ +public interface IDirectorySourceLocation extends ICSourceLocation +{ + IPath getDirectory(); + IPath getAssociation(); +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java new file mode 100644 index 00000000000..c91914598de --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java @@ -0,0 +1,19 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.core.sourcelookup; + +import org.eclipse.core.resources.IProject; + +/** + * + * Enter type comment. + * + * @since Dec 24, 2002 + */ +public interface IProjectSourceLocation extends ICSourceLocation +{ + IProject getProject(); +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java index 1fa50350288..8dc59455ac2 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java @@ -9,6 +9,7 @@ import java.io.File; import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; +import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IStorage; import org.eclipse.core.resources.ResourcesPlugin; @@ -23,7 +24,7 @@ import org.eclipse.core.runtime.Path; * * @since Sep 23, 2002 */ -public class CDirectorySourceLocation implements ICSourceLocation +public class CDirectorySourceLocation implements IDirectorySourceLocation { /** * The root directory of this source location @@ -87,7 +88,7 @@ public class CDirectorySourceLocation implements ICSourceLocation * * @param directory a directory */ - protected void setDirectory( IPath directory ) + private void setDirectory( IPath directory ) { fDirectory = directory; } @@ -102,7 +103,7 @@ public class CDirectorySourceLocation implements ICSourceLocation return fDirectory; } - protected void setAssociation( IPath association ) + private void setAssociation( IPath association ) { fAssociation = association; } @@ -149,18 +150,15 @@ public class CDirectorySourceLocation implements ICSourceLocation IPath path = getDirectory(); if ( path != null ) { - path = path.append( fileName ); - - // Try for a file in another workspace project - IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path ); - if ( f != null ) - { - return f; - } - + path = path.append( fileName ); File file = path.toFile(); if ( file.exists() ) { + IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path ); + if ( f != null ) + { + return f; + } return createExternalFileStorage( path ); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java index f9ac5ce9a0a..c450fe8ea2f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.HashSet; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; +import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -25,7 +26,7 @@ import org.eclipse.core.runtime.Path; * * @since Sep 23, 2002 */ -public class CProjectSourceLocation implements ICSourceLocation +public class CProjectSourceLocation implements IProjectSourceLocation { /** * The project associated with this source location diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java index 1c41f32150f..8bffd512cf3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java @@ -7,6 +7,7 @@ package org.eclipse.cdt.debug.internal.core.sourcelookup; import java.util.ArrayList; +import java.util.List; import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.debug.core.model.IStackFrameInfo; @@ -159,7 +160,7 @@ public class CSourceLocator implements ICSourceLocator /** * Returns a default collection of source locations for * the given project. Default source locations consist - * of the given project and all of its referenced projects . + * of the given project and all of its referenced projects. * * @param project a project * @return a collection of source locations for all required @@ -169,15 +170,25 @@ public class CSourceLocator implements ICSourceLocator public static ICSourceLocation[] getDefaultSourceLocations( IProject project ) { ArrayList list = new ArrayList(); + if ( project != null ) + { + list.add( new CProjectSourceLocation( project ) ); + addReferencedSourceLocations( list, project ); + } + return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ); + } + + private static void addReferencedSourceLocations( List list, IProject project ) + { if ( project != null ) { try { IProject[] projects = project.getReferencedProjects(); - list.add( new CProjectSourceLocation( project ) ); for ( int i = 0; i < projects.length; i++ ) { list.add( new CProjectSourceLocation( projects[i] ) ); + addReferencedSourceLocations( list, projects[i] ); } } catch( CoreException e ) @@ -185,9 +196,8 @@ public class CSourceLocator implements ICSourceLocator // do nothing } } - return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ); } - + private Object findFileByAbsolutePath( String fileName ) { Path path = new Path( fileName );