Search in sources :

Example 1 with ModuleStub

use of org.elixir_lang.beam.psi.stubs.ModuleStub in project intellij-elixir by KronicDeth.

the class BeamFileImpl method buildFileStub.

public static PsiFileStub<?> buildFileStub(byte[] bytes) {
    ElixirFileStubImpl stub = new ElixirFileStubImpl();
    Beam beam = null;
    try {
        beam = Beam.from(bytes);
    } catch (IOException e) {
        LOGGER.error(e);
    } catch (OtpErlangDecodeException e) {
        LOGGER.error(e);
    }
    ModuleStub moduleStub = buildModuleStub(stub, beam);
    if (moduleStub == null) {
        stub = null;
    }
    return stub;
}
Also used : ElixirFileStubImpl(org.elixir_lang.psi.stub.impl.ElixirFileStubImpl) Beam(org.elixir_lang.beam.Beam) OtpErlangDecodeException(com.ericsson.otp.erlang.OtpErlangDecodeException) ModuleStub(org.elixir_lang.beam.psi.stubs.ModuleStub) IOException(java.io.IOException)

Example 2 with ModuleStub

use of org.elixir_lang.beam.psi.stubs.ModuleStub in project intellij-elixir by KronicDeth.

the class BeamFileImpl method buildModuleStub.

@Nullable
private static ModuleStub buildModuleStub(PsiFileStub<ElixirFile> parentStub, Beam beam) {
    ModuleStub moduleStub = null;
    if (beam != null) {
        Atoms atoms = beam.atoms();
        if (atoms != null) {
            String moduleName = atoms.moduleName();
            if (moduleName != null) {
                String name = defmoduleArgument(moduleName);
                moduleStub = new ModuleStubImpl(parentStub, name);
                buildCallDefinitions(moduleStub, beam, atoms);
            }
        }
    }
    return moduleStub;
}
Also used : ModuleStubImpl(org.elixir_lang.beam.psi.impl.ModuleStubImpl) Atoms(org.elixir_lang.beam.chunk.Atoms) ModuleStub(org.elixir_lang.beam.psi.stubs.ModuleStub) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ModuleStub (org.elixir_lang.beam.psi.stubs.ModuleStub)2 OtpErlangDecodeException (com.ericsson.otp.erlang.OtpErlangDecodeException)1 IOException (java.io.IOException)1 Beam (org.elixir_lang.beam.Beam)1 Atoms (org.elixir_lang.beam.chunk.Atoms)1 ModuleStubImpl (org.elixir_lang.beam.psi.impl.ModuleStubImpl)1 ElixirFileStubImpl (org.elixir_lang.psi.stub.impl.ElixirFileStubImpl)1 Nullable (org.jetbrains.annotations.Nullable)1