1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-08 09:35:23 +02:00

Merge from HEAD to address bugs targeted for 1.2.1

This commit is contained in:
David Inglis 2003-11-18 22:04:16 +00:00
parent 8e1e5f6454
commit 493af74925
7 changed files with 69 additions and 336 deletions

View file

@ -1,3 +1,40 @@
2003-10-27
Fixed 46129
AbstractCLaunchDelegate.java
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'.
2003-11-17 Mikhail Khodjaiants
src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java:
"Search for duplicate source files" option support.
2003-10-07 Mikhail Khodjaiants
src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java:
use 'MultiStatus' instead of 'Status' in the 'abort' method.
2003-09-22 David Inglis
Add help context IDs to plugin and associate ids to each launch tab control.

View file

@ -13,5 +13,3 @@ providerName=Eclipse.org
LocalCDTLaunch.name= C/C++ Local
CoreFileCDTLaunch.name= C/C++ Postmortem debugger
DefaultSourceLocator.name=Default C/C++ Source Locator

View file

@ -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>
@ -83,13 +82,5 @@
</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>

View file

@ -5,6 +5,7 @@
package org.eclipse.cdt.launch;
import java.io.File;
import java.io.FileNotFoundException;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.util.ArrayList;
@ -17,11 +18,11 @@ import java.util.Map.Entry;
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;
@ -32,6 +33,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
@ -244,11 +246,9 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
* @param code error code
*/
protected void abort(String message, Throwable exception, int code) throws CoreException {
String newMessage = message;
if (exception != null) {
newMessage = message + " : " + exception.getLocalizedMessage();
}
throw new CoreException(new Status(IStatus.ERROR, getPluginID(), code, newMessage, exception));
MultiStatus status = new MultiStatus(getPluginID(),code, message,exception);
status.add(new Status(IStatus.ERROR,getPluginID(),code, exception == null ? "" : exception.getLocalizedMessage(),exception));
throw new CoreException(status);
}
protected void cancel(String message, int code) throws CoreException {
@ -298,7 +298,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
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);
@ -383,16 +383,16 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
protected ICProject verifyCProject(ILaunchConfiguration config) throws CoreException {
String name = getProjectName(config);
if (name == null) {
abort("C project not specified", null, ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT);
abort("C Project not specified", null, ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT);
}
ICProject cproject = getCProject(config);
if (cproject == null) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if (!project.exists()) {
abort("Project does not exist", null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
abort("Project '"+ name + "' does not exist", null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
}
else if (!project.isOpen()) {
abort("Project is closed", null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
abort("Project '"+ name + "' is closed", null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
}
abort("Project is not a C/C++ project", null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
}
@ -408,7 +408,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
IFile programPath = ((IProject) cproject.getResource()).getFile(fileName);
if (programPath == null || !programPath.exists() || !programPath.getLocation().toFile().exists()) {
abort("Program file does not exist", null, ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
abort("Program file does not exist", new FileNotFoundException(programPath.getLocation() + " not found."), ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
}
return programPath;
}
@ -446,7 +446,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
else {
abort(
"Working directory does not exist",
null,
new FileNotFoundException(path.toOSString() + " not found."),
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
}
@ -458,7 +458,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
else {
abort(
"Working directory does not exist",
null,
new FileNotFoundException(path.toOSString() + "Does not exsit."),
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
}

View file

@ -80,7 +80,7 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
final Shell shell = LaunchUIPlugin.getShell();
final String res[] = { null };
if (shell == null) {
abort("No Shell availible in Launch", null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
abort("No Shell available in Launch", null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
Display display = shell.getDisplay();
display.syncExec(new Runnable() {

View file

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

View file

@ -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 class CSourceLookupTab extends CLaunchConfigurationTab
*/
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 class CSourceLookupTab extends CLaunchConfigurationTab
*/
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,27 +66,10 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
*/
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() );
}
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
}
catch( CoreException e )
{
}
}
fBlock.performApply( configuration );
}
/* (non-Javadoc)
@ -129,7 +83,8 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
*/
public Image getImage() {
public Image getImage()
{
return LaunchImages.get( LaunchImages.IMG_VIEW_SOURCE_TAB );
}
@ -153,4 +108,13 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
return string == null || string.length() == 0;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose()
*/
public void dispose()
{
if ( fBlock != null )
fBlock.dispose();
super.dispose();
}
}