Add more toString() methods and additional wrapping for Kotlin elements

This commit is contained in:
Nikolay Krasko
2015-03-24 01:16:35 +03:00
parent ad23e9159c
commit 4e04d9b887
8 changed files with 55 additions and 9 deletions
@@ -148,7 +148,7 @@ public abstract class KotlinLightField<T extends JetDeclaration, D extends PsiFi
@Override
public String toString() {
return "PsiField:" + getName();
return "KotlinLightField:" + getName();
}
@NotNull
@@ -125,4 +125,6 @@ open public class KotlinLightMethodForDeclaration(
getContainingClass() == other.getContainingClass()
override fun hashCode(): Int = (getName().hashCode() * 31 + origin.hashCode()) * 31 + getContainingClass()!!.hashCode()
override fun toString(): String = "KotlinLightMethodForDeclaration:" + getName()
}
@@ -0,0 +1,34 @@
/*
* 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.asJava
import com.intellij.psi.*
import com.intellij.psi.impl.light.LightField
import com.intellij.psi.impl.light.LightMethod
public class KotlinNoOriginLightMethod(manager: PsiManager, method: PsiMethod, containingClass: PsiClass) :
LightMethod(manager, method, containingClass) {
override fun toString() = "KotlinNoOriginLightMethod:${getName()}" + if (isConstructor()) " ctor" else ""
}
public class KotlinNoOriginLightField(manager: PsiManager, field: PsiField, containingClass: PsiClass) :
LightField(manager, field, containingClass) {
override fun toString() = "KotlinNoOriginLightField:${getName()}"
}
@@ -22,8 +22,6 @@ import com.intellij.navigation.ItemPresentationProviders;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiClassImplUtil;
import com.intellij.psi.impl.light.AbstractLightClass;
import com.intellij.psi.impl.light.LightField;
import com.intellij.psi.impl.light.LightMethod;
import com.intellij.psi.impl.source.ClassInnerStuffCache;
import com.intellij.psi.impl.source.PsiExtensibleClass;
import com.intellij.psi.scope.PsiScopeProcessor;
@@ -138,7 +136,7 @@ public abstract class KotlinWrappingLightClass extends AbstractLightClass implem
if (declaration != null) {
return new KotlinLightFieldForDeclaration(myManager, declaration, field, KotlinWrappingLightClass.this);
}
return new LightField(myManager, field, KotlinWrappingLightClass.this);
return new KotlinNoOriginLightField(myManager, field, KotlinWrappingLightClass.this);
}
});
}
@@ -157,7 +155,7 @@ public abstract class KotlinWrappingLightClass extends AbstractLightClass implem
new KotlinLightMethodForTraitFakeOverride(myManager, method, declaration, KotlinWrappingLightClass.this);
}
return new LightMethod(myManager, method, KotlinWrappingLightClass.this);
return new KotlinNoOriginLightMethod(myManager, method, KotlinWrappingLightClass.this);
}
});
}
@@ -27,4 +27,8 @@ object Test7 {
}
// ANNOTATION: java.lang.Deprecated
// SEARCH: PsiMethod:test1, PsiMethod:test2, PsiMethod:test4, PsiMethod:test6, PsiMethod:test7
// SEARCH: KotlinLightMethodForDeclaration:test1
// SEARCH: KotlinLightMethodForDeclaration:test2
// SEARCH: KotlinLightMethodForDeclaration:test4
// SEARCH: KotlinLightMethodForDeclaration:test6
// SEARCH: KotlinLightMethodForDeclaration:test7
@@ -5,4 +5,5 @@ MyAnnotation("f", "s") class Test1() {}
annotation class MyAnnotation(val first: String, val second: String)
// ANNOTATION: MyAnnotation
// SEARCH: PsiMethod:test1, KotlinLightClass:Test1
// SEARCH: KotlinLightMethodForDeclaration:test1
// SEARCH: KotlinLightClass:Test1
+6 -1
View File
@@ -17,4 +17,9 @@ class MyTestClass {
}
// ANNOTATION: org.junit.Test
// SEARCH: PsiMethod:test1, PsiMethod:test2, PsiMethod:test3, PsiMethod:test4, PsiMethod:test5, PsiMethod:test6
// SEARCH: KotlinLightMethodForDeclaration:test1
// SEARCH: KotlinLightMethodForDeclaration:test2
// SEARCH: KotlinLightMethodForDeclaration:test3
// SEARCH: KotlinLightMethodForDeclaration:test4
// SEARCH: KotlinLightMethodForDeclaration:test5
// SEARCH: KotlinLightMethodForDeclaration:test6
@@ -10,4 +10,6 @@ class MyTestClass {
}
// ANNOTATION: org.junit.Test
// SEARCH: PsiMethod:test1, PsiMethod:test2, PsiMethod:test3
// SEARCH: KotlinLightMethodForDeclaration:test1
// SEARCH: KotlinLightMethodForDeclaration:test2
// SEARCH: KotlinLightMethodForDeclaration:test3