com.intellij.openapi.fileTypes
Class FileTypeManager

java.lang.Object
  extended by com.intellij.openapi.fileTypes.FileTypeManager
All Implemented Interfaces:
SettingsSavingComponent

public abstract class FileTypeManager
extends java.lang.Object
implements SettingsSavingComponent

Manages the relationship between filenames and FileType instances.


Constructor Summary
FileTypeManager()
           
 
Method Summary
abstract  void addFileTypeListener(FileTypeListener listener)
          Adds a listener for receiving notifications about changes in the list of registered file types.
abstract  void associateExtension(FileType type, java.lang.String extension)
          Adds an extension to the list of extensions associated with a file type.
abstract  java.lang.String[] getAssociatedExtensions(FileType type)
          Returns the list of extensions associated with the specified file type.
abstract  FileType getFileTypeByExtension(java.lang.String extension)
          Returns the file type for the specified extension.
abstract  FileType getFileTypeByFile(VirtualFile file)
          Returns the file type for the specified file.
abstract  FileType getFileTypeByFileName(java.lang.String fileName)
          Returns the file type for the specified file name.
static FileTypeManager getInstance()
          Returns the singleton instance of the FileTypeManager component.
abstract  FileType getKnownFileTypeOrAssociate(VirtualFile file)
          If fileName is already associated with any known file type returns it.
abstract  FileType[] getRegisteredFileTypes()
          Returns the list of all registered file types.
abstract  boolean isFileIgnored(java.lang.String name)
          Checks if the specified file is ignored by IDEA.
abstract  void registerFileType(FileType type, java.lang.String[] defaultAssociatedExtensions)
          Registers a file type.
abstract  void removeAssociatedExtension(FileType type, java.lang.String extension)
          Removes an extension from the list of extensions associated with a file type.
abstract  void removeFileTypeListener(FileTypeListener listener)
          Removes a listener for receiving notifications about changes in the list of registered file types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.intellij.openapi.components.SettingsSavingComponent
save
 

Constructor Detail

FileTypeManager

public FileTypeManager()
Method Detail

getInstance

public static FileTypeManager getInstance()
Returns the singleton instance of the FileTypeManager component.

Returns:
the instace of FileTypeManager

registerFileType

public abstract void registerFileType(@NotNull
                                      FileType type,
                                      @Nullable
                                      java.lang.String[] defaultAssociatedExtensions)
Registers a file type.

Parameters:
type - The file type to register.
defaultAssociatedExtensions - The list of extensions which cause the file to be treated as the specified file type. The extensions should not start with '.'.

getFileTypeByFileName

@NotNull
public abstract FileType getFileTypeByFileName(@NotNull
                                                       java.lang.String fileName)
Returns the file type for the specified file name.

Parameters:
fileName - The file name for which the type is requested.
Returns:
The file type instance.

getFileTypeByFile

@NotNull
public abstract FileType getFileTypeByFile(@NotNull
                                                   VirtualFile file)
Returns the file type for the specified file.

Parameters:
file - The file for which the type is requested.
Returns:
The file type instance.

getFileTypeByExtension

@NotNull
public abstract FileType getFileTypeByExtension(@NotNull
                                                        java.lang.String extension)
Returns the file type for the specified extension.

Parameters:
extension - The extension for which the file type is requested, not including the leading '.'.
Returns:
The file type instance.

getRegisteredFileTypes

public abstract FileType[] getRegisteredFileTypes()
Returns the list of all registered file types.

Returns:
The list of file types.

isFileIgnored

public abstract boolean isFileIgnored(@NotNull
                                      java.lang.String name)
Checks if the specified file is ignored by IDEA. Ignored files are not visible in different project views and cannot be opened in the editor. They will neither be parsed nor compiled.

Parameters:
name - The name of the file to check.
Returns:
true if the file is ignored, false otherwise.

getAssociatedExtensions

public abstract java.lang.String[] getAssociatedExtensions(FileType type)
Returns the list of extensions associated with the specified file type.

Parameters:
type - The file type for which the extensions are requested.
Returns:
The array of extensions associated with the file type.

addFileTypeListener

public abstract void addFileTypeListener(FileTypeListener listener)
Adds a listener for receiving notifications about changes in the list of registered file types.

Parameters:
listener - The listener instance.

removeFileTypeListener

public abstract void removeFileTypeListener(FileTypeListener listener)
Removes a listener for receiving notifications about changes in the list of registered file types.

Parameters:
listener - The listener instance.

getKnownFileTypeOrAssociate

@NotNull
public abstract FileType getKnownFileTypeOrAssociate(VirtualFile file)
If fileName is already associated with any known file type returns it. Otherwise asks user to select file type and associates it with fileName extension if any selected.

Returns:
Known file type or null. Never returns StdFileTypes.UNKNOWN.

associateExtension

public abstract void associateExtension(FileType type,
                                        java.lang.String extension)
Adds an extension to the list of extensions associated with a file type.

Parameters:
type - the file type to associate the extension with.
extension - the extension to associate.
Since:
5.0.2

removeAssociatedExtension

public abstract void removeAssociatedExtension(FileType type,
                                               java.lang.String extension)
Removes an extension from the list of extensions associated with a file type.

Parameters:
type - the file type to remove the extension from.
extension - the extension to remove.
Since:
5.0.2