Java Code Examples for com.intellij.openapi.fileTypes.FileTypeManager#getFileTypeByFileName()
The following examples show how to use
com.intellij.openapi.fileTypes.FileTypeManager#getFileTypeByFileName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeAssociationFix.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@Override public void invoke(@NotNull final Project project, Editor editor, PsiFile psiFile) throws IncorrectOperationException { FileTypeManager manager = FileTypeManager.getInstance(); FileType type = manager.getFileTypeByFileName(psiFile.getName()); // Remove the BUILD file matcher from the wrong type then add it to PythonFileType for (FileNameMatcher matcher : manager.getAssociations(type)) { if (matcher.acceptsCharSequence(psiFile.getName())) { manager.removeAssociation(type, matcher); } } }
Example 2
Source File: LocalFilePath.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public FileType getFileType() { VirtualFile file = getVirtualFile(); FileTypeManager manager = FileTypeManager.getInstance(); return file != null ? manager.getFileTypeByFile(file) : manager.getFileTypeByFileName(getName()); }
Example 3
Source File: PsiVFSListener.java From consulo with Apache License 2.0 | 5 votes |
@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); }