1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2010-12-02 01:55:05 +00:00
parent caadfdc7d1
commit df47a5c6f6

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Nokia - Added support for AbsoluteSourceContainer( 159833 )
* Texas Instruments - added extension point for source container type (279473)
* QNX Software Systems - Initial API and implementation
* Nokia - Added support for AbsoluteSourceContainer(159833)
* Texas Instruments - added extension point for source container type (279473)
*******************************************************************************/
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
* has no association (global).
*
*/
public class CSourceLookupDirector extends AbstractSourceLookupDirector {
private static Set<String> fSupportedTypes;
private static Object fSupportedTypesLock = new Object();
@ -60,100 +58,97 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
* @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
*/
public void initializeParticipants() {
addParticipants( new ISourceLookupParticipant[]{ new CSourceLookupParticipant() } );
addParticipants(new ISourceLookupParticipant[]{ new CSourceLookupParticipant() });
}
/* (non-Javadoc)
* @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();
return fSupportedTypes.contains( type.getId() );
return fSupportedTypes.contains(type.getId());
}
public boolean contains( String source ) {
public boolean contains(String source) {
ISourceContainer[] containers = getSourceContainers();
for ( int i = 0; i < containers.length; ++i ) {
if ( contains( containers[i], source ) )
for (int i = 0; i < containers.length; ++i) {
if (contains(containers[i], source))
return true;
}
return false;
}
public boolean contains( ICBreakpoint breakpoint ) {
public boolean contains(ICBreakpoint breakpoint) {
try {
String handle = breakpoint.getSourceHandle();
ISourceContainer[] containers = getSourceContainers();
for ( int i = 0; i < containers.length; ++i ) {
if ( contains( containers[i], handle ) )
for (int i = 0; i < containers.length; ++i) {
if (contains(containers[i], handle))
return true;
}
}
catch( CoreException e ) {
} catch (CoreException e) {
}
return false;
}
public boolean contains( IProject project ) {
public boolean contains(IProject project) {
ISourceContainer[] containers = getSourceContainers();
for ( int i = 0; i < containers.length; ++i ) {
if ( contains( containers[i], project ) )
for (int i = 0; i < containers.length; ++i) {
if (contains(containers[i], project))
return true;
}
return false;
}
private boolean contains( ISourceContainer container, IProject project ) {
if ( container instanceof ProjectSourceContainer && ((ProjectSourceContainer)container).getProject().equals( project ) ) {
private boolean contains(ISourceContainer container, IProject project) {
if (container instanceof ProjectSourceContainer && ((ProjectSourceContainer) container).getProject().equals(project)) {
return true;
}
try {
ISourceContainer[] containers;
containers = container.getSourceContainers();
for ( int i = 0; i < containers.length; ++i ) {
if ( contains( containers[i], project ) )
for (int i = 0; i < containers.length; ++i) {
if (contains(containers[i], project))
return true;
}
}
catch( CoreException e ) {
} catch (CoreException e) {
}
return false;
}
private boolean contains( ISourceContainer container, String sourceName ) {
IPath path = new Path( sourceName );
if ( !path.isValidPath( sourceName ) )
private boolean contains(ISourceContainer container, String sourceName) {
IPath path = new Path(sourceName);
if (!path.isValidPath(sourceName))
return false;
if ( container instanceof ProjectSourceContainer ) {
if (container instanceof ProjectSourceContainer) {
IProject project = ((ProjectSourceContainer)container).getProject();
IPath projPath = project.getLocation();
if ( projPath != null && projPath.isPrefixOf( path ) ) {
IFile file = ((ProjectSourceContainer)container).getProject().getFile( path.removeFirstSegments( projPath.segmentCount() ) );
return ( file != null && file.exists() );
if (projPath != null && projPath.isPrefixOf(path)) {
IFile file = ((ProjectSourceContainer)container).getProject().getFile(path.removeFirstSegments(projPath.segmentCount()));
return (file != null && file.exists());
}
}
if ( container instanceof FolderSourceContainer ) {
if (container instanceof FolderSourceContainer) {
IContainer folder = ((FolderSourceContainer)container).getContainer();
IPath folderPath = folder.getLocation();
if ( folderPath != null && folderPath.isPrefixOf( path ) ) {
IFile file = ((FolderSourceContainer)container).getContainer().getFile( path.removeFirstSegments( folderPath.segmentCount() ) );
return ( file != null && file.exists() );
if (folderPath != null && folderPath.isPrefixOf(path)) {
IFile file = ((FolderSourceContainer)container).getContainer().getFile(path.removeFirstSegments(folderPath.segmentCount()));
return (file != null && file.exists());
}
}
if ( container instanceof DirectorySourceContainer ) {
if (container instanceof DirectorySourceContainer) {
File dir = ((DirectorySourceContainer)container).getDirectory();
boolean searchSubfolders = ((DirectorySourceContainer)container).isComposite();
IPath dirPath = new Path( dir.getAbsolutePath() );
if ( searchSubfolders || dirPath.segmentCount() + 1 == path.segmentCount() )
return dirPath.isPrefixOf( path );
IPath dirPath = new Path(dir.getAbsolutePath());
if (searchSubfolders || dirPath.segmentCount() + 1 == path.segmentCount())
return dirPath.isPrefixOf(path);
}
if ( container instanceof MappingSourceContainer ) {
return ( ((MappingSourceContainer)container).getCompilationPath( sourceName ) != null );
if (container instanceof MappingSourceContainer) {
return (((MappingSourceContainer)container).getCompilationPath(sourceName) != null);
}
if ( container instanceof AbsolutePathSourceContainer ) {
return ( ((AbsolutePathSourceContainer)container).isValidAbsoluteFilePath( sourceName ) );
if (container instanceof AbsolutePathSourceContainer) {
return (((AbsolutePathSourceContainer)container).isValidAbsoluteFilePath(sourceName));
}
if ( container instanceof ProgramRelativePathSourceContainer ) {
if (container instanceof ProgramRelativePathSourceContainer) {
try {
Object[] elements = ((ProgramRelativePathSourceContainer)container).findSourceElements(sourceName);
return elements.length > 0;
@ -164,22 +159,21 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
try {
ISourceContainer[] containers;
containers = container.getSourceContainers();
for ( int i = 0; i < containers.length; ++i ) {
if ( contains( containers[i], sourceName ) )
for (int i = 0; i < containers.length; ++i) {
if (contains(containers[i], sourceName))
return true;
}
}
catch( CoreException e ) {
} catch (CoreException e) {
}
return false;
}
public IPath getCompilationPath( String sourceName ) {
public IPath getCompilationPath(String sourceName) {
IPath path = null;
ISourceContainer[] containers = getSourceContainers();
for ( int i = 0; i < containers.length; ++i ) {
IPath cp = getCompilationPath( containers[i], sourceName );
if ( cp != null ) {
for (int i = 0; i < containers.length; ++i) {
IPath cp = getCompilationPath(containers[i], sourceName);
if (cp != null) {
path = cp;
break;
}
@ -187,22 +181,20 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
return path;
}
private IPath getCompilationPath( ISourceContainer container, String sourceName ) {
private IPath getCompilationPath(ISourceContainer container, String sourceName) {
IPath path = null;
if ( container instanceof MappingSourceContainer ) {
path = ((MappingSourceContainer)container).getCompilationPath( sourceName );
}
else {
if (container instanceof MappingSourceContainer) {
path = ((MappingSourceContainer) container).getCompilationPath(sourceName);
} else {
try {
ISourceContainer[] containers;
containers = container.getSourceContainers();
for ( int i = 0; i < containers.length; ++i ) {
path = getCompilationPath( containers[i], sourceName );
if ( path != null )
for (int i = 0; i < containers.length; ++i) {
path = getCompilationPath(containers[i], sourceName);
if (path != null)
break;
}
}
catch( CoreException e ) {
} catch (CoreException e) {
}
}
return path;
@ -211,17 +203,19 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
// >> Bugzilla 279473
private void readSupportedContainerTypes() {
synchronized (fSupportedTypesLock) {
if( fSupportedTypes == null) {
if (fSupportedTypes == null) {
fSupportedTypes = new HashSet<String>();
String name = CDebugCorePlugin.PLUGIN_ID+".supportedSourceContainerTypes"; //$NON-NLS-1$;
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( name);
if( extensionPoint != null)
for( IExtension extension : extensionPoint.getExtensions())
for( IConfigurationElement configurationElements : extension.getConfigurationElements()) {
String id = configurationElements.getAttribute("id");//$NON-NLS-1$;
if( id != null)
String name = CDebugCorePlugin.PLUGIN_ID + ".supportedSourceContainerTypes"; //$NON-NLS-1$;
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(name);
if (extensionPoint != null) {
for (IExtension extension : extensionPoint.getExtensions()) {
for (IConfigurationElement configurationElements : extension.getConfigurationElements()) {
String id = configurationElements.getAttribute("id"); //$NON-NLS-1$;
if (id != null)
fSupportedTypes.add(id);
}
}
}
}
}
}