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

Generic parameters and exception logging.

This commit is contained in:
Sergey Prigogin 2010-12-02 01:33:01 +00:00
parent e19da24804
commit caadfdc7d1
3 changed files with 88 additions and 96 deletions

View file

@ -31,7 +31,6 @@ import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer;
* The source container for path mappings.
*/
public class MappingSourceContainer extends AbstractSourceContainer {
/**
* Unique identifier for the mapping source container type
* (value <code>org.eclipse.cdt.debug.core.containerType.mapping</code>).
@ -94,24 +93,20 @@ public class MappingSourceContainer extends AbstractSourceContainer {
for (int j = 0; j < objects.length; j++) {
results.add(objects[j]);
}
}
else {
} else {
if (objects.length == 1) {
return objects;
}
return new Object[]{ objects[0] };
}
}
}
catch( CoreException e ) {
} catch (CoreException e) {
if (single == null) {
single = e;
}
else if ( multiStatus == null ) {
} else if (multiStatus == null) {
multiStatus = new MultiStatus(DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, new IStatus[]{ single.getStatus() }, SourceLookupMessages.getString("MappingSourceContainer.0"), null); //$NON-NLS-1$
multiStatus.add(e.getStatus());
}
else {
} else {
multiStatus.add(e.getStatus());
}
}
@ -119,8 +114,7 @@ public class MappingSourceContainer extends AbstractSourceContainer {
if (results == null) {
if (multiStatus != null) {
throw new CoreException(multiStatus);
}
else if ( single != null ) {
} else if (single != null) {
throw single;
}
return EMPTY;
@ -197,8 +191,8 @@ public class MappingSourceContainer extends AbstractSourceContainer {
break;
}
}
}
catch( CoreException e ) {
} catch (CoreException e) {
CDebugCorePlugin.log(e);
}
return result;
}

View file

@ -47,7 +47,7 @@ public class CSourcePathComputerDelegate implements ISourcePathComputerDelegate
// First, get all the the containers in the global preferences (but add them last)
ISourceContainer[] common = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().getSourceContainers();
List<ISourceContainer> containers = new ArrayList<ISourceContainer>(common.length + 2);
List<ISourceContainer> containers = new ArrayList<ISourceContainer>(common.length + 3);
// Add a container that fetches files that are specified with an absolute path
containers.add(new AbsolutePathSourceContainer());

View file

@ -36,7 +36,6 @@ import com.ibm.icu.text.MessageFormat;
* The source container that maps a backend path to the local filesystem path.
*/
public class MapEntrySourceContainer extends AbstractSourceContainer {
/**
* Unique identifier for the map entry source container type
* (value <code>org.eclipse.cdt.debug.core.containerType.mapEntry</code>).
@ -73,7 +72,8 @@ public class MapEntrySourceContainer extends AbstractSourceContainer {
* @return converted string
*/
public static IPath createPath(String path) {
if (path == null) return null;
if (path == null)
return null;
if (path.contains("\\")) { //$NON-NLS-1$
// handle Windows slashes and canonicalize
path = path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
@ -88,8 +88,7 @@ public class MapEntrySourceContainer extends AbstractSourceContainer {
String device = path.substring(0, idx + 1);
path = path.substring(idx + 1);
return new Path(path).setDevice(device);
}
else {
} else {
// Cygwin or UNC path
if (path.startsWith("//")) { //$NON-NLS-1$
String network;
@ -119,7 +118,7 @@ public class MapEntrySourceContainer extends AbstractSourceContainer {
path = getLocalPath().append(path);
IFile[] wsFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(path);
ArrayList list = new ArrayList();
ArrayList<IFile> list = new ArrayList<IFile>();
for (int j = 0; j < wsFiles.length; ++j) {
if (wsFiles[j].exists()) {
list.add(wsFiles[j]);
@ -134,22 +133,21 @@ public class MapEntrySourceContainer extends AbstractSourceContainer {
// The file is not already in the workspace so try to create an external translation unit for it.
ISourceLookupDirector director = getDirector();
if (director != null && file.exists() && file.isFile() )
{
if (director != null && file.exists() && file.isFile()) {
ILaunchConfiguration launchConfiguration = director.getLaunchConfiguration();
if (launchConfiguration != null)
{
if (launchConfiguration != null) {
String projectName = launchConfiguration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
if (projectName.length() > 0) {
ICProject project = CoreModel.getDefault().getCModel().getCProject(projectName);
if (project != null)
{
if (project != null) {
String id;
try {
final IPath location= Path.fromOSString(file.getCanonicalPath());
id = CoreModel.getRegistedContentTypeId(project.getProject(), location.lastSegment());
return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, location, id) };
} catch (IOException e) { e.printStackTrace(); }
} catch (IOException e) {
CDebugCorePlugin.log(e);
}
}
}
}