Test it's safe to call PsiElement methods on Kotlin light elements
This commit is contained in:
committed by
Nikolay Krasko
parent
7c752c1463
commit
178aba54dd
+2
@@ -27,4 +27,6 @@ public class KotlinLightTypeParameterListBuilder(manager: PsiManager): LightType
|
||||
override fun processDeclarations(processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement): Boolean {
|
||||
return getTypeParameters().all { processor.execute(it, state) }
|
||||
}
|
||||
|
||||
override fun getText(): String? = ""
|
||||
}
|
||||
|
||||
@@ -69,9 +69,9 @@ sealed class KtLightFieldImpl(
|
||||
|
||||
override fun hasModifierProperty(@NonNls name: String) = delegate.hasModifierProperty(name)
|
||||
|
||||
override fun getText() = delegate.text
|
||||
override fun getText() = origin?.text ?: ""
|
||||
|
||||
override fun getTextRange() = TextRange(-1, -1)
|
||||
override fun getTextRange() = origin?.textRange ?: TextRange.EMPTY_RANGE
|
||||
|
||||
override fun isValid() = containingClass.isValid
|
||||
|
||||
@@ -82,7 +82,7 @@ sealed class KtLightFieldImpl(
|
||||
override fun getDelegate() = delegate
|
||||
|
||||
override fun getNavigationElement() = origin ?: super.getNavigationElement()
|
||||
|
||||
|
||||
override fun isEquivalentTo(another: PsiElement?): Boolean {
|
||||
if (another is KtLightField && origin == another.getOrigin() && delegate == another.getDelegate()) {
|
||||
return true
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.asJava
|
||||
|
||||
import com.intellij.core.JavaCoreBundle
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.impl.light.LightMethod
|
||||
import com.intellij.psi.scope.PsiScopeProcessor
|
||||
@@ -68,6 +69,8 @@ sealed class KtLightMethodImpl(
|
||||
override fun getDelegate() = delegate
|
||||
override fun getOrigin() = origin
|
||||
override fun getParent(): PsiElement? = containingClass
|
||||
override fun getText() = origin?.text ?: ""
|
||||
override fun getTextRange() = origin?.textRange ?: TextRange.EMPTY_RANGE
|
||||
|
||||
override fun accept(visitor: PsiElementVisitor) {
|
||||
if (visitor is JavaElementVisitor) {
|
||||
@@ -140,7 +143,7 @@ sealed class KtLightMethodImpl(
|
||||
override fun hashCode(): Int = ((name.hashCode() * 31 + (origin?.hashCode() ?: 0)) * 31 + containingClass.hashCode()) * 31 + delegate.hashCode()
|
||||
|
||||
override fun toString(): String = "${this.javaClass.simpleName}:$name"
|
||||
|
||||
|
||||
private class KtLightMethodForDeclaration(
|
||||
delegate: PsiMethod, origin: KtDeclaration?, containingClass: KtLightClass
|
||||
) : KtLightMethodImpl(delegate, origin, containingClass)
|
||||
|
||||
@@ -135,4 +135,9 @@ public class KtLightParameter extends LightParameter implements KtLightElement<K
|
||||
public KtLightMethod getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,11 @@ public class KtLightTypeParameter
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
@@ -155,7 +155,7 @@ public abstract class KtWrappingLightClass extends AbstractLightClass implements
|
||||
@Override
|
||||
public String getText() {
|
||||
KtClassOrObject origin = getOrigin();
|
||||
return origin == null ? null : origin.getText();
|
||||
return origin == null ? "" : origin.getText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user