mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
isFileOfType(): add javadoc, run detectors when asked about PlainTextFileType (IDEA-CR-48346)
GitOrigin-RevId: a70ba89a9b352ca4e968259feb4e57872344286d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2e9b4a9914
commit
3a0661d33d
@@ -32,6 +32,13 @@ public abstract class FileTypeRegistry {
|
||||
|
||||
public abstract boolean isFileIgnored(@NotNull VirtualFile file);
|
||||
|
||||
/**
|
||||
* Checks if the given file has the given file type. This is faster than getting the file type
|
||||
* and comparing it, because for file types that are identified by virtual file, it will only
|
||||
* check if the given file type matches, and will not run other detectors. However, this can
|
||||
* lead to inconsistent results if two file types report the same file as matching (which should
|
||||
* generally be avoided).
|
||||
*/
|
||||
public abstract boolean isFileOfType(@NotNull VirtualFile file, @NotNull FileType type);
|
||||
|
||||
@Nullable
|
||||
|
||||
+5
-2
@@ -996,9 +996,12 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
|
||||
@Override
|
||||
public boolean isFileOfType(@NotNull VirtualFile file, @NotNull FileType type) {
|
||||
if (type instanceof UnknownFileType) {
|
||||
if (type.equals(PlainTextFileType.INSTANCE) || type.equals(UnknownFileType.INSTANCE)) {
|
||||
// a file has unknown file type if none of file type detectors matched it
|
||||
return file.getFileType() instanceof UnknownFileType;
|
||||
// for plain text file type, we run file type detection based on content
|
||||
|
||||
//noinspection SSBasedInspection
|
||||
return file.getFileType().equals(type);
|
||||
}
|
||||
|
||||
if (file instanceof LightVirtualFile) {
|
||||
|
||||
Reference in New Issue
Block a user