Package org.eclipse.jdt.internal.compiler.parser

Examples of org.eclipse.jdt.internal.compiler.parser.Scanner$VanguardScanner


  public void setIdentifier(String identifier) {
    // update internalSetIdentifier if this is changed
    if (identifier == null) {
      throw new IllegalArgumentException();
    }
    Scanner scanner = this.ast.scanner;
    long sourceLevel = scanner.sourceLevel;
    long complianceLevel = scanner.complianceLevel;

    try {
      scanner.sourceLevel = ClassFileConstants.JDK1_3;
      scanner.complianceLevel = ClassFileConstants.JDK1_5;
      char[] source = identifier.toCharArray();
      scanner.setSource(source);
      final int length = source.length;
      scanner.resetTo(0, length - 1);
      try {
        int tokenType = scanner.scanIdentifier();
        if (tokenType != TerminalTokens.TokenNameIdentifier) {
          throw new IllegalArgumentException("Invalid identifier : >" + identifier + "<")//$NON-NLS-1$//$NON-NLS-2$
        }
        if (scanner.currentPosition != length) {
          // this is the case when there is only one identifier see 87849
View Full Code Here


   * comments with statements.
   */
  public void setLeadingComment(String comment) {
    if (comment != null) {
      char[] source = comment.toCharArray();
      Scanner scanner = this.ast.scanner;
      scanner.resetTo(0, source.length);
      scanner.setSource(source);
      try {
        int token;
        boolean onlyOneComment = false;
        while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
          switch(token) {
            case TerminalTokens.TokenNameCOMMENT_BLOCK :
            case TerminalTokens.TokenNameCOMMENT_JAVADOC :
            case TerminalTokens.TokenNameCOMMENT_LINE :
              if (onlyOneComment) {
View Full Code Here

  public void setEscapedValue(String token) {
    // update internalSetEscapedValue(String) if this is changed
    if (token == null) {
      throw new IllegalArgumentException("Token cannot be null"); //$NON-NLS-1$
    }
    Scanner scanner = this.ast.scanner;
    char[] source = token.toCharArray();
    scanner.setSource(source);
    scanner.resetTo(0, source.length);
    try {
      int tokenType = scanner.getNextToken();
      switch(tokenType) {
        case TerminalTokens.TokenNameStringLiteral:
          break;
        default:
          throw new IllegalArgumentException("Invalid string literal : >" + token + "<"); //$NON-NLS-1$//$NON-NLS-2$
View Full Code Here

    int len = s.length();
    if (len < 2 || s.charAt(0) != '\"' || s.charAt(len-1) != '\"' ) {
      throw new IllegalArgumentException();
    }

    Scanner scanner = this.ast.scanner;
    char[] source = s.toCharArray();
    scanner.setSource(source);
    scanner.resetTo(0, source.length);
    try {
      int tokenType = scanner.getNextToken();
      switch(tokenType) {
        case TerminalTokens.TokenNameStringLiteral:
          return scanner.getCurrentStringLiteral();
        default:
          throw new IllegalArgumentException();
      }
    } catch(InvalidInputException e) {
      throw new IllegalArgumentException();
View Full Code Here

  public CodeFormatterVisitor(DefaultCodeFormatterOptions preferences, Map settings, IRegion[] regions, CodeSnippetParsingUtil codeSnippetParsingUtil, boolean includeComments) {
    long sourceLevel = settings == null
      ? ClassFileConstants.JDK1_3
      : CompilerOptions.versionToJdkLevel(settings.get(JavaCore.COMPILER_SOURCE));
    this.localScanner = new Scanner(true, false, false/*nls*/, sourceLevel/*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);

    this.preferences = preferences;
    this.scribe = new Scribe(this, sourceLevel, regions, codeSnippetParsingUtil, includeComments);
  }
View Full Code Here

  }

  final TokenScanner getScanner() {
    if (this.tokenScanner == null) {
      CompilerOptions compilerOptions = new CompilerOptions(this.options);
      Scanner scanner;
      if (this.recoveryScannerData == null) {
        scanner =
          new Scanner(
              true,/*tokenizeComments*/
              false,/*tokenizeWhiteSpace*/
              false,/*checkNonExternalizedStringLiterals*/
              compilerOptions.sourceLevel,
              compilerOptions.complianceLevel,
              null/*taskTags*/,
              null/*taskPriorities*/,
              true/*taskCaseSensitive*/);
      } else {
        scanner =
          new RecoveryScanner(
              false,/*tokenizeWhiteSpace*/
              false,/*checkNonExternalizedStringLiterals*/
              compilerOptions.sourceLevel,
              compilerOptions.complianceLevel,
              null/*taskTags*/,
              null/*taskPriorities*/,
              true/*taskCaseSensitive*/,
              this.recoveryScannerData);
      }
      scanner.setSource(this.content);
      this.tokenScanner= new TokenScanner(scanner);
    }
    return this.tokenScanner;
  }
View Full Code Here

              break;
          }
        }
      }
    }
    this.scanner = new Scanner(true, true, false/*nls*/, sourceLevel/*sourceLevel*/, taskTags, null/*taskPriorities*/, true/*taskCaseSensitive*/);
    this.editsEnabled = true;
  }
View Full Code Here

    long sourceLevel = CompilerOptions.versionToJdkLevel(sourceModeSetting);
    if (sourceLevel == 0) {
      // unknown sourceModeSetting
      sourceLevel = ClassFileConstants.JDK1_3;
    }
    this.scanner = new Scanner(
      true /*comment*/,
      false /*whitespace*/,
      false /*nls*/,
      sourceLevel /*sourceLevel*/,
      null /*taskTags*/,
 
View Full Code Here

    int [] positions = new int[]{start, end};
    int token;
    int trimLeftPosition = start;
    int trimRightPosition = end;
    boolean first = true;
    Scanner removeBlankScanner = this.ast.scanner;
    try {
      removeBlankScanner.setSource(this.compilationUnitSource);
      removeBlankScanner.resetTo(start, end);
      while (true) {
        token = removeBlankScanner.getNextToken();
        switch (token) {
          case TerminalTokens.TokenNameCOMMENT_JAVADOC :
          case TerminalTokens.TokenNameCOMMENT_LINE :
          case TerminalTokens.TokenNameCOMMENT_BLOCK :
            if (first) {
View Full Code Here

            this.compilerOptions,
            true,
            (this.bits & CompilationUnitResolver.STATEMENT_RECOVERY) != 0);
        RecoveryScannerData data = constructorDeclaration.compilationResult.recoveryScannerData;
        if(data != null) {
          Scanner scanner = converter.scanner;
          converter.scanner = new RecoveryScanner(scanner, data.removeUnused());
          converter.docParser.scanner = converter.scanner;
          converter.scanner.setSource(scanner.source);
         
          compilationUnit.setStatementsRecoveryData(data);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.parser.Scanner$VanguardScanner

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.