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); } }
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()); } }
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); } }
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); } }
@Override public void serialize(@NotNull AtParamStub stub, @NotNull StubOutputStream dataStream) throws IOException { dataStream.writeName(stub.getName()); dataStream.writeName(stub.type); dataStream.writeBoolean(stub.isOptional); }
@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()); }
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); } }
@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()); } }
@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()); }
@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); } }
@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()); } }
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); } } }
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); }
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); } } }
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); }
@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()); }
@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()); }
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()); }
@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()); }
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); } }
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); } } }
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); } }
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); } }
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()); }
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()); }
@Override public void serialize(@NotNull CSharpMethodDeclStub stub, @NotNull StubOutputStream stubOutputStream) throws IOException { stubOutputStream.writeName(stub.getParentQName()); stubOutputStream.writeInt(stub.getOtherModifierMask()); stubOutputStream.writeInt(stub.getOperatorIndex()); }
@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()); }
@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); } }
@Override public void serialize(@NotNull CSharpTypeDeclStub stub, @NotNull StubOutputStream stubOutputStream) throws IOException { stubOutputStream.writeName(stub.getParentQName()); stubOutputStream.writeName(stub.getVmQName()); stubOutputStream.writeInt(stub.getOtherModifierMask()); }
@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); }
@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); } }
@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()); }