Search in sources :

Example 11 with StringRef

use of com.intellij.util.io.StringRef in project intellij-community by JetBrains.

the class PyTargetExpressionElementType method deserialize.

@NotNull
public PyTargetExpressionStub deserialize(@NotNull final StubInputStream stream, final StubElement parentStub) throws IOException {
    String name = StringRef.toString(stream.readName());
    String docString = stream.readUTFFast();
    if (docString.isEmpty()) {
        docString = null;
    }
    PyTargetExpressionStub.InitializerType initializerType = PyTargetExpressionStub.InitializerType.fromIndex(stream.readVarInt());
    final StringRef typeCommentRef = stream.readName();
    final String typeComment = typeCommentRef == null ? null : typeCommentRef.getString();
    if (initializerType == PyTargetExpressionStub.InitializerType.Custom) {
        final String typeName = stream.readName().getString();
        for (CustomTargetExpressionStubType type : getCustomStubTypes()) {
            if (type.getClass().getCanonicalName().equals(typeName)) {
                CustomTargetExpressionStub stub = type.deserializeStub(stream);
                return new PyTargetExpressionStubImpl(name, docString, typeComment, stub, parentStub);
            }
        }
        throw new IOException("Unknown custom stub type " + typeName);
    }
    QualifiedName initializer = QualifiedName.deserialize(stream);
    boolean isQualified = stream.readBoolean();
    return new PyTargetExpressionStubImpl(name, docString, initializerType, initializer, isQualified, typeComment, parentStub);
}
Also used : QualifiedName(com.intellij.psi.util.QualifiedName) StringRef(com.intellij.util.io.StringRef) IOException(java.io.IOException) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with StringRef

use of com.intellij.util.io.StringRef in project kotlin by JetBrains.

the class IdeStubIndexService method deserializeFileStub.

@NotNull
@Override
public KotlinFileStub deserializeFileStub(@NotNull StubInputStream dataStream) throws IOException {
    StringRef packageFqNameAsString = dataStream.readName();
    boolean isScript = dataStream.readBoolean();
    StringRef facadeSimpleName = dataStream.readName();
    StringRef partSimpleName = dataStream.readName();
    int numPartNames = dataStream.readInt();
    List<StringRef> facadePartNames = new ArrayList<StringRef>();
    for (int i = 0; i < numPartNames; ++i) {
        StringRef partNameRef = dataStream.readName();
        facadePartNames.add(partNameRef);
    }
    return new KotlinFileStubForIde(null, packageFqNameAsString, isScript, facadeSimpleName, partSimpleName, facadePartNames);
}
Also used : ArrayList(java.util.ArrayList) StringRef(com.intellij.util.io.StringRef) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with StringRef

use of com.intellij.util.io.StringRef in project kotlin by JetBrains.

the class IdeStubIndexService method createFileStub.

@NotNull
@Override
public KotlinFileStub createFileStub(@NotNull KtFile file) {
    StringRef packageFqName = StringRef.fromString(file.getPackageFqNameByTree().asString());
    boolean isScript = file.isScriptByTree();
    if (PackagePartClassUtils.fileHasTopLevelCallables(file)) {
        JvmFileClassInfo fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(file);
        StringRef facadeSimpleName = StringRef.fromString(fileClassInfo.getFacadeClassFqName().shortName().asString());
        StringRef partSimpleName = StringRef.fromString(fileClassInfo.getFileClassFqName().shortName().asString());
        return new KotlinFileStubForIde(file, packageFqName, isScript, facadeSimpleName, partSimpleName, null);
    }
    return new KotlinFileStubForIde(file, packageFqName, isScript, null, null, null);
}
Also used : JvmFileClassInfo(org.jetbrains.kotlin.fileClasses.JvmFileClassInfo) StringRef(com.intellij.util.io.StringRef) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with StringRef

use of com.intellij.util.io.StringRef in project kotlin by JetBrains.

the class IdeStubIndexService method serializeFileStub.

@Override
public void serializeFileStub(@NotNull KotlinFileStub stub, @NotNull StubOutputStream dataStream) throws IOException {
    KotlinFileStubForIde fileStub = (KotlinFileStubForIde) stub;
    dataStream.writeName(fileStub.getPackageFqName().asString());
    dataStream.writeBoolean(fileStub.isScript());
    dataStream.writeName(StringRef.toString(fileStub.getFacadeSimpleName()));
    dataStream.writeName(StringRef.toString(fileStub.getPartSimpleName()));
    List<StringRef> facadePartNames = fileStub.getFacadePartSimpleNames();
    if (facadePartNames == null) {
        dataStream.writeInt(0);
    } else {
        dataStream.writeInt(facadePartNames.size());
        for (StringRef partName : facadePartNames) {
            dataStream.writeName(StringRef.toString(partName));
        }
    }
}
Also used : StringRef(com.intellij.util.io.StringRef)

Example 15 with StringRef

use of com.intellij.util.io.StringRef in project intellij-community by JetBrains.

the class JavaClassElementType method deserialize.

@NotNull
@Override
public PsiClassStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
    byte flags = dataStream.readByte();
    boolean isAnonymous = PsiClassStubImpl.isAnonymous(flags);
    boolean isEnumConst = PsiClassStubImpl.isEnumConstInitializer(flags);
    JavaClassElementType type = typeForClass(isAnonymous, isEnumConst);
    if (!isAnonymous) {
        StringRef name = dataStream.readName();
        StringRef qname = dataStream.readName();
        StringRef sourceFileName = dataStream.readName();
        PsiClassStubImpl classStub = new PsiClassStubImpl(type, parentStub, StringRef.toString(qname), StringRef.toString(name), null, flags);
        classStub.setSourceFileName(StringRef.toString(sourceFileName));
        return classStub;
    } else {
        StringRef baseRef = dataStream.readName();
        return new PsiClassStubImpl(type, parentStub, null, null, StringRef.toString(baseRef), flags);
    }
}
Also used : PsiClassStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiClassStubImpl) StringRef(com.intellij.util.io.StringRef) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StringRef (com.intellij.util.io.StringRef)32 NotNull (org.jetbrains.annotations.NotNull)24 FqName (org.jetbrains.kotlin.name.FqName)6 TypeInfo (com.intellij.psi.impl.cache.TypeInfo)3 QualifiedName (com.intellij.psi.util.QualifiedName)2 IOException (java.io.IOException)2 Nullable (org.jetbrains.annotations.Nullable)2 KotlinImportDirectiveStubImpl (org.jetbrains.kotlin.psi.stubs.impl.KotlinImportDirectiveStubImpl)2 KotlinParameterStubImpl (org.jetbrains.kotlin.psi.stubs.impl.KotlinParameterStubImpl)2 PsiClassStubImpl (com.intellij.psi.impl.java.stubs.impl.PsiClassStubImpl)1 PsiFieldStubImpl (com.intellij.psi.impl.java.stubs.impl.PsiFieldStubImpl)1 PsiImportStatementStubImpl (com.intellij.psi.impl.java.stubs.impl.PsiImportStatementStubImpl)1 PsiJavaFileStubImpl (com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl)1 PsiMethodStubImpl (com.intellij.psi.impl.java.stubs.impl.PsiMethodStubImpl)1 PsiParameterStubImpl (com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl)1 PyFileStubImpl (com.jetbrains.python.psi.impl.stubs.PyFileStubImpl)1 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 JvmFileClassInfo (org.jetbrains.kotlin.fileClasses.JvmFileClassInfo)1 KotlinAnnotationEntryStubImpl (org.jetbrains.kotlin.psi.stubs.impl.KotlinAnnotationEntryStubImpl)1