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;
}
Aggregations