mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Corrected logic for determining if a URI points to a workspace file.
This commit is contained in:
parent
8f07ba0efc
commit
bd4da84e73
1 changed files with 12 additions and 2 deletions
|
@ -25,6 +25,7 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -442,7 +443,7 @@ public class AddIncludeOnSelectionAction extends TextEditorAction {
|
||||||
*/
|
*/
|
||||||
private IIndexFile getRepresentativeFile(IIndexFile headerFile, IIndex index) {
|
private IIndexFile getRepresentativeFile(IIndexFile headerFile, IIndex index) {
|
||||||
try {
|
try {
|
||||||
if (ResourceLookup.findFilesForLocationURI(headerFile.getLocation().getURI()).length > 0) {
|
if (isWorkspaceFile(headerFile.getLocation().getURI())) {
|
||||||
return headerFile;
|
return headerFile;
|
||||||
}
|
}
|
||||||
// TODO(sprigogin): Change to ArrayDeque when Java 5 support is no longer needed.
|
// TODO(sprigogin): Change to ArrayDeque when Java 5 support is no longer needed.
|
||||||
|
@ -461,7 +462,7 @@ public class AddIncludeOnSelectionAction extends TextEditorAction {
|
||||||
IIndexFile includer = include.getIncludedBy();
|
IIndexFile includer = include.getIncludedBy();
|
||||||
if (!processed.contains(includer)) {
|
if (!processed.contains(includer)) {
|
||||||
URI uri = includer.getLocation().getURI();
|
URI uri = includer.getLocation().getURI();
|
||||||
if (isSource(uri.getPath()) || ResourceLookup.findFilesForLocationURI(uri).length > 0) {
|
if (isSource(uri.getPath()) || isWorkspaceFile(uri)) {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
front.add(includer);
|
front.add(includer);
|
||||||
|
@ -475,6 +476,15 @@ public class AddIncludeOnSelectionAction extends TextEditorAction {
|
||||||
return headerFile;
|
return headerFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isWorkspaceFile(URI uri) {
|
||||||
|
for (IFile file : ResourceLookup.findFilesForLocationURI(uri)) {
|
||||||
|
if (file.exists()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean hasExtension(String path) {
|
private boolean hasExtension(String path) {
|
||||||
return path.indexOf('.', path.lastIndexOf('/') + 1) >= 0;
|
return path.indexOf('.', path.lastIndexOf('/') + 1) >= 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue