mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
FIXED - bug 252511: UnhandedASTModificationException when refactoring source files in linked directories
https://bugs.eclipse.org/bugs/show_bug.cgi?id=252511 Patch by Tom Ball
This commit is contained in:
parent
9ca7ade7ee
commit
4beb0402dc
3 changed files with 10 additions and 4 deletions
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
|||
import org.eclipse.cdt.internal.core.dom.rewrite.util.FileContentHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.util.FileHelper;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -230,10 +231,13 @@ public class ChangeGenerator extends CPPASTVisitor {
|
|||
targetLocation = getFileLocationOfEmptyTranslationUnit(modification.getTargetNode());
|
||||
String currentFile = targetLocation.getFileName();
|
||||
IPath implPath = new Path(currentFile);
|
||||
IFile relevantFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(implPath);
|
||||
if (relevantFile == null) { // if not in workspace
|
||||
IFile[] relevantFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(implPath);
|
||||
if (relevantFiles.length == 0) { // if not in workspace or local file system
|
||||
throw new UnhandledASTModificationException(modification);
|
||||
}
|
||||
// There may be multiple links to the same file, but since their contents are the
|
||||
// same, just use the first one.
|
||||
IFile relevantFile = relevantFiles[0];
|
||||
MultiTextEdit edit;
|
||||
if (changes.containsKey(relevantFile)) {
|
||||
edit = changes.get(relevantFile);
|
||||
|
|
|
@ -150,7 +150,8 @@ public class NodeCommenter {
|
|||
return true;
|
||||
}
|
||||
IPath path = new Path(node.getContainingFilename());
|
||||
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
|
||||
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(path);
|
||||
IFile file = files.length > 0 ? files[0] : null; // NPE thrown below, like original behavior
|
||||
|
||||
//XXX HSR Guido: Possible Performance Issue (File access)
|
||||
try {
|
||||
|
|
|
@ -36,7 +36,8 @@ public class FileHelper {
|
|||
|
||||
public static IFile getIFilefromIASTNode(IASTNode node) {
|
||||
IPath implPath = new Path(node.getContainingFilename());
|
||||
return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(implPath);
|
||||
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(implPath);
|
||||
return files.length > 0 ? files[0] : null;
|
||||
}
|
||||
|
||||
public static boolean isFirstWithinSecondLocation(IASTFileLocation loc1, IASTFileLocation loc2){
|
||||
|
|
Loading…
Add table
Reference in a new issue