use of org.elixir_lang.beam.chunk.Atoms in project intellij-elixir by KronicDeth.
the class BeamTest method elixirModule.
@Test
public void elixirModule() throws IOException, OtpErlangDecodeException {
Beam beam = beam("Elixir.Kernel");
assertNotNull(beam);
Atoms atoms = beam.atoms();
assertNotNull(atoms);
assertEquals("Elixir.Kernel", atoms.moduleName());
Exports exports = beam.exports();
assertNotNull(exports);
int exportCount = exports.size();
assertTrue("There are no exports", exportCount > 0);
SortedSet<MacroNameArity> macroNameAritySortedSet = exports.macroNameAritySortedSet(atoms);
assertEquals("There are nameless exports", exportCount, macroNameAritySortedSet.size());
List<MacroNameArity> nodes = ContainerUtil.filter(macroNameAritySortedSet, new Condition<MacroNameArity>() {
@Override
public boolean value(MacroNameArity macroNameArity) {
return "node".equals(macroNameArity.name);
}
});
assertEquals(nodes.size(), 2);
assertEquals(0, (int) nodes.get(0).arity);
assertEquals(1, (int) nodes.get(1).arity);
}
use of org.elixir_lang.beam.chunk.Atoms in project intellij-elixir by KronicDeth.
the class BeamTest method erlangModule.
@Test
public void erlangModule() throws IOException, OtpErlangDecodeException {
Beam beam = beam("elixir_interpolation");
assertNotNull(beam);
Atoms atoms = beam.atoms();
assertNotNull(atoms);
assertEquals("elixir_interpolation", atoms.moduleName());
Exports exports = beam.exports();
assertNotNull(exports);
int exportCount = exports.size();
assertTrue("There are no exports", exportCount > 0);
SortedSet<MacroNameArity> macroNameAritySortedSet = exports.macroNameAritySortedSet(atoms);
assertEquals("There are nameless exports", exportCount, macroNameAritySortedSet.size());
List<MacroNameArity> extracts = ContainerUtil.filter(macroNameAritySortedSet, new Condition<MacroNameArity>() {
@Override
public boolean value(MacroNameArity macroNameArity) {
return "extract".equals(macroNameArity.name);
}
});
assertEquals(1, extracts.size());
assertEquals(6, (int) extracts.get(0).arity);
}
use of org.elixir_lang.beam.chunk.Atoms in project intellij-elixir by KronicDeth.
the class Decompiler method decompiled.
@NotNull
private static CharSequence decompiled(@Nullable Beam beam) {
StringBuilder decompiled = new StringBuilder("Decompilated Error");
if (beam != null) {
Atoms atoms = beam.atoms();
if (atoms != null) {
String moduleName = atoms.moduleName();
if (moduleName != null) {
String defmoduleArgument = defmoduleArgument(moduleName);
decompiled = new StringBuilder("# Source code recreated from a .beam file by IntelliJ Elixir\n").append("defmodule ").append(defmoduleArgument).append(" do\n");
appendExports(decompiled, beam, atoms);
decompiled.append("end\n");
}
}
}
return decompiled;
}
use of org.elixir_lang.beam.chunk.Atoms 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;
}
use of org.elixir_lang.beam.chunk.Atoms in project intellij-elixir by KronicDeth.
the class Beam method atoms.
/*
* Instance Methods
*/
@Nullable
public Atoms atoms() {
Atoms atoms = null;
Chunk chunk = chunk(ATOM);
if (chunk != null) {
atoms = Atoms.from(chunk);
}
return atoms;
}
Aggregations