mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Fix bug 159833.
This commit is contained in:
parent
fdabd9645c
commit
d770ae8727
10 changed files with 135 additions and 17 deletions
|
@ -7,6 +7,7 @@
|
|||
#
|
||||
# Contributors:
|
||||
# QNX Software Systems - Initial API and implementation
|
||||
# Nokia - Added support for AbsoluteSourceContainer( 159833 )
|
||||
###############################################################################
|
||||
pluginName=C/C++ Development Tools Debug Model
|
||||
providerName=Eclipse.org
|
||||
|
@ -24,3 +25,5 @@ containerName.mapEntry=Path Map Entry
|
|||
containerDescription.mapEntry=An entry in a path mapping.
|
||||
containerName.directory=File System Directory
|
||||
containerDescription.directory=A directory in the local file system.
|
||||
containerName.absolutePath=Absolute File Path
|
||||
containerDescription.absolutePath=An absolute path to a file in the local file system.
|
||||
|
|
|
@ -158,6 +158,11 @@
|
|||
description="%containerDescription.directory"
|
||||
id="org.eclipse.cdt.debug.core.containerType.directory"
|
||||
name="%containerName.directory"/>
|
||||
<sourceContainerType
|
||||
class="org.eclipse.cdt.debug.internal.core.sourcelookup.AbsolutePathSourceContainerType"
|
||||
description="%containerDescription.absolutePath"
|
||||
id="org.eclipse.cdt.debug.core.containerType.absolutePath"
|
||||
name="%containerName.absolutePath"/>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Nokia and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Nokia - Initial implementation (159833)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.core.sourcelookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
|
||||
|
||||
public class AbsolutePathSourceContainer extends AbstractSourceContainer {
|
||||
/**
|
||||
* Unique identifier for the absolute source container type
|
||||
* (value <code>org.eclipse.cdt.debug.core.containerType.absolutePath</code>).
|
||||
*/
|
||||
public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.absolutePath"; //$NON-NLS-1$
|
||||
|
||||
private Object[] findSourceElementByFile( File file ) {
|
||||
IFile[] wfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( new Path( file.getAbsolutePath() ) );
|
||||
if ( wfiles.length > 0 )
|
||||
return wfiles;
|
||||
|
||||
try {
|
||||
// Check the canonical path as well to support case insensitive file systems like Windows.
|
||||
wfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( new Path( file.getCanonicalPath() ) );
|
||||
if ( wfiles.length > 0 )
|
||||
return wfiles;
|
||||
} catch (IOException e) { // ignore if getCanonicalPath throws
|
||||
}
|
||||
|
||||
return new LocalFileStorage[] { new LocalFileStorage( file ) };
|
||||
}
|
||||
|
||||
public boolean isValidAbsoluteFilePath( String name )
|
||||
{
|
||||
return isValidAbsoluteFilePath( new File(name) );
|
||||
}
|
||||
|
||||
public boolean isValidAbsoluteFilePath( File file )
|
||||
{
|
||||
return file.isAbsolute() && file.exists() && file.isFile();
|
||||
}
|
||||
|
||||
public Object[] findSourceElements( String name ) throws CoreException {
|
||||
if ( name != null ) {
|
||||
File file = new File( name );
|
||||
if ( isValidAbsoluteFilePath(file) ) {
|
||||
return findSourceElementByFile( file );
|
||||
}
|
||||
}
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return SourceLookupMessages.getString( "AbsolutePathSourceContainer.0" );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
|
||||
*/
|
||||
public ISourceContainerType getType() {
|
||||
return getSourceContainerType( TYPE_ID );
|
||||
}
|
||||
|
||||
}
|
|
@ -7,5 +7,7 @@
|
|||
#
|
||||
# Contributors:
|
||||
# QNX Software Systems - initial API and implementation
|
||||
# Nokia - added support for AbsolutePathSourceContainer
|
||||
###############################################################################
|
||||
MappingSourceContainer.0=Source lookup error
|
||||
AbsolutePathSourceContainer.0=Absolute File Path
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Nokia and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Nokia - Initial implementation (159833)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate;
|
||||
|
||||
public class AbsolutePathSourceContainerType extends AbstractSourceContainerTypeDelegate {
|
||||
|
||||
public ISourceContainer createSourceContainer(String memento) throws CoreException {
|
||||
return new AbsolutePathSourceContainer();
|
||||
}
|
||||
|
||||
public String getMemento(ISourceContainer container) throws CoreException {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
|
@ -7,13 +7,15 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
* Nokia - Added support for AbsoluteSourceContainer( 159833 )
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -151,6 +153,9 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
|||
if ( container instanceof MappingSourceContainer ) {
|
||||
return ( ((MappingSourceContainer)container).getCompilationPath( sourceName ) != null );
|
||||
}
|
||||
if ( container instanceof AbsolutePathSourceContainer ) {
|
||||
return ( ((AbsolutePathSourceContainer)container).isValidAbsoluteFilePath( sourceName ) );
|
||||
}
|
||||
try {
|
||||
ISourceContainer[] containers;
|
||||
containers = container.getSourceContainers();
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
* Nokia - Added support for AbsoluteSourceContainer( 159833 )
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -77,23 +78,9 @@ public class CSourceLookupParticipant extends AbstractSourceLookupParticipant {
|
|||
else if ( object instanceof String ) {
|
||||
name = (String)object;
|
||||
}
|
||||
// Workaround. See bug #91808.
|
||||
if ( name != null ) {
|
||||
File file = new File( name );
|
||||
if ( file.isAbsolute() && file.exists() ) {
|
||||
return findSourceElementByFile( file );
|
||||
}
|
||||
}
|
||||
return super.findSourceElements( object );
|
||||
}
|
||||
|
||||
private Object[] findSourceElementByFile( File file ) {
|
||||
IFile[] wfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( new Path( file.getPath() ) );
|
||||
if ( wfiles.length > 0 )
|
||||
return wfiles;
|
||||
return new LocalFileStorage[] { new LocalFileStorage( file ) };
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant#dispose()
|
||||
*/
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
* Nokia - Added support for AbsoluteSourceContainer( 159833 )
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
@ -54,6 +56,7 @@ public class CSourcePathComputerDelegate implements ISourcePathComputerDelegate
|
|||
containers.add( 0, new ProjectSourceContainer( project, true ) );
|
||||
}
|
||||
}
|
||||
containers.add( new AbsolutePathSourceContainer() );
|
||||
return (ISourceContainer[])containers.toArray( new ISourceContainer[containers.size()] );
|
||||
}
|
||||
}
|
||||
|
|
BIN
debug/org.eclipse.cdt.debug.ui/icons/obj16/abspath_obj.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/obj16/abspath_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 924 B |
|
@ -1213,6 +1213,10 @@
|
|||
containerTypeID="org.eclipse.cdt.debug.core.containerType.mapEntry"
|
||||
icon="icons/obj16/mapentry_obj.gif"
|
||||
id="org.eclipse.cdt.debug.ui.sourceContainerPresentation.mapEntry"/>
|
||||
<sourceContainerPresentation
|
||||
containerTypeID="org.eclipse.cdt.debug.core.containerType.absolutePath"
|
||||
icon="icons/obj16/abspath_obj.gif"
|
||||
id="org.eclipse.cdt.debug.ui.sourceContainerPresentation.absolutePath"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.filebuffers.annotationModelCreation">
|
||||
|
|
Loading…
Add table
Reference in a new issue