mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
IDEA-320457: rename method `FileTypeIndexingHint.{whenFileTypeHintUnsure > slowPathIfFileTypeHintUnsure}
to emphasise that there are two paths: slow (slowPathIfFileTypeHintUnsure) and fast (acceptsFileTypeFastPath) GitOrigin-RevId: e4d5d2fd3208395ba1f67931292f7e9a2400fba7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a7e363d7de
commit
11c36db203
@@ -25,19 +25,19 @@ import org.jetbrains.annotations.ApiStatus.Experimental
|
||||
*
|
||||
* In runtime indexing framework first evaluates [acceptsFileTypeFastPath]. If [acceptsFileTypeFastPath] returns `YES` or `NO`, this value is used
|
||||
* for any file with the same filetype. If [acceptsFileTypeFastPath] returns [ThreeState.UNSURE], the framework will switch to "slow"
|
||||
* mode and will invoke [whenFileTypeHintUnsure] for each indexable file.
|
||||
* mode and will invoke [slowPathIfFileTypeHintUnsure] for each indexable file.
|
||||
*
|
||||
* Hint results are cached (at least until IDE restart). In particular, if hint uses ExtensionPoints to evaluate result, changes
|
||||
* in relevant extension points (e.g. loading/unloading plugins) should reset caches.
|
||||
* Use [com.intellij.util.indexing.FileBasedIndexEx.resetHints] to reset cached indexing hints.
|
||||
*
|
||||
* [whenFileTypeHintUnsure] is only invoked when [acceptsFileTypeFastPath] returned `UNSURE`, there is no need to add the logic from [acceptsFileTypeFastPath]
|
||||
* to [whenFileTypeHintUnsure]. But this logic still should be added to [InputFilter.acceptInput] as explained below.
|
||||
* [slowPathIfFileTypeHintUnsure] is only invoked when [acceptsFileTypeFastPath] returned `UNSURE`, there is no need to add the logic from [acceptsFileTypeFastPath]
|
||||
* to [slowPathIfFileTypeHintUnsure]. But this logic still should be added to [InputFilter.acceptInput] as explained below.
|
||||
*
|
||||
* **When used with [InputFilter] or [ProjectSpecificInputFilter]:**
|
||||
*
|
||||
* Indexing framework evaluates [acceptsFileTypeFastPath] and falls back to [whenFileTypeHintUnsure].
|
||||
* [whenFileTypeHintUnsure] must answer either `true` or `false`. This means that indexing framework
|
||||
* Indexing framework evaluates [acceptsFileTypeFastPath] and falls back to [slowPathIfFileTypeHintUnsure].
|
||||
* [slowPathIfFileTypeHintUnsure] must answer either `true` or `false`. This means that indexing framework
|
||||
* will not invoke [InputFilter.acceptInput] or [ProjectSpecificInputFilter.acceptInput]. However, there may be other clients which may
|
||||
* invoke `acceptInput` without analyzing any hints. Therefore, `acceptInput` should provide answer just like if the filter didn't have any
|
||||
* hints in the first place.
|
||||
@@ -86,5 +86,5 @@ import org.jetbrains.annotations.ApiStatus.Experimental
|
||||
interface FileTypeIndexingHint {
|
||||
fun acceptsFileTypeFastPath(fileType: FileType): ThreeState
|
||||
|
||||
fun whenFileTypeHintUnsure(file: IndexedFile): Boolean
|
||||
fun slowPathIfFileTypeHintUnsure(file: IndexedFile): Boolean
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class StubUpdatingIndex extends SingleEntryFileBasedIndexExtension<
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean whenFileTypeHintUnsure(@NotNull IndexedFile file) {
|
||||
public boolean slowPathIfFileTypeHintUnsure(@NotNull IndexedFile file) {
|
||||
if (file.getFileType() instanceof LanguageFileType) {
|
||||
ParserDefinition parserDefinition = getParserDefinition(file.getFileType(), file.getFileName());
|
||||
if (parserDefinition == null) return false;
|
||||
|
||||
@@ -41,7 +41,7 @@ abstract class BaseFileTypeInputFilter(private val fileTypeStrategy: FileTypeSub
|
||||
return when (acceptsFileTypeFastPath(file.fileType)) {
|
||||
ThreeState.YES -> true
|
||||
ThreeState.NO -> false
|
||||
ThreeState.UNSURE -> whenFileTypeHintUnsure(file)
|
||||
ThreeState.UNSURE -> slowPathIfFileTypeHintUnsure(file)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ enum class BinaryFileTypePolicy { BINARY, NON_BINARY, BINARY_OR_NON_BINARY }
|
||||
class FileNameSuffixInputFilter(private val fileNameSuffix: String,
|
||||
private val ignoreCase: Boolean,
|
||||
binary: BinaryFileTypePolicy = BINARY_OR_NON_BINARY) : BaseWeakFileNameSuffixInputFilter(binary) {
|
||||
override fun whenFileTypeHintUnsure(file: IndexedFile): Boolean {
|
||||
override fun slowPathIfFileTypeHintUnsure(file: IndexedFile): Boolean {
|
||||
return file.fileName.endsWith(fileNameSuffix, ignoreCase)
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class FileNameSuffixInputFilter(private val fileNameSuffix: String,
|
||||
class ExactFileNameInputFilter(private val fileName: String,
|
||||
private val ignoreCase: Boolean,
|
||||
binary: BinaryFileTypePolicy = BINARY_OR_NON_BINARY) : BaseWeakFileNameSuffixInputFilter(binary) {
|
||||
override fun whenFileTypeHintUnsure(file: IndexedFile): Boolean {
|
||||
override fun slowPathIfFileTypeHintUnsure(file: IndexedFile): Boolean {
|
||||
return file.fileName.equals(fileName, ignoreCase)
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class FileNameExtensionInputFilter(extension: String,
|
||||
binary: BinaryFileTypePolicy = BINARY_OR_NON_BINARY) : BaseWeakFileNameSuffixInputFilter(binary) {
|
||||
private val dotExtension = ".$extension"
|
||||
|
||||
override fun whenFileTypeHintUnsure(file: IndexedFile): Boolean {
|
||||
override fun slowPathIfFileTypeHintUnsure(file: IndexedFile): Boolean {
|
||||
return file.fileName.endsWith(dotExtension, ignoreCase)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class FileTypeInputFilterPredicate : BaseFileTypeInputFilter {
|
||||
|
||||
constructor(vararg fileTypes: FileType) : this({ fileType -> fileTypes.contains(fileType) })
|
||||
|
||||
override fun whenFileTypeHintUnsure(file: IndexedFile): Boolean = false // for directories
|
||||
override fun slowPathIfFileTypeHintUnsure(file: IndexedFile): Boolean = false // for directories
|
||||
|
||||
override fun acceptFileType(fileType: FileType): ThreeState = ThreeState.fromBoolean(predicate(fileType))
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
/**
|
||||
* Returns `NO` for binary file types, and `UNSURE` for others (i.e. delegates to [whenFileTypeHintUnsure]).
|
||||
* Returns `NO` for binary file types, and `UNSURE` for others (i.e. delegates to [slowPathIfFileTypeHintUnsure]).
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
class NonBinaryFileTypeInputFilter(private val acceptInput: FileBasedIndex.InputFilter) : BaseFileTypeInputFilter() {
|
||||
@@ -17,7 +17,7 @@ class NonBinaryFileTypeInputFilter(private val acceptInput: FileBasedIndex.Input
|
||||
return if (fileType.isBinary) ThreeState.NO else ThreeState.UNSURE;
|
||||
}
|
||||
|
||||
override fun whenFileTypeHintUnsure(file: IndexedFile): Boolean {
|
||||
override fun slowPathIfFileTypeHintUnsure(file: IndexedFile): Boolean {
|
||||
return acceptInput.acceptInput(file.file)
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,6 @@ class FileTypeInputFilterPredicateTest {
|
||||
fun testHitFallbackForDirectory() {
|
||||
val hint = FileTypeInputFilterPredicate(PlainTextFileType.INSTANCE)
|
||||
val someDir = VfsUtil.findFile(tempDir.createDir(), true)!!
|
||||
Assert.assertFalse(hint.whenFileTypeHintUnsure(IndexedFileImpl(someDir, p.project)))
|
||||
Assert.assertFalse(hint.slowPathIfFileTypeHintUnsure(IndexedFileImpl(someDir, p.project)))
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public final class TodoIndex extends SingleEntryFileBasedIndexExtension<Map<Todo
|
||||
public @NotNull FileBasedIndex.InputFilter getInputFilter() {
|
||||
return new BaseFileTypeInputFilter(AFTER_SUBSTITUTION) {
|
||||
@Override
|
||||
public boolean whenFileTypeHintUnsure(@NotNull IndexedFile file) {
|
||||
public boolean slowPathIfFileTypeHintUnsure(@NotNull IndexedFile file) {
|
||||
return TodoIndexers.needsTodoIndex(file);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ internal class RequiredIndexesEvaluator(private val registeredIndexes: Registere
|
||||
ThreeState.YES -> truePredicate
|
||||
ThreeState.NO -> falsePredicate
|
||||
ThreeState.UNSURE -> object : IndexedFilePredicate {
|
||||
override fun test(indexedFile: IndexedFile): Boolean = indexingHint.whenFileTypeHintUnsure(indexedFile)
|
||||
override fun test(indexedFile: IndexedFile): Boolean = indexingHint.slowPathIfFileTypeHintUnsure(indexedFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class HtmlTagIdIndex extends XmlIndex<Integer> {
|
||||
public FileBasedIndex.InputFilter getInputFilter() {
|
||||
return new BaseFileTypeInputFilter(BEFORE_SUBSTITUTION) {
|
||||
@Override
|
||||
public boolean whenFileTypeHintUnsure(@NotNull IndexedFile file) {
|
||||
public boolean slowPathIfFileTypeHintUnsure(@NotNull IndexedFile file) {
|
||||
return file.getFile().isInLocalFileSystem();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user