mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 06:55:23 +02:00
Enhanced loops.
This commit is contained in:
parent
11f33b6627
commit
e0da7a58dd
1 changed files with 21 additions and 23 deletions
|
@ -77,36 +77,34 @@ public class CSourceLookup extends AbstractDsfService implements ISourceLookup {
|
||||||
|
|
||||||
private List<String> getSourceLookupPath(ISourceContainer[] containers) {
|
private List<String> getSourceLookupPath(ISourceContainer[] containers) {
|
||||||
ArrayList<String> list = new ArrayList<String>(containers.length);
|
ArrayList<String> list = new ArrayList<String>(containers.length);
|
||||||
|
|
||||||
for (int i = 0; i < containers.length; ++i) {
|
for (ISourceContainer container : containers) {
|
||||||
if (containers[i] instanceof ProjectSourceContainer) {
|
if (container instanceof ProjectSourceContainer) {
|
||||||
IProject project = ((ProjectSourceContainer)containers[i]).getProject();
|
IProject project = ((ProjectSourceContainer) container).getProject();
|
||||||
if (project != null && project.exists()) {
|
if (project != null && project.exists()) {
|
||||||
IPath location = project.getLocation();
|
IPath location = project.getLocation();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
list.add(location.toPortableString());
|
list.add(location.toPortableString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (container instanceof FolderSourceContainer) {
|
||||||
if (containers[i] instanceof FolderSourceContainer) {
|
IContainer folder = ((FolderSourceContainer) container).getContainer();
|
||||||
IContainer container = ((FolderSourceContainer)containers[i]).getContainer();
|
if (folder != null && folder.exists()) {
|
||||||
if (container != null && container.exists()) {
|
IPath location = folder.getLocation();
|
||||||
IPath location = container.getLocation();
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
list.add(location.toPortableString());
|
list.add(location.toPortableString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (container instanceof DirectorySourceContainer) {
|
||||||
if (containers[i] instanceof DirectorySourceContainer) {
|
File dir = ((DirectorySourceContainer) container).getDirectory();
|
||||||
File dir = ((DirectorySourceContainer)containers[i]).getDirectory();
|
|
||||||
if (dir != null && dir.exists()) {
|
if (dir != null && dir.exists()) {
|
||||||
IPath path = new Path( dir.getAbsolutePath());
|
IPath path = new Path(dir.getAbsolutePath());
|
||||||
list.add(path.toPortableString());
|
list.add(path.toPortableString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (containers[i].isComposite()) {
|
if (container.isComposite()) {
|
||||||
try {
|
try {
|
||||||
list.addAll(getSourceLookupPath(containers[i].getSourceContainers()));
|
list.addAll(getSourceLookupPath(container.getSourceContainers()));
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,11 +116,12 @@ public class CSourceLookup extends AbstractDsfService implements ISourceLookup {
|
||||||
@Override
|
@Override
|
||||||
public void initialize(final RequestMonitor requestMonitor) {
|
public void initialize(final RequestMonitor requestMonitor) {
|
||||||
super.initialize(
|
super.initialize(
|
||||||
new RequestMonitor(getExecutor(), requestMonitor) {
|
new RequestMonitor(getExecutor(), requestMonitor) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
doInitialize(requestMonitor);
|
doInitialize(requestMonitor);
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doInitialize(final RequestMonitor requestMonitor) {
|
private void doInitialize(final RequestMonitor requestMonitor) {
|
||||||
|
@ -140,7 +139,7 @@ public class CSourceLookup extends AbstractDsfService implements ISourceLookup {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getDebuggerPath(ISourceLookupDMContext sourceLookupCtx, Object source, final DataRequestMonitor<String> rm) {
|
public void getDebuggerPath(ISourceLookupDMContext sourceLookupCtx, Object source, final DataRequestMonitor<String> rm) {
|
||||||
if (! (source instanceof String)) {
|
if (!(source instanceof String)) {
|
||||||
// In future if needed other elements such as URIs could be supported.
|
// In future if needed other elements such as URIs could be supported.
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Only string source element is supported", null)); //$NON-NLS-1$);
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Only string source element is supported", null)); //$NON-NLS-1$);
|
||||||
rm.done();
|
rm.done();
|
||||||
|
@ -165,14 +164,13 @@ public class CSourceLookup extends AbstractDsfService implements ISourceLookup {
|
||||||
rm.setData(sourceString);
|
rm.setData(sourceString);
|
||||||
}
|
}
|
||||||
rm.done();
|
rm.done();
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
}.schedule();
|
}.schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSource(ISourceLookupDMContext sourceLookupCtx, final String debuggerPath, final DataRequestMonitor<Object> rm) {
|
public void getSource(ISourceLookupDMContext sourceLookupCtx, final String debuggerPath, final DataRequestMonitor<Object> rm) {
|
||||||
if (!fDirectors.containsKey(sourceLookupCtx) ){
|
if (!fDirectors.containsKey(sourceLookupCtx)) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID,
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID,
|
||||||
IDsfStatusConstants.INVALID_HANDLE, "No source director configured for given context", null)); //$NON-NLS-1$);
|
IDsfStatusConstants.INVALID_HANDLE, "No source director configured for given context", null)); //$NON-NLS-1$);
|
||||||
rm.done();
|
rm.done();
|
||||||
|
|
Loading…
Add table
Reference in a new issue