IDEA-320457: add support for FileTypeStrategy to FileTypeInputFilterPredicate and restore legacy behavior of ruby, html and json indexers

behavior was unintentionally changed in one of the previous commits which migrated these indexers to indexing hint API. Originally these indexers were checking file type before substitution. After migration these indexers check file type after substitution. In most cases these file types are the same, so this change went unnoticed. Now (after this commit) these indexers check file type before substitution (as it was before migration).

GitOrigin-RevId: 4e657675fba588df5d2cc8dac89f45c8c1d61c31
This commit is contained in:
Andrei.Kuznetsov
2023-05-30 21:14:46 +02:00
committed by intellij-monorepo-bot
parent 329180b4a2
commit ea331c4995
3 changed files with 16 additions and 3 deletions

View File

@@ -24,6 +24,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import static com.intellij.util.indexing.hints.BaseFileTypeInputFilter.FileTypeStrategy.BEFORE_SUBSTITUTION;
public class JsonSchemaFileValuesIndex extends FileBasedIndexExtension<String, String> {
public static final ID<String, String> INDEX_ID = ID.create("json.file.root.values");
private static final int VERSION = 5;
@@ -70,7 +72,7 @@ public class JsonSchemaFileValuesIndex extends FileBasedIndexExtension<String, S
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new FileTypeInputFilterPredicate(fileType -> fileType instanceof JsonFileType);
return new FileTypeInputFilterPredicate(BEFORE_SUBSTITUTION, fileType -> fileType instanceof JsonFileType);
}
@Override

View File

@@ -11,7 +11,16 @@ import org.jetbrains.annotations.ApiStatus
* Returns `YES` or `NO` for given filetype predicate. Never returns `UNSURE`, therefore `acceptInput` is never invoked.
*/
@ApiStatus.Experimental
class FileTypeInputFilterPredicate(private val predicate: (filetype: FileType) -> Boolean) : BaseFileTypeInputFilter() {
class FileTypeInputFilterPredicate : BaseFileTypeInputFilter {
private val predicate: (filetype: FileType) -> Boolean
constructor(predicate: (filetype: FileType) -> Boolean) : super() {
this.predicate = predicate
}
constructor(fileTypeStrategy: FileTypeStrategy, predicate: (filetype: FileType) -> Boolean) : super(fileTypeStrategy) {
this.predicate = predicate
}
constructor(vararg fileTypes: FileType) : this({ fileType -> fileTypes.contains(fileType) })

View File

@@ -24,6 +24,8 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.intellij.util.indexing.hints.BaseFileTypeInputFilter.FileTypeStrategy.BEFORE_SUBSTITUTION;
public class HtmlTagIdIndex extends XmlIndex<Integer> {
public static final ID<String, Integer> INDEX = ID.create("HtmlTagIdIndex");
@@ -36,7 +38,7 @@ public class HtmlTagIdIndex extends XmlIndex<Integer> {
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new BaseFileTypeInputFilter() {
return new BaseFileTypeInputFilter(BEFORE_SUBSTITUTION) {
@Override
public boolean whenAllOtherHintsUnsure(@NotNull IndexedFile file) {
return file.getFile().isInLocalFileSystem();