Package org.netbeans.api.lexer

Examples of org.netbeans.api.lexer.Token


        AbstractDocument doc = (AbstractDocument) context.getDocument();
        doc.readLock();
        try {
            TokenHierarchy th = TokenHierarchy.get(doc);
            TokenSequence ts = th.tokenSequence();
            Token token = findTokenAtContext(ts, context.getSearchOffset());
            if (token == null) {
                return null;
            }
            int ordinal = token.id().ordinal();
            for (BracePair bp : bracePairs) {
                if (ordinal == bp.open) {
                    originToken = bp.open;
                    matchToken = bp.close;
                    searchForward = true;
                    ret = new int[]{ts.offset(), ts.offset() + token.length()};
                } else if (ordinal == bp.close) {
                    originToken = bp.close;
                    matchToken = bp.open;
                    searchForward = false;
                    ret = new int[]{ts.offset(), ts.offset() + token.length()};
                }
            }
        } finally {
            ((AbstractDocument) context.getDocument()).readUnlock();
        }
View Full Code Here


        //return defaultMatcher.findOrigin();
    }

    private static Token findTokenAtContext(TokenSequence ts, int offset) {
        ts.move(offset);
        Token token = ts.token();
        //there are cases when this could be null
        //in which case use the next one.
        if (token == null) {
            ts.moveNext();
            token = ts.token();
View Full Code Here

        }
        while (searchForward ? ts.moveNext() : ts.movePrevious()) {
            if (MatcherContext.isTaskCanceled()) {
                return null;
            }
            Token t = ts.token();
            if (t.id().ordinal() == originToken) {
                count++;
            }
            if (t.id().ordinal() == matchToken) {
                count--;
            }
            //System.out.println(t);
            if (count == -1) {
                ret = new int[]{ts.offset(), ts.offset() + t.length()};
                break;
            }
        }
        return ret;
    }
View Full Code Here

        ts.moveStart();
        int newIndent = 0;
        boolean nextIndent = false;
        TreeMap<Integer, Integer> newIdentMap = new TreeMap<Integer, Integer>(new ReverseOrderInteger());
        do {
            Token token = ts.token();
            if (token != null && token.id().ordinal() != PL_SQLLexer.WHITESPACE) {
                if (nextIndent) {
                    newIndent += indent;
                    nextIndent = false;
                }
                if (FORMAT_TOKEN_LIST.contains(token.id().ordinal())) {
                    nextIndent = true;
                }
                if (LA(token, ts)) {
                    newIndent -= indent;
                }
View Full Code Here

    private boolean LA(Token token, TokenSequence ts) {
        boolean ret = false;
        if (token.id().ordinal() == PL_SQLLexer.END_KEYWORD) {
            ret = true;
            //int orgOffset = ts.offset();
            Token nextToken = null;
            while (ts.moveNext()) {
                nextToken = ts.token();
                if (nextToken == null || nextToken.id().ordinal() != PL_SQLLexer.WHITESPACE) {
                    break;
                }
            }
            /*if (nextToken == null || !FORMAT_TOKEN_LIST.contains(nextToken.id().ordinal())) {
            ts.move(orgOffset);
View Full Code Here

        ts.move(offset);
        do {
            if (!ts.movePrevious()) {
                return false;
            }
            Token token = ts.token();
            if (INDENT_TOKEN_LIST.contains(token.id().ordinal())) {
                return true;
            }
        } while (ts.token().id().ordinal() == PL_SQLLexer.WHITESPACE);
        return false;
    }
View Full Code Here

     */
    public static String getDocRoot(Document document) {
        TokenHierarchy th = TokenHierarchy.get(document);
        TokenSequence ts = th.tokenSequence();
        while (ts.moveNext()) {
            Token nextToken = ts.token();
            if (nextToken.id() == XMLTokenId.TAG) {
                String tagName = nextToken.text().toString();
                if (tagName.startsWith("<")) {
                    return tagName.substring(1, tagName.length());
                }
            }
        }
View Full Code Here

        List<Embedding> embeddings = new ArrayList<Embedding>();

        int offset = -1;
        int length = 0;
        while ( sequence.moveNext() ) {
            Token t = sequence.token();
           
            if ( t.id() == TwigTopTokenId.T_HTML ) {
                if ( offset < 0 ) offset = sequence.offset();
                length += t.length();
            } else if ( offset >= 0 ) {
                embeddings.add( snapshot.create( offset, length, "text/html" ) );
                offset = -1;
                length = 0;
            }
View Full Code Here

      if(ts.token().id() == LatteTopTokenId.LATTE) {
        TokenSequence<LatteTokenId> ts2 = LexUtils.getSequence(ts.token());

        ts2.moveStart();
        while(ts2.moveNext()) {
          Token token2 = ts2.token();
          if(token2.id() == LatteTokenId.VARIABLE && token2.toString().equals(ident)) {
            int offset = ts.offset() + ts2.offset();
            regions.add(new OffsetRange(offset + 1, offset + token2.length()));
          }
        }
      }
    }
View Full Code Here

    LatteResolver latteResolver = new LatteResolver(this);
    HtmlPhpResolver htmlPhpResolver = new HtmlPhpResolver(this);

    while(sequence.moveNext()) {
      Token t = sequence.token();
      if(t.id() == LatteTopTokenId.LATTE) {
        latteResolver.solve(t, sequence);                    // deals with all latte macros
        SyntaxUtils.findArrayForHint(getSnapshot().getSource().getDocument(true), sequence);
      } else {
        htmlPhpResolver.solve(t, sequence);
      }
View Full Code Here

TOP

Related Classes of org.netbeans.api.lexer.Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.