Search in sources :

Example 1 with SerializerNotFoundException

use of com.intellij.psi.stubs.SerializerNotFoundException in project intellij-community by JetBrains.

the class GroovyTraitMethodsFileIndex method read.

@Override
public PsiJavaFileStub read(@NotNull DataInput in) throws IOException {
    try {
        byte[] buffer = new byte[in.readInt()];
        in.readFully(buffer);
        return (PsiJavaFileStub) SerializationManagerEx.getInstanceEx().deserialize(new ByteArrayInputStream(buffer));
    } catch (SerializerNotFoundException e) {
        throw new IOException(e);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SerializerNotFoundException(com.intellij.psi.stubs.SerializerNotFoundException) IOException(java.io.IOException) PsiJavaFileStub(com.intellij.psi.impl.java.stubs.PsiJavaFileStub)

Example 2 with SerializerNotFoundException

use of com.intellij.psi.stubs.SerializerNotFoundException in project smali by JesusFreke.

the class LightCodeInsightParsingTestCase method doTest.

protected void doTest(boolean checkResult) {
    String name = getTestName(false);
    try {
        String text = loadFile(name + "." + myFileExt);
        PsiFile f = createPsiFile(name, text);
        if (f instanceof PsiFileImpl) {
            // Also want to test stub serialization/deserialization
            StubTree stubTree = ((PsiFileImpl) f).calcStubTree();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            SerializationManagerImpl.getInstanceEx().serialize(stubTree.getRoot(), baos);
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            SerializationManagerImpl.getInstanceEx().deserialize(bais);
        }
        ensureParsed(f);
        assertEquals("light virtual file text mismatch", text, ((LightVirtualFile) f.getVirtualFile()).getContent().toString());
        assertEquals("virtual file text mismatch", text, LoadTextUtil.loadText(f.getVirtualFile()));
        assertEquals("doc text mismatch", text, f.getViewProvider().getDocument().getText());
        assertEquals("psi text mismatch", text, f.getText());
        if (checkResult) {
            checkResult(name, f);
        } else {
            toParseTreeText(f, skipSpaces(), includeRanges());
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    } catch (SerializerNotFoundException e) {
        throw new RuntimeException(e);
    }
}
Also used : StubTree(com.intellij.psi.stubs.StubTree) ByteArrayInputStream(java.io.ByteArrayInputStream) PsiFileImpl(com.intellij.psi.impl.source.PsiFileImpl) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) SerializerNotFoundException(com.intellij.psi.stubs.SerializerNotFoundException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

SerializerNotFoundException (com.intellij.psi.stubs.SerializerNotFoundException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 PsiJavaFileStub (com.intellij.psi.impl.java.stubs.PsiJavaFileStub)1 PsiFileImpl (com.intellij.psi.impl.source.PsiFileImpl)1 StubTree (com.intellij.psi.stubs.StubTree)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1