From f6623b4defa14899097d60b9ae60939dd10c827b Mon Sep 17 00:00:00 2001 From: Egor Malyshev Date: Wed, 14 May 2025 13:21:01 +0200 Subject: [PATCH] Remove deprecated API (cherry picked from commit 20ba179e0d555063b1459489f07c883519aa208d) (cherry picked from commit 488eefe185b0fe45e8839fade7631f05c6b25ddc) IJ-MR-166587 GitOrigin-RevId: e37799dfe287df9fcd8f9abb976fefc3a3700e83 --- .../intellij/build/impl/BuiltInHelpPlugin.kt | 4 ++-- .../jetbrains/builtInHelp/search/HelpSearch.kt | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/BuiltInHelpPlugin.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/BuiltInHelpPlugin.kt index 94a0b32cf98b..ad977c088a4d 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/BuiltInHelpPlugin.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/BuiltInHelpPlugin.kt @@ -31,11 +31,11 @@ internal fun buildHelpPlugin(pluginVersion: String, context: BuildContext): Plug spec.directoryName = "${productName.replace(" ", "")}Help" spec.excludeFromModule(BUILT_IN_HELP_MODULE_NAME, "com/jetbrains/builtInHelp/indexer/**") spec.withPatch { patcher, buildContext -> - patcher.patchModuleOutput( +/* patcher.patchModuleOutput( moduleName = BUILT_IN_HELP_MODULE_NAME, path = "META-INF/services/org.apache.lucene.codecs.Codec", content = "org.apache.lucene.codecs.lucene50.Lucene50Codec" - ) + )*/ patcher.patchModuleOutput( moduleName = BUILT_IN_HELP_MODULE_NAME, path = "META-INF/plugin.xml", diff --git a/plugins/built-in-help/src/com/jetbrains/builtInHelp/search/HelpSearch.kt b/plugins/built-in-help/src/com/jetbrains/builtInHelp/search/HelpSearch.kt index 5dd6ab0776ce..f8f16dcb06eb 100644 --- a/plugins/built-in-help/src/com/jetbrains/builtInHelp/search/HelpSearch.kt +++ b/plugins/built-in-help/src/com/jetbrains/builtInHelp/search/HelpSearch.kt @@ -9,7 +9,7 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer import org.apache.lucene.index.DirectoryReader import org.apache.lucene.queryparser.simple.SimpleQueryParser import org.apache.lucene.search.IndexSearcher -import org.apache.lucene.search.TopScoreDocCollector +import org.apache.lucene.search.TopScoreDocCollectorManager import org.apache.lucene.search.highlight.Highlighter import org.apache.lucene.search.highlight.QueryScorer import org.apache.lucene.search.highlight.Scorer @@ -59,17 +59,18 @@ class HelpSearch { reader = DirectoryReader.open(indexDirectory) val searcher = IndexSearcher(reader) - val collector: TopScoreDocCollector = TopScoreDocCollector.create(maxHits, maxHits) - val q = SimpleQueryParser(analyzer, mapOf(Pair("contents", 1.0F), Pair("title", 1.5F))).parse(query) - searcher.search(q, collector) - val hits = collector.topDocs().scoreDocs + val q = SimpleQueryParser(analyzer, mapOf(Pair("contents", 1.0F), + Pair("title", 1.5F))).parse(query) + val hits = searcher.search(q, + TopScoreDocCollectorManager(maxHits, maxHits)) val scorer: Scorer = QueryScorer(q) val highlighter = Highlighter(scorer) - val results = ArrayList() - for (i in hits.indices) { - val doc = searcher.doc(hits[i].doc) + val results = mutableListOf() + + for (i in hits.scoreDocs.indices) { + val doc = searcher.storedFields().document(hits.scoreDocs[i].doc) val contentValue = buildString { append(highlighter.getBestFragment( analyzer, "contents", doc.get("contents")