[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Source lookup changes
|
This patch completes the implementation of the
workbench source lookup preferences. It also includes refactoring and changes
to minimize dependencies between the launcher plugin and the
debugger plugins.
The documentation on the new features and the ui
changes will be provided later.
Dave,
The build is broken without this
patch.
The
'org.eclipse.cdt.launch.internal.ui.sourcelookup' package should be
deleted.
|
Index: .classpath
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/.classpath,v
retrieving revision 1.3
diff -u -r1.3 .classpath
--- .classpath 18 Feb 2003 20:53:39 -0000 1.3
+++ .classpath 27 Oct 2003 20:27:25 -0000
@@ -9,7 +9,6 @@
<classpathentry kind="src" path="/org.eclipse.cdt.ui"/>
<classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/>
<classpathentry kind="src" path="/org.eclipse.cdt.debug.ui"/>
- <classpathentry kind="src" path="/org.apache.xerces"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
Index: .project
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/.project,v
retrieving revision 1.3
diff -u -r1.3 .project
--- .project 18 Feb 2003 20:53:39 -0000 1.3
+++ .project 27 Oct 2003 20:27:25 -0000
@@ -3,7 +3,6 @@
<name>org.eclipse.cdt.launch</name>
<comment></comment>
<projects>
- <project>org.apache.xerces</project>
<project>org.eclipse.cdt.core</project>
<project>org.eclipse.cdt.debug.core</project>
<project>org.eclipse.cdt.debug.ui</project>
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/ChangeLog,v
retrieving revision 1.43
diff -u -r1.43 ChangeLog
--- ChangeLog 23 Oct 2003 17:24:21 -0000 1.43
+++ ChangeLog 27 Oct 2003 20:27:25 -0000
@@ -1,3 +1,23 @@
+2003-10-27 Mikhail Khodjaiants
+ Changed the initialization of 'SourceLookupBlock'.
+ * CSourceLookupTab.java
+
+2003-10-27 Mikhail Khodjaiants
+ Moved the 'org.eclipse.debug.core.sourceLocators' extension from the launcher.
+ * plugin.xml
+ * plugin.properties
+
+2003-10-27 Mikhail Khodjaiants
+ Removed the dependency to 'org.apache.xerces'.
+ * plugin.xml
+ * .classpath
+ * .project
+
+2003-10-27 Mikhail Khodjaiants
+ Moved 'DefaultSourceLocator' from the 'org.eclipse.cdt.launch' plugin and merge it with 'CUISourceLocator'.
+ Removed the 'org.eclipse.cdt.launch.internal.ui.sourcelookup' package.
+ * DefaultSourceLocator.java: moved to the 'org.eclipse.cdt.debug.ui' plugin.
+
2003-11-22 Mikhail Khodjaiants
src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java:
Dispose 'SourceLookupBlock' when disposing 'CSourceLookupTab'.
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/plugin.properties,v
retrieving revision 1.8
diff -u -r1.8 plugin.properties
--- plugin.properties 3 Apr 2003 19:10:36 -0000 1.8
+++ plugin.properties 27 Oct 2003 20:27:26 -0000
@@ -13,5 +13,3 @@
LocalCDTLaunch.name= C/C++ Local
CoreFileCDTLaunch.name= C/C++ Postmortem debugger
-
-DefaultSourceLocator.name=Default C/C++ Source Locator
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/plugin.xml,v
retrieving revision 1.13
diff -u -r1.13 plugin.xml
--- plugin.xml 1 Oct 2003 20:22:50 -0000 1.13
+++ plugin.xml 27 Oct 2003 20:27:26 -0000
@@ -20,7 +20,6 @@
<import plugin="org.eclipse.cdt.ui"/>
<import plugin="org.eclipse.cdt.debug.core"/>
<import plugin="org.eclipse.cdt.debug.ui"/>
- <import plugin="org.apache.xerces"/>
</requires>
@@ -82,14 +81,6 @@
id="org.eclipse.debug.ui.DebugPerspective">
</perspective>
</shortcut>
- </extension>
- <extension
- point="org.eclipse.debug.core.sourceLocators">
- <sourceLocator
- name="%DefaultSourceLocator.name"
- class="org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator"
- id="org.eclipse.cdt.launch.DefaultSourceLocator">
- </sourceLocator>
</extension>
</plugin>
Index: src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java,v
retrieving revision 1.17
diff -u -r1.17 AbstractCLaunchDelegate.java
--- src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java 9 Oct 2003 13:08:36 -0000 1.17
+++ src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java 27 Oct 2003 20:27:26 -0000
@@ -17,11 +17,11 @@
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.debug.core.*;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
-import org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator;
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -297,7 +297,7 @@
if (cProject == null) {
abort("Project does not exist", null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
}
- sourceLocator = new DefaultSourceLocator();
+ sourceLocator = CDebugUIPlugin.createDefaultSourceLocator();
sourceLocator.initializeDefaults(configuration);
} else {
sourceLocator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(id);
Index: src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java
===================================================================
RCS file: src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java
diff -N src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java
--- src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java 5 Aug 2003 17:06:19 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,257 +0,0 @@
-/*
- *(c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- *
- */
-package org.eclipse.cdt.launch.sourcelookup;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.text.MessageFormat;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.xerces.dom.DocumentImpl;
-import org.eclipse.cdt.debug.core.CDebugUtils;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
-import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
-import org.eclipse.cdt.debug.ui.sourcelookup.CUISourceLocator;
-import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.IPersistableSourceLocator;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * The wrapper for the CUISourceLocator class.
- *
- * @since: Dec 11, 2002
- */
-public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptable
-{
- private static final String ELEMENT_NAME = "PromptingSourceLocator";
- private static final String ATTR_PROJECT = "project";
- private static final String ATTR_MEMENTO = "memento";
-
- /**
- * Identifier for the 'Default C/C++ Source Locator' extension
- * (value <code>"org.eclipse.cdt.launch.DefaultSourceLocator"</code>).
- */
- public static final String ID_DEFAULT_SOURCE_LOCATOR = LaunchUIPlugin.getUniqueIdentifier() + ".DefaultSourceLocator"; //$NON-NLS-1$
-
- private CUISourceLocator fSourceLocator = null;
- private final static int ERROR = 1000; // ????
-
- /**
- * Constructor for DefaultSourceLocator.
- */
- public DefaultSourceLocator()
- {
- }
-
- /**
- * Constructor for DefaultSourceLocator.
- */
- public DefaultSourceLocator( CUISourceLocator locator )
- {
- fSourceLocator = locator;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
- */
- public String getMemento() throws CoreException
- {
- if ( fSourceLocator != null )
- {
- Document doc = new DocumentImpl();
- Element node = doc.createElement( ELEMENT_NAME );
- doc.appendChild( node );
- node.setAttribute( ATTR_PROJECT, fSourceLocator.getProject().getName() );
-
- IPersistableSourceLocator psl = getPersistableSourceLocator();
- if ( psl != null )
- {
- node.setAttribute( ATTR_MEMENTO, psl.getMemento() );
- }
- try
- {
- return CDebugUtils.serializeDocument( doc, " " );
- }
- catch( IOException e )
- {
- abort( "Unable to create memento for C/C++ source locator.", e );
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(String)
- */
- public void initializeFromMemento( String memento ) throws CoreException
- {
- Exception ex = null;
- try
- {
- Element root = null;
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- StringReader reader = new StringReader( memento );
- InputSource source = new InputSource( reader );
- root = parser.parse( source ).getDocumentElement();
-
- if ( !root.getNodeName().equalsIgnoreCase( ELEMENT_NAME ) )
- {
- abort( "Unable to restore prompting source locator - invalid format.", null );
- }
-
- String projectName = root.getAttribute( ATTR_PROJECT );
- String data = root.getAttribute( ATTR_MEMENTO );
- if ( isEmpty( projectName ) )
- {
- abort( "Unable to restore prompting source locator - invalid format.", null );
- }
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
- if ( project == null )
- {
- abort( MessageFormat.format( "Unable to restore prompting source locator - project {0} not found.", new String[] { projectName } ), null );
- }
- ICSourceLocator locator = getCSourceLocator();
- if ( locator == null )
- {
- fSourceLocator = new CUISourceLocator( project );
- }
- else if ( locator.getProject() != null && !project.equals( locator.getProject() ) )
- {
- return;
- }
- 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 )
- {
- ex = e;
- }
- catch( SAXException e )
- {
- ex = e;
- }
- catch( IOException e )
- {
- ex = e;
- }
- abort( "Exception occurred initializing source locator.", ex );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(ILaunchConfiguration)
- */
- public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException
- {
- fSourceLocator = new CUISourceLocator( getProject( configuration ) );
- String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
- if ( !isEmpty( memento ) )
- initializeFromMemento( memento );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame)
- */
- public Object getSourceElement( IStackFrame stackFrame )
- {
- return ( fSourceLocator != null ) ? fSourceLocator.getSourceElement( stackFrame ) : null;
- }
-
- private IProject getProject( ILaunchConfiguration configuration ) throws CoreException
- {
- String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null );
- if ( !isEmpty( projectName ) )
- {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
- if ( project.exists() )
- {
- return project;
- }
- }
- abort( MessageFormat.format( "Project \"{0}\" does not exist.", new String[] { projectName } ), null );
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
- */
- public Object getAdapter( Class adapter )
- {
- if ( fSourceLocator != null )
- {
- if ( adapter.equals( ICSourceLocator.class ) )
- {
- return fSourceLocator.getAdapter( adapter );
- }
- if ( adapter.equals( IResourceChangeListener.class ) )
- {
- return fSourceLocator.getAdapter( adapter );
- }
- if ( adapter.equals( ISourceMode.class ) )
- {
- return fSourceLocator.getAdapter( adapter );
- }
- }
- return null;
- }
-
- private ICSourceLocator getCSourceLocator()
- {
- if ( fSourceLocator != null )
- {
- return (ICSourceLocator)fSourceLocator.getAdapter( ICSourceLocator.class );
- }
- return null;
- }
-
- private IPersistableSourceLocator getPersistableSourceLocator()
- {
- ICSourceLocator sl = getCSourceLocator();
- return ( sl instanceof IPersistableSourceLocator ) ? (IPersistableSourceLocator)sl : null;
- }
-
- /**
- * Throws an internal error exception
- */
- private void abort( String message, Throwable e ) throws CoreException
- {
- IStatus s = new Status( IStatus.ERROR,
- LaunchUIPlugin.getUniqueIdentifier(),
- ERROR,
- message,
- e );
- throw new CoreException( s );
- }
-
-
- private boolean isEmpty( String string )
- {
- return string == null || string.length() == 0;
- }
-}
Index: src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java,v
retrieving revision 1.7
diff -u -r1.7 CSourceLookupTab.java
--- src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java 23 Oct 2003 17:24:21 -0000 1.7
+++ src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java 27 Oct 2003 20:27:26 -0000
@@ -6,10 +6,9 @@
package org.eclipse.cdt.launch.ui;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupBlock;
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
-import org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -51,7 +50,7 @@
*/
public void setDefaults( ILaunchConfigurationWorkingCopy configuration )
{
- configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
+ configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, CDebugUIPlugin.getDefaultSourceLocatorID() );
}
/* (non-Javadoc)
@@ -59,35 +58,7 @@
*/
public void initializeFrom( ILaunchConfiguration configuration )
{
- IProject project = getProject( configuration );
- IProject oldProject = fBlock.getProject();
- fBlock.setProject( getProject( configuration ) );
- if ( project != null )
- {
- try
- {
- String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" );
- if ( isEmpty( id ) || DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR.equals( id ) )
- {
- DefaultSourceLocator locator = new DefaultSourceLocator();
- String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
- if ( project.equals( oldProject ) && !isEmpty( memento ) )
- {
- locator.initializeFromMemento( memento );
- }
- else
- {
- locator.initializeDefaults( configuration );
- }
- ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
- if ( clocator != null )
- fBlock.initialize( clocator );
- }
- }
- catch( CoreException e )
- {
- }
- }
+ fBlock.initialize( configuration );
}
/* (non-Javadoc)
@@ -95,28 +66,10 @@
*/
public void performApply( ILaunchConfigurationWorkingCopy configuration )
{
- configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
+ configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, CDebugUIPlugin.getDefaultSourceLocatorID() );
IProject project = getProject( configuration );
if ( project != null )
- {
- DefaultSourceLocator locator = new DefaultSourceLocator();
- try
- {
- locator.initializeDefaults( configuration );
- ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
- if ( clocator != null )
- {
- if ( !project.equals( fBlock.getProject() ) )
- fBlock.initialize( clocator );
- clocator.setSourceLocations( fBlock.getSourceLocations() );
- clocator.setSearchForDuplicateFiles( fBlock.searchForDuplicateFiles() );
- }
- configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
- }
- catch( CoreException e )
- {
- }
- }
+ fBlock.performApply( configuration );
}
/* (non-Javadoc)