Example usage for org.aspectj.weaver.patterns IToken getLiteralKind

List of usage examples for org.aspectj.weaver.patterns IToken getLiteralKind

Introduction

In this page you can find the example usage for org.aspectj.weaver.patterns IToken getLiteralKind.

Prototype

public String getLiteralKind();

Source Link

Document

Whether this should be treated as a literal value Kinds == "string", ???

Usage

From source file:org.caesarj.compiler.aspectj.CaesarWrapperPatternParser.java

License:Open Source License

public List<NamePattern> parseDottedNamePattern() {
    List<NamePattern> names = new ArrayList<NamePattern>();
    StringBuffer buf = new StringBuffer();
    IToken previous = null;/*w ww. j a v  a2  s .c o  m*/
    boolean justProcessedEllipsis = false; // Remember if we just dealt with an ellipsis (PR61536)
    boolean justProcessedDot = false;
    boolean onADot = false;
    while (true) {
        IToken tok = null;
        int startPos = tokenSource.peek().getStart();
        String afterDot = null;
        while (true) {
            if (previous != null && previous.getString().equals("."))
                justProcessedDot = true;
            tok = tokenSource.peek();
            onADot = (tok.getString().equals("."));
            if (previous != null) {
                if (!isAdjacent(previous, tok))
                    break;
            }
            if (tok.getString() == "*" || tok.isIdentifier()) {
                buf.append(tok.getString());
            } else if (tok.getLiteralKind() != null) {
                //System.err.println("literal kind: " + tok.getString());
                String s = tok.getString();
                int dot = s.indexOf('.');
                if (dot != -1) {
                    buf.append(s.substring(0, dot));
                    afterDot = s.substring(dot + 1);
                    previous = tokenSource.next();
                    break;
                }
                buf.append(s); // ??? so-so
            } else {
                break;
            }
            previous = tokenSource.next();
            //XXX need to handle floats and other fun stuff
        }
        int endPos = tokenSource.peek(-1).getEnd();
        if (buf.length() == 0 && names.isEmpty()) {
            throw new ParserException("expected name pattern", tok);
        }

        if (buf.length() == 0 && justProcessedEllipsis) {
            throw new ParserException("name pattern cannot finish with ..", tok);
        }
        if (buf.length() == 0 && justProcessedDot && !onADot) {
            throw new ParserException("name pattern cannot finish with .", tok);
        }

        if (buf.length() == 0) {
            names.add(NamePattern.ELLIPSIS);
            justProcessedEllipsis = true;
        } else {
            checkLegalName(buf.toString(), previous);
            NamePattern ret = new NamePattern(buf.toString());
            ret.setLocation(sourceContext, startPos, endPos);
            names.add(ret);
            justProcessedEllipsis = false;
        }

        if (afterDot == null) {
            buf.setLength(0);
            if (!maybeEat("."))
                break;
            else
                previous = tokenSource.peek(-1);
        } else {
            buf.setLength(0);
            buf.append(afterDot);
            afterDot = null;
        }
    }
    //System.err.println("parsed: " + names);
    return names;
}