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

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


*     - '*' is not valid inside type arguments definition <>
*     - '?' is treated as a wildcard when it is inside <> (ie. it must be put on first position of the type argument)
*/
private static SearchPattern createTypePattern(String patternString, int limitTo, int matchRule, char indexSuffix) {
 
  Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
  scanner.setSource(patternString.toCharArray());
  String type = null;
  int token;
  try {
    token = scanner.getNextToken();
  } catch (InvalidInputException e) {
    return null;
  }
  int argCount = 0;
  while (token != TerminalTokens.TokenNameEOF) {
    if (argCount == 0) {
      switch (token) {
        case TerminalTokens.TokenNameWHITESPACE:
          break;
        case TerminalTokens.TokenNameLESS:
          argCount++;
          // fall through default case to add token to type
        default: // all other tokens are considered identifiers (see bug 21763 Problem in Java search [search])
          if (type == null)
            type = scanner.getCurrentTokenString();
          else
            type += scanner.getCurrentTokenString();
      }
    } else {
      switch (token) {
        case TerminalTokens.TokenNameGREATER:
        case TerminalTokens.TokenNameRIGHT_SHIFT:
        case TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT:
          argCount--;
          break;
        case TerminalTokens.TokenNameLESS:
          argCount++;
          break;
      }
      if (type == null) return null; // invalid syntax
      type += scanner.getCurrentTokenString();
    }
    try {
      token = scanner.getNextToken();
    } catch (InvalidInputException e) {
      return null;
    }
  }
  if (type == null) return null;
View Full Code Here


  public void setIdentifier(String identifier) {
    // update internalSetIdentifier if this is changed
    if (identifier == null) {
      throw new IllegalArgumentException();
    }
    Scanner scanner = this.ast.scanner;
    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();
      }
      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

    this.lookupEnvironment =
      new LookupEnvironment(this, this.compilerOptions, this.problemReporter, nameEnvironment);
    this.parser =
      new CompletionParser(this.problemReporter);
    this.nameScanner =
      new Scanner(
        false /*comment*/,
        false /*whitespace*/,
        false /*nls*/,
        this.compilerOptions.sourceLevel,
        null /*taskTags*/,
View Full Code Here

      && (level != AST.JLS3)) {
      throw new IllegalArgumentException();
    }
    this.apiLevel = level;
    // initialize a scanner
    this.scanner = new Scanner(
        true /*comment*/,
        true /*whitespace*/,
        false /*nls*/,
        ClassFileConstants.JDK1_3 /*sourceLevel*/,
        ClassFileConstants.JDK1_5 /*complianceLevel*/,
 
View Full Code Here

      complianceLevel = ClassFileConstants.JDK1_4;
    } else if (JavaCore.VERSION_1_5.equals(complianceLevelOption)) {
      complianceLevel = ClassFileConstants.JDK1_5;
    }
    // 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

      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 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

  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 = 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;
    char nextChar = (char) 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(nextChar)) {
              int number = ScannerHelper.getNumericValue(nextChar);
              nextChar = (char) scanner.getNextChar();
              if (nextChar == -1) {
                throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
              }
              if (nextChar != '\'') {
                if (!ScannerHelper.isDigit(nextChar)) {
                  throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
                }
                number = (number * 8) + ScannerHelper.getNumericValue(nextChar);
                nextChar = (char) scanner.getNextChar();
                if (nextChar == -1) {
                  throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
                }
                if (nextChar != '\'') {
                  if (!ScannerHelper.isDigit(nextChar)) {
                    throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
                  }
                  number = (number * 8) + ScannerHelper.getNumericValue(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 = (char) scanner.getNextChar();
      if (nextChar == -1) {
        throw new IllegalArgumentException("illegal character literal");//$NON-NLS-1$
      }
    }
    if (nextChar == -1 || nextChar != '\'') {
View Full Code Here

TOP

Related Classes of org.aspectj.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.