Determine file type based on content

Is there a way to determine file type based on content?
I have a plugin were one file name can have two diffrent content types and I want to detect it's content and then assosiate it with a file type.
I've tried to look at fileTypeDetector extension point, but haven't found any documentation on it.

1 comment
Comment actions Permalink

Not sure about `fileTypeDetector` extension point, because it allows to determine file type for unrecognized files only.
This extension point gets called in `FileTypeManagerImpl.detectFromContentAndCache`:
https://github.com/JetBrains/intellij-community/blob/54f41430afc7ac0e7f955e4b6fd1ec834ac6570f/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java#L732

Perhaps `com.intellij.psi.LanguageSubstitutor` extension point could help you.

0

Please sign in to leave a comment.