mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WI-450 (file exclusion): Moved all implementation to lang-impl, removed extensions, reverted isFileIgnored().
This commit is contained in:
+3
-3
@@ -30,7 +30,7 @@ import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
@@ -115,8 +115,8 @@ public class ProjectFileExclusionManager implements PersistentStateComponent<Ele
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ProjectFileExclusionManager getInstance(Project project) {
|
||||
public static ProjectFileExclusionManager getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, ProjectFileExclusionManager.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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.file.exclude;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class ProjectFileExclusionProvider extends FileExclusionProvider {
|
||||
|
||||
private final ProjectFileExclusionManager myFileExclusionManager;
|
||||
|
||||
public ProjectFileExclusionProvider(Project project) {
|
||||
myFileExclusionManager = ProjectFileExclusionManager.getInstance(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileExcluded(VirtualFile file) {
|
||||
return myFileExclusionManager.isExcluded(file);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.file.exclude.ProjectFileExclusionManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -36,6 +37,7 @@ public class ModuleFileIndexImpl implements ModuleFileIndex {
|
||||
private final FileTypeManager myFileTypeManager;
|
||||
private final DirectoryIndex myDirectoryIndex;
|
||||
private final ContentFilter myContentFilter;
|
||||
private final ProjectFileExclusionManager myExclusionManager;
|
||||
|
||||
public ModuleFileIndexImpl(Module module, DirectoryIndex directoryIndex) {
|
||||
myModule = module;
|
||||
@@ -43,6 +45,7 @@ public class ModuleFileIndexImpl implements ModuleFileIndex {
|
||||
myFileTypeManager = FileTypeManager.getInstance();
|
||||
|
||||
myContentFilter = new ContentFilter();
|
||||
myExclusionManager = ProjectFileExclusionManager.getInstance(module.getProject());
|
||||
}
|
||||
|
||||
public boolean iterateContent(@NotNull ContentIterator iterator) {
|
||||
@@ -153,6 +156,7 @@ public class ModuleFileIndexImpl implements ModuleFileIndex {
|
||||
return info != null && myModule.equals(info.module);
|
||||
}
|
||||
else {
|
||||
if(myExclusionManager.isExcluded(file)) return false;
|
||||
return !myFileTypeManager.isFileIgnored(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots.impl;
|
||||
|
||||
import com.intellij.injected.editor.VirtualFileWindow;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.file.exclude.ProjectFileExclusionManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -41,6 +42,7 @@ public class ProjectFileIndexImpl implements ProjectFileIndex {
|
||||
private final FileTypeManager myFileTypeManager;
|
||||
private final DirectoryIndex myDirectoryIndex;
|
||||
private final ContentFilter myContentFilter;
|
||||
private final ProjectFileExclusionManager myFileExclusionManager;
|
||||
|
||||
public ProjectFileIndexImpl(Project project, DirectoryIndex directoryIndex, FileTypeManager fileTypeManager) {
|
||||
myProject = project;
|
||||
@@ -48,6 +50,7 @@ public class ProjectFileIndexImpl implements ProjectFileIndex {
|
||||
myDirectoryIndex = directoryIndex;
|
||||
myFileTypeManager = fileTypeManager;
|
||||
myContentFilter = new ContentFilter();
|
||||
myFileExclusionManager = ProjectFileExclusionManager.getInstance(project);
|
||||
}
|
||||
|
||||
public boolean iterateContent(@NotNull ContentIterator iterator) {
|
||||
@@ -88,6 +91,7 @@ public class ProjectFileIndexImpl implements ProjectFileIndex {
|
||||
|
||||
public boolean isIgnored(@NotNull VirtualFile file) {
|
||||
if (myFileTypeManager.isFileIgnored(file)) return true;
|
||||
if (myFileExclusionManager.isExcluded(file)) return true;
|
||||
VirtualFile dir = file.isDirectory() ? file : file.getParent();
|
||||
if (dir == null) return false;
|
||||
|
||||
@@ -242,6 +246,7 @@ public class ProjectFileIndexImpl implements ProjectFileIndex {
|
||||
return info != null && info.module != null;
|
||||
}
|
||||
else {
|
||||
if (myFileExclusionManager.isExcluded(file)) return false;
|
||||
return !myFileTypeManager.isFileIgnored(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.command.undo.UndoManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.file.exclude.ProjectFileExclusionManager;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.fileTypes.*;
|
||||
@@ -63,6 +64,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
private volatile Content myContent;
|
||||
private volatile SoftReference<Document> myDocument;
|
||||
private final Language myBaseLanguage;
|
||||
private final ProjectFileExclusionManager myExclusionManager;
|
||||
|
||||
public SingleRootFileViewProvider(@NotNull PsiManager manager, @NotNull VirtualFile file) {
|
||||
this(manager, file, true);
|
||||
@@ -81,6 +83,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
myPhysical = isEventSystemEnabled() &&
|
||||
!(virtualFile instanceof LightVirtualFile) &&
|
||||
!(virtualFile.getFileSystem() instanceof DummyFileSystem);
|
||||
myExclusionManager = ProjectFileExclusionManager.getInstance(manager.getProject());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -234,6 +237,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
protected boolean isIgnored() {
|
||||
final VirtualFile file = getVirtualFile();
|
||||
if (file instanceof LightVirtualFile) return false;
|
||||
if (myExclusionManager.isExcluded(file)) return true;
|
||||
return FileTypeManager.getInstance().isFileIgnored(file);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.ide.caches.CacheUpdater;
|
||||
import com.intellij.ide.caches.FileContent;
|
||||
import com.intellij.ide.startup.StartupManagerEx;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.file.exclude.ProjectFileExclusionManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
@@ -40,12 +41,14 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple
|
||||
private final FileBasedIndex myIndex;
|
||||
private final ProjectRootManagerEx myRootManager;
|
||||
private final FileTypeManager myFileTypeManager;
|
||||
private final ProjectFileExclusionManager myExclusionManager;
|
||||
|
||||
public FileBasedIndexProjectHandler(final FileBasedIndex index, final Project project, final ProjectRootManagerEx rootManager, FileTypeManager ftManager, final ProjectManager projectManager) {
|
||||
super(project);
|
||||
myIndex = index;
|
||||
myRootManager = rootManager;
|
||||
myFileTypeManager = ftManager;
|
||||
myExclusionManager = ProjectFileExclusionManager.getInstance(project);
|
||||
|
||||
final StartupManagerEx startupManager = (StartupManagerEx)StartupManager.getInstance(project);
|
||||
if (startupManager != null) {
|
||||
@@ -73,6 +76,7 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple
|
||||
public boolean isInSet(final VirtualFile file) {
|
||||
final ProjectFileIndex index = myRootManager.getFileIndex();
|
||||
if (index.isInContent(file) || index.isInLibraryClasses(file) || index.isInLibrarySource(file)) {
|
||||
if (myExclusionManager.isExcluded(file)) return false;
|
||||
return !myFileTypeManager.isFileIgnored(file);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.openapi.fileTypes;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.CachedSingletonsRegistry;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -115,23 +114,8 @@ public abstract class FileTypeManager{
|
||||
|
||||
public abstract boolean isFileIgnored(@NonNls @NotNull String name);
|
||||
|
||||
/**
|
||||
* @param file The file to be checked.
|
||||
* @return true if the file is ignored, false otherwise.
|
||||
* @deprecated A preferred method is {@link FileTypeManager#isFileIgnored(com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile)}
|
||||
*/
|
||||
public abstract boolean isFileIgnored(@NonNls @NotNull VirtualFile file);
|
||||
|
||||
/**
|
||||
* Checkes if the file is to be ignored within a given project.
|
||||
* @param project The project containing the file to check.
|
||||
* @param file The file to to be checked.
|
||||
* @return true if the file is ignored, false otherwise.
|
||||
*/
|
||||
public boolean isFileIgnored(@Nullable Project project, @NotNull VirtualFile file) {
|
||||
return isFileIgnored(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of extensions associated with the specified file type.
|
||||
*
|
||||
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* 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.file.exclude;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public abstract class FileExclusionProvider {
|
||||
|
||||
public static ExtensionPointName<FileExclusionProvider> EP_NAME = ExtensionPointName.create("com.intellij.fileExclusionProvider");
|
||||
public static ExtensionPointName<FileExclusionProvider> PROJECT_EP_NAME =
|
||||
ExtensionPointName.create("com.intellij.projectFileExclusionProvider");
|
||||
|
||||
public boolean isFileExcluded(final VirtualFile file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isFileNameExcluded(final String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isExcluded(final @Nullable Project project, final VirtualFile file) {
|
||||
if (file.isDirectory()) return false;
|
||||
for (FileExclusionProvider exclusionProvider : Extensions.getExtensions(EP_NAME)) {
|
||||
if (exclusionProvider.isFileExcluded(file)) return true;
|
||||
}
|
||||
if (project != null) {
|
||||
for (FileExclusionProvider exclusionProvider : Extensions.getExtensions(PROJECT_EP_NAME, project)) {
|
||||
if (exclusionProvider.isFileExcluded(file)) return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Project openProject : ProjectManager.getInstance().getOpenProjects()) {
|
||||
assert openProject != null;
|
||||
if(isExcluded(openProject, file)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isExcluded (final String fileName) {
|
||||
for (FileExclusionProvider exclusionProvider : Extensions.getExtensions(EP_NAME)) {
|
||||
if (exclusionProvider.isFileNameExcluded(fileName)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-9
@@ -25,14 +25,12 @@ import com.intellij.openapi.components.ExportableApplicationComponent;
|
||||
import com.intellij.openapi.components.RoamingType;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.file.exclude.FileExclusionProvider;
|
||||
import com.intellij.openapi.fileTypes.*;
|
||||
import com.intellij.openapi.fileTypes.ex.*;
|
||||
import com.intellij.openapi.options.BaseSchemeProcessor;
|
||||
import com.intellij.openapi.options.ExternalInfo;
|
||||
import com.intellij.openapi.options.SchemesManager;
|
||||
import com.intellij.openapi.options.SchemesManagerFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -377,17 +375,12 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
}
|
||||
|
||||
public boolean isFileIgnored(@NotNull String name) {
|
||||
return myIgnoredPatterns.isIgnored(name) || FileExclusionProvider.isExcluded(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileIgnored(@Nullable Project project, @NonNls @NotNull VirtualFile file) {
|
||||
return isFileIgnored(file.getName()) || FileExclusionProvider.isExcluded(project, file);
|
||||
return myIgnoredPatterns.isIgnored(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileIgnored(@NonNls @NotNull VirtualFile file) {
|
||||
return isFileIgnored(file.getName()) || FileExclusionProvider.isExcluded(null, file);
|
||||
return isFileIgnored(file.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation"})
|
||||
|
||||
@@ -278,7 +278,6 @@
|
||||
<applicationConfigurable instance="com.intellij.codeInsight.intention.impl.config.IntentionSettingsConfigurable" id="intentions"/>
|
||||
|
||||
<!-- File Exclusions -->
|
||||
<projectFileExclusionProvider implementation="com.intellij.openapi.file.exclude.ProjectFileExclusionProvider"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.openapi.file.exclude.ProjectFileExclusionManager"
|
||||
serviceImplementation="com.intellij.openapi.file.exclude.ProjectFileExclusionManager"/>
|
||||
|
||||
@@ -44,9 +44,6 @@
|
||||
area="IDEA_PROJECT"/>
|
||||
<extensionPoint name="customFileTypeFactory" interface="com.intellij.openapi.fileTypes.ex.CustomFileTypeFactory"/>
|
||||
<extensionPoint name="fileTypeRegistrator" interface="com.intellij.ide.highlighter.FileTypeRegistrator"/>
|
||||
<extensionPoint name="fileExclusionProvider" interface="com.intellij.openapi.file.exclude.FileExclusionProvider"/>
|
||||
<extensionPoint name="projectFileExclusionProvider" interface="com.intellij.openapi.file.exclude.FileExclusionProvider"
|
||||
area="IDEA_PROJECT"/>
|
||||
|
||||
<extensionPoint name="undoProvider" interface="com.intellij.openapi.command.impl.UndoProvider"/>
|
||||
<extensionPoint name="projectUndoProvider" interface="com.intellij.openapi.command.impl.UndoProvider"
|
||||
|
||||
Reference in New Issue
Block a user