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

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


            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


      supportedOnlyIn2();
    if (docComment == null) {
      throw new IllegalArgumentException();
    }
    char[] source = docComment.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_JAVADOC :
            if (onlyOneComment) {
              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

  public void setEscapedValue(String value) {
    // check setInternalEscapedValue(String) if this method is changed
    if (value == null) {
      throw new IllegalArgumentException();
    }
    Scanner scanner = this.ast.scanner;
    char[] source = value.toCharArray();
    scanner.setSource(source);
    scanner.resetTo(0, source.length);
    try {
      int tokenType = scanner.getNextToken();
      switch(tokenType) {
        case TerminalTokens.TokenNameCharacterLiteral:
          break;
        default:
          throw new IllegalArgumentException();
View Full Code Here

   * @return the character value without enclosing quotes and embedded
   *    escapes
   * @exception IllegalArgumentException if the literal value cannot be converted
   */
  public char charValue() {
    Scanner scanner = this.ast.scanner;
    char[] source = this.escapedValue.toCharArray();
    scanner.setSource(source);
    scanner.resetTo(0, source.length);
    int firstChar = scanner.getNextChar();
    int secondChar = scanner.getNextChar();

    if (firstChar == -1 || firstChar != '\'') {
      throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
    }
    char value = (char) secondChar;
    int nextChar = scanner.getNextChar();
    if (secondChar == '\\') {
      if (nextChar == -1) {
        throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
      }
      switch(nextChar) {
        case 'b' :
          value = '\b';
          break;
        case 't' :
          value = '\t';
          break;
        case 'n' :
          value = '\n';
          break;
        case 'f' :
          value = '\f';
          break;
        case 'r' :
          value = '\r';
          break;
        case '\"':
          value = '\"';
          break;
        case '\'':
          value = '\'';
          break;
        case '\\':
          value = '\\';
          break;
        default : //octal (well-formed: ended by a ' )
          try {
            if (ScannerHelper.isDigit((char) nextChar)) {
              int number = ScannerHelper.getNumericValue((char) nextChar);
              nextChar = scanner.getNextChar();
              if (nextChar == -1) {
                throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
              }
              if (nextChar != '\'') {
                if (!ScannerHelper.isDigit((char) nextChar)) {
                  throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
                }
                number = (number * 8) + ScannerHelper.getNumericValue((char) nextChar);
                nextChar = scanner.getNextChar();
                if (nextChar == -1) {
                  throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
                }
                if (nextChar != '\'') {
                  if (!ScannerHelper.isDigit((char) nextChar)) {
                    throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
                  }
                  number = (number * 8) + ScannerHelper.getNumericValue((char) nextChar);
                }
              }
              return (char) number;
            } else {
              throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
            }
          } catch (InvalidInputException e) {
            throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
          }
      }
      nextChar = scanner.getNextChar();
      if (nextChar == -1) {
        throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
      }
    }
    if (nextChar == -1 || nextChar != '\'') {
View Full Code Here

  ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
  if (compilationUnit == null) return start;
  char[] contents = compilationUnit.getContents();
  if (contents.length == 0) return start;
  if (this.positionScanner == null) {
    this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false);
    this.positionScanner.returnOnlyGreater = true;
  }
  this.positionScanner.setSource(contents);
  this.positionScanner.resetTo(start, contents.length);
  int end = start;
View Full Code Here

  ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
  if (compilationUnit == null) return sourceEnd;
  char[] contents = compilationUnit.getContents();
  if (contents.length == 0) return sourceEnd;
  if (this.positionScanner == null) {
    this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false);
  }
  this.positionScanner.setSource(contents);
  this.positionScanner.resetTo(sourceStart, sourceEnd);
  try {
    int token;
View Full Code Here

  ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
  if (compilationUnit == null) return sourceStart;
  char[] contents = compilationUnit.getContents();
  if (contents.length == 0) return sourceStart;
  if (this.positionScanner == null) {
    this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false);
  }
  this.positionScanner.setSource(contents);
  this.positionScanner.resetTo(sourceStart, sourceEnd);
  int count = 0;
  try {
View Full Code Here

    // ignore
  }
  return sourceStart;
}
public void scannerError(Parser parser, String errorTokenName) {
  Scanner scanner = parser.scanner;

  int flag = IProblem.ParsingErrorNoSuggestion;
  int startPos = scanner.startPosition;
  int endPos = scanner.currentPosition - 1;
View Full Code Here

public class InternalNamingConventions {
  private static final char[] DEFAULT_NAME = "name".toCharArray(); //$NON-NLS-1$

  private static Scanner getNameScanner(CompilerOptions compilerOptions) {
    return
      new Scanner(
        false /*comment*/,
        false /*whitespace*/,
        false /*nls*/,
        compilerOptions.sourceLevel /*sourceLevel*/,
        null /*taskTags*/,
 
View Full Code Here

TOP

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

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.