mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for bug 51062: Source locator oddness.
This commit is contained in:
parent
84cfa94f9b
commit
934d7c87a0
2 changed files with 23 additions and 34 deletions
|
@ -1,3 +1,7 @@
|
|||
2004-02-11 Mikhail Khodjaiants
|
||||
Fix for bug 51062: Source locator oddness.
|
||||
* DefualtSourceLocator.java
|
||||
|
||||
2004-02-10 Mikhail Khodjaiants
|
||||
Fix for bug 40108: The memory view does not handle big/little endian.
|
||||
* MemoryPresentation.java
|
||||
|
|
|
@ -131,11 +131,6 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
|
|||
private static final String ATTR_PROJECT = "project";
|
||||
private static final String ATTR_MEMENTO = "memento";
|
||||
|
||||
/**
|
||||
* The project being debugged.
|
||||
*/
|
||||
private IProject fProject = null;
|
||||
|
||||
/**
|
||||
* Underlying source locator.
|
||||
*/
|
||||
|
@ -154,12 +149,12 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
|
|||
*/
|
||||
public String getMemento() throws CoreException
|
||||
{
|
||||
if ( fSourceLocator != null )
|
||||
if ( getCSourceLocator() != null )
|
||||
{
|
||||
Document doc = new DocumentImpl();
|
||||
Element node = doc.createElement( ELEMENT_NAME );
|
||||
doc.appendChild( node );
|
||||
node.setAttribute( ATTR_PROJECT, fSourceLocator.getProject().getName() );
|
||||
node.setAttribute( ATTR_PROJECT, getCSourceLocator().getProject().getName() );
|
||||
|
||||
IPersistableSourceLocator psl = getPersistableSourceLocator();
|
||||
if ( psl != null )
|
||||
|
@ -204,28 +199,18 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
|
|||
abort( "Unable to restore prompting source locator - invalid format.", null );
|
||||
}
|
||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
|
||||
if ( project == null || !project.exists() || !project.isOpen() )
|
||||
{
|
||||
abort( MessageFormat.format( "Unable to restore prompting source locator - project {0} not found.", new String[] { projectName } ), null );
|
||||
}
|
||||
ICSourceLocator locator = getCSourceLocator();
|
||||
if ( locator == null )
|
||||
{
|
||||
fSourceLocator = SourceLookupFactory.createSourceLocator( project );
|
||||
}
|
||||
else if ( locator.getProject() != null && !project.equals( locator.getProject() ) )
|
||||
{
|
||||
if ( getCSourceLocator() == null )
|
||||
setCSourceLocator( SourceLookupFactory.createSourceLocator( project ) );
|
||||
if ( getCSourceLocator().getProject() != null && !getCSourceLocator().getProject().equals( project ) )
|
||||
return;
|
||||
}
|
||||
if ( project == null || !project.exists() || !project.isOpen() )
|
||||
abort( MessageFormat.format( "Unable to restore prompting source locator - project {0} not found.", new String[] { projectName } ), null );
|
||||
|
||||
IPersistableSourceLocator psl = getPersistableSourceLocator();
|
||||
if ( psl != null )
|
||||
{
|
||||
psl.initializeFromMemento( data );
|
||||
}
|
||||
else
|
||||
{
|
||||
abort( "Unable to restore C/C++ source locator - invalid format.", null );
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch( ParserConfigurationException e )
|
||||
|
@ -248,7 +233,7 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
|
|||
*/
|
||||
public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException
|
||||
{
|
||||
fSourceLocator = SourceLookupFactory.createSourceLocator( getProject( configuration ) );
|
||||
setCSourceLocator( SourceLookupFactory.createSourceLocator( getProject( configuration ) ) );
|
||||
String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
|
||||
if ( !isEmpty( memento ) )
|
||||
initializeFromMemento( memento );
|
||||
|
@ -259,19 +244,19 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
|
|||
*/
|
||||
public Object getAdapter( Class adapter )
|
||||
{
|
||||
if ( fSourceLocator instanceof IAdaptable )
|
||||
if ( getCSourceLocator() instanceof IAdaptable )
|
||||
{
|
||||
if ( adapter.equals( ICSourceLocator.class ) )
|
||||
{
|
||||
return ((IAdaptable)fSourceLocator).getAdapter( adapter );
|
||||
return ((IAdaptable)getCSourceLocator()).getAdapter( adapter );
|
||||
}
|
||||
if ( adapter.equals( IResourceChangeListener.class ) )
|
||||
{
|
||||
return ((IAdaptable)fSourceLocator).getAdapter( adapter );
|
||||
return ((IAdaptable)getCSourceLocator()).getAdapter( adapter );
|
||||
}
|
||||
if ( adapter.equals( ISourceMode.class ) )
|
||||
{
|
||||
return ((IAdaptable)fSourceLocator).getAdapter( adapter );
|
||||
return ((IAdaptable)getCSourceLocator()).getAdapter( adapter );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -285,7 +270,7 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
|
|||
Object res = cacheLookup( stackFrame );
|
||||
if ( res == null )
|
||||
{
|
||||
res = fSourceLocator.getSourceElement( stackFrame );
|
||||
res = getCSourceLocator().getSourceElement( stackFrame );
|
||||
if ( res instanceof List )
|
||||
{
|
||||
List list = (List)res;
|
||||
|
@ -317,11 +302,6 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
|
|||
return res;
|
||||
}
|
||||
|
||||
public IProject getProject()
|
||||
{
|
||||
return fProject;
|
||||
}
|
||||
|
||||
protected void saveChanges( ILaunchConfiguration configuration, IPersistableSourceLocator locator )
|
||||
{
|
||||
try
|
||||
|
@ -396,6 +376,11 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
|
|||
{
|
||||
return fSourceLocator;
|
||||
}
|
||||
|
||||
private void setCSourceLocator( ICSourceLocator locator )
|
||||
{
|
||||
fSourceLocator = locator;
|
||||
}
|
||||
|
||||
private IPersistableSourceLocator getPersistableSourceLocator()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue