1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 22:22:11 +02:00

The DirectorySourceContainer's UI now supports the subfolders searching option (see bug 89748). Removed CDirectorySourceContainer and related classes. The CDirectorySourceContainerType is kept for migration purposes.

This commit is contained in:
Mikhail Khodjaiants 2006-02-27 21:56:06 +00:00
parent 76e299dfbf
commit fd4aeb67d1
7 changed files with 27 additions and 193 deletions

View file

@ -1,3 +1,15 @@
2006-02-27 Mikhail Khodjaiants
The DirectorySourceContainer's UI now supports the subfolders searching option (see bug 89748).
Removed CDirectorySourceContainer and related classes.
The CDirectorySourceContainerType is kept for migration purposes.
- CDirectorySourceContainer.java
* CDebugTarget.java
* CDirectorySourceContainerType.java
* CSourceLookupDirector.java
* SourceUtils.java
* plugin.properties
* plugin.xml
2006-02-24 Mikhail Khodjaiants
Fix for bugs 129152 (Keyboard shortcuts are gone in CDT CVS HEAD)
and 128844 (No prompt for Debug perspective on suspend).

View file

@ -22,5 +22,5 @@ containerName.mapping=Path Mapping
containerDescription.mapping=A path mapping.
containerName.mapEntry=Path Map Entry
containerDescription.mapEntry=An entry in a path mapping.
containerName.directory=File System Directory With Subfolders
containerDescription.directory=A directory in the local file system with the subfolders search option.
containerName.directory=File System Directory
containerDescription.directory=A directory in the local file system.

View file

@ -1,178 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.sourcelookup;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
import org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
/**
* It is not supposed to subclass DirectorySourceContainer, but we need to use
* the different browser.
*/
public class CDirectorySourceContainer extends CompositeSourceContainer {
/**
* Unique identifier for the CDT directory source container type
* (value <code>org.eclipse.cdt.debug.core.containerType.directory</code>).
*/
public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.directory"; //$NON-NLS-1$
// root directory
private File fDirectory;
// whether to search subfolders
private boolean fSubfolders = false;
/**
* Consutructs an external folder container for the
* directory identified by the given path.
*
* @param dirPath path to a directory in the local file system
* @param subfolders whether folders within the root directory
* should be searched for source elements
*/
public CDirectorySourceContainer( IPath dirPath, boolean subfolders ) {
this( dirPath.toFile(), subfolders );
}
/**
* Consutructs an external folder container for the
* directory identified by the given file.
*
* @param dir a directory in the local file system
* @param subfolders whether folders within the root directory
* should be searched for source elements
*/
public CDirectorySourceContainer( File dir, boolean subfolders ) {
fDirectory = dir;
fSubfolders = subfolders;
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#getName()
*/
public String getName() {
return fDirectory.getName();
}
/**
* Returns the root directory in the local file system associated
* with this source container.
*
* @return the root directory in the local file system associated
* with this source container
*/
public File getDirectory() {
return fDirectory;
}
public boolean searchSubfolders() {
return fSubfolders;
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#getType()
*/
public ISourceContainerType getType() {
return getSourceContainerType( TYPE_ID );
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String)
*/
public Object[] findSourceElements( String name ) throws CoreException {
ArrayList sources = new ArrayList();
File directory = getDirectory();
File file = new File( directory, name );
if ( file.exists() && file.isFile() ) {
sources.add( new LocalFileStorage( file ) );
}
// check subfolders
if ( (isFindDuplicates() && fSubfolders) || (sources.isEmpty() && fSubfolders) ) {
ISourceContainer[] containers = getSourceContainers();
for( int i = 0; i < containers.length; i++ ) {
Object[] objects = containers[i].findSourceElements( name );
if ( objects == null || objects.length == 0 ) {
continue;
}
if ( isFindDuplicates() ) {
for( int j = 0; j < objects.length; j++ )
sources.add( objects[j] );
}
else {
sources.add( objects[0] );
break;
}
}
}
if ( sources.isEmpty() )
return EMPTY;
return sources.toArray();
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#isComposite()
*/
public boolean isComposite() {
return fSubfolders;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals( Object obj ) {
if ( obj instanceof CDirectorySourceContainer ) {
CDirectorySourceContainer container = (CDirectorySourceContainer)obj;
return container.getDirectory().equals( getDirectory() );
}
return false;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return getDirectory().hashCode();
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.sourcelookup.containers.CompositeSourceContainer#createSourceContainers()
*/
protected ISourceContainer[] createSourceContainers() throws CoreException {
if ( isComposite() ) {
String[] files = fDirectory.list();
if ( files != null ) {
List dirs = new ArrayList();
for( int i = 0; i < files.length; i++ ) {
String name = files[i];
File file = new File( getDirectory(), name );
if ( file.exists() && file.isDirectory() ) {
dirs.add( new CDirectorySourceContainer( file, true ) );
}
}
ISourceContainer[] containers = (ISourceContainer[])dirs.toArray( new ISourceContainer[dirs.size()] );
for( int i = 0; i < containers.length; i++ ) {
ISourceContainer container = containers[i];
container.init( getDirector() );
}
return containers;
}
}
return new ISourceContainer[0];
}
}

View file

@ -78,7 +78,6 @@ import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
import org.eclipse.cdt.debug.core.model.IPersistableRegisterGroup;
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.ISourceLookupChangeListener;
import org.eclipse.cdt.debug.internal.core.CBreakpointManager;
@ -122,6 +121,7 @@ import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
@ -1642,8 +1642,8 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if ( container != null && container.exists() )
list.add( container.getLocation().toPortableString() );
}
if ( containers[i] instanceof CDirectorySourceContainer ) {
File dir = ((CDirectorySourceContainer)containers[i]).getDirectory();
if ( containers[i] instanceof DirectorySourceContainer ) {
File dir = ((DirectorySourceContainer)containers[i]).getDirectory();
if ( dir != null && dir.exists() ) {
IPath path = new Path( dir.getAbsolutePath() );
list.add( path.toPortableString() );

View file

@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.sourcelookup;
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate;
import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -38,7 +38,7 @@ public class CDirectorySourceContainerType extends AbstractSourceContainerTypeDe
}
String nest = element.getAttribute( "nest" ); //$NON-NLS-1$
boolean nested = "true".equals( nest ); //$NON-NLS-1$
return new CDirectorySourceContainer( new Path( string ), nested );
return new DirectorySourceContainer( new Path( string ), nested );
}
abort( InternalSourceLookupMessages.getString( "CDirectorySourceContainerType.1" ), null ); //$NON-NLS-1$
}
@ -50,7 +50,7 @@ public class CDirectorySourceContainerType extends AbstractSourceContainerTypeDe
* @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
*/
public String getMemento( ISourceContainer container ) throws CoreException {
CDirectorySourceContainer folder = (CDirectorySourceContainer)container;
DirectorySourceContainer folder = (DirectorySourceContainer)container;
Document document = newDocument();
Element element = document.createElement( "directory" ); //$NON-NLS-1$
element.setAttribute( "path", folder.getDirectory().getAbsolutePath() ); //$NON-NLS-1$

View file

@ -14,7 +14,6 @@ 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.CDirectorySourceContainer;
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@ -28,6 +27,7 @@ import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
@ -44,7 +44,7 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
fSupportedTypes.add( WorkspaceSourceContainer.TYPE_ID );
fSupportedTypes.add( ProjectSourceContainer.TYPE_ID );
fSupportedTypes.add( FolderSourceContainer.TYPE_ID );
fSupportedTypes.add( CDirectorySourceContainer.TYPE_ID );
fSupportedTypes.add( DirectorySourceContainer.TYPE_ID );
fSupportedTypes.add( MappingSourceContainer.TYPE_ID );
}
@ -131,9 +131,9 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector {
return ( file != null && file.exists() );
}
}
if ( container instanceof CDirectorySourceContainer ) {
File dir = ((CDirectorySourceContainer)container).getDirectory();
boolean searchSubfolders = ((CDirectorySourceContainer)container).searchSubfolders();
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 );

View file

@ -22,7 +22,6 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
@ -32,6 +31,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -181,7 +181,7 @@ public class SourceUtils {
containers.add( mapping );
}
containers.add( new CDirectorySourceContainer( d.getDirectory(), d.searchSubfolders() ) );
containers.add( new DirectorySourceContainer( d.getDirectory(), d.searchSubfolders() ) );
}
}
return (ISourceContainer[])containers.toArray( new ISourceContainer[containers.size()] );