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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations