use of org.erlide.engine.model.erlang.IErlComment in project erlide_eclipse by erlang.
the class ErlParser method checkForComment.
private void checkForComment(final List<IErlMember> all, final int i) {
final IErlMember m = all.get(i);
if (m instanceof IErlFunction) {
final IErlFunction function = (IErlFunction) m;
final LinkedList<IErlComment> comments = Lists.newLinkedList();
int j = considerPrevious(i, all, comments, function);
j = considerPrevious(j, all, comments, function);
j = considerPrevious(j, all, comments, function);
if (!comments.isEmpty()) {
function.setComments(comments);
}
}
}
use of org.erlide.engine.model.erlang.IErlComment in project erlide_eclipse by erlang.
the class ErlParser method considerPrevious.
private int considerPrevious(final int i, final List<IErlMember> all, final Deque<IErlComment> comments, final IErlFunction function) {
final int j = i - 1;
if (j > 0) {
final IErlMember member = all.get(i);
final IErlMember prevMember = all.get(j);
if (prevMember instanceof IErlComment) {
if (prevMember.getLineEnd() + ErlParser.FUNCTION_COMMENT_THRESHOLD >= member.getLineStart()) {
comments.addFirst((IErlComment) prevMember);
}
} else if (prevMember instanceof IErlTypespec) {
final IErlTypespec spec = (IErlTypespec) prevMember;
if (spec.getName().equals(function.getName()) && spec.getArity() == function.getArity() && prevMember.getLineEnd() + ErlParser.FUNCTION_COMMENT_THRESHOLD >= member.getLineStart()) {
function.setTypespec(spec);
}
} else {
return -1;
}
}
return j;
}
Aggregations