Search in sources :

Example 1 with PsiFieldStubImpl

use of com.intellij.psi.impl.java.stubs.impl.PsiFieldStubImpl in project intellij-community by JetBrains.

the class JavaFieldStubElementType method deserialize.

@NotNull
@Override
public PsiFieldStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
    StringRef name = dataStream.readName();
    TypeInfo type = TypeInfo.readTYPE(dataStream);
    StringRef initializerText = dataStream.readName();
    byte flags = dataStream.readByte();
    return new PsiFieldStubImpl(parentStub, StringRef.toString(name), type, StringRef.toString(initializerText), flags);
}
Also used : PsiFieldStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiFieldStubImpl) StringRef(com.intellij.util.io.StringRef) TypeInfo(com.intellij.psi.impl.cache.TypeInfo) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PsiFieldStubImpl

use of com.intellij.psi.impl.java.stubs.impl.PsiFieldStubImpl in project intellij-community by JetBrains.

the class JavaFieldStubElementType method createStub.

@Override
public PsiFieldStub createStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub) {
    final TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);
    boolean isDeprecatedByComment = false;
    boolean hasDeprecatedAnnotation = false;
    boolean hasDocComment = false;
    String name = null;
    String initializer = null;
    boolean expectingInit = false;
    for (final LighterASTNode child : tree.getChildren(node)) {
        final IElementType type = child.getTokenType();
        if (type == JavaDocElementType.DOC_COMMENT) {
            hasDocComment = true;
            isDeprecatedByComment = RecordUtil.isDeprecatedByDocComment(tree, child);
        } else if (type == JavaElementType.MODIFIER_LIST) {
            hasDeprecatedAnnotation = RecordUtil.isDeprecatedByAnnotation(tree, child);
        } else if (type == JavaTokenType.IDENTIFIER) {
            name = RecordUtil.intern(tree.getCharTable(), child);
        } else if (type == JavaTokenType.EQ) {
            expectingInit = true;
        } else if (expectingInit && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) && type != JavaTokenType.SEMICOLON) {
            initializer = encodeInitializer(tree, child);
            break;
        }
    }
    final boolean isEnumConst = node.getTokenType() == JavaElementType.ENUM_CONSTANT;
    final byte flags = PsiFieldStubImpl.packFlags(isEnumConst, isDeprecatedByComment, hasDeprecatedAnnotation, hasDocComment);
    return new PsiFieldStubImpl(parentStub, name, typeInfo, initializer, flags);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) LighterASTNode(com.intellij.lang.LighterASTNode) PsiFieldStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiFieldStubImpl) TypeInfo(com.intellij.psi.impl.cache.TypeInfo)

Aggregations

TypeInfo (com.intellij.psi.impl.cache.TypeInfo)2 PsiFieldStubImpl (com.intellij.psi.impl.java.stubs.impl.PsiFieldStubImpl)2 LighterASTNode (com.intellij.lang.LighterASTNode)1 IElementType (com.intellij.psi.tree.IElementType)1 StringRef (com.intellij.util.io.StringRef)1 NotNull (org.jetbrains.annotations.NotNull)1