diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICSourceLocator.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICSourceLocator.java index 61016174117..dba4157b8f6 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICSourceLocator.java @@ -5,7 +5,9 @@ */ package org.eclipse.cdt.debug.core; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.ISourceLocator; @@ -46,4 +48,39 @@ public interface ICSourceLocator extends ISourceLocator * or -1 if line number information is unavailable */ int getLineNumber( IStackFrameInfo frameInfo ); -} + + /** + * Returns a source element that corresponds to the given file name, or + * null if a source element could not be located. + * + * @param fileName the file name for which to locate source + * @return an object representing a source element. + */ + Object getSourceElement( String fileName ); + + /** + * Returns a source element that corresponds to the given function, or + * null if a source element could not be located. + * + * @param function the function name for which to locate source + * @return an object representing a source element. + */ + Object getSourceElementForFunection( String function ); + + /** + * Returns a source element that corresponds to the given address, or + * null if a source element could not be located. + * + * @param address the address for which to locate source + * @return an object representing a source element. + */ + Object getSourceElementForAddress( long address ); + + /** + * Returns whether the given resource is contained in this source locator. + * + * @param resource the resource + * @return whether the given resource is contained in this source locator + */ + boolean contains( IResource resource ); +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSourceLocator.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSourceLocator.java index 4ff09bf8440..8adb87f484b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CSourceLocator.java @@ -215,4 +215,78 @@ public class CSourceLocator implements ICSourceLocator } return null; } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.ICSourceLocator#getSourceElement(String) + */ + public Object getSourceElement( String fileName ) + { + return findFile( fProject, fileName ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.ICSourceLocator#getSourceElementForAddress(long) + */ + public Object getSourceElementForAddress( long address ) + { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.ICSourceLocator#getSourceElementForFunection(String) + */ + public Object getSourceElementForFunection( String function ) + { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.ICSourceLocator#contains(IResource) + */ + public boolean contains( IResource resource ) + { + if ( resource instanceof IProject ) + { + if ( fProject.equals( resource ) ) + { + return true; + } + IProject[] projects = getReferencedProjects(); + for ( int i = 0; i < projects.length; ++i ) + { + if ( projects[i].equals( resource ) ) + { + return true; + } + } + return false; + } + if ( fProject.exists( resource.getFullPath() ) ) + { + return true; + } + IProject[] projects = getReferencedProjects(); + for ( int i = 0; i < projects.length; ++i ) + { + if ( projects[i].exists( resource.getFullPath() ) ) + { + return true; + } + } + return false; + } + + protected IProject[] getReferencedProjects() + { + IProject[] projects = new IProject[0]; + try + { + projects = fProject.getReferencedProjects(); + } + catch( CoreException e ) + { + CDebugCorePlugin.log( e ); + } + return projects; + } }