Package org.eclipse.wst.sse.core.internal.parser

Examples of org.eclipse.wst.sse.core.internal.parser.ContextRegion


    if (context == DOMRegionContext.BLOCK_TEXT) {
      newRegion = new ForeignRegion(context, start, textLength, length);
      ((ForeignRegion) newRegion).setSurroundingTag(surroundingTag);
    }
    else {
      newRegion = new ContextRegion(context, start, textLength, length);
    }
    return newRegion;
  }
View Full Code Here


  public ITextRegion createToken(String context, int start, int textLength, int length) {
    return this.createToken(context, start, textLength, length, null, null);
  }

  public ITextRegion createToken(String context, int start, int textLength, int length, String lang, String surroundingTag) {
    ITextRegion newRegion = new ContextRegion(context, start, textLength, length);
    return newRegion;


  }
View Full Code Here

      int yylengthLength, int yylength, Object lexerState) {
    assert (phpTokens.size() == 0 || getLastToken().getEnd() == start)
        && tokensIterator == null;

    if (phpTokens.size() > 0) {
      ContextRegion lastContextRegion = (ContextRegion) phpTokens
          .get(phpTokens.size() - 1);
      if (deprecatedKeywordAfter(lastContextRegion.getType())) {
        if (isKeyword(yylex)) {
          yylex = PHPRegionTypes.PHP_STRING;
        }
      }
    }
    // if state was change - we add a new token and add state
    if (lexerStateChanges.size() == 0
        || !getLastChange().state.equals(lexerState)) {
      int textLength = (AbstractPhpLexer.WHITESPACE.equals(yylex)) ? 0
          : yylengthLength;

      final ContextRegion contextRegion = new ContextRegion(yylex, start,
          textLength, yylength);
      phpTokens.addLast(contextRegion);
      lexerStateChanges.addLast(new LexerStateChange(
          (LexerState) lexerState, contextRegion));
      return;
    }

    assert phpTokens.size() > 0;
    // if we can only adjust the previous token size
    if (yylex == AbstractPhpLexer.WHITESPACE) {
      final ITextRegion last = phpTokens.getLast();
      last.adjustLength(yylength);
    } else { // else - add as a new token
      final ContextRegion contextRegion = new ContextRegion(yylex, start,
          yylengthLength, yylength);
      phpTokens.addLast(contextRegion);
    }
  }
View Full Code Here

        length++;
      }
      bufferedTokens = new LinkedList<ITextRegion>();
      checkForTodo(bufferedTokens, PHPRegionTypes.PHPDOC_COMMENT, 0,
          length, buffer.toString());
      bufferedTokens.add(new ContextRegion(yylex, 0, yylength(),
          yylength()));
      yylex = removeFromBuffer();
    } else if (PHPPartitionTypes.isPHPCommentState(yylex)) {
      bufferedTokens = new LinkedList<ITextRegion>();
      checkForTodo(bufferedTokens, yylex, 0, yylength(), yytext());
View Full Code Here

    ITextRegion tRegion = null;
    while (matcher != null) {
      int startIndex = matcher.start();
      int endIndex = matcher.end();
      if (startIndex != startPosition) {
        tRegion = new ContextRegion(token,
            commentStart + startPosition, startIndex
                - startPosition, startIndex - startPosition);
        result.add(tRegion);
      }
      tRegion = new ContextRegion(PHPRegionTypes.PHPDOC_TODO,
          commentStart + startIndex, endIndex - startIndex, endIndex
              - startIndex);
      result.add(tRegion);
      startPosition = endIndex;
      matcher = getMinimalMatcher(matchers, startPosition);
    }
    final int length = commentLength - startPosition;
    if (length != 0) {
      result.add(new ContextRegion(token, commentStart + startPosition,
          length, length));
    }

    // String[] words = comment.split("\\W+");
    // int startPosition = 0;
View Full Code Here

      if (phpScriptRegion instanceof IPhpScriptRegion) {
        IPhpScriptRegion scriptRegion = (IPhpScriptRegion) phpScriptRegion;
        // the region we are trying to check if it is the indent base
        // for the line we need to format
        ContextRegion checkedRegion = (ContextRegion) scriptRegion
            .getPhpToken(lineStart - phpContentStartOffset);
        // the current region we need to format
        ContextRegion currentRegion = (ContextRegion) scriptRegion
            .getPhpToken(forOffset - phpContentStartOffset);
        String checkedType = checkedRegion.getType();
        String currentType = currentRegion.getType();
        // if we are in the beginning of a comment (DOC or Multi
        // comment) and we have before another
        // Doc comment or Multi comment, the base line we'll be the
        // beginning of the previous multi comment
        if (currentType.equals(PHPRegionTypes.PHPDOC_COMMENT_START)
View Full Code Here

            tokenizer = new TwigTokenizer(tokens.toCharArray());
            contextRegions = new Stack<ContextRegion>();
            assertTrue(contextRegions.size() == 0);

            while (!tokenizer.isEOF()) {
                ContextRegion region = (ContextRegion) tokenizer.getNextToken();
                assertNotNull(region);
                contextRegions.push(region);
            }

            assertEquals(3, contextRegions.size());
            assertEquals(contextRegions.get(0).getType(),
                    TwigRegionContext.TWIG_STMT_OPEN);
            assertEquals(contextRegions.get(1).getType(),
                    TwigRegionContext.TWIG_CONTENT);
            assertEquals(contextRegions.get(2).getType(),
                    TwigRegionContext.TWIG_STMT_CLOSE);

            tokens = "{% use \"blocks.html\" with sidebar as base_sidebar %}";
            tokenizer = new TwigTokenizer(tokens.toCharArray());
            contextRegions = new Stack<ContextRegion>();
            assertTrue(contextRegions.size() == 0);

            while (!tokenizer.isEOF()) {
                ContextRegion region = (ContextRegion) tokenizer.getNextToken();
                assertNotNull(region);
                contextRegions.push(region);
            }

            assertEquals(3, contextRegions.size());
View Full Code Here

            contextRegions = new Stack<ContextRegion>();
            assertTrue(contextRegions.size() == 0);

            while (!tokenizer.isEOF()) {
                ContextRegion region = (ContextRegion) tokenizer.getNextToken();
                assertNotNull(region);
                contextRegions.push(region);
            }

            assertEquals(contextRegions.get(0).getType(),
View Full Code Here

            tokenizer = new TwigTokenizer(tokens.toCharArray());
            contextRegions = new Stack<ContextRegion>();
            assertTrue(contextRegions.size() == 0);

            while (!tokenizer.isEOF()) {
                ContextRegion region = (ContextRegion) tokenizer.getNextToken();
                contextRegions.push(region);
            }

            assertEquals(3, contextRegions.size());
            assertEquals(contextRegions.get(0).getType(),
                    TwigRegionContext.TWIG_STMT_OPEN);
            assertEquals(contextRegions.get(1).getType(),
                    TwigRegionContext.TWIG_CONTENT);
            assertEquals(contextRegions.get(2).getType(),
                    TwigRegionContext.TWIG_STMT_CLOSE);
            assertTrue(contextRegions.get(1) instanceof TwigScriptRegion);

            tokens = "{% foobar %}";
            tokenizer = new TwigTokenizer(tokens.toCharArray());
            contextRegions = new Stack<ContextRegion>();
            assertTrue(contextRegions.size() == 0);

            while (!tokenizer.isEOF()) {

                ContextRegion region = (ContextRegion) tokenizer.getNextToken();
                contextRegions.push(region);

            }

            assertEquals(3, contextRegions.size());
View Full Code Here

                || !getLastChange().state.equals(lexerState)) {
            int textLength = (AbstractTwigLexer.WHITESPACE.equals(yylex))
                    ? 0
                    : yylengthLength;

            final ContextRegion contextRegion = new ContextRegion(yylex, start,
                    textLength, yylength);
            twigTokens.addLast(contextRegion);
            lexerStateChanges.addLast(new LexerStateChange(
                    (LexerState) lexerState, contextRegion));
            return;
        }

        assert twigTokens.size() > 0;
        // if we can only adjust the previous token size
        if (yylex == AbstractTwigLexer.WHITESPACE) {
            final ITextRegion last = twigTokens.getLast();
            last.adjustLength(yylength);
        } else { // else - add as a new token
            final ContextRegion contextRegion = new ContextRegion(yylex, start,
                    yylengthLength, yylength);
            twigTokens.addLast(contextRegion);
        }

    }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.sse.core.internal.parser.ContextRegion

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.