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

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


  /* (non-Javadoc)
   * Create and store a specific comment recorder scanner.
   * @see org.eclipse.jdt.internal.compiler.parser.Parser#initializeScanner()
   */
  public void initializeScanner() {
    this.scanner = new Scanner(
        false /*comment*/,
        false /*whitespace*/,
        this.options.getSeverity(CompilerOptions.NonExternalizedString) != ProblemSeverities.Ignore /*nls*/,
        this.options.sourceLevel /*sourceLevel*/,
        this.options.taskTags/*taskTags*/,
 
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

    return this.containerPath.toOSString(); // external jar
 
  private  boolean isValidPackageNameForClass(String className) {
    char[] classNameArray = className.toCharArray();
    if (this.scanner == null)
      this.scanner = new Scanner(false /* comment */, true /* whitespace */, false /* nls */,
          ClassFileConstants.JDK1_3/* sourceLevel */, null/* taskTag */, null/* taskPriorities */, true /* taskCaseSensitive */);
    this.scanner.setSource(classNameArray);
    this.scanner.eofPosition = classNameArray.length - SuffixConstants.SUFFIX_CLASS.length;
    try {
      if (this.scanner.scanIdentifier() == TerminalTokens.TokenNameIdentifier) {
View Full Code Here

    switch(level) {
      case JLS2_INTERNAL :
      case JLS3 :
        this.apiLevel = level;
        // initialize a scanner
        this.scanner = new Scanner(
            true /*comment*/,
            true /*whitespace*/,
            false /*nls*/,
            ClassFileConstants.JDK1_3 /*sourceLevel*/,
            ClassFileConstants.JDK1_5 /*complianceLevel*/,
            null/*taskTag*/,
            null/*taskPriorities*/,
            true/*taskCaseSensitive*/);
        break;
      case JLS4 :
        this.apiLevel = level;
        // initialize a scanner
        this.scanner = new Scanner(
            true /*comment*/,
            true /*whitespace*/,
            false /*nls*/,
            ClassFileConstants.JDK1_7 /*sourceLevel*/,
            ClassFileConstants.JDK1_7 /*complianceLevel*/,
 
View Full Code Here

      complianceLevel = ClassFileConstants.JDK1_5;
    } else if (JavaCore.VERSION_1_7.equals(complianceLevelOption)) {
      complianceLevel = ClassFileConstants.JDK1_7;
    }
    // override scanner if 1.4 or 1.5 asked for
    this.scanner = new Scanner(
      true /*comment*/,
      true /*whitespace*/,
      false /*nls*/,
      sourceLevel /*sourceLevel*/,
      complianceLevel /*complianceLevel*/,
 
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

  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

     * @see org.eclipse.jdt.internal.compiler.parser.Parser#initializeScanner()
     */
    @Override
    public void initializeScanner() {
        scanner =
                new Scanner(
                        false /*comment*/,
                        false /*whitespace*/,
                        options.getSeverity(CompilerOptions.NonExternalizedString) != ProblemSeverities.Ignore /*nls*/,
                        options.sourceLevel /*sourceLevel*/,
                        options.taskTags/*taskTags*/,
 
View Full Code Here

  // perform final changes to the open and close body ranges
  int openBodyEnd, openBodyStart, closeBodyStart, closeBodyEnd;
  DOMNode first = (DOMNode) getFirstChild();
  DOMNode lastNode = null;
  // look for the open body
  Scanner scanner = new Scanner();
  scanner.setSource(this.fDocument);
  scanner.resetTo(this.fNameRange[1] + 1, this.fDocument.length);

  try {
    int currentToken = scanner.getNextToken();
    while(currentToken != TerminalTokens.TokenNameLBRACE &&
        currentToken != TerminalTokens.TokenNameEOF) {
      currentToken = scanner.getNextToken();
    }
    if(currentToken == TerminalTokens.TokenNameLBRACE) {
      openBodyEnd = scanner.currentPosition - 1;
      openBodyStart = scanner.startPosition;
    } else {
      openBodyEnd = this.fDocument.length;
      openBodyStart = this.fDocument.length;
    }
  } catch(InvalidInputException e) {
    openBodyEnd = this.fDocument.length;
    openBodyStart = this.fDocument.length;
  }
  if (first != null) {
    int lineStart = finder.getLineStart(first.getStartPosition());
    if (lineStart > openBodyEnd) {
      openBodyEnd = lineStart - 1;
    } else {
      openBodyEnd = first.getStartPosition() - 1;
    }
    lastNode = (DOMNode) first.getNextNode();
    if (lastNode == null) {
      lastNode = first;
    } else {
      while (lastNode.getNextNode() != null) {
        lastNode = (DOMNode) lastNode.getNextNode();
      }
    }
    scanner.setSource(this.fDocument);
    scanner.resetTo(lastNode.getEndPosition() + 1, this.fDocument.length);
    try {
      int currentToken = scanner.getNextToken();
      while(currentToken != TerminalTokens.TokenNameRBRACE &&
          currentToken != TerminalTokens.TokenNameEOF) {
        currentToken = scanner.getNextToken();
      }
      if(currentToken == TerminalTokens.TokenNameRBRACE) {
        closeBodyStart = scanner.startPosition;
        closeBodyEnd = scanner.currentPosition - 1;
      } else {
        closeBodyStart = this.fDocument.length;
        closeBodyEnd = this.fDocument.length;
      }
    } catch(InvalidInputException e) {
      closeBodyStart = this.fDocument.length;
      closeBodyEnd = this.fDocument.length;
    }
  } else {
    scanner.resetTo(openBodyEnd, this.fDocument.length);
    try {
      int currentToken = scanner.getNextToken();
      while(currentToken != TerminalTokens.TokenNameRBRACE &&
          currentToken != TerminalTokens.TokenNameEOF) {
        currentToken = scanner.getNextToken();
      }
      if(currentToken == TerminalTokens.TokenNameRBRACE) {
        closeBodyStart = scanner.startPosition;
        closeBodyEnd = scanner.currentPosition - 1;
      } else {
View Full Code Here

  public void setToken(String token) {
    // update internalSetToken(String) if this is changed
    if (token == null || token.length() == 0) {
      throw new IllegalArgumentException();
    }
    Scanner scanner = this.ast.scanner;
    char[] source = token.toCharArray();
    scanner.setSource(source);
    scanner.resetTo(0, source.length);
    scanner.tokenizeComments = false;
    scanner.tokenizeWhiteSpace = false;
    try {
      int tokenType = scanner.getNextToken();
      switch(tokenType) {
        case TerminalTokens.TokenNameDoubleLiteral:
        case TerminalTokens.TokenNameIntegerLiteral:
        case TerminalTokens.TokenNameFloatingPointLiteral:
        case TerminalTokens.TokenNameLongLiteral:
          break;
        case TerminalTokens.TokenNameMINUS :
          tokenType = scanner.getNextToken();
          switch(tokenType) {
            case TerminalTokens.TokenNameDoubleLiteral:
            case TerminalTokens.TokenNameIntegerLiteral:
            case TerminalTokens.TokenNameFloatingPointLiteral:
            case TerminalTokens.TokenNameLongLiteral:
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.