Presentation for extension property to include receiver type
This commit is contained in:
@@ -464,16 +464,18 @@
|
|||||||
<runLineMarkerContributor language="kotlin" implementationClass="org.jetbrains.kotlin.idea.highlighter.KotlinTestRunLineMarkerContributor"/>
|
<runLineMarkerContributor language="kotlin" implementationClass="org.jetbrains.kotlin.idea.highlighter.KotlinTestRunLineMarkerContributor"/>
|
||||||
|
|
||||||
<iconProvider implementation="org.jetbrains.kotlin.idea.KotlinIconProvider"/>
|
<iconProvider implementation="org.jetbrains.kotlin.idea.KotlinIconProvider"/>
|
||||||
|
|
||||||
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtFunctionPresenter"
|
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtFunctionPresenter"
|
||||||
forClass="org.jetbrains.kotlin.psi.KtFunction"/>
|
forClass="org.jetbrains.kotlin.psi.KtFunction"/>
|
||||||
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtClassPresenter"
|
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtDefaultDeclarationPresenter"
|
||||||
forClass="org.jetbrains.kotlin.psi.KtClass"/>
|
forClass="org.jetbrains.kotlin.psi.KtClass"/>
|
||||||
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtObjectPresenter"
|
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtDefaultDeclarationPresenter"
|
||||||
forClass="org.jetbrains.kotlin.psi.KtObjectDeclaration"/>
|
forClass="org.jetbrains.kotlin.psi.KtObjectDeclaration"/>
|
||||||
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtPropertyPresenter"
|
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtDefaultDeclarationPresenter"
|
||||||
forClass="org.jetbrains.kotlin.psi.KtProperty"/>
|
forClass="org.jetbrains.kotlin.psi.KtProperty"/>
|
||||||
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtParameterPresenter"
|
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.KtDefaultDeclarationPresenter"
|
||||||
forClass="org.jetbrains.kotlin.psi.KtParameter"/>
|
forClass="org.jetbrains.kotlin.psi.KtParameter"/>
|
||||||
|
|
||||||
<gotoTargetRendererProvider id="JetGotoTargetRenderProvider" implementation="org.jetbrains.kotlin.idea.KotlinGotoTargetRenderProvider"
|
<gotoTargetRendererProvider id="JetGotoTargetRenderProvider" implementation="org.jetbrains.kotlin.idea.KotlinGotoTargetRenderProvider"
|
||||||
order="first"/>
|
order="first"/>
|
||||||
<elementDescriptionProvider implementation="org.jetbrains.kotlin.idea.findUsages.KotlinElementDescriptionProvider" order="first"/>
|
<elementDescriptionProvider implementation="org.jetbrains.kotlin.idea.findUsages.KotlinElementDescriptionProvider" order="first"/>
|
||||||
|
|||||||
+16
-1
@@ -17,10 +17,12 @@
|
|||||||
package org.jetbrains.kotlin.idea.presentation
|
package org.jetbrains.kotlin.idea.presentation
|
||||||
|
|
||||||
import com.intellij.navigation.ColoredItemPresentation
|
import com.intellij.navigation.ColoredItemPresentation
|
||||||
|
import com.intellij.navigation.ItemPresentationProvider
|
||||||
import com.intellij.openapi.editor.colors.CodeInsightColors
|
import com.intellij.openapi.editor.colors.CodeInsightColors
|
||||||
import com.intellij.openapi.editor.colors.TextAttributesKey
|
import com.intellij.openapi.editor.colors.TextAttributesKey
|
||||||
import com.intellij.openapi.util.Iconable
|
import com.intellij.openapi.util.Iconable
|
||||||
import org.jetbrains.kotlin.idea.KotlinIconProvider
|
import org.jetbrains.kotlin.idea.KotlinIconProvider
|
||||||
|
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||||
|
|
||||||
@@ -37,9 +39,22 @@ open class KotlinDefaultNamedDeclarationPresentation(private val declaration: Kt
|
|||||||
|
|
||||||
override fun getLocationString(): String? {
|
override fun getLocationString(): String? {
|
||||||
val name = declaration.fqName ?: return null
|
val name = declaration.fqName ?: return null
|
||||||
return "(" + name.parent().asString() + ")"
|
val receiverTypeRef = (declaration as? KtCallableDeclaration)?.receiverTypeReference
|
||||||
|
if (receiverTypeRef != null) {
|
||||||
|
return "(for " + receiverTypeRef.text + " in " + name.parent() + ")"
|
||||||
|
}
|
||||||
|
else if (declaration.parent is KtFile) {
|
||||||
|
return "(" + name.parent() + ")"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "(in " + name.parent() + ")"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getIcon(unused: Boolean)
|
override fun getIcon(unused: Boolean)
|
||||||
= KotlinIconProvider.INSTANCE.getIcon(declaration, Iconable.ICON_FLAG_VISIBILITY or Iconable.ICON_FLAG_READ_STATUS)
|
= KotlinIconProvider.INSTANCE.getIcon(declaration, Iconable.ICON_FLAG_VISIBILITY or Iconable.ICON_FLAG_READ_STATUS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class KtDefaultDeclarationPresenter : ItemPresentationProvider<KtNamedDeclaration> {
|
||||||
|
override fun getPresentation(item: KtNamedDeclaration) = KotlinDefaultNamedDeclarationPresentation(item)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 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.presentation
|
|
||||||
|
|
||||||
import com.intellij.navigation.ItemPresentationProvider
|
|
||||||
import org.jetbrains.kotlin.psi.KtClass
|
|
||||||
|
|
||||||
class KtClassPresenter : ItemPresentationProvider<KtClass> {
|
|
||||||
override fun getPresentation(item: KtClass) = KotlinDefaultNamedDeclarationPresentation(item)
|
|
||||||
}
|
|
||||||
@@ -43,10 +43,7 @@ class KtFunctionPresenter : ItemPresentationProvider<KtFunction> {
|
|||||||
return "(in $name)"
|
return "(in $name)"
|
||||||
}
|
}
|
||||||
|
|
||||||
val name = function.fqName ?: return null
|
return super.getLocationString()
|
||||||
val receiverTypeRef = function.receiverTypeReference
|
|
||||||
val extensionLocation = if (receiverTypeRef != null) "for " + receiverTypeRef.text + " " else ""
|
|
||||||
return "(${extensionLocation}in ${name.parent()})"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 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.presentation
|
|
||||||
|
|
||||||
import com.intellij.navigation.ItemPresentationProvider
|
|
||||||
import org.jetbrains.kotlin.psi.KtObjectDeclaration
|
|
||||||
|
|
||||||
class KtObjectPresenter : ItemPresentationProvider<KtObjectDeclaration> {
|
|
||||||
override fun getPresentation(item: KtObjectDeclaration) = KotlinDefaultNamedDeclarationPresentation(item)
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 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.presentation
|
|
||||||
|
|
||||||
import com.intellij.navigation.ItemPresentationProvider
|
|
||||||
import org.jetbrains.kotlin.psi.KtParameter
|
|
||||||
|
|
||||||
class KtParameterPresenter : ItemPresentationProvider<KtParameter> {
|
|
||||||
override fun getPresentation(item: KtParameter) = KotlinDefaultNamedDeclarationPresentation(item)
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 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.presentation
|
|
||||||
|
|
||||||
import com.intellij.navigation.ItemPresentationProvider
|
|
||||||
import org.jetbrains.kotlin.psi.KtProperty
|
|
||||||
|
|
||||||
class KtPropertyPresenter : ItemPresentationProvider<KtProperty> {
|
|
||||||
override fun getPresentation(item: KtProperty) = KotlinDefaultNamedDeclarationPresentation(item)
|
|
||||||
}
|
|
||||||
+1
-1
@@ -5,4 +5,4 @@ fun foo() {}
|
|||||||
|
|
||||||
fun bar() {}
|
fun bar() {}
|
||||||
|
|
||||||
// REF: (in <root>).bar()
|
// REF: (<root>).bar()
|
||||||
|
|||||||
+4
-4
@@ -15,7 +15,7 @@ class InClassObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SEARCH_TEXT: ClassObject
|
// SEARCH_TEXT: ClassObject
|
||||||
// REF: (test.InClassObject.Companion).ClassObjectClass
|
// REF: (in test.InClassObject.Companion).ClassObjectClass
|
||||||
// REF: (test.InClassObject.Companion).ClassObjectObject
|
// REF: (in test.InClassObject.Companion).ClassObjectObject
|
||||||
// REF: (test.InClassObject.Companion).ClassObjectTrait
|
// REF: (in test.InClassObject.Companion).ClassObjectTrait
|
||||||
// REF: (test.InClassObject.Companion).ClassObjectTraitWithImpl
|
// REF: (in test.InClassObject.Companion).ClassObjectTraitWithImpl
|
||||||
+1
-1
@@ -7,4 +7,4 @@ class A {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SEARCH_TEXT: Inner
|
// SEARCH_TEXT: Inner
|
||||||
// REF: (small.A).InnerA
|
// REF: (in small.A).InnerA
|
||||||
+1
-1
@@ -6,7 +6,7 @@ class Some {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SEARCH_TEXT: test
|
// SEARCH_TEXT: test
|
||||||
// REF: (in <root>).testFunction()
|
// REF: (<root>).testFunction()
|
||||||
// REF: (in Some).testFunInClass()
|
// REF: (in Some).testFunInClass()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -18,6 +18,6 @@ class Some() {
|
|||||||
|
|
||||||
// SEARCH_TEXT: test
|
// SEARCH_TEXT: test
|
||||||
// REF: (<root>).testGlobal
|
// REF: (<root>).testGlobal
|
||||||
// REF: (Some).testInClass
|
// REF: (in Some).testInClass
|
||||||
// REF: (Some.Companion).testInClassObject
|
// REF: (in Some.Companion).testInClassObject
|
||||||
// REF: (SomeTrait).testInTrait
|
// REF: (in SomeTrait).testInTrait
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// RUNTIME_WITH_SOURCES
|
// RUNTIME_WITH_SOURCES
|
||||||
// CHECK_BOX
|
// CHECK_BOX
|
||||||
// SEARCH_TEXT: arrayListOf
|
// SEARCH_TEXT: arrayListOf
|
||||||
// REF: (in kotlin).arrayListOf(T)
|
// REF: (kotlin).arrayListOf(T)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// RUNTIME
|
// RUNTIME
|
||||||
// CHECK_BOX
|
// CHECK_BOX
|
||||||
// SEARCH_TEXT: arrayListOf
|
// SEARCH_TEXT: arrayListOf
|
||||||
// REF: (in kotlin).arrayListOf(T)
|
// REF: (kotlin).arrayListOf(T)
|
||||||
|
|||||||
+2
-2
@@ -8,5 +8,5 @@ class OtherTestInBody(some: Int, other: String): Test(some) {
|
|||||||
override var some: Int = some
|
override var some: Int = some
|
||||||
}
|
}
|
||||||
|
|
||||||
// REF: (testing.OtherTestInConstructor).some
|
// REF: (in testing.OtherTestInConstructor).some
|
||||||
// REF: (testing.OtherTestInBody).some
|
// REF: (in testing.OtherTestInBody).some
|
||||||
@@ -12,5 +12,5 @@ enum class <caret>E {
|
|||||||
open fun foo(n: Int): Int = n
|
open fun foo(n: Int): Int = n
|
||||||
}
|
}
|
||||||
|
|
||||||
// REF: (E).A
|
// REF: (in E).A
|
||||||
// REF: (E).B
|
// REF: (in E).B
|
||||||
@@ -13,5 +13,5 @@ class SubSubBase: SubBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// REF: (testing.SubBase).test
|
// REF: (in testing.SubBase).test
|
||||||
// REF: (testing.SubSubBase).test
|
// REF: (in testing.SubSubBase).test
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
public class Class {
|
public class Class {
|
||||||
}
|
}
|
||||||
|
|
||||||
// REF: (k.KAnno).d
|
// REF: (in k.KAnno).d
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ public class AutoGeneratedOverloads {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// REF: (in k).withJvmOverloads(Int,Boolean,String)
|
// REF: (k).withJvmOverloads(Int, Boolean, String)
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ public class ClassObjectField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// REF: (k.StaticFieldInClassObjectInTrait.Companion).XX
|
// REF: (in k.StaticFieldInClassObjectInTrait.Companion).XX
|
||||||
+1
-1
@@ -4,4 +4,4 @@ public class EnumEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// REF: (k.EnumClass).ENTRY
|
// REF: (in k.EnumClass).ENTRY
|
||||||
|
|||||||
+1
-1
@@ -4,4 +4,4 @@ public class Getter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// REF: (k.Class).prop
|
// REF: (in k.Class).prop
|
||||||
|
|||||||
+1
-1
@@ -5,4 +5,4 @@ val tl = <caret>topLevel()
|
|||||||
// CONTEXT: return <ref-caret>local()
|
// CONTEXT: return <ref-caret>local()
|
||||||
// WITH_LIBRARY: /resolve/referenceInLib/inLibrarySource
|
// WITH_LIBRARY: /resolve/referenceInLib/inLibrarySource
|
||||||
|
|
||||||
// REF: .local()
|
// REF: local()
|
||||||
@@ -4,4 +4,4 @@ import dependency.*
|
|||||||
|
|
||||||
val a: Outer.<caret>Inner? = null
|
val a: Outer.<caret>Inner? = null
|
||||||
|
|
||||||
// REF: (dependency.Outer).Inner
|
// REF: (in dependency.Outer).Inner
|
||||||
@@ -4,4 +4,4 @@ import dependency.*
|
|||||||
|
|
||||||
val a: Outer.<caret>Nested? = null
|
val a: Outer.<caret>Nested? = null
|
||||||
|
|
||||||
// REF: (dependency.Outer).Nested
|
// REF: (in dependency.Outer).Nested
|
||||||
Reference in New Issue
Block a user