diff --git a/java/openapi/src/com/intellij/psi/search/PackageScope.java b/java/openapi/src/com/intellij/psi/search/PackageScope.java index d2c7a292d224..dcfe5eea194c 100644 --- a/java/openapi/src/com/intellij/psi/search/PackageScope.java +++ b/java/openapi/src/com/intellij/psi/search/PackageScope.java @@ -23,7 +23,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.PackageIndex; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiPackage; import org.jetbrains.annotations.NotNull; @@ -49,7 +49,7 @@ public class PackageScope extends GlobalSearchScope { public boolean contains(VirtualFile file) { for (VirtualFile scopeDir : myDirs) { boolean inDir = myIncludeSubpackages - ? VfsUtil.isAncestor(scopeDir, file, false) + ? VfsUtilCore.isAncestor(scopeDir, file, false) : Comparing.equal(file.getParent(), scopeDir); if (inDir) return true; } diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java new file mode 100644 index 000000000000..914cf9a2998b --- /dev/null +++ b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.vfs; + +import org.jetbrains.annotations.NotNull; + +public class VfsUtilCore { + /** + * Checks whether the ancestor {@link com.intellij.openapi.vfs.VirtualFile} is parent of file + * {@link com.intellij.openapi.vfs.VirtualFile}. + * + * @param ancestor the file + * @param file the file + * @param strict if false then this method returns true if ancestor + * and file are equal + * @return true if ancestor is parent of file; false otherwise + */ + public static boolean isAncestor(@NotNull VirtualFile ancestor, @NotNull VirtualFile file, boolean strict) { + if (!file.getFileSystem().equals(ancestor.getFileSystem())) return false; + VirtualFile parent = strict ? file.getParent() : file; + while (true) { + if (parent == null) return false; + if (parent.equals(ancestor)) return true; + parent = parent.getParent(); + } + } +} diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java index d1ff5d7f8393..15f10cb78acb 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java @@ -42,7 +42,7 @@ import java.net.URL; import java.nio.charset.Charset; import java.util.*; -public class VfsUtil { +public class VfsUtil extends VfsUtilCore { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.VfsUtil"); public static String loadText(@NotNull VirtualFile file) throws IOException{ @@ -60,26 +60,6 @@ public class VfsUtil { file.setBinaryContent(text.getBytes(charset.name())); } - /** - * Checks whether the ancestor {@link VirtualFile} is parent of file - * {@link VirtualFile}. - * - * @param ancestor the file - * @param file the file - * @param strict if false then this method returns true if ancestor - * and file are equal - * @return true if ancestor is parent of file; false otherwise - */ - public static boolean isAncestor(@NotNull VirtualFile ancestor, @NotNull VirtualFile file, boolean strict) { - if (!file.getFileSystem().equals(ancestor.getFileSystem())) return false; - VirtualFile parent = strict ? file.getParent() : file; - while (true) { - if (parent == null) return false; - if (parent.equals(ancestor)) return true; - parent = parent.getParent(); - } - } - /** * Gets the relative path of file to its ancestor. Uses separator for * separating files.