Package org.erlide.engine.internal.model.erlang

Examples of org.erlide.engine.internal.model.erlang.ErlRecordDef


            final OtpErlangTuple recordTuple = (OtpErlangTuple) val;
            if (recordTuple.elementAt(0) instanceof OtpErlangAtom) {
                final String s = extra instanceof OtpErlangString ? ((OtpErlangString) extra)
                        .stringValue() : null;
                final OtpErlangList fields = (OtpErlangList) recordTuple.elementAt(1);
                final ErlRecordDef r = new ErlRecordDef(module, null, s);
                setPos(r, pos);
                if (fields != null) {
                    final List<ErlRecordField> children = Lists
                            .newArrayListWithCapacity(fields.arity());
                    for (final OtpErlangObject o : fields) {
                        if (o instanceof OtpErlangTuple) {
                            final OtpErlangTuple fieldTuple = (OtpErlangTuple) o;
                            final OtpErlangAtom fieldNameAtom = (OtpErlangAtom) fieldTuple
                                    .elementAt(0);
                            final String fieldName = fieldNameAtom.atomValue();
                            final ErlRecordField field = new ErlRecordField(r, fieldName);
                            final OtpErlangTuple posTuple = (OtpErlangTuple) fieldTuple
                                    .elementAt(1);
                            if (fieldTuple.arity() > 2) {
                                final OtpErlangObject fieldExtra = fieldTuple
                                        .elementAt(2);
                                field.setExtra(Util.stringValue(fieldExtra));
                            }
                            setPos(field, posTuple);
                            children.add(field);
                        } else {
                            ErlLogger.error("bad record def: %s", o);
                        }
                    }
                    r.setChildren(children);
                } else {
                    r.setChildren(new ArrayList<IErlElement>());
                }
                return r;
            }
        }
        if (val instanceof OtpErlangAtom) {
            final String s = extra instanceof OtpErlangString ? ((OtpErlangString) extra)
                    .stringValue() : null;
            final ErlRecordDef r = new ErlRecordDef(module, null, s);
            setPos(r, pos);
            return r;
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.erlide.engine.internal.model.erlang.ErlRecordDef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.