Introduced category for default object usages.
This commit is contained in:
@@ -389,6 +389,7 @@ usageType.type.definition = Type definition
|
||||
usageType.is = Target type of 'is' operation
|
||||
usageType.as = Target type of 'as' operation
|
||||
usageType.class.object = Nested class/object
|
||||
usageType.default.object = Default object
|
||||
usageType.instantiation = Instantiation
|
||||
usageType.function.call = Function call
|
||||
usageType.implicit.get = Implicit 'get'
|
||||
|
||||
@@ -29,12 +29,14 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
|
||||
import com.intellij.psi.PsiPackage
|
||||
import com.intellij.psi.PsiReferenceExpression
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.idea.findUsages.UsageTypeEnum.*
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch
|
||||
import org.jetbrains.kotlin.idea.references.JetArrayAccessReference
|
||||
import org.jetbrains.kotlin.idea.references.JetInvokeFunctionReference
|
||||
import org.jetbrains.kotlin.idea.references.unwrappedTargets
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
|
||||
@@ -208,6 +210,7 @@ public object UsageTypeUtils {
|
||||
is ClassifierDescriptor -> when {
|
||||
// Treat object accesses as variables to simulate the old behaviour (when variables were created for objects)
|
||||
DescriptorUtils.isNonDefaultObject(descriptor), DescriptorUtils.isEnumEntry(descriptor) -> getVariableUsageType()
|
||||
DescriptorUtils.isDefaultObject(descriptor) -> DEFAULT_OBJECT_ACCESS
|
||||
else -> getClassUsageType()
|
||||
}
|
||||
is PackageViewDescriptor -> {
|
||||
@@ -229,6 +232,7 @@ enum class UsageTypeEnum {
|
||||
TYPE_DEFINITION
|
||||
IS
|
||||
CLASS_OBJECT_ACCESS
|
||||
DEFAULT_OBJECT_ACCESS
|
||||
EXTENSION_RECEIVER_TYPE
|
||||
SUPER_TYPE_QUALIFIER
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public object JetUsageTypeProvider : UsageTypeProviderEx {
|
||||
TYPE_DEFINITION -> JetUsageTypes.TYPE_DEFINITION
|
||||
IS -> JetUsageTypes.IS
|
||||
CLASS_OBJECT_ACCESS -> JetUsageTypes.CLASS_OBJECT_ACCESS
|
||||
DEFAULT_OBJECT_ACCESS -> JetUsageTypes.DEFAULT_OBJECT_ACCESS
|
||||
EXTENSION_RECEIVER_TYPE -> JetUsageTypes.EXTENSION_RECEIVER_TYPE
|
||||
SUPER_TYPE_QUALIFIER -> JetUsageTypes.SUPER_TYPE_QUALIFIER
|
||||
|
||||
@@ -84,6 +85,7 @@ object JetUsageTypes {
|
||||
val TYPE_DEFINITION = UsageType(JetBundle.message("usageType.type.definition"))
|
||||
val IS = UsageType(JetBundle.message("usageType.is"))
|
||||
val CLASS_OBJECT_ACCESS = UsageType(JetBundle.message("usageType.class.object"))
|
||||
val DEFAULT_OBJECT_ACCESS = UsageType(JetBundle.message("usageType.default.object"))
|
||||
val EXTENSION_RECEIVER_TYPE = UsageType(JetBundle.message("usageType.extension.receiver.type"))
|
||||
val SUPER_TYPE_QUALIFIER = UsageType(JetBundle.message("usageType.super.type.qualifier"))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Nested class/object (5: 5) Foo.f()
|
||||
Nested class/object (8: 9) Foo.Bar.f()
|
||||
Unclassified usage (6: 13) val x = Foo
|
||||
Unclassified usage (9: 18) val xx = Foo.Bar
|
||||
Default object (5: 5) Foo.f()
|
||||
Default object (6: 13) val x = Foo
|
||||
Default object (8: 9) Foo.Bar.f()
|
||||
Default object (9: 18) val xx = Foo.Bar
|
||||
@@ -1,4 +1,4 @@
|
||||
Nested class/object (5: 5) Foo.f()
|
||||
Nested class/object (8: 9) Foo.Default.f()
|
||||
Unclassified usage (6: 13) val x = Foo
|
||||
Unclassified usage (9: 18) val xx = Foo.Default
|
||||
Default object (5: 5) Foo.f()
|
||||
Default object (6: 13) val x = Foo
|
||||
Default object (8: 9) Foo.Default.f()
|
||||
Default object (9: 18) val xx = Foo.Default
|
||||
@@ -1,10 +1,10 @@
|
||||
Class/object property type (6: 21) var nextServer: Server? = new Server()
|
||||
Default object (32: 28) fun Client.bar(s: Server = Server.NAME) {
|
||||
Default object (5: 29) class Client(name: String = Server.NAME): Server() {
|
||||
Default object (7: 16) val name = Server.NAME
|
||||
Function return types (14: 26) fun getNextServer(): Server? {
|
||||
Function return types (40: 21) fun Any.asServer(): Server? {
|
||||
Local variable declaration (10: 21) val server: Server = s
|
||||
Nested class/object (32: 28) fun Client.bar(s: Server = Server.NAME) {
|
||||
Nested class/object (5: 29) class Client(name: String = Server.NAME): Server() {
|
||||
Nested class/object (7: 16) val name = Server.NAME
|
||||
Parameter type (32: 19) fun Client.bar(s: Server = Server.NAME) {
|
||||
Parameter type (9: 16) fun foo(s: Server) {
|
||||
Super type qualifier (19: 15) super<Server>.work()
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
Class/object property type (6: 21) var nextServer: Server? = new Server()
|
||||
Default object (28: 28) fun Client.bar(s: Server = Server.NAME) {
|
||||
Default object (5: 29) class Client(name: String = Server.NAME): Server() {
|
||||
Default object (7: 16) val name = Server.NAME
|
||||
Function return types (14: 26) fun getNextServer(): Server? {
|
||||
Function return types (36: 21) fun Any.asServer(): Server? {
|
||||
Local variable declaration (10: 21) val server: Server = s
|
||||
Nested class/object (28: 28) fun Client.bar(s: Server = Server.NAME) {
|
||||
Nested class/object (5: 29) class Client(name: String = Server.NAME): Server() {
|
||||
Nested class/object (7: 16) val name = Server.NAME
|
||||
Parameter type (28: 19) fun Client.bar(s: Server = Server.NAME) {
|
||||
Parameter type (9: 16) fun foo(s: Server) {
|
||||
Super type qualifier (19: 15) super<Server>.work()
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
Class/object property type (6: 21) var next: Inner.A? = Inner.A()
|
||||
Default object (10: 15) Inner.A.bar = ""
|
||||
Default object (11: 15) Inner.A.foo()
|
||||
Default object (5: 37) public class X(bar: String? = Inner.A.bar): Inner.A() {
|
||||
Default object (7: 32) val myBar: String? = Inner.A.bar
|
||||
Field declaration (6: 11) Inner.A next = new Inner.A();
|
||||
Function return types (19: 26) fun getNext(): Inner.A? {
|
||||
Function return types (40: 22) fun Any.toA(): Inner.A? {
|
||||
Local variable declaration (15: 23) val aa: Inner.A = a
|
||||
Nested class/object (10: 15) Inner.A.bar = ""
|
||||
Nested class/object (11: 15) Inner.A.foo()
|
||||
Nested class/object (5: 37) public class X(bar: String? = Inner.A.bar): Inner.A() {
|
||||
Nested class/object (7: 32) val myBar: String? = Inner.A.bar
|
||||
New instance creation (36: 30) fun X.bar(a: Inner.A = Inner.A()) {
|
||||
New instance creation (6: 30) Inner.A next = new Inner.A();
|
||||
New instance creation (6: 32) var next: Inner.A? = Inner.A()
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
Class/object property type (6: 21) var next: Outer.A? = Outer.A()
|
||||
Default object (10: 15) Outer.A.bar = ""
|
||||
Default object (11: 15) Outer.A.foo()
|
||||
Default object (5: 37) public class X(bar: String? = Outer.A.bar): Outer.A() {
|
||||
Default object (7: 32) val myBar: String? = Outer.A.bar
|
||||
Field declaration (6: 11) Outer.A next = new Outer.A();
|
||||
Function return types (19: 26) fun getNext(): Outer.A? {
|
||||
Function return types (40: 22) fun Any.toA(): Outer.A? {
|
||||
Local variable declaration (15: 23) val aa: Outer.A = a
|
||||
Nested class/object (10: 15) Outer.A.bar = ""
|
||||
Nested class/object (11: 15) Outer.A.foo()
|
||||
Nested class/object (5: 37) public class X(bar: String? = Outer.A.bar): Outer.A() {
|
||||
Nested class/object (7: 32) val myBar: String? = Outer.A.bar
|
||||
New instance creation (36: 30) fun X.bar(a: Outer.A = Outer.A()) {
|
||||
New instance creation (6: 30) Outer.A next = new Outer.A();
|
||||
New instance creation (6: 32) var next: Outer.A? = Outer.A()
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
Class/object property type (Client) (6: 21) var nextServer: Server? = new Server()
|
||||
Default object (Client) (5: 29) class Client(name: String = Server.NAME): Server() {
|
||||
Default object (Client) (7: 16) val name = Server.NAME
|
||||
Default object (bar) (32: 28) fun Client.bar(s: Server = Server.NAME) {
|
||||
Function return types (Client) (14: 26) fun getNextServer(): Server? {
|
||||
Function return types (asServer) (40: 21) fun Any.asServer(): Server? {
|
||||
Local variable declaration (Client) (10: 21) val server: Server = s
|
||||
Nested class/object (Client) (5: 29) class Client(name: String = Server.NAME): Server() {
|
||||
Nested class/object (Client) (7: 16) val name = Server.NAME
|
||||
Nested class/object (bar) (32: 28) fun Client.bar(s: Server = Server.NAME) {
|
||||
Parameter type (Client) (9: 16) fun foo(s: Server) {
|
||||
Parameter type (bar) (32: 19) fun Client.bar(s: Server = Server.NAME) {
|
||||
Super type qualifier (Client) (19: 15) super<Server>.work()
|
||||
|
||||
Reference in New Issue
Block a user