Serialize annotation target psi element
This commit is contained in:
@@ -22,18 +22,28 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
|||||||
import org.jetbrains.kotlin.lexer.JetKeywordToken
|
import org.jetbrains.kotlin.lexer.JetKeywordToken
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens
|
import org.jetbrains.kotlin.lexer.JetTokens
|
||||||
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationEntryStub
|
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationEntryStub
|
||||||
|
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationUseSiteTargetStub
|
||||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub
|
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub
|
||||||
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes
|
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes
|
||||||
|
|
||||||
public class JetAnnotationUseSiteTarget : JetElementImplStub<KotlinPlaceHolderStub<JetAnnotationUseSiteTarget>> {
|
public class JetAnnotationUseSiteTarget : JetElementImplStub<KotlinAnnotationUseSiteTargetStub> {
|
||||||
|
|
||||||
constructor(node: ASTNode) : super(node)
|
constructor(node: ASTNode) : super(node)
|
||||||
|
|
||||||
constructor(stub: KotlinPlaceHolderStub<JetAnnotationUseSiteTarget>) : super(stub, JetStubElementTypes.ANNOTATION_TARGET)
|
constructor(stub: KotlinAnnotationUseSiteTargetStub) : super(stub, JetStubElementTypes.ANNOTATION_TARGET)
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: JetVisitor<R, D>, data: D) = visitor.visitAnnotationUseSiteTarget(this, data)
|
override fun <R, D> accept(visitor: JetVisitor<R, D>, data: D) = visitor.visitAnnotationUseSiteTarget(this, data)
|
||||||
|
|
||||||
public fun getAnnotationUseSiteTarget(): AnnotationUseSiteTarget {
|
public fun getAnnotationUseSiteTarget(): AnnotationUseSiteTarget {
|
||||||
|
val targetString = stub?.getUseSiteTarget()
|
||||||
|
if (targetString != null) {
|
||||||
|
try {
|
||||||
|
return AnnotationUseSiteTarget.valueOf(targetString)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
// Ok, resolve via node tree
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val node = getFirstChild().getNode()
|
val node = getFirstChild().getNode()
|
||||||
return when (node.getElementType()) {
|
return when (node.getElementType()) {
|
||||||
JetTokens.FIELD_KEYWORD -> AnnotationUseSiteTarget.FIELD
|
JetTokens.FIELD_KEYWORD -> AnnotationUseSiteTarget.FIELD
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ public interface KotlinAnnotationEntryStub : StubElement<JetAnnotationEntry> {
|
|||||||
public fun hasValueArguments(): Boolean
|
public fun hasValueArguments(): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface KotlinAnnotationUseSiteTargetStub : StubElement<JetAnnotationUseSiteTarget> {
|
||||||
|
public fun getUseSiteTarget(): String
|
||||||
|
}
|
||||||
|
|
||||||
public interface KotlinFunctionStub : KotlinCallableStubBase<JetNamedFunction> {
|
public interface KotlinFunctionStub : KotlinCallableStubBase<JetNamedFunction> {
|
||||||
public fun hasBlockBody(): Boolean
|
public fun hasBlockBody(): Boolean
|
||||||
public fun hasBody(): Boolean
|
public fun hasBody(): Boolean
|
||||||
|
|||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.psi.stubs.elements
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.stubs.StubElement
|
||||||
|
import com.intellij.psi.stubs.StubInputStream
|
||||||
|
import com.intellij.psi.stubs.StubOutputStream
|
||||||
|
import com.intellij.util.io.StringRef
|
||||||
|
import org.jetbrains.kotlin.psi.JetAnnotationUseSiteTarget
|
||||||
|
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationUseSiteTargetStub
|
||||||
|
import org.jetbrains.kotlin.psi.stubs.impl.KotlinAnnotationUseSiteTargetStubImpl
|
||||||
|
|
||||||
|
public class JetAnnotationUseSiteTargetElementType(debugName: String) : JetStubElementType<KotlinAnnotationUseSiteTargetStub, JetAnnotationUseSiteTarget>(
|
||||||
|
debugName, javaClass<JetAnnotationUseSiteTarget>(), javaClass<KotlinAnnotationUseSiteTargetStub>()
|
||||||
|
) {
|
||||||
|
|
||||||
|
override fun createStub(psi: JetAnnotationUseSiteTarget, parentStub: StubElement<PsiElement>): KotlinAnnotationUseSiteTargetStub {
|
||||||
|
val useSiteTarget = psi.getAnnotationUseSiteTarget().name()
|
||||||
|
return KotlinAnnotationUseSiteTargetStubImpl(parentStub, StringRef.fromString(useSiteTarget)!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(stub: KotlinAnnotationUseSiteTargetStub, dataStream: StubOutputStream) {
|
||||||
|
dataStream.writeName(stub.getUseSiteTarget())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<PsiElement>): KotlinAnnotationUseSiteTargetStub {
|
||||||
|
val useSiteTarget = dataStream.readName()
|
||||||
|
return KotlinAnnotationUseSiteTargetStubImpl(parentStub, useSiteTarget)
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-2
@@ -50,8 +50,7 @@ public interface JetStubElementTypes {
|
|||||||
JetPlaceHolderStubElementType<JetAnnotation> ANNOTATION =
|
JetPlaceHolderStubElementType<JetAnnotation> ANNOTATION =
|
||||||
new JetPlaceHolderStubElementType<JetAnnotation>("ANNOTATION", JetAnnotation.class);
|
new JetPlaceHolderStubElementType<JetAnnotation>("ANNOTATION", JetAnnotation.class);
|
||||||
|
|
||||||
JetPlaceHolderStubElementType<JetAnnotationUseSiteTarget> ANNOTATION_TARGET =
|
JetAnnotationUseSiteTargetElementType ANNOTATION_TARGET = new JetAnnotationUseSiteTargetElementType("ANNOTATION_TARGET");
|
||||||
new JetPlaceHolderStubElementType<JetAnnotationUseSiteTarget>("ANNOTATION_TARGET", JetAnnotationUseSiteTarget.class);
|
|
||||||
|
|
||||||
JetPlaceHolderStubElementType<JetClassBody> CLASS_BODY =
|
JetPlaceHolderStubElementType<JetClassBody> CLASS_BODY =
|
||||||
new JetPlaceHolderStubElementType<JetClassBody>("CLASS_BODY", JetClassBody.class);
|
new JetPlaceHolderStubElementType<JetClassBody>("CLASS_BODY", JetClassBody.class);
|
||||||
|
|||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.psi.stubs.impl
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.stubs.StubElement
|
||||||
|
import com.intellij.util.io.StringRef
|
||||||
|
import org.jetbrains.kotlin.psi.JetAnnotationUseSiteTarget
|
||||||
|
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationUseSiteTargetStub
|
||||||
|
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes
|
||||||
|
|
||||||
|
public class KotlinAnnotationUseSiteTargetStubImpl(
|
||||||
|
parent: StubElement<out PsiElement>?,
|
||||||
|
private val target: StringRef
|
||||||
|
) : KotlinStubBaseImpl<JetAnnotationUseSiteTarget>(parent, JetStubElementTypes.ANNOTATION_TARGET), KotlinAnnotationUseSiteTargetStub {
|
||||||
|
|
||||||
|
override fun getUseSiteTarget() = target.string
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user