mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FileTypeManager#isFileIgnored(VirtualFile)
This commit is contained in:
@@ -300,7 +300,7 @@ final class ThumbnailViewUI extends JPanel implements DataProvider, Disposable {
|
||||
ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
|
||||
boolean projectIgnored = rootManager.getFileIndex().isIgnored(file);
|
||||
|
||||
if (!projectIgnored && !FileTypeManager.getInstance().isFileIgnored(file.getName())) {
|
||||
if (!projectIgnored && !FileTypeManager.getInstance().isFileIgnored(file)) {
|
||||
ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
|
||||
if (file.isDirectory()) {
|
||||
if (thumbnailView.isRecursive()) {
|
||||
|
||||
@@ -141,7 +141,7 @@ public class ModuleChunkSourcepath extends CompositeGenerator{
|
||||
}
|
||||
|
||||
private void addExcludePatterns(Module module, final VirtualFile root, VirtualFile dir, CompositeGenerator generator, final boolean parentIncluded) {
|
||||
if (FileTypeManager.getInstance().isFileIgnored(dir.getName())) {
|
||||
if (FileTypeManager.getInstance().isFileIgnored(dir)) {
|
||||
// ignored files are handled by global 'ignored' patternset
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -939,7 +939,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
|
||||
new Object() {
|
||||
void processFile(VirtualFile file) {
|
||||
if (fileTypeManager.isFileIgnored(file.getName())) {
|
||||
if (fileTypeManager.isFileIgnored(file)) {
|
||||
return;
|
||||
}
|
||||
final int fileId = getFileId(file);
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public abstract class IncrementalCompilerInstructionCreatorBase implements Incre
|
||||
if (children != null) {
|
||||
for (VirtualFile child : children) {
|
||||
if (copyExcluded) {
|
||||
if (fileTypeManager.isFileIgnored(child.getName())) continue;
|
||||
if (fileTypeManager.isFileIgnored(child)) continue;
|
||||
}
|
||||
else {
|
||||
if (index.isIgnored(child)) continue;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class JavaUtilForVfs {
|
||||
}
|
||||
FileTypeManager typeManager = FileTypeManager.getInstance();
|
||||
final String dirName = dir.getName();
|
||||
if (typeManager.isFileIgnored(dirName) || StringUtil.startsWithIgnoreCase(dirName, "testdata")) {
|
||||
if (typeManager.isFileIgnored(dir) || StringUtil.startsWithIgnoreCase(dirName, "testdata")) {
|
||||
return;
|
||||
}
|
||||
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
|
||||
@@ -89,7 +89,7 @@ public class TreeViewUtil {
|
||||
int subpackagesCount = 0;
|
||||
int directoriesCount = 0;
|
||||
for (VirtualFile file : files) {
|
||||
if (FileTypeManager.getInstance().isFileIgnored(file.getName())) continue;
|
||||
if (FileTypeManager.getInstance().isFileIgnored(file)) continue;
|
||||
if (!file.isDirectory()) return false;
|
||||
PsiDirectory childDir = manager.findDirectory(file);
|
||||
if (childDir != null) {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class FileIndexUtil {
|
||||
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
|
||||
if (file.isDirectory()) return false;
|
||||
if (fileTypeManager.getFileTypeByFile(file) != StdFileTypes.JAVA) return false;
|
||||
if (fileTypeManager.isFileIgnored(file.getName())) return false;
|
||||
if (fileTypeManager.isFileIgnored(file)) return false;
|
||||
return ProjectRootManager.getInstance(project).getFileIndex().isInSource(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class CommonRefactoringUtil {
|
||||
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
|
||||
if (children != null) {
|
||||
for (VirtualFile virtualFile : children) {
|
||||
if (fileTypeManager.isFileIgnored(virtualFile.getName())) continue;
|
||||
if (fileTypeManager.isFileIgnored(virtualFile)) continue;
|
||||
addVirtualFiles(virtualFile, list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ public class FindInProjectUtil {
|
||||
final VirtualFileFilter contentFilter = new VirtualFileFilter() {
|
||||
public boolean accept(final VirtualFile file) {
|
||||
if (file.isDirectory()) return true;
|
||||
if (fileTypeManager.isFileIgnored(file.getName()) || fileTypeManager.getFileTypeByFile(file).isBinary()) return false;
|
||||
if (fileTypeManager.isFileIgnored(file) || fileTypeManager.getFileTypeByFile(file).isBinary()) return false;
|
||||
return searchScope.contains(file);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -338,7 +338,7 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Expo
|
||||
LOG.debug("FileTemplateManagerImpl.loadTemplates() reading default templates...");
|
||||
// Read default templates
|
||||
for (VirtualFile file : defaultTemplates) {
|
||||
if(FileTypeManagerEx.getInstance().isFileIgnored(file.getName())) continue;
|
||||
if(FileTypeManagerEx.getInstance().isFileIgnored(file)) continue;
|
||||
String name = file.getName(); //name.extension.ft , e.g. "NewClass.java.ft"
|
||||
@NonNls String extension = myTypeManager.getExtension(name);
|
||||
name = name.substring(0, name.length() - extension.length() - 1); //name="NewClass.java" extension="ft"
|
||||
|
||||
@@ -257,7 +257,7 @@ public class DeleteHandler {
|
||||
* Fills readOnlyFiles with VirtualFiles
|
||||
*/
|
||||
private static void getReadOnlyVirtualFiles(VirtualFile file, ArrayList<VirtualFile> readOnlyFiles, final FileTypeManager ftManager) {
|
||||
if (ftManager.isFileIgnored(file.getName())) return;
|
||||
if (ftManager.isFileIgnored(file)) return;
|
||||
if (!file.isWritable()) {
|
||||
readOnlyFiles.add(file);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class DirectoryIndexImpl extends DirectoryIndex implements ProjectCompone
|
||||
}
|
||||
|
||||
private static boolean isIgnored(@NotNull VirtualFile f) {
|
||||
return FileTypeManager.getInstance().isFileIgnored(f.getName());
|
||||
return FileTypeManager.getInstance().isFileIgnored(f);
|
||||
}
|
||||
|
||||
public DirectoryInfo getInfoForDirectory(VirtualFile dir) {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ModuleFileIndexImpl implements ModuleFileIndex {
|
||||
public boolean isContentJavaSourceFile(@NotNull VirtualFile file) {
|
||||
return !file.isDirectory()
|
||||
&& myFileTypeManager.getFileTypeByFile(file) == StdFileTypes.JAVA
|
||||
&& !myFileTypeManager.isFileIgnored(file.getName())
|
||||
&& !myFileTypeManager.isFileIgnored(file)
|
||||
&& isInSourceContent(file);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class ModuleFileIndexImpl implements ModuleFileIndex {
|
||||
return info != null && myModule.equals(info.module);
|
||||
}
|
||||
else {
|
||||
return !myFileTypeManager.isFileIgnored(file.getName());
|
||||
return !myFileTypeManager.isFileIgnored(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
|
||||
package com.intellij.openapi.roots.impl;
|
||||
|
||||
import com.intellij.ide.startup.StartupManagerEx;
|
||||
import com.intellij.injected.editor.VirtualFileWindow;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ContentIterator;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
@@ -89,7 +87,7 @@ public class ProjectFileIndexImpl implements ProjectFileIndex {
|
||||
}
|
||||
|
||||
public boolean isIgnored(@NotNull VirtualFile file) {
|
||||
if (myFileTypeManager.isFileIgnored(file.getName())) return true;
|
||||
if (myFileTypeManager.isFileIgnored(file)) return true;
|
||||
VirtualFile dir = file.isDirectory() ? file : file.getParent();
|
||||
if (dir == null) return false;
|
||||
|
||||
@@ -157,14 +155,14 @@ public class ProjectFileIndexImpl implements ProjectFileIndex {
|
||||
public boolean isContentJavaSourceFile(@NotNull VirtualFile file) {
|
||||
if (file.isDirectory()) return false;
|
||||
if (myFileTypeManager.getFileTypeByFile(file) != StdFileTypes.JAVA) return false;
|
||||
if (myFileTypeManager.isFileIgnored(file.getName())) return false;
|
||||
if (myFileTypeManager.isFileIgnored(file)) return false;
|
||||
return isInSourceContent(file);
|
||||
}
|
||||
|
||||
public boolean isLibraryClassFile(@NotNull VirtualFile file) {
|
||||
if (file.isDirectory()) return false;
|
||||
if (myFileTypeManager.getFileTypeByFile(file) != StdFileTypes.CLASS) return false;
|
||||
if (myFileTypeManager.isFileIgnored(file.getName())) return false;
|
||||
if (myFileTypeManager.isFileIgnored(file)) return false;
|
||||
VirtualFile parent = file.getParent();
|
||||
DirectoryInfo parentInfo = getInfoForDirectory(parent);
|
||||
return parentInfo != null && parentInfo.libraryClassRoot != null;
|
||||
@@ -244,7 +242,7 @@ public class ProjectFileIndexImpl implements ProjectFileIndex {
|
||||
return info != null && info.module != null;
|
||||
}
|
||||
else {
|
||||
return !myFileTypeManager.isFileIgnored(file.getName());
|
||||
return !myFileTypeManager.isFileIgnored(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,8 +234,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
protected boolean isIgnored() {
|
||||
final VirtualFile file = getVirtualFile();
|
||||
if (file instanceof LightVirtualFile) return false;
|
||||
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
|
||||
return fileTypeManager.isFileIgnored(file.getName());
|
||||
return FileTypeManager.getInstance().isFileIgnored(file);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -47,7 +47,7 @@ public class CheckUtil {
|
||||
}
|
||||
|
||||
public static void checkDelete(VirtualFile file) throws IncorrectOperationException{
|
||||
if (FileTypeManager.getInstance().isFileIgnored(file.getName())) return;
|
||||
if (FileTypeManager.getInstance().isFileIgnored(file)) return;
|
||||
if (!file.isWritable()) {
|
||||
throw new IncorrectOperationException(PsiBundle.message("cannot.delete.a.read.only.file", file.getPresentableUrl()));
|
||||
}
|
||||
|
||||
@@ -878,7 +878,7 @@ public class FileManagerImpl implements FileManager {
|
||||
if (vFile.isDirectory()) {
|
||||
PsiDirectory psiDir = myVFileToPsiDirMap.get(vFile);
|
||||
if (psiDir != null) {
|
||||
if (myFileTypeManager.isFileIgnored(vFile.getName())) {
|
||||
if (myFileTypeManager.isFileIgnored(vFile)) {
|
||||
removeFilesAndDirsRecursively(vFile);
|
||||
|
||||
treeEvent.setChild(psiDir);
|
||||
@@ -957,7 +957,7 @@ public class FileManagerImpl implements FileManager {
|
||||
final PsiDirectory oldParentDir = findDirectory(event.getOldParent());
|
||||
final PsiDirectory newParentDir = findDirectory(event.getNewParent());
|
||||
if (oldParentDir == null && newParentDir == null) return;
|
||||
if (myFileTypeManager.isFileIgnored(vFile.getName())) return;
|
||||
if (myFileTypeManager.isFileIgnored(vFile)) return;
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new ExternalChangeAction() {
|
||||
|
||||
@@ -73,7 +73,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)) {
|
||||
return !myFileTypeManager.isFileIgnored(file.getName());
|
||||
return !myFileTypeManager.isFileIgnored(file);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class IdeaGateway {
|
||||
if (ProjectRootManager.getInstance(each).getFileIndex().isIgnored(f)) return false;
|
||||
}
|
||||
|
||||
return !FileTypeManager.getInstance().isFileIgnored(fileName);
|
||||
return !FileTypeManager.getInstance().isFileIgnored(f);
|
||||
}
|
||||
|
||||
public boolean areContentChangesVersioned(VirtualFile f) {
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ public class FileChooserDescriptor implements Cloneable{
|
||||
}
|
||||
|
||||
// do not include ignored files
|
||||
if (isHideIgnored() && FileTypeManager.getInstance().isFileIgnored(file.getName())) {
|
||||
if (isHideIgnored() && FileTypeManager.getInstance().isFileIgnored(file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,8 @@ public abstract class FileTypeManager{
|
||||
|
||||
public abstract boolean isFileIgnored(@NonNls @NotNull String name);
|
||||
|
||||
public abstract boolean isFileIgnored(@NonNls @NotNull VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the list of extensions associated with the specified file type.
|
||||
*
|
||||
|
||||
@@ -62,6 +62,11 @@ class MockFileTypeManager extends FileTypeManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileIgnored(@NonNls @NotNull VirtualFile file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getAssociatedExtensions(@NotNull FileType type) {
|
||||
|
||||
@@ -696,7 +696,7 @@ public class VfsUtil {
|
||||
final FileTypeManager ftm = FileTypeManager.getInstance();
|
||||
processFilesRecursively(root, processor, new Convertor<VirtualFile, Boolean>() {
|
||||
public Boolean convert(final VirtualFile vf) {
|
||||
return ! ftm.isFileIgnored(vf.getName());
|
||||
return ! ftm.isFileIgnored(vf);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class PruneEmptyDirectoriesAction extends AnAction {
|
||||
|
||||
private static void pruneEmptiesIn(final VirtualFile file, FileTypeManager ftManager) throws IOException {
|
||||
if (file.isDirectory()) {
|
||||
if (ftManager.isFileIgnored(file.getName())) return;
|
||||
if (ftManager.isFileIgnored(file)) return;
|
||||
|
||||
for (VirtualFile child : file.getChildren()) {
|
||||
pruneEmptiesIn(child, ftManager);
|
||||
|
||||
+5
@@ -411,6 +411,11 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileIgnored(@NonNls @NotNull VirtualFile file) {
|
||||
return isFileIgnored(file.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation"})
|
||||
@NotNull
|
||||
public String[] getAssociatedExtensions(@NotNull FileType type) {
|
||||
|
||||
+1
-1
@@ -466,7 +466,7 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
}
|
||||
|
||||
private static boolean isInContent(VirtualFile file) {
|
||||
return file == null || !FileTypeManager.getInstance().isFileIgnored(file.getName());
|
||||
return file == null || !FileTypeManager.getInstance().isFileIgnored(file);
|
||||
}
|
||||
|
||||
private static DirectoryContent getDirectoryContent(VirtualFile directory, final Runnable checkCanceled) {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class VfsSamplePlugin implements ProjectComponent {
|
||||
private static boolean updateCount(VirtualFile file, int increase) {
|
||||
|
||||
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
|
||||
if (!fileTypeManager.isFileIgnored(file.getName())
|
||||
if (!fileTypeManager.isFileIgnored(file)
|
||||
&& fileTypeManager.getFileTypeByFile(file) == StdFileTypes.JAVA) {
|
||||
ourJavaFilesCount += increase;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user