Search in sources :

Example 6 with FileTypeManager

use of com.intellij.openapi.fileTypes.FileTypeManager in project intellij-community by JetBrains.

the class PsiVFSListener method createFileCopyWithNewName.

@Nullable
private PsiFile createFileCopyWithNewName(VirtualFile vFile, String name) {
    // TODO[ik] remove this. Event handling and generation must be in view providers mechanism since we
    // need to track changes in _all_ psi views (e.g. namespace changes in XML)
    final FileTypeManager instance = FileTypeManager.getInstance();
    if (instance.isFileIgnored(name))
        return null;
    final FileType fileTypeByFileName = instance.getFileTypeByFileName(name);
    final Document document = FileDocumentManager.getInstance().getDocument(vFile);
    return PsiFileFactory.getInstance(myManager.getProject()).createFileFromText(name, fileTypeByFileName, document != null ? document.getCharsSequence() : "", vFile.getModificationStamp(), true, false);
}
Also used : FileType(com.intellij.openapi.fileTypes.FileType) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager) Document(com.intellij.openapi.editor.Document) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with FileTypeManager

use of com.intellij.openapi.fileTypes.FileTypeManager in project intellij-community by JetBrains.

the class FileIndexUtil method isJavaSourceFile.

public static boolean isJavaSourceFile(@NotNull Project project, @NotNull VirtualFile file) {
    FileTypeManager fileTypeManager = FileTypeManager.getInstance();
    if (file.isDirectory() || file.getFileType() != StdFileTypes.JAVA || fileTypeManager.isFileIgnored(file)) {
        return false;
    }
    ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    return fileIndex.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || fileIndex.isInLibrarySource(file);
}
Also used : FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager)

Example 8 with FileTypeManager

use of com.intellij.openapi.fileTypes.FileTypeManager in project buck by facebook.

the class BuckModuleTest method initBuckModule.

public Project initBuckModule() {
    Extensions.registerAreaClass("IDEA_PROJECT", null);
    MockDisposable mockDisposable = new MockDisposable();
    MockProjectEx project = new MockProjectEx(mockDisposable);
    MockApplication application = new MockApplicationEx(mockDisposable);
    ApplicationManager.setApplication(application, mockDisposable);
    application.registerService(UISettings.class, UISettings.getShadowInstance());
    application.registerService(PropertiesComponent.class, new ProjectPropertiesComponentImpl());
    FileTypeManager fileTypeManager = EasyMock.createMock(FileTypeManager.class);
    EasyMock.expect(fileTypeManager.getFileTypeByFileName(BuckFileType.INSTANCE.getDefaultExtension())).andReturn(BuckFileType.INSTANCE).times(3);
    EasyMock.replay(fileTypeManager);
    application.registerService(FileTypeManager.class, fileTypeManager);
    project.addComponent(PsiDocumentManager.class, EasyMock.createMock(PsiDocumentManager.class));
    return project;
}
Also used : MockApplicationEx(com.intellij.mock.MockApplicationEx) MockApplication(com.intellij.mock.MockApplication) MockDisposable(com.facebook.buck.intellij.ideabuck.test.util.MockDisposable) ProjectPropertiesComponentImpl(com.intellij.ide.util.ProjectPropertiesComponentImpl) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager) MockProjectEx(com.intellij.mock.MockProjectEx) PsiDocumentManager(com.intellij.psi.PsiDocumentManager)

Example 9 with FileTypeManager

use of com.intellij.openapi.fileTypes.FileTypeManager in project intellij-community by JetBrains.

the class IgnoredFileFilter method accept.

public boolean accept(File file) {
    final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
    final String name = file.getName();
    return !fileTypeManager.isFileIgnored(name) && fileTypeManager.getFileTypeByFileName(name) != StdFileTypes.IDEA_PROJECT && fileTypeManager.getFileTypeByFileName(name) != StdFileTypes.IDEA_MODULE && fileTypeManager.getFileTypeByFileName(name) != StdFileTypes.IDEA_WORKSPACE;
}
Also used : FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager)

Example 10 with FileTypeManager

use of com.intellij.openapi.fileTypes.FileTypeManager in project intellij-community by JetBrains.

the class TranslatingCompilerFilesMonitor method isIgnoredOrUnderIgnoredDirectory.

private static boolean isIgnoredOrUnderIgnoredDirectory(final VirtualFile file) {
    if (isIgnoredByBuild(file)) {
        return true;
    }
    final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
    VirtualFile current = file.getParent();
    while (current != null) {
        if (fileTypeManager.isFileIgnored(current)) {
            return true;
        }
        current = current.getParent();
    }
    return false;
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager)

Aggregations

FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)21 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 VirtualFileVisitor (com.intellij.openapi.vfs.VirtualFileVisitor)5 NotNull (org.jetbrains.annotations.NotNull)5 FileType (com.intellij.openapi.fileTypes.FileType)4 Result (com.intellij.openapi.application.Result)3 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)3 IOException (java.io.IOException)3 Nullable (org.jetbrains.annotations.Nullable)3 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 Project (com.intellij.openapi.project.Project)2 VfsUtilCore (com.intellij.openapi.vfs.VfsUtilCore)2 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 MockDisposable (com.facebook.buck.intellij.ideabuck.test.util.MockDisposable)1 HashMultiset (com.google.common.collect.HashMultiset)1 Multiset (com.google.common.collect.Multiset)1 FindBundle (com.intellij.find.FindBundle)1 FindModel (com.intellij.find.FindModel)1 FindInProjectManager (com.intellij.find.findInProject.FindInProjectManager)1