mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
versions for file type detectors + usage of them for file type index
This commit is contained in:
@@ -102,5 +102,7 @@ public abstract class FileTypeRegistry {
|
||||
*/
|
||||
@Nullable
|
||||
FileType detect(@NotNull VirtualFile file, @NotNull ByteSequence firstBytes, @Nullable CharSequence firstCharsIfText);
|
||||
|
||||
int getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.search;
|
||||
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeRegistry;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
@@ -87,6 +88,11 @@ public class FileTypeIndex extends ScalarIndexExtension<FileType>
|
||||
for (FileType type : types) {
|
||||
version += type.getName().hashCode();
|
||||
}
|
||||
|
||||
version *= 31;
|
||||
for (FileTypeRegistry.FileTypeDetector detector : Extensions.getExtensions(FileTypeRegistry.FileTypeDetector.EP_NAME)) {
|
||||
version += detector.getVersion();
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,4 +36,9 @@ public class GroovyHashBangFileTypeDetector implements FileTypeRegistry.FileType
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,9 @@ public class PyFileTypeDetector implements FileTypeRegistry.FileTypeDetector {
|
||||
public FileType detect(@NotNull VirtualFile file, @NotNull ByteSequence firstBytes, @Nullable CharSequence firstCharsIfText) {
|
||||
return FileUtil.isHashBangLine(firstCharsIfText, "python") ? PythonFileType.INSTANCE : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user