Don't generate stub for value arguments list when no arguments present (KT-23738)
Need this to conform stubs list obtained by decompiler. Also ignore green stub, because is might not contain actual psi node.
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationEntryStub;
|
||||
@@ -60,8 +61,8 @@ public class KtAnnotationEntry extends KtElementImplStub<KotlinAnnotationEntrySt
|
||||
@Override
|
||||
public KtValueArgumentList getValueArgumentList() {
|
||||
KotlinAnnotationEntryStub stub = getStub();
|
||||
if (stub != null && !stub.hasValueArguments()) {
|
||||
return null;
|
||||
if (stub == null && getGreenStub() != null) {
|
||||
return (KtValueArgumentList) findChildByType(KtNodeTypes.VALUE_ARGUMENT_LIST);
|
||||
}
|
||||
|
||||
return getStubOrPsiChild(KtStubElementTypes.VALUE_ARGUMENT_LIST);
|
||||
@@ -70,6 +71,11 @@ public class KtAnnotationEntry extends KtElementImplStub<KotlinAnnotationEntrySt
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends ValueArgument> getValueArguments() {
|
||||
KotlinAnnotationEntryStub stub = getStub();
|
||||
if (stub != null && !stub.hasValueArguments()) {
|
||||
return Collections.<KtValueArgument>emptyList();
|
||||
}
|
||||
|
||||
KtValueArgumentList list = getValueArgumentList();
|
||||
return list != null ? list.getArguments() : Collections.<KtValueArgument>emptyList();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ object KotlinStubVersions {
|
||||
// Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version
|
||||
// if you are not 100% sure it can be avoided.
|
||||
// Increasing this version will lead to reindexing of all kotlin source files on the first IDE startup with the new version.
|
||||
const val SOURCE_STUB_VERSION = 133
|
||||
const val SOURCE_STUB_VERSION = 134
|
||||
|
||||
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
|
||||
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
|
||||
|
||||
+3
@@ -22,6 +22,9 @@ public class KtValueArgumentListElementType extends KtPlaceHolderStubElementType
|
||||
return false;
|
||||
}
|
||||
|
||||
KtValueArgumentList psi = node.getPsi(KtValueArgumentList.class);
|
||||
if (psi.getArguments().isEmpty()) return false;
|
||||
|
||||
return super.shouldCreateStub(node);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user