Use stubs in KtProperty for getDelegate() and getDelegateExpression()

This commit is contained in:
Nikolay Krasko
2018-10-18 15:59:23 +03:00
parent f892714bea
commit 4f52f62b44
@@ -37,7 +37,7 @@ import java.util.Collections;
import java.util.List;
import static org.jetbrains.kotlin.KtNodeTypes.PROPERTY_DELEGATE;
import static org.jetbrains.kotlin.lexer.KtTokens.*;
import static org.jetbrains.kotlin.lexer.KtTokens.EQ;
public class KtProperty extends KtTypeParameterListOwnerStub<KotlinPropertyStub>
implements KtVariableDeclaration, PsiModifiableCodeBlock {
@@ -195,11 +195,17 @@ public class KtProperty extends KtTypeParameterListOwnerStub<KotlinPropertyStub>
if (stub != null) {
return stub.hasDelegate();
}
return getDelegate() != null;
}
@Nullable
public KtPropertyDelegate getDelegate() {
KotlinPropertyStub stub = getStub();
if (stub != null && !stub.hasDelegate()) {
return null;
}
return (KtPropertyDelegate) findChildByType(PROPERTY_DELEGATE);
}
@@ -208,15 +214,22 @@ public class KtProperty extends KtTypeParameterListOwnerStub<KotlinPropertyStub>
if (stub != null) {
return stub.hasDelegateExpression();
}
return getDelegateExpression() != null;
}
@Nullable
public KtExpression getDelegateExpression() {
KotlinPropertyStub stub = getStub();
if (stub != null && !stub.hasDelegateExpression()) {
return null;
}
KtPropertyDelegate delegate = getDelegate();
if (delegate != null) {
return delegate.getExpression();
}
return null;
}