From d7476ab63c271e4a1cc520dbdeaa7c85b5032f5c Mon Sep 17 00:00:00 2001 From: Emanuel Graf Date: Thu, 24 Jul 2008 12:48:00 +0000 Subject: [PATCH] fix for bug 241960: [Refactoring] Refactoring delete comments in project outside the workspace https://bugs.eclipse.org/bugs/show_bug.cgi?id=241960 --- .../dom/rewrite/commenthandler/ASTCommenter.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java index 12505df3796..4398eb261f7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java @@ -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; }