Search in sources :

Example 6 with IErlComment

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);
        }
    }
}
Also used : IErlComment(org.erlide.engine.model.erlang.IErlComment) IErlMember(org.erlide.engine.model.erlang.IErlMember) IErlFunction(org.erlide.engine.model.erlang.IErlFunction)

Example 7 with IErlComment

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;
}
Also used : IErlComment(org.erlide.engine.model.erlang.IErlComment) IErlMember(org.erlide.engine.model.erlang.IErlMember) IErlTypespec(org.erlide.engine.model.erlang.IErlTypespec)

Aggregations

IErlComment (org.erlide.engine.model.erlang.IErlComment)7 IErlMember (org.erlide.engine.model.erlang.IErlMember)3 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 ErlModelException (org.erlide.engine.model.ErlModelException)2 IErlElement (org.erlide.engine.model.IErlElement)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 IRegion (org.eclipse.jface.text.IRegion)1 Position (org.eclipse.jface.text.Position)1 IProjectionPosition (org.eclipse.jface.text.source.projection.IProjectionPosition)1 ErlComment (org.erlide.engine.internal.model.erlang.ErlComment)1 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)1 IErlTypespec (org.erlide.engine.model.erlang.IErlTypespec)1