From 934d7c87a098aaff31930bfc24efa583cd58066d Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Wed, 11 Feb 2004 19:33:05 +0000 Subject: [PATCH] Fix for bug 51062: Source locator oddness. --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 4 ++ .../ui/sourcelookup/DefaultSourceLocator.java | 53 +++++++------------ 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index f2c0769c999..15987aaeb1c 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -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 diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/DefaultSourceLocator.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/DefaultSourceLocator.java index 5dac8882209..3e0167cd310 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/DefaultSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/DefaultSourceLocator.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() {