mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
fix source locator
This commit is contained in:
parent
d06efcf027
commit
c0bb4d9b23
4 changed files with 52 additions and 47 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-02-20 Mikhail Khodjaiants
|
||||||
|
The generation of launch configuration shouldn't fail if project is not set or project name is empty.
|
||||||
|
* DefaultSourceLocator.java
|
||||||
|
* CSourceLookupTab.java
|
||||||
|
|
||||||
2003-02-18 Mikhail Khodjaiants
|
2003-02-18 Mikhail Khodjaiants
|
||||||
New 'Source Lookup' tab.
|
New 'Source Lookup' tab.
|
||||||
* plugin.xml
|
* plugin.xml
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
|
||||||
private IProject getProject( ILaunchConfiguration configuration ) throws CoreException
|
private IProject getProject( ILaunchConfiguration configuration ) throws CoreException
|
||||||
{
|
{
|
||||||
String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null );
|
String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null );
|
||||||
if ( projectName != null )
|
if ( !isEmpty( projectName ) )
|
||||||
{
|
{
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
|
||||||
if ( project.exists() )
|
if ( project.exists() )
|
||||||
|
|
|
@ -106,10 +106,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
String configPlatform = getPlatform(config);
|
String configPlatform = getPlatform(config);
|
||||||
String programCPU = "native";
|
String programCPU = "native";
|
||||||
ICElement ce = getContext(config, configPlatform);
|
ICElement ce = getContext(config, configPlatform);
|
||||||
try {
|
if (ce instanceof IBinary) {
|
||||||
IBinary bin = (IBinary) ce;
|
IBinary bin = (IBinary) ce;
|
||||||
programCPU = bin.getCPU();
|
programCPU = bin.getCPU();
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
fDCombo.removeAll();
|
fDCombo.removeAll();
|
||||||
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
|
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
|
||||||
|
@ -246,10 +245,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
String projectPlatform = getPlatform(config);
|
String projectPlatform = getPlatform(config);
|
||||||
String projectCPU = "native";
|
String projectCPU = "native";
|
||||||
if (ce != null) {
|
if (ce != null) {
|
||||||
try {
|
if (ce instanceof IBinary) {
|
||||||
IBinary bin = (IBinary) ce;
|
IBinary bin = (IBinary) ce;
|
||||||
projectCPU = bin.getCPU();
|
projectCPU = bin.getCPU();
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ICDebugConfiguration debugConfig = getDebugConfig();
|
ICDebugConfiguration debugConfig = getDebugConfig();
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.eclipse.cdt.launch.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
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.debug.ui.sourcelookup.SourceLookupBlock;
|
||||||
import org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator;
|
import org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -15,6 +14,8 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,10 +32,12 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
|
||||||
*/
|
*/
|
||||||
public void createControl( Composite parent )
|
public void createControl( Composite parent )
|
||||||
{
|
{
|
||||||
|
Composite control = new Composite( parent, SWT.NONE );
|
||||||
|
control.setLayout( new GridLayout() );
|
||||||
fBlock = new SourceLookupBlock();
|
fBlock = new SourceLookupBlock();
|
||||||
fBlock.createControl( parent );
|
fBlock.createControl( control );
|
||||||
fBlock.setLaunchConfigurationDialog( getLaunchConfigurationDialog() );
|
fBlock.setLaunchConfigurationDialog( getLaunchConfigurationDialog() );
|
||||||
setControl( fBlock.getControl() );
|
setControl( control );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -43,16 +46,6 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
|
||||||
public void setDefaults( ILaunchConfigurationWorkingCopy configuration )
|
public void setDefaults( ILaunchConfigurationWorkingCopy configuration )
|
||||||
{
|
{
|
||||||
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
|
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
|
||||||
DefaultSourceLocator locator = new DefaultSourceLocator();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
locator.initializeDefaults( configuration );
|
|
||||||
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
|
|
||||||
}
|
|
||||||
catch( CoreException e )
|
|
||||||
{
|
|
||||||
CDebugUIPlugin.log( e.getStatus() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -60,28 +53,33 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
|
||||||
*/
|
*/
|
||||||
public void initializeFrom( ILaunchConfiguration configuration )
|
public void initializeFrom( ILaunchConfiguration configuration )
|
||||||
{
|
{
|
||||||
try
|
IProject project = getProject( configuration );
|
||||||
|
fBlock.setProject( getProject( configuration ) );
|
||||||
|
if ( project != null )
|
||||||
{
|
{
|
||||||
String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" );
|
try
|
||||||
if ( isEmpty( id )|| DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR.equals( id ) )
|
|
||||||
{
|
{
|
||||||
DefaultSourceLocator locator = new DefaultSourceLocator();
|
String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" );
|
||||||
String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
|
if ( isEmpty( id )|| DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR.equals( id ) )
|
||||||
if ( !isEmpty( memento ) )
|
|
||||||
{
|
{
|
||||||
locator.initializeFromMemento( memento );
|
DefaultSourceLocator locator = new DefaultSourceLocator();
|
||||||
|
String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
|
||||||
|
if ( !isEmpty( memento ) )
|
||||||
|
{
|
||||||
|
locator.initializeFromMemento( memento );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
locator.initializeDefaults( configuration );
|
||||||
|
}
|
||||||
|
ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
|
||||||
|
if ( clocator != null )
|
||||||
|
fBlock.initialize( clocator );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
locator.initializeDefaults( configuration );
|
|
||||||
}
|
|
||||||
ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
|
|
||||||
if ( clocator != null )
|
|
||||||
fBlock.initialize( clocator.getSourceLocations() );
|
|
||||||
}
|
}
|
||||||
}
|
catch( CoreException e )
|
||||||
catch( CoreException e )
|
{
|
||||||
{
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,18 +88,22 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
|
||||||
*/
|
*/
|
||||||
public void performApply( ILaunchConfigurationWorkingCopy configuration )
|
public void performApply( ILaunchConfigurationWorkingCopy configuration )
|
||||||
{
|
{
|
||||||
DefaultSourceLocator locator = new DefaultSourceLocator();
|
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
|
||||||
try
|
IProject project = getProject( configuration );
|
||||||
{
|
if ( project != null )
|
||||||
locator.initializeDefaults( configuration );
|
|
||||||
ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
|
|
||||||
if ( clocator != null )
|
|
||||||
clocator.setSourceLocations( fBlock.getSourceLocations() );
|
|
||||||
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
|
|
||||||
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
|
|
||||||
}
|
|
||||||
catch( CoreException e )
|
|
||||||
{
|
{
|
||||||
|
DefaultSourceLocator locator = new DefaultSourceLocator();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
locator.initializeDefaults( configuration );
|
||||||
|
ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
|
||||||
|
if ( clocator != null )
|
||||||
|
clocator.setSourceLocations( fBlock.getSourceLocations() );
|
||||||
|
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +112,7 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
|
||||||
*/
|
*/
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return "Source Lookup";
|
return "Source";
|
||||||
}
|
}
|
||||||
|
|
||||||
private IProject getProject( ILaunchConfiguration configuration )
|
private IProject getProject( ILaunchConfiguration configuration )
|
||||||
|
|
Loading…
Add table
Reference in a new issue