Minor: remove deprecated usages of PsiSearchHelper.SERVICE
This commit is contained in:
+3
@@ -118,6 +118,8 @@
|
||||
<Problem reference="com.intellij.openapi.ui.popup.PopupChooserBuilder#PopupChooserBuilder(javax.swing.JList)" reason="Generified in 182. Use PopupChooserBuilderWrapper instead." />
|
||||
<Problem reference="com.intellij.openapi.editor.event.EditorFactoryListener" reason="Default implementations were added in 183. Use EditorFactoryListenerWrapper for inheritance instead." />
|
||||
<Problem reference="com.intellij.codeInspection.reference.RefFile#getPsiElement" reason="Absent in 182. Use psiFile extension instead." />
|
||||
<Problem reference="com.intellij.psi.search.PsiSearchHelper#getInstance" reason="Absent in 181. Use psiSearchHelperInstance() instead." />
|
||||
<Problem reference="com.intellij.psi.search.PsiSearchHelper.SERVICE" reason="Deprecated since 182. Use psiSearchHelperInstance() instead." />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
@@ -399,6 +401,7 @@
|
||||
</inspection_tool>
|
||||
<inspection_tool class="StringEquality" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="StringEqualsEmptyString" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="StringOperationCanBeSimplifiedMerged" />
|
||||
<inspection_tool class="SwitchStatementWithConfusingDeclaration" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="SynchronizeOnThis" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="SystemOutErr" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.search.PsiSearchHelper
|
||||
import com.intellij.psi.search.SearchScope
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.util.compat.psiSearchHelperInstance
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
@@ -93,8 +94,7 @@ fun SearchScope.excludeFileTypes(vararg fileTypes: FileType): SearchScope {
|
||||
fun ReferencesSearch.SearchParameters.effectiveSearchScope(element: PsiElement): SearchScope {
|
||||
if (element == elementToSearch) return effectiveSearchScope
|
||||
if (isIgnoreAccessScope) return scopeDeterminedByUser
|
||||
// BUNCH: 181
|
||||
@Suppress("DEPRECATION") val accessScope = PsiSearchHelper.SERVICE.getInstance(element.project).getUseScope(element)
|
||||
val accessScope = psiSearchHelperInstance(element.project).getUseScope(element)
|
||||
return scopeDeterminedByUser.intersectWith(accessScope)
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -52,6 +52,7 @@ import org.jetbrains.kotlin.idea.search.restrictToKotlinSources
|
||||
import org.jetbrains.kotlin.idea.util.FuzzyType
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.idea.util.compat.psiSearchHelperInstance
|
||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocName
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.sam.SingleAbstractMethodUtils
|
||||
@@ -368,9 +369,7 @@ class ExpressionsOfTypeProcessor(
|
||||
}
|
||||
}
|
||||
|
||||
// BUNCH: 181
|
||||
@Suppress("DEPRECATION")
|
||||
PsiSearchHelper.SERVICE.getInstance(project).processRequests(searchRequestCollector) { reference ->
|
||||
psiSearchHelperInstance(project).processRequests(searchRequestCollector) { reference ->
|
||||
if (reference.element.parents.any { it is KtImportDirective }) {
|
||||
// Found declaration in import - process all file with an ordinal reference search
|
||||
val containingFile = reference.element.containingFile
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.util.compat
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.PsiSearchHelper
|
||||
|
||||
// BUNCH: 181
|
||||
@Suppress("IncompatibleAPI")
|
||||
fun psiSearchHelperInstance(project: Project): PsiSearchHelper {
|
||||
return PsiSearchHelper.getInstance(project)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.util.compat
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.PsiSearchHelper
|
||||
|
||||
// BUNCH: 181
|
||||
@Suppress("IncompatibleAPI")
|
||||
fun psiSearchHelperInstance(project: Project): PsiSearchHelper {
|
||||
return PsiSearchHelper.SERVICE.getInstance(project)
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.PsiReference
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.PsiSearchHelper
|
||||
import com.intellij.psi.search.PsiSearchHelper.SearchCostResult.FEW_OCCURRENCES
|
||||
import com.intellij.psi.search.PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
@@ -25,6 +24,7 @@ import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.search.isCheapEnoughToSearchConsideringOperators
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.getAccessorNames
|
||||
import org.jetbrains.kotlin.idea.stubindex.KotlinSourceFilterScope
|
||||
import org.jetbrains.kotlin.idea.util.compat.psiSearchHelperInstance
|
||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
@@ -83,7 +83,7 @@ class CanBeParameterInspection : AbstractKotlinInspection() {
|
||||
|
||||
val useScope = parameter.useScope
|
||||
val restrictedScope = if (useScope is GlobalSearchScope) {
|
||||
val psiSearchHelper = PsiSearchHelper.SERVICE.getInstance(parameter.project)
|
||||
val psiSearchHelper = psiSearchHelperInstance(parameter.project)
|
||||
for (accessorName in parameter.getAccessorNames()) {
|
||||
when (psiSearchHelper.isCheapEnoughToSearchConsideringOperators(accessorName, useScope, null, null)) {
|
||||
ZERO_OCCURRENCES -> {
|
||||
|
||||
+2
-1
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.idea.search.isCheapEnoughToSearchConsideringOperator
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.dataClassComponentFunction
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
|
||||
import org.jetbrains.kotlin.idea.stubindex.KotlinSourceFilterScope
|
||||
import org.jetbrains.kotlin.idea.util.compat.psiSearchHelperInstance
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
@@ -102,7 +103,7 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
|
||||
// properties can be referred by component1/component2, which is too expensive to search, don't analyze them
|
||||
if (declaration is KtParameter && declaration.dataClassComponentFunction() != null) return false
|
||||
|
||||
val psiSearchHelper = PsiSearchHelper.SERVICE.getInstance(declaration.project)
|
||||
val psiSearchHelper = psiSearchHelperInstance(declaration.project)
|
||||
val useScope = declaration.useScope
|
||||
val name = declaration.name ?: return false
|
||||
val restrictedScope = if (useScope is GlobalSearchScope) {
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.PsiReference
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.PsiSearchHelper
|
||||
import com.intellij.psi.search.PsiSearchHelper.SearchCostResult.*
|
||||
import com.intellij.psi.search.SearchScope
|
||||
import com.intellij.psi.search.searches.DefinitionsScopedSearch
|
||||
@@ -61,6 +60,7 @@ import org.jetbrains.kotlin.idea.search.usagesSearch.getAccessorNames
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.getClassNameForCompanionObject
|
||||
import org.jetbrains.kotlin.idea.stubindex.KotlinSourceFilterScope
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.idea.util.compat.psiSearchHelperInstance
|
||||
import org.jetbrains.kotlin.idea.util.hasActualsFor
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -221,7 +221,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
|
||||
private fun hasNonTrivialUsages(declaration: KtNamedDeclaration, descriptor: DeclarationDescriptor? = null): Boolean {
|
||||
val project = declaration.project
|
||||
val psiSearchHelper = PsiSearchHelper.SERVICE.getInstance(project)
|
||||
val psiSearchHelper = psiSearchHelperInstance(project)
|
||||
|
||||
val useScope = declaration.useScope
|
||||
val restrictedScope = if (useScope is GlobalSearchScope) {
|
||||
|
||||
Reference in New Issue
Block a user