Java 类com.intellij.psi.stubs.StubOutputStream 实例源码

项目:intellij-ce-playground    文件:TypeInfo.java   
public static void writeTYPE(@NotNull StubOutputStream dataStream, @NotNull TypeInfo typeInfo) throws IOException {
  if (typeInfo == NULL) {
    dataStream.writeByte(FREQUENT_INDEX_MASK);
    return;
  }

  String text = typeInfo.text;
  byte arrayCount = typeInfo.arrayCount;
  int frequentIndex = ourFrequentTypeIndex.get(text);
  int flags = (typeInfo.isEllipsis ? HAS_ELLIPSIS : 0) | (arrayCount != 0 ? HAS_ARRAY_COUNT : 0) | frequentIndex;
  dataStream.writeByte(flags);

  if (arrayCount != 0) {
    dataStream.writeByte(arrayCount);
  }

  if (frequentIndex == 0) {
    dataStream.writeName(text);
  }
}
项目:intellij-ce-playground    文件:PyTargetExpressionElementType.java   
public void serialize(@NotNull final PyTargetExpressionStub stub, @NotNull final StubOutputStream stream)
    throws IOException {
  stream.writeName(stub.getName());
  final String docString = stub.getDocString();
  stream.writeUTFFast(docString != null ? docString : "");
  stream.writeVarInt(stub.getInitializerType().getIndex());
  final CustomTargetExpressionStub customStub = stub.getCustomStub(CustomTargetExpressionStub.class);
  if (customStub != null) {
    stream.writeName(customStub.getTypeClass().getCanonicalName());
    customStub.serialize(stream);
  }
  else {
    QualifiedName.serialize(stub.getInitializer(), stream);
    stream.writeBoolean(stub.isQualified());
  }
}
项目:tools-idea    文件:TypeInfo.java   
public static void writeTYPE(@NotNull StubOutputStream dataStream, @NotNull TypeInfo typeInfo) throws IOException {
  if (typeInfo == NULL) {
    dataStream.writeByte(FREQUENT_INDEX_MASK);
    return;
  }

  String text = typeInfo.text.getString();
  byte arrayCount = typeInfo.arrayCount;
  int frequentIndex = ourFrequentTypeIndex.get(text);
  int flags = (typeInfo.isEllipsis ? HAS_ELLIPSIS : 0) | (arrayCount != 0 ? HAS_ARRAY_COUNT : 0) | frequentIndex;
  dataStream.writeByte(flags);

  if (arrayCount != 0) {
    dataStream.writeByte(arrayCount);
  }

  if (frequentIndex == 0) {
    dataStream.writeName(text);
  }
}
项目:consulo-java    文件:TypeInfo.java   
public static void writeTYPE(@NotNull StubOutputStream dataStream, @NotNull TypeInfo typeInfo) throws IOException
{
    if(typeInfo == NULL)
    {
        dataStream.writeByte(FREQUENT_INDEX_MASK);
        return;
    }

    String text = typeInfo.text;
    byte arrayCount = typeInfo.arrayCount;
    int frequentIndex = ourFrequentTypeIndex.get(text);
    int flags = (typeInfo.isEllipsis ? HAS_ELLIPSIS : 0) | (arrayCount != 0 ? HAS_ARRAY_COUNT : 0) | frequentIndex;
    dataStream.writeByte(flags);

    if(arrayCount != 0)
    {
        dataStream.writeByte(arrayCount);
    }

    if(frequentIndex == 0)
    {
        dataStream.writeName(text);
    }
}
项目:bamboo-soy    文件:AtParamStub.java   
@Override
public void serialize(@NotNull AtParamStub stub, @NotNull StubOutputStream dataStream)
    throws IOException {
  dataStream.writeName(stub.getName());
  dataStream.writeName(stub.type);
  dataStream.writeBoolean(stub.isOptional);
}
项目:lua-for-idea    文件:LuaStubModuleDeclarationType.java   
@Override
public void serialize(LuaModuleDeclarationStub stub, StubOutputStream dataStream) throws IOException {
    dataStream.writeName(stub.getName());
    dataStream.writeName(stub.getModule());
    dataStream.writeVarInt(stub.getEncodedType().length);
    dataStream.write(stub.getEncodedType());
}
项目:lua-for-idea    文件:LuaStubUtils.java   
public static void writeSubstitutableType(LuaType type, byte[] encoded, StubOutputStream dataStream) throws IOException {
    final boolean primitive = type instanceof LuaPrimitiveType;

    dataStream.writeBoolean(primitive);

    if (primitive) {
        dataStream.writeByte(((LuaPrimitiveType) type).getId());
    } else {
        assert encoded != null : "Invalid encoded type";
        dataStream.writeVarInt(encoded.length);
        dataStream.write(encoded);
    }
}
项目:intellij-ce-playground    文件:JavaMethodElementType.java   
@Override
public void serialize(@NotNull final PsiMethodStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  TypeInfo.writeTYPE(dataStream, stub.getReturnTypeText(false));
  dataStream.writeByte(((PsiMethodStubImpl)stub).getFlags());
  if (stub.isAnnotationMethod()) {
    dataStream.writeName(stub.getDefaultValueText());
  }
}
项目: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    文件:JavaClassReferenceListElementType.java   
@Override
public void serialize(@NotNull PsiClassReferenceListStub stub, @NotNull StubOutputStream dataStream) throws IOException {
  byte role = encodeRole(stub.getRole());
  dataStream.writeByte(role);

  String[] names = stub.getReferencedNames();
  dataStream.writeVarInt(names.length);
  for (String name : names) {
    dataStream.writeName(name);
  }
}
项目:intellij-ce-playground    文件:JavaClassElementType.java   
@Override
public void serialize(@NotNull final PsiClassStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
  dataStream.writeByte(((PsiClassStubImpl)stub).getFlags());
  if (!stub.isAnonymous()) {
    dataStream.writeName(stub.getName());
    dataStream.writeName(stub.getQualifiedName());
    dataStream.writeByte(stub.getLanguageLevel().ordinal());
    dataStream.writeName(stub.getSourceFileName());
  }
  else {
    dataStream.writeName(stub.getBaseClassReferenceText());
  }
}
项目:intellij-ce-playground    文件:QualifiedName.java   
public static void serialize(@Nullable QualifiedName qName, StubOutputStream dataStream) throws IOException {
  if (qName == null) {
    dataStream.writeVarInt(0);
  }
  else {
    dataStream.writeVarInt(qName.getComponentCount());
    for (String s : qName.myComponents) {
      dataStream.writeName(s);
    }
  }
}
项目:intellij-ce-playground    文件:PyFileElementType.java   
private static void writeBitSet(StubOutputStream dataStream, BitSet bitset) throws IOException {
  // NOTE: here we assume that bitset has no more than 32 bits so that the value fits into an int.
  int result = 0;
  for (int i = 0; i < 32; i += 1) {
    int bit = (bitset.get(i) ? 1 : 0) << i;
    result |= bit;
  }
  dataStream.writeInt(result);
}
项目:intellij-ce-playground    文件:PyFileElementType.java   
public static void writeNullableList(StubOutputStream dataStream, final List<String> names) throws IOException {
  if (names == null) {
    dataStream.writeBoolean(false);
  }
  else {
    dataStream.writeBoolean(true);
    dataStream.writeVarInt(names.size());
    for (String name : names) {
      dataStream.writeName(name);
    }
  }
}
项目:intellij-ce-playground    文件:PyNamedParameterElementType.java   
public void serialize(@NotNull final PyNamedParameterStub stub, @NotNull final StubOutputStream dataStream)
    throws IOException {
  dataStream.writeName(stub.getName());

  byte flags = 0;
  if (stub.isPositionalContainer()) flags |= POSITIONAL_CONTAINER;
  if (stub.isKeywordContainer()) flags |= KEYWORD_CONTAINER;
  if (stub.hasDefaultValue()) flags |= HAS_DEFAULT_VALUE;
  dataStream.writeByte(flags);
}
项目:intellij-ce-playground    文件:ElementStubSerializer.java   
@Override
public void serialize(@NotNull ElementStub stub, @NotNull StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  dataStream.writeName(stub.getNamespaceKey());
  dataStream.writeVarInt(stub.getIndex());
  dataStream.writeBoolean(stub.isCustom());
  dataStream.writeName(stub.getElementClass());
  dataStream.writeUTFFast(stub.getValue());
}
项目:intellij-ce-playground    文件:GrMethodElementType.java   
@Override
public void serialize(@NotNull GrMethodStub stub, @NotNull StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  GrStubUtils.writeStringArray(dataStream, stub.getAnnotations());
  GrStubUtils.writeStringArray(dataStream, stub.getNamedParameters());
  GrStubUtils.writeNullableString(dataStream, stub.getTypeText());
  dataStream.writeByte(stub.getFlags());
}
项目:intellij-ce-playground    文件:GrFieldElementType.java   
static void serializeFieldStub(GrFieldStub stub, StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  GrStubUtils.writeStringArray(dataStream, stub.getAnnotations());
  GrStubUtils.writeStringArray(dataStream, stub.getNamedParameters());
  dataStream.writeByte(stub.getFlags());
  GrStubUtils.writeNullableString(dataStream, stub.getTypeText());
}
项目:intellij-ce-playground    文件:GrTypeDefinitionElementType.java   
@Override
public void serialize(@NotNull GrTypeDefinitionStub stub, @NotNull StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  dataStream.writeName(stub.getQualifiedName());
  dataStream.writeByte(stub.getFlags());
  writeStringArray(dataStream, stub.getSuperClassNames());
  writeStringArray(dataStream, stub.getAnnotations());
}
项目:intellij-ce-playground    文件:GrStubUtils.java   
public static void writeStringArray(StubOutputStream dataStream, String[] array) throws IOException {
  if (array.length > Byte.MAX_VALUE) {
    dataStream.writeByte(TOO_LONG);
    dataStream.writeInt(array.length);
  }
  else {
    dataStream.writeByte(array.length);
  }
  for (String s : array) {
    LOG.assertTrue(s != null);
    dataStream.writeName(s);
  }
}
项目:epigraph    文件:SerializedFqnTypeRef.java   
public void serialize(@NotNull StubOutputStream stream) throws IOException {
  initFromTypeRef();
  stream.writeName(shortName == null ? null : shortName.toString());
  if (shortName != null) {
    if (namespacesToSearch == null) stream.writeShort(0);
    else {
      // NB we're writing all namespaces to search for every type ref, but it won't take much space
      // thanks to names de-duplication done by IDEA. However this can be optimized further.
      // TODO(low) remove star imports from this list, write them at the file level
      // Estimated overhead is a few KBs per file at most.

      StubSerializerUtil.serializeCollection(namespacesToSearch, (item, s) -> s.writeName(item.toString()), stream);
    }
  }
}
项目:epigraph    文件:StubSerializerUtil.java   
public static <T> void serializeCollection(@Nullable Collection<T> collection,
                                           @NotNull Serializer<T> itemSerializer,
                                           @NotNull StubOutputStream stream) throws IOException {
  if (collection == null) stream.writeShort(0);
  else {
    stream.writeShort(collection.size());
    for (T item : collection) itemSerializer.serialize(item, stream);
  }
}
项目:epigraph    文件:StubSerializerUtil.java   
public static <T> void serializeCollection(@Nullable T[] collection,
                                           @NotNull Serializer<T> itemSerializer,
                                           @NotNull StubOutputStream stream) throws IOException {
  if (collection == null) stream.writeShort(0);
  else {
    stream.writeShort(collection.length);
    for (T item : collection) itemSerializer.serialize(item, stream);
  }
}
项目:tools-idea    文件:JavaMethodElementType.java   
@Override
public void serialize(@NotNull final PsiMethodStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  TypeInfo.writeTYPE(dataStream, stub.getReturnTypeText(false));
  dataStream.writeByte(((PsiMethodStubImpl)stub).getFlags());
  if (stub.isAnnotationMethod()) {
    dataStream.writeName(stub.getDefaultValueText());
  }
}
项目: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    文件:JavaClassReferenceListElementType.java   
@Override
public void serialize(@NotNull PsiClassReferenceListStub stub, @NotNull StubOutputStream dataStream) throws IOException {
  byte role = encodeRole(stub.getRole());
  dataStream.writeByte(role);

  String[] names = stub.getReferencedNames();
  dataStream.writeVarInt(names.length);
  for (String name : names) {
    dataStream.writeName(name);
  }
}
项目:tools-idea    文件:JavaClassElementType.java   
@Override
public void serialize(@NotNull final PsiClassStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
  dataStream.writeByte(((PsiClassStubImpl)stub).getFlags());
  if (!stub.isAnonymous()) {
    dataStream.writeName(stub.getName());
    dataStream.writeName(stub.getQualifiedName());
    dataStream.writeByte(stub.getLanguageLevel().ordinal());
    dataStream.writeName(stub.getSourceFileName());
  }
  else {
    dataStream.writeName(stub.getBaseClassReferenceText());
  }
}
项目:tools-idea    文件:GrMethodElementType.java   
public void serialize(@NotNull GrMethodStub stub, @NotNull StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  GrStubUtils.writeStringArray(dataStream, stub.getAnnotations());
  GrStubUtils.writeStringArray(dataStream, stub.getNamedParameters());
  GrStubUtils.writeNullableString(dataStream, stub.getTypeText());
  dataStream.writeByte(stub.getFlags());
}
项目:tools-idea    文件:GrFieldElementType.java   
static void serializeFieldStub(GrFieldStub stub, StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  GrStubUtils.writeStringArray(dataStream, stub.getAnnotations());
  GrStubUtils.writeStringArray(dataStream, stub.getNamedParameters());
  dataStream.writeByte(stub.getFlags());
  GrStubUtils.writeNullableString(dataStream, stub.getTypeText());
}
项目:tools-idea    文件:GrTypeDefinitionElementType.java   
public void serialize(@NotNull GrTypeDefinitionStub stub, @NotNull StubOutputStream dataStream) throws IOException {
  dataStream.writeName(stub.getName());
  dataStream.writeName(stub.getQualifiedName());
  dataStream.writeByte(stub.getFlags());
  writeStringArray(dataStream, stub.getSuperClassNames());
  writeStringArray(dataStream, stub.getAnnotations());
}
项目:tools-idea    文件:GrStubUtils.java   
public static void writeStringArray(StubOutputStream dataStream, String[] array) throws IOException {
  if (array.length > Byte.MAX_VALUE) {
    dataStream.writeByte(TOO_LONG);
    dataStream.writeInt(array.length);
  }
  else {
    dataStream.writeByte(array.length);
  }
  for (String s : array) {
    LOG.assertTrue(s != null);
    dataStream.writeName(s);
  }
}
项目:consulo-csharp    文件:CSharpMethodStubElementType.java   
@Override
public void serialize(@NotNull CSharpMethodDeclStub stub, @NotNull StubOutputStream stubOutputStream) throws IOException
{
    stubOutputStream.writeName(stub.getParentQName());
    stubOutputStream.writeInt(stub.getOtherModifierMask());
    stubOutputStream.writeInt(stub.getOperatorIndex());
}
项目:consulo-csharp    文件:CSharpReferenceExpressionStubElementType.java   
@Override
public void serialize(@NotNull CSharpReferenceExpressionStub stub, @NotNull StubOutputStream dataStream) throws IOException
{
    dataStream.writeName(stub.getReferenceText());
    dataStream.writeVarInt(stub.getKindIndex());
    dataStream.writeVarInt(stub.getMemberAccessTypeIndex());
    dataStream.writeBoolean(stub.isGlobal());
}
项目:consulo-csharp    文件:CSharpTypeListElementType.java   
@Override
public void serialize(@NotNull CSharpTypeListStub cSharpTypeListStub, @NotNull StubOutputStream stubOutputStream) throws IOException
{
    String[] references = cSharpTypeListStub.geShortReferences();
    stubOutputStream.writeByte(references.length);
    for(String reference : references)
    {
        stubOutputStream.writeName(reference);
    }
}
项目:consulo-csharp    文件:CSharpTypeStubElementType.java   
@Override
public void serialize(@NotNull CSharpTypeDeclStub stub, @NotNull StubOutputStream stubOutputStream) throws IOException
{
    stubOutputStream.writeName(stub.getParentQName());
    stubOutputStream.writeName(stub.getVmQName());
    stubOutputStream.writeInt(stub.getOtherModifierMask());
}
项目:consulo-lua    文件:LuaStubGlobalDeclarationType.java   
@Override
public void serialize(LuaGlobalDeclarationStub stub,
    StubOutputStream dataStream) throws IOException {
    dataStream.writeName(stub.getName());
    dataStream.writeName(stub.getModule());
    LuaStubUtils.writeSubstitutableType(stub.getLuaType(),
        stub.getEncodedType(), dataStream);
}
项目:consulo-lua    文件:LuaStubModuleDeclarationType.java   
@Override
public void serialize(LuaModuleDeclarationStub stub, StubOutputStream dataStream) throws IOException {
    dataStream.writeName(stub.getName());
    dataStream.writeName(stub.getModule());
    dataStream.writeVarInt(stub.getEncodedType().length);
    dataStream.write(stub.getEncodedType());
}
项目:consulo-lua    文件:LuaTableStubType.java   
@Override
public void serialize(LuaTableStub stub, StubOutputStream dataStream) throws IOException {
    final byte[] encodedType = stub.getEncodedType();
    final boolean hasType = encodedType != null;
    dataStream.writeBoolean(hasType);
    if (hasType) {
        dataStream.writeVarInt(encodedType.length);
        dataStream.write(encodedType);
    }
}
项目:consulo-lua    文件:LuaStubUtils.java   
public static void writeSubstitutableType(LuaType type, byte[] encoded, StubOutputStream dataStream) throws IOException {
    final boolean primitive = type instanceof LuaPrimitiveType;

    dataStream.writeBoolean(primitive);

    if (primitive) {
        dataStream.writeByte(((LuaPrimitiveType) type).getId());
    } else {
        assert encoded != null : "Invalid encoded type";
        dataStream.writeVarInt(encoded.length);
        dataStream.write(encoded);
    }
}
项目:consulo-javaee    文件:JspJavaFileElementType.java   
@Override
public void serialize(@NotNull PsiJavaFileStub stub, @NotNull StubOutputStream dataStream) throws IOException
{
    LanguageLevel level = stub.getLanguageLevel();
    dataStream.writeByte(level != null ? level.ordinal() : -1);
    dataStream.writeName(stub.getPackageName());
}