public class FileTypeManagerImpl extends FileTypeManagerEx implements PersistentStateComponent<Element>, Disposable
FileTypeRegistry.FileTypeDetector
Disposable.Parent
TOPIC
ourInstanceGetter
Constructor and Description |
---|
FileTypeManagerImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addFileTypeListener(FileTypeListener listener)
Adds a listener for receiving notifications about changes in the list of
registered file types.
|
void |
associate(FileType type,
FileNameMatcher matcher) |
void |
associate(FileType fileType,
FileNameMatcher matcher,
boolean fireChange) |
void |
dispose()
Usually not invoked directly, see class javadoc.
|
void |
drainReDetectQueue() |
LanguageFileType |
findFileTypeByLanguage(Language language) |
FileType |
findFileTypeByName(java.lang.String fileTypeName)
Finds a file type with the specified name.
|
void |
fireBeforeFileTypesChanged() |
void |
fireFileTypesChanged() |
void |
freezeFileTypeTemporarilyIn(VirtualFile file,
java.lang.Runnable runnable) |
java.lang.String [] |
getAssociatedExtensions(FileType type)
Returns the list of extensions associated with the specified file type.
|
java.util.List<FileNameMatcher> |
getAssociations(FileType type) |
FileType |
getByFile(VirtualFile file) |
java.lang.String |
getExtension(java.lang.String fileName) |
FileType |
getFileTypeByExtension(java.lang.String extension)
Returns the file type for the specified extension.
|
FileType |
getFileTypeByFile(VirtualFile file)
Returns the file type for the specified file.
|
FileType |
getFileTypeByFile(VirtualFile file,
byte [] content)
Returns the file type for the specified file.
|
FileType |
getFileTypeByFileName(java.lang.CharSequence fileName)
Returns the file type for the specified file name.
|
FileType |
getFileTypeByFileName(java.lang.String fileName)
Same as FileTypeRegistry.getFileTypeByFileName(CharSequence) but receives String parameter.
|
java.lang.String |
getIgnoredFilesList()
Returns the semicolon-delimited list of patterns for files and folders
which are excluded from the project structure though they may be present
physically on disk.
|
FileType |
getKnownFileTypeOrAssociate(VirtualFile file)
If file is already associated with any known file type returns it.
|
FileType |
getKnownFileTypeOrAssociate(VirtualFile file,
Project project) |
FileType [] |
getRegisteredFileTypes()
Returns the list of all registered file types.
|
Element |
getState() |
FileType |
getStdFileType(java.lang.String name) |
void |
initializeComponent()
If class also is a component, then this method will be called after loading state (even if not state) but only once throughout the life cycle
|
boolean |
isFileIgnored(java.lang.String name)
Checks if the specified file is ignored by the IDE.
|
boolean |
isFileIgnored(VirtualFile file) |
boolean |
isIgnoredFilesListEqualToCurrent(java.lang.String list) |
void |
loadState(Element state)
This method is called when new component state is loaded.
|
protected byte |
readFlagsFromCache(VirtualFile file) |
void |
registerFileType(FileType fileType)
Deprecated.
|
void |
registerFileType(FileType type,
java.util.List<? extends FileNameMatcher> defaultAssociations) |
void |
removeAssociation(FileType type,
FileNameMatcher matcher) |
void |
removeAssociation(FileType fileType,
FileNameMatcher matcher,
boolean fireChange) |
void |
removeFileTypeListener(FileTypeListener listener)
Removes a listener for receiving notifications about changes in the list of
registered file types.
|
void |
setIgnoredFilesList(java.lang.String list)
Sets new list of semicolon-delimited patterns for files and folders which
are excluded from the project structure.
|
void |
unregisterFileType(FileType fileType) |
protected void |
writeFlagsToCache(VirtualFile file,
int flags) |
getInstanceEx
associateExtension, associatePattern, getInstance, parseFromString, registerFileType, removeAssociatedExtension
isFileOfType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
noStateLoaded
public void drainReDetectQueue()
public FileType getStdFileType(java.lang.String name)
getStdFileType
in class FileTypeManager
public void initializeComponent()
PersistentStateComponent
initializeComponent
in interface PersistentStateComponent<Element>
public FileType getFileTypeByFileName(java.lang.String fileName)
FileTypeRegistry
getFileTypeByFileName
in class FileTypeRegistry
public FileType getFileTypeByFileName(java.lang.CharSequence fileName)
FileTypeRegistry
getFileTypeByFileName
in class FileTypeRegistry
fileName
- The file name for which the type is requested.FileTypes.UNKNOWN
if not found.public void freezeFileTypeTemporarilyIn(VirtualFile file, java.lang.Runnable runnable)
public FileType getFileTypeByFile(VirtualFile file)
FileTypeRegistry
getFileTypeByFile
in class FileTypeRegistry
file
- The file for which the type is requested.public FileType getFileTypeByFile(VirtualFile file, byte [] content)
FileTypeRegistry
getFileTypeByFile
in class FileTypeRegistry
file
- The file for which the type is requested.content
- Content of the file (if already available, to avoid reading from disk again)public FileType getByFile(VirtualFile file)
protected byte readFlagsFromCache(VirtualFile file)
protected void writeFlagsToCache(VirtualFile file, int flags)
public FileType findFileTypeByName(java.lang.String fileTypeName)
FileTypeRegistry
findFileTypeByName
in class FileTypeRegistry
public LanguageFileType findFileTypeByLanguage(Language language)
findFileTypeByLanguage
in class FileTypeRegistry
public FileType getFileTypeByExtension(java.lang.String extension)
FileTypeRegistry
FileTypeRegistry.getFileTypeByFile(VirtualFile)
getFileTypeByExtension
in class FileTypeRegistry
extension
- The extension for which the file type is requested, not including the leading '.'.UnknownFileType.INSTANCE
if corresponding file type not found@Deprecated public void registerFileType(FileType fileType)
registerFileType
in class FileTypeManagerEx
public void registerFileType(FileType type, java.util.List<? extends FileNameMatcher> defaultAssociations)
registerFileType
in class FileTypeManager
public void unregisterFileType(FileType fileType)
unregisterFileType
in class FileTypeManagerEx
public FileType [] getRegisteredFileTypes()
FileTypeRegistry
getRegisteredFileTypes
in class FileTypeRegistry
public java.lang.String getExtension(java.lang.String fileName)
getExtension
in class FileTypeManagerEx
public java.lang.String getIgnoredFilesList()
FileTypeManager
getIgnoredFilesList
in class FileTypeManager
public void setIgnoredFilesList(java.lang.String list)
FileTypeManager
setIgnoredFilesList
in class FileTypeManager
list
- List of semicolon-delimited patterns.public boolean isIgnoredFilesListEqualToCurrent(java.lang.String list)
isIgnoredFilesListEqualToCurrent
in class FileTypeManagerEx
public boolean isFileIgnored(java.lang.String name)
FileTypeManager
isFileIgnored
in class FileTypeManager
name
- The name of the file to check.true
if the file is ignored, false
otherwise.public boolean isFileIgnored(VirtualFile file)
isFileIgnored
in class FileTypeRegistry
public java.lang.String [] getAssociatedExtensions(FileType type)
FileTypeManager
getAssociatedExtensions
in class FileTypeManager
type
- The file type for which the extensions are requested.public java.util.List<FileNameMatcher> getAssociations(FileType type)
getAssociations
in class FileTypeManager
public void associate(FileType type, FileNameMatcher matcher)
associate
in class FileTypeManager
public void removeAssociation(FileType type, FileNameMatcher matcher)
removeAssociation
in class FileTypeManager
public void fireBeforeFileTypesChanged()
fireBeforeFileTypesChanged
in class FileTypeManagerEx
public void fireFileTypesChanged()
fireFileTypesChanged
in class FileTypeManagerEx
public void addFileTypeListener(FileTypeListener listener)
FileTypeManager
addFileTypeListener
in class FileTypeManager
listener
- The listener instance.public void removeFileTypeListener(FileTypeListener listener)
FileTypeManager
removeFileTypeListener
in class FileTypeManager
listener
- The listener instance.public void loadState(Element state)
PersistentStateComponent
State object should be used directly, defensive copying is not required.
loadState
in interface PersistentStateComponent<Element>
state
- loaded component stateXmlSerializerUtil.copyBean(Object, Object)
public Element getState()
getState
in interface PersistentStateComponent<Element>
null
value indicates
that the returned state won't be stored, as a result previously stored state will be used.XmlSerializer
public void associate(FileType fileType, FileNameMatcher matcher, boolean fireChange)
public void removeAssociation(FileType fileType, FileNameMatcher matcher, boolean fireChange)
public FileType getKnownFileTypeOrAssociate(VirtualFile file)
FileTypeManager
getKnownFileTypeOrAssociate
in class FileTypeManager
file
- file to ask for file type associationnull
. Never returns FileTypes.UNKNOWN
.public FileType getKnownFileTypeOrAssociate(VirtualFile file, Project project)
getKnownFileTypeOrAssociate
in class FileTypeManager
public void dispose()
Disposable
dispose
in interface Disposable