Package org.eclipse.php.internal.core.documentModel.parser

Examples of org.eclipse.php.internal.core.documentModel.parser.AbstractPhpLexer


            phpVerSuite.addTest(new DocumentLexerTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void runTest() throws Throwable {

                AbstractPhpLexer lexer = PhpLexerFactory
                    .createLexer(new ByteArrayInputStream(
                        pdttFile.getFile().trim()
                            .getBytes()),
                        phpVersion);
                int inScriptingState = lexer.getClass()
                    .getField("ST_PHP_IN_SCRIPTING")
                    .getInt(lexer); // different lexers have
                            // different state codes
                lexer.initialize(inScriptingState);

                StringBuilder actualBuf = new StringBuilder();
                String tokenType = lexer.yylex();
                while (tokenType != null) {
                  actualBuf.append(tokenType).append('|')
                      .append(lexer.yytext()).append('|')
                      .append(lexer.yystate())
                      .append('\n');
                  tokenType = lexer.yylex();
                }

                assertContents(pdttFile.getExpected(),
                    actualBuf.toString());
              }
View Full Code Here


            .getState(newTokenOffset);
        final LexerState endState = tokensContaier.getState(tokenEnd
            .getEnd() + 1);

        final PhpTokenContainer newContainer = new PhpTokenContainer();
        final AbstractPhpLexer phpLexer = getPhpLexer(
            new DocumentReader(flatnode, changes, requestStart,
                lengthToReplace, newTokenOffset), startState);

        Object state = startState;
        try {
          String yylex = phpLexer.getNextToken();
          if (shouldDeprecatedKeyword
              && PhpTokenContainer.isKeyword(yylex)) {
            yylex = PHPRegionTypes.PHP_STRING;
          }
          int yylength;
          final int toOffset = offset + length;
          while (yylex != null && newTokenOffset <= toOffset
              && yylex != PHPRegionTypes.PHP_CLOSETAG) {
            yylength = phpLexer.getLength();
            newContainer.addLast(yylex, newTokenOffset, yylength,
                yylength, state);
            newTokenOffset += yylength;
            state = phpLexer.createLexicalStateMemento();
            yylex = phpLexer.getNextToken();
          }
          if (yylex == PHPRegionTypes.WHITESPACE) {
            yylength = phpLexer.getLength();
            newContainer.adjustWhitespace(yylex, newTokenOffset,
                yylength, yylength, state);
          }
        } catch (IOException e) {
          Logger.logException(e);
View Full Code Here

   */
  public void completeReparse(IDocument doc, int start, int length) {
    // bug fix for 225118 we need to refresh the constants since this
    // function is being called
    // after the project's PHP version was changed.
    AbstractPhpLexer phpLexer = getPhpLexer(new BlockDocumentReader(doc,
        start, length), null);
    try {
      ST_PHP_LINE_COMMENT = phpLexer.getClass()
          .getField("ST_PHP_LINE_COMMENT").getInt(phpLexer); //$NON-NLS-1$
      ST_PHP_IN_SCRIPTING = phpLexer.getClass()
          .getField("ST_PHP_IN_SCRIPTING").getInt(phpLexer); //$NON-NLS-1$
    } catch (Exception e) {
      Logger.logException(e);
    }
    completeReparse(phpLexer);
View Full Code Here

   * @param stream
   * @return a new lexer for the given project with the given stream
   */
  private AbstractPhpLexer getPhpLexer(Reader stream, LexerState startState) {
    final PHPVersion phpVersion = ProjectOptions.getPhpVersion(project);
    final AbstractPhpLexer lexer = PhpLexerFactory.createLexer(stream,
        phpVersion);
    lexer.initialize(ST_PHP_IN_SCRIPTING);
    lexer.setPatterns(project);

    // set the wanted state
    if (startState != null) {
      startState.restoreState(lexer);
    }
    lexer.setAspTags(ProjectOptions.isSupportingAspTags(project));
    return lexer;
  }
View Full Code Here

      }
      if (phpVersion == null) {
        phpVersion = PHPVersion.getLatestVersion();
      }

      AbstractPhpLexer lexer = PhpLexerFactory.createLexer(
          new StringReader(textSequence.toString()), phpVersion);
      lexer.initialize(lexer.getScriptingState());
      String symbol = null;
      int level = 0;
      int argIndex = 0;
      do {
        try {
          symbol = lexer.getNextToken();
          if (symbol != null) {
            CharSequence text = textSequence.subSequence(
                lexer.getTokenStart(), lexer.getTokenStart()
                    + lexer.getLength());
            if (symbol.equals(PHPRegionTypes.PHP_TOKEN)) {
              if (text.equals(LPAREN) || text.equals(LBRACE)
                  || text.equals(LBRACKET)) {
                level++;
              } else if (text.equals(RPAREN)
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.core.documentModel.parser.AbstractPhpLexer

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.