Search in sources :

Example 1 with ErlComment

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

the class ErlParser method createComment.

/**
 * create an IErlComment from a token record
 *
 * @param IErlModule
 *            module containing comment
 * @param OtpErlangTuple
 *            token record from noparse
 * @return IErlComment
 */
private IErlComment createComment(final IErlModule module, final OtpErlangTuple c) {
    final OtpErlangLong lineL = (OtpErlangLong) c.elementAt(ErlParser.LINE);
    final OtpErlangObject s = c.elementAt(ErlParser.TEXT);
    int line;
    int lastLine;
    try {
        line = lineL.intValue();
    } catch (final OtpErlangRangeException x) {
        line = 0;
    }
    lastLine = line;
    try {
        if (c.elementAt(ErlParser.LAST_LINE) instanceof OtpErlangLong) {
            final OtpErlangLong lastLineL = (OtpErlangLong) c.elementAt(ErlParser.LAST_LINE);
            lastLine = lastLineL.intValue();
        }
    } catch (final OtpErlangRangeException e1) {
        lastLine = line;
    }
    final ErlComment comment = new ErlComment(module, Util.stringValue(s), line <= ErlParser.MODULE_HEADER_COMMENT_THRESHOLD);
    try {
        final int ofs = ((OtpErlangLong) c.elementAt(ErlParser.OFFSET)).intValue();
        final int len = ((OtpErlangLong) c.elementAt(ErlParser.LENGTH)).intValue();
        setPos(comment, line, lastLine, ofs + 1, len);
    } catch (final OtpErlangRangeException e) {
        return null;
    }
    return comment;
}
Also used : IErlComment(org.erlide.engine.model.erlang.IErlComment) ErlComment(org.erlide.engine.internal.model.erlang.ErlComment) OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException)

Aggregations

OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 ErlComment (org.erlide.engine.internal.model.erlang.ErlComment)1 IErlComment (org.erlide.engine.model.erlang.IErlComment)1