show context when invoking Show Implementations from Find Usages popup

#KT-13475 Fixed
This commit is contained in:
Dmitry Jemerov
2016-08-25 19:30:59 +02:00
parent e462a97c64
commit cbb2e5c379
2 changed files with 35 additions and 0 deletions

View File

@@ -733,6 +733,8 @@
<nameSuggestionProvider implementation="org.jetbrains.kotlin.idea.core.KotlinNameSuggestionProvider"/>
<usageToPsiElementProvider implementation="org.jetbrains.kotlin.idea.codeInsight.KotlinUsageToPsiElementProvider"/>
<intentionAction>
<className>org.jetbrains.kotlin.idea.intentions.IfNullToElvisIntention</className>
<category>Kotlin</category>

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.codeInsight
import com.intellij.psi.PsiElement
import com.intellij.usages.UsageToPsiElementProvider
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.psi.KtImportDirective
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
class KotlinUsageToPsiElementProvider : UsageToPsiElementProvider() {
override fun getAppropriateParentFrom(element: PsiElement): PsiElement? {
if (element.language == KotlinLanguage.INSTANCE) {
return element.parentsWithSelf.first { it is KtNamedDeclaration || it is KtImportDirective }
}
return null
}
}