[FE] Minor: do not try to check stub is not null
This commit is contained in:
committed by
TeamCityServer
parent
617af898b0
commit
f75571b97a
@@ -188,38 +188,10 @@ abstract class KtClassOrObject :
|
|||||||
return parts.joinToString(separator = ".")
|
return parts.joinToString(separator = ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getContextReceiverList(): KtContextReceiverList? {
|
fun getContextReceiverList(): KtContextReceiverList? = getStubOrPsiChild(KtStubElementTypes.CONTEXT_RECEIVER_LIST)
|
||||||
val stub = stub
|
|
||||||
if (stub != null) {
|
|
||||||
return getStubOrPsiChild(KtStubElementTypes.CONTEXT_RECEIVER_LIST)
|
|
||||||
}
|
|
||||||
var node = node.firstChildNode
|
|
||||||
while (node != null) {
|
|
||||||
val tt = node.elementType
|
|
||||||
if (tt === KtNodeTypes.CONTEXT_RECEIVER_LIST) {
|
|
||||||
return node.psi as KtContextReceiverList
|
|
||||||
}
|
|
||||||
node = node.treeNext
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getContextReceivers(): List<KtContextReceiver> {
|
override fun getContextReceivers(): List<KtContextReceiver> =
|
||||||
val stub = stub
|
getContextReceiverList()?.let { return it.contextReceivers() } ?: emptyList()
|
||||||
if (stub != null) {
|
|
||||||
return getStubOrPsiChildrenAsList(KtStubElementTypes.CONTEXT_RECEIVER)
|
|
||||||
}
|
|
||||||
var node = node.firstChildNode
|
|
||||||
while (node != null) {
|
|
||||||
val tt = node.elementType
|
|
||||||
if (tt === KtNodeTypes.CONTEXT_RECEIVER_LIST) {
|
|
||||||
val contextReceiver = node.psi as KtContextReceiverList
|
|
||||||
return contextReceiver.contextReceivers()
|
|
||||||
}
|
|
||||||
node = node.treeNext
|
|
||||||
}
|
|
||||||
return emptyList()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -201,13 +201,12 @@ public class KtNamedFunction extends KtTypeParameterListOwnerStub<KotlinFunction
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<KtContextReceiver> getContextReceivers() {
|
public List<KtContextReceiver> getContextReceivers() {
|
||||||
KtContextReceiverList list = getContextReceiverList();
|
KtContextReceiverList contextReceiverList = getStubOrPsiChild(KtStubElementTypes.CONTEXT_RECEIVER_LIST);
|
||||||
return list != null ? list.contextReceivers() : Collections.emptyList();
|
if (contextReceiverList != null) {
|
||||||
}
|
return contextReceiverList.contextReceivers();
|
||||||
|
} else {
|
||||||
@Nullable
|
return Collections.emptyList();
|
||||||
private KtContextReceiverList getContextReceiverList() {
|
}
|
||||||
return getStubOrPsiChild(KtStubElementTypes.CONTEXT_RECEIVER_LIST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -117,33 +117,12 @@ public class KtProperty extends KtTypeParameterListOwnerStub<KotlinPropertyStub>
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<KtContextReceiver> getContextReceivers() {
|
public List<KtContextReceiver> getContextReceivers() {
|
||||||
KotlinPropertyStub stub = getStub();
|
KtContextReceiverList contextReceiverList = getStubOrPsiChild(KtStubElementTypes.CONTEXT_RECEIVER_LIST);
|
||||||
if (stub != null) {
|
if (contextReceiverList != null) {
|
||||||
KtContextReceiverList contextReceiver = getStubOrPsiChild(KtStubElementTypes.CONTEXT_RECEIVER_LIST);
|
return contextReceiverList.contextReceivers();
|
||||||
if (contextReceiver != null) {
|
} else {
|
||||||
return contextReceiver.contextReceivers();
|
return Collections.emptyList();
|
||||||
} else {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return getContextReceiverTypeRefsByTree();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private List<KtContextReceiver> getContextReceiverTypeRefsByTree() {
|
|
||||||
ASTNode node = getNode().getFirstChildNode();
|
|
||||||
while (node != null) {
|
|
||||||
IElementType tt = node.getElementType();
|
|
||||||
if (tt == KtTokens.COLON) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (tt == KtNodeTypes.CONTEXT_RECEIVER_LIST) {
|
|
||||||
KtContextReceiverList contextReceiver = (KtContextReceiverList) node.getPsi();
|
|
||||||
return contextReceiver.contextReceivers();
|
|
||||||
}
|
|
||||||
node = node.getTreeNext();
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
Reference in New Issue
Block a user