Search in sources :

Example 1 with ErlAttribute

use of org.erlide.engine.internal.model.erlang.ErlAttribute in project erlide_eclipse by erlang.

the class ErlParser method addModuleAttribute.

private IErlAttribute addModuleAttribute(final IErlModule module, final OtpErlangObject pos, final OtpErlangAtom value, final OtpErlangObject extra, final String nameS) {
    final String s = Util.stringValue(extra);
    final ErlAttribute r = new ErlAttribute(module, nameS, value, s);
    setPos(r, pos);
    return r;
}
Also used : IErlAttribute(org.erlide.engine.model.erlang.IErlAttribute) ErlAttribute(org.erlide.engine.internal.model.erlang.ErlAttribute) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 2 with ErlAttribute

use of org.erlide.engine.internal.model.erlang.ErlAttribute in project erlide_eclipse by erlang.

the class IParentTest method addChild.

// void addChild(IErlElement child);
@Test
public void addChild() throws Exception {
    module.open(null);
    final int childCount = module.getChildCount();
    final String aname = "test_a";
    final IErlAttribute attribute = new ErlAttribute(module, aname, null, "test");
    module.addChild(attribute);
    final int childCount2 = module.getChildCount();
    final IErlElement childNamed = module.getChildNamed(aname);
    assertEquals(childCount + 1, childCount2);
    assertEquals(attribute, childNamed);
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) ErlAttribute(org.erlide.engine.internal.model.erlang.ErlAttribute) Test(org.junit.Test)

Example 3 with ErlAttribute

use of org.erlide.engine.internal.model.erlang.ErlAttribute in project erlide_eclipse by erlang.

the class ErlParser method addOtherAttribute.

private IErlAttribute addOtherAttribute(final IErlModule module, final OtpErlangObject pos, final OtpErlangObject val, final OtpErlangObject extra, final String nameS) {
    // user-defined attribute? or maybe if else endif...
    // OtpErlangObject val1 = concreteTerm(val);
    // if (val instanceof OtpErlangList) {
    // final OtpErlangList list = (OtpErlangList) val;
    // if (list.arity() == 0) {
    // val1 = null;
    // }
    // }
    // final ErlAttribute a = new ErlAttribute(parent, nameS, val1, null);
    OtpErlangObject o = val;
    if (o instanceof OtpErlangAtom) {
        final OtpErlangAtom u = (OtpErlangAtom) o;
        if ("u".equals(u.atomValue())) {
            o = null;
        }
    }
    final ErlAttribute a = new ErlAttribute(module, nameS, o, Util.stringValue(extra));
    setPos(a, pos);
    // a.setParseTree(val);
    return a;
}
Also used : IErlAttribute(org.erlide.engine.model.erlang.IErlAttribute) ErlAttribute(org.erlide.engine.internal.model.erlang.ErlAttribute) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 4 with ErlAttribute

use of org.erlide.engine.internal.model.erlang.ErlAttribute in project erlide_eclipse by erlang.

the class TestingSupport method createErlAttribute.

public static IErlElement createErlAttribute(final IParent parent, final String name, final OtpErlangObject value, final String extra, final int sourceRangeOffset, final int sourceRangeLength) {
    final ErlAttribute attribute = new ErlAttribute(parent, name, value, extra);
    attribute.setSourceRangeOffset(sourceRangeOffset);
    attribute.setSourceRangeLength(sourceRangeLength);
    return attribute;
}
Also used : ErlAttribute(org.erlide.engine.internal.model.erlang.ErlAttribute)

Example 5 with ErlAttribute

use of org.erlide.engine.internal.model.erlang.ErlAttribute in project erlide_eclipse by erlang.

the class IParentTest method setChildren.

// public void setChildren(final Collection<? extends IErlElement>
// children);
@Test
public void setChildren() throws Exception {
    module.open(null);
    final List<IErlElement> children = module.getChildren();
    final String aname = "test_a";
    final IErlAttribute attribute = new ErlAttribute(module, aname, null, "test");
    module.setChildren(Lists.newArrayList(attribute));
    final int childCount = module.getChildCount();
    final List<IErlElement> children2 = module.getChildren();
    final IErlElement element = children2.iterator().next();
    assertEquals(1, childCount);
    assertFalse(children2.equals(children));
    assertEquals(attribute, element);
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) ErlAttribute(org.erlide.engine.internal.model.erlang.ErlAttribute) Test(org.junit.Test)

Aggregations

ErlAttribute (org.erlide.engine.internal.model.erlang.ErlAttribute)5 IErlElement (org.erlide.engine.model.IErlElement)2 IErlAttribute (org.erlide.engine.model.erlang.IErlAttribute)2 Test (org.junit.Test)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1