Stubbed VALUE_ARGUMENT_LIST and store it for annotations (KT-23738)

This commit is contained in:
Nikolay Krasko
2018-10-11 20:16:19 +03:00
parent 0f0dfe725e
commit fbb0e7d927
11 changed files with 53 additions and 5 deletions
@@ -62,7 +62,7 @@ public interface KtNodeTypes {
IElementType ANNOTATION_TARGET = KtStubElementTypes.ANNOTATION_TARGET;
IElementType TYPE_ARGUMENT_LIST = KtStubElementTypes.TYPE_ARGUMENT_LIST;
KtNodeType VALUE_ARGUMENT_LIST = new KtNodeType("VALUE_ARGUMENT_LIST", KtValueArgumentList.class);
IElementType VALUE_ARGUMENT_LIST = KtStubElementTypes.VALUE_ARGUMENT_LIST;
KtNodeType VALUE_ARGUMENT = new KtNodeType("VALUE_ARGUMENT", KtValueArgument.class);
KtNodeType LAMBDA_ARGUMENT = new KtNodeType("LAMBDA_ARGUMENT", KtLambdaArgument.class);
KtNodeType VALUE_ARGUMENT_NAME = new KtNodeType("VALUE_ARGUMENT_NAME", KtValueArgumentName.class);
@@ -20,7 +20,6 @@ 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;
@@ -64,7 +63,8 @@ public class KtAnnotationEntry extends KtElementImplStub<KotlinAnnotationEntrySt
if (stub != null && !stub.hasValueArguments()) {
return null;
}
return (KtValueArgumentList) findChildByType(KtNodeTypes.VALUE_ARGUMENT_LIST);
return getStubOrPsiChild(KtStubElementTypes.VALUE_ARGUMENT_LIST);
}
@NotNull
@@ -22,14 +22,20 @@ 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.psi.stubs.KotlinPlaceHolderStub;
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
import java.util.List;
public class KtValueArgumentList extends KtElementImpl {
public class KtValueArgumentList extends KtElementImplStub<KotlinPlaceHolderStub<KtValueArgumentList>> {
public KtValueArgumentList(@NotNull ASTNode node) {
super(node);
}
public KtValueArgumentList(@NotNull KotlinPlaceHolderStub<KtValueArgumentList> stub) {
super(stub, KtStubElementTypes.VALUE_ARGUMENT_LIST);
}
@Override
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
return visitor.visitValueArgumentList(this, data);
@@ -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 = 127
const val SOURCE_STUB_VERSION = 128
// 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).
@@ -101,6 +101,9 @@ public interface KtStubElementTypes {
KtPlaceHolderStubElementType<KtTypeArgumentList> TYPE_ARGUMENT_LIST =
new KtPlaceHolderStubElementType<>("TYPE_ARGUMENT_LIST", KtTypeArgumentList.class);
KtPlaceHolderStubElementType<KtValueArgumentList> VALUE_ARGUMENT_LIST =
new KtValueArgumentListElementType("VALUE_ARGUMENT_LIST");
KtPlaceHolderStubElementType<KtSuperTypeList> SUPER_TYPE_LIST =
new KtPlaceHolderStubElementType<>("SUPER_TYPE_LIST", KtSuperTypeList.class);
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.psi.stubs.elements;
import com.intellij.lang.ASTNode;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.psi.KtValueArgumentList;
public class KtValueArgumentListElementType extends KtPlaceHolderStubElementType<KtValueArgumentList> {
public KtValueArgumentListElementType(@NotNull @NonNls String debugName) {
super(debugName, KtValueArgumentList.class);
}
@Override
public boolean shouldCreateStub(ASTNode node) {
ASTNode treeParent = node.getTreeParent();
if (treeParent == null || treeParent.getElementType() != KtStubElementTypes.ANNOTATION_ENTRY) {
return false;
}
return super.shouldCreateStub(node);
}
}