1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Implementation of source locator.

This commit is contained in:
Mikhail Khodjaiants 2002-09-20 17:47:52 +00:00
parent 5d14c78a5c
commit 74a38d9081
2 changed files with 112 additions and 1 deletions

View file

@ -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
* <code>null</code> 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
* <code>null</code> 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
* <code>null</code> 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 );
}

View file

@ -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;
}
}