mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 03:53:21 +02:00
Cosmetics.
This commit is contained in:
parent
caadfdc7d1
commit
df47a5c6f6
1 changed files with 66 additions and 72 deletions
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Nokia - Added support for AbsoluteSourceContainer( 159833 )
|
* Nokia - Added support for AbsoluteSourceContainer(159833)
|
||||||
* Texas Instruments - added extension point for source container type (279473)
|
* Texas Instruments - added extension point for source container type (279473)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
package org.eclipse.cdt.debug.internal.core.sourcelookup;
|
||||||
|
|
||||||
|
@ -49,10 +49,8 @@ import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
|
||||||
*
|
*
|
||||||
* An instance is either associated with a particular launch configuration or it
|
* An instance is either associated with a particular launch configuration or it
|
||||||
* has no association (global).
|
* has no association (global).
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
||||||
|
|
||||||
private static Set<String> fSupportedTypes;
|
private static Set<String> fSupportedTypes;
|
||||||
private static Object fSupportedTypesLock = new Object();
|
private static Object fSupportedTypesLock = new Object();
|
||||||
|
|
||||||
|
@ -60,100 +58,97 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
||||||
* @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
|
* @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
|
||||||
*/
|
*/
|
||||||
public void initializeParticipants() {
|
public void initializeParticipants() {
|
||||||
addParticipants( new ISourceLookupParticipant[]{ new CSourceLookupParticipant() } );
|
addParticipants(new ISourceLookupParticipant[]{ new CSourceLookupParticipant() });
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#supportsSourceContainerType(org.eclipse.debug.core.sourcelookup.ISourceContainerType)
|
* @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#supportsSourceContainerType(org.eclipse.debug.core.sourcelookup.ISourceContainerType)
|
||||||
*/
|
*/
|
||||||
public boolean supportsSourceContainerType( ISourceContainerType type ) {
|
public boolean supportsSourceContainerType(ISourceContainerType type) {
|
||||||
readSupportedContainerTypes();
|
readSupportedContainerTypes();
|
||||||
return fSupportedTypes.contains( type.getId() );
|
return fSupportedTypes.contains(type.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains( String source ) {
|
public boolean contains(String source) {
|
||||||
ISourceContainer[] containers = getSourceContainers();
|
ISourceContainer[] containers = getSourceContainers();
|
||||||
for ( int i = 0; i < containers.length; ++i ) {
|
for (int i = 0; i < containers.length; ++i) {
|
||||||
if ( contains( containers[i], source ) )
|
if (contains(containers[i], source))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains( ICBreakpoint breakpoint ) {
|
public boolean contains(ICBreakpoint breakpoint) {
|
||||||
try {
|
try {
|
||||||
String handle = breakpoint.getSourceHandle();
|
String handle = breakpoint.getSourceHandle();
|
||||||
ISourceContainer[] containers = getSourceContainers();
|
ISourceContainer[] containers = getSourceContainers();
|
||||||
for ( int i = 0; i < containers.length; ++i ) {
|
for (int i = 0; i < containers.length; ++i) {
|
||||||
if ( contains( containers[i], handle ) )
|
if (contains(containers[i], handle))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains( IProject project ) {
|
public boolean contains(IProject project) {
|
||||||
ISourceContainer[] containers = getSourceContainers();
|
ISourceContainer[] containers = getSourceContainers();
|
||||||
for ( int i = 0; i < containers.length; ++i ) {
|
for (int i = 0; i < containers.length; ++i) {
|
||||||
if ( contains( containers[i], project ) )
|
if (contains(containers[i], project))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean contains( ISourceContainer container, IProject project ) {
|
private boolean contains(ISourceContainer container, IProject project) {
|
||||||
if ( container instanceof ProjectSourceContainer && ((ProjectSourceContainer)container).getProject().equals( project ) ) {
|
if (container instanceof ProjectSourceContainer && ((ProjectSourceContainer) container).getProject().equals(project)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ISourceContainer[] containers;
|
ISourceContainer[] containers;
|
||||||
containers = container.getSourceContainers();
|
containers = container.getSourceContainers();
|
||||||
for ( int i = 0; i < containers.length; ++i ) {
|
for (int i = 0; i < containers.length; ++i) {
|
||||||
if ( contains( containers[i], project ) )
|
if (contains(containers[i], project))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean contains( ISourceContainer container, String sourceName ) {
|
private boolean contains(ISourceContainer container, String sourceName) {
|
||||||
IPath path = new Path( sourceName );
|
IPath path = new Path(sourceName);
|
||||||
if ( !path.isValidPath( sourceName ) )
|
if (!path.isValidPath(sourceName))
|
||||||
return false;
|
return false;
|
||||||
if ( container instanceof ProjectSourceContainer ) {
|
if (container instanceof ProjectSourceContainer) {
|
||||||
IProject project = ((ProjectSourceContainer)container).getProject();
|
IProject project = ((ProjectSourceContainer)container).getProject();
|
||||||
IPath projPath = project.getLocation();
|
IPath projPath = project.getLocation();
|
||||||
if ( projPath != null && projPath.isPrefixOf( path ) ) {
|
if (projPath != null && projPath.isPrefixOf(path)) {
|
||||||
IFile file = ((ProjectSourceContainer)container).getProject().getFile( path.removeFirstSegments( projPath.segmentCount() ) );
|
IFile file = ((ProjectSourceContainer)container).getProject().getFile(path.removeFirstSegments(projPath.segmentCount()));
|
||||||
return ( file != null && file.exists() );
|
return (file != null && file.exists());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( container instanceof FolderSourceContainer ) {
|
if (container instanceof FolderSourceContainer) {
|
||||||
IContainer folder = ((FolderSourceContainer)container).getContainer();
|
IContainer folder = ((FolderSourceContainer)container).getContainer();
|
||||||
IPath folderPath = folder.getLocation();
|
IPath folderPath = folder.getLocation();
|
||||||
if ( folderPath != null && folderPath.isPrefixOf( path ) ) {
|
if (folderPath != null && folderPath.isPrefixOf(path)) {
|
||||||
IFile file = ((FolderSourceContainer)container).getContainer().getFile( path.removeFirstSegments( folderPath.segmentCount() ) );
|
IFile file = ((FolderSourceContainer)container).getContainer().getFile(path.removeFirstSegments(folderPath.segmentCount()));
|
||||||
return ( file != null && file.exists() );
|
return (file != null && file.exists());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( container instanceof DirectorySourceContainer ) {
|
if (container instanceof DirectorySourceContainer) {
|
||||||
File dir = ((DirectorySourceContainer)container).getDirectory();
|
File dir = ((DirectorySourceContainer)container).getDirectory();
|
||||||
boolean searchSubfolders = ((DirectorySourceContainer)container).isComposite();
|
boolean searchSubfolders = ((DirectorySourceContainer)container).isComposite();
|
||||||
IPath dirPath = new Path( dir.getAbsolutePath() );
|
IPath dirPath = new Path(dir.getAbsolutePath());
|
||||||
if ( searchSubfolders || dirPath.segmentCount() + 1 == path.segmentCount() )
|
if (searchSubfolders || dirPath.segmentCount() + 1 == path.segmentCount())
|
||||||
return dirPath.isPrefixOf( path );
|
return dirPath.isPrefixOf(path);
|
||||||
}
|
}
|
||||||
if ( container instanceof MappingSourceContainer ) {
|
if (container instanceof MappingSourceContainer) {
|
||||||
return ( ((MappingSourceContainer)container).getCompilationPath( sourceName ) != null );
|
return (((MappingSourceContainer)container).getCompilationPath(sourceName) != null);
|
||||||
}
|
}
|
||||||
if ( container instanceof AbsolutePathSourceContainer ) {
|
if (container instanceof AbsolutePathSourceContainer) {
|
||||||
return ( ((AbsolutePathSourceContainer)container).isValidAbsoluteFilePath( sourceName ) );
|
return (((AbsolutePathSourceContainer)container).isValidAbsoluteFilePath(sourceName));
|
||||||
}
|
}
|
||||||
if ( container instanceof ProgramRelativePathSourceContainer ) {
|
if (container instanceof ProgramRelativePathSourceContainer) {
|
||||||
try {
|
try {
|
||||||
Object[] elements = ((ProgramRelativePathSourceContainer)container).findSourceElements(sourceName);
|
Object[] elements = ((ProgramRelativePathSourceContainer)container).findSourceElements(sourceName);
|
||||||
return elements.length > 0;
|
return elements.length > 0;
|
||||||
|
@ -164,22 +159,21 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
||||||
try {
|
try {
|
||||||
ISourceContainer[] containers;
|
ISourceContainer[] containers;
|
||||||
containers = container.getSourceContainers();
|
containers = container.getSourceContainers();
|
||||||
for ( int i = 0; i < containers.length; ++i ) {
|
for (int i = 0; i < containers.length; ++i) {
|
||||||
if ( contains( containers[i], sourceName ) )
|
if (contains(containers[i], sourceName))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPath getCompilationPath( String sourceName ) {
|
public IPath getCompilationPath(String sourceName) {
|
||||||
IPath path = null;
|
IPath path = null;
|
||||||
ISourceContainer[] containers = getSourceContainers();
|
ISourceContainer[] containers = getSourceContainers();
|
||||||
for ( int i = 0; i < containers.length; ++i ) {
|
for (int i = 0; i < containers.length; ++i) {
|
||||||
IPath cp = getCompilationPath( containers[i], sourceName );
|
IPath cp = getCompilationPath(containers[i], sourceName);
|
||||||
if ( cp != null ) {
|
if (cp != null) {
|
||||||
path = cp;
|
path = cp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -187,22 +181,20 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPath getCompilationPath( ISourceContainer container, String sourceName ) {
|
private IPath getCompilationPath(ISourceContainer container, String sourceName) {
|
||||||
IPath path = null;
|
IPath path = null;
|
||||||
if ( container instanceof MappingSourceContainer ) {
|
if (container instanceof MappingSourceContainer) {
|
||||||
path = ((MappingSourceContainer)container).getCompilationPath( sourceName );
|
path = ((MappingSourceContainer) container).getCompilationPath(sourceName);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
try {
|
try {
|
||||||
ISourceContainer[] containers;
|
ISourceContainer[] containers;
|
||||||
containers = container.getSourceContainers();
|
containers = container.getSourceContainers();
|
||||||
for ( int i = 0; i < containers.length; ++i ) {
|
for (int i = 0; i < containers.length; ++i) {
|
||||||
path = getCompilationPath( containers[i], sourceName );
|
path = getCompilationPath(containers[i], sourceName);
|
||||||
if ( path != null )
|
if (path != null)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
|
@ -211,17 +203,19 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
|
||||||
// >> Bugzilla 279473
|
// >> Bugzilla 279473
|
||||||
private void readSupportedContainerTypes() {
|
private void readSupportedContainerTypes() {
|
||||||
synchronized (fSupportedTypesLock) {
|
synchronized (fSupportedTypesLock) {
|
||||||
if( fSupportedTypes == null) {
|
if (fSupportedTypes == null) {
|
||||||
fSupportedTypes = new HashSet<String>();
|
fSupportedTypes = new HashSet<String>();
|
||||||
String name = CDebugCorePlugin.PLUGIN_ID+".supportedSourceContainerTypes"; //$NON-NLS-1$;
|
String name = CDebugCorePlugin.PLUGIN_ID + ".supportedSourceContainerTypes"; //$NON-NLS-1$;
|
||||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( name);
|
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(name);
|
||||||
if( extensionPoint != null)
|
if (extensionPoint != null) {
|
||||||
for( IExtension extension : extensionPoint.getExtensions())
|
for (IExtension extension : extensionPoint.getExtensions()) {
|
||||||
for( IConfigurationElement configurationElements : extension.getConfigurationElements()) {
|
for (IConfigurationElement configurationElements : extension.getConfigurationElements()) {
|
||||||
String id = configurationElements.getAttribute("id");//$NON-NLS-1$;
|
String id = configurationElements.getAttribute("id"); //$NON-NLS-1$;
|
||||||
if( id != null)
|
if (id != null)
|
||||||
fSupportedTypes.add(id);
|
fSupportedTypes.add(id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue