mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
fix for bug 241960: [Refactoring] Refactoring delete comments in project outside the workspace
https://bugs.eclipse.org/bugs/show_bug.cgi?id=241960
This commit is contained in:
parent
0e2c6945bd
commit
d7476ab63c
1 changed files with 11 additions and 2 deletions
|
@ -15,12 +15,18 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.util.OffsetHelper;
|
||||
import org.eclipse.cdt.internal.core.model.CProject;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
@ -137,9 +143,12 @@ public class ASTCommenter {
|
|||
}
|
||||
|
||||
private static boolean isInWorkspace(IASTNode node) {
|
||||
IPath workspacePath = Platform.getLocation();
|
||||
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
||||
IPath nodePath = new Path(node.getContainingFilename());
|
||||
return workspacePath.isPrefixOf(nodePath);
|
||||
for (IProject project : projects) {
|
||||
if(project.getLocation().isPrefixOf(nodePath)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue