Java 类com.intellij.psi.impl.java.stubs.impl.PsiFieldStubImpl 实例源码

项目:intellij-ce-playground    文件:JavaFieldStubElementType.java   
@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);
}
项目:intellij-ce-playground    文件:JavaFieldStubElementType.java   
@Override
public void serialize(@NotNull final PsiFieldStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  TypeInfo.writeTYPE(dataStream, stub.getType(false));
  dataStream.writeName(stub.getInitializerText());
  dataStream.writeByte(((PsiFieldStubImpl)stub).getFlags());
}
项目:intellij-ce-playground    文件:JavaFieldStubElementType.java   
@NotNull
@Override
public PsiFieldStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
  final StringRef name = dataStream.readName();
  final TypeInfo type = TypeInfo.readTYPE(dataStream);
  final StringRef initializerText = dataStream.readName();
  final byte flags = dataStream.readByte();
  return new PsiFieldStubImpl(parentStub, name, type, initializerText, flags);
}
项目:tools-idea    文件:JavaFieldStubElementType.java   
@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;
  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) {
      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);

  return new PsiFieldStubImpl(parentStub, name, typeInfo, initializer, flags);
}
项目:tools-idea    文件:JavaFieldStubElementType.java   
@Override
public void serialize(@NotNull final PsiFieldStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  TypeInfo.writeTYPE(dataStream, stub.getType(false));
  dataStream.writeName(stub.getInitializerText());
  dataStream.writeByte(((PsiFieldStubImpl)stub).getFlags());
}
项目:tools-idea    文件:JavaFieldStubElementType.java   
@NotNull
@Override
public PsiFieldStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
  final StringRef name = dataStream.readName();
  final TypeInfo type = TypeInfo.readTYPE(dataStream);
  final StringRef initializerText = dataStream.readName();
  final byte flags = dataStream.readByte();
  return new PsiFieldStubImpl(parentStub, name, type, initializerText, flags);
}
项目:consulo-java    文件:JavaFieldStubElementType.java   
@Override
public void serialize(@NotNull final PsiFieldStub stub,
        @NotNull final StubOutputStream dataStream) throws IOException
{
    dataStream.writeName(stub.getName());
    TypeInfo.writeTYPE(dataStream, stub.getType(false));
    dataStream.writeName(stub.getInitializerText());
    dataStream.writeByte(((PsiFieldStubImpl) stub).getFlags());
}
项目:consulo-java    文件:JavaFieldStubElementType.java   
@NotNull
@Override
public PsiFieldStub deserialize(@NotNull final StubInputStream dataStream,
        final StubElement parentStub) throws IOException
{
    final StringRef name = dataStream.readName();
    final TypeInfo type = TypeInfo.readTYPE(dataStream);
    final StringRef initializerText = dataStream.readName();
    final byte flags = dataStream.readByte();
    return new PsiFieldStubImpl(parentStub, name, type, initializerText, flags);
}
项目:consulo-java    文件:JavaFieldStubElementType.java   
@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);
}