Package org.eclipse.jdt.core.compiler

Examples of org.eclipse.jdt.core.compiler.InvalidInputException


  if (this.currentPosition < this.eofPosition) {
    while (this.source[this.currentPosition] == 'u') {
      this.currentPosition++;
      if (this.currentPosition >= this.eofPosition) {
        this.currentPosition--;
        throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
      }
      unicodeSize++;
    }
  } else {
    this.currentPosition--;
    throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
  }

  if ((this.currentPosition + 4) > this.eofPosition) {
    this.currentPosition += (this.eofPosition - this.currentPosition);
    throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
  }
  if ((c1 = ScannerHelper.getHexadecimalValue(this.source[this.currentPosition++])) > 15
        || c1 < 0
        || (c2 = ScannerHelper.getHexadecimalValue(this.source[this.currentPosition++])) > 15
        || c2 < 0
        || (c3 = ScannerHelper.getHexadecimalValue(this.source[this.currentPosition++])) > 15
        || c3 < 0
        || (c4 = ScannerHelper.getHexadecimalValue(this.source[this.currentPosition++])) > 15
        || c4 < 0){
    throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
  }
  this.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
  //need the unicode buffer
  if (this.withoutUnicodePtr == 0) {
    //buffer all the entries that have been left aside....
View Full Code Here


              }
            }
            boolean isJavaIdStart;
            if (c >= HIGH_SURROGATE_MIN_VALUE && c <= HIGH_SURROGATE_MAX_VALUE) {
              if (this.complianceLevel < ClassFileConstants.JDK1_5) {
                throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
              }
              // Unicode 4 detection
              char low = (char) getNextChar();
              if (low < LOW_SURROGATE_MIN_VALUE || low > LOW_SURROGATE_MAX_VALUE) {
                // illegal low surrogate
View Full Code Here

          }
        } else { // has read \OctalDigit --> ignore last character
          this.currentPosition--;
        }
        if (number > 255)
          throw new InvalidInputException(INVALID_ESCAPE);
        this.currentCharacter = (char) number;
      } else
        throw new InvalidInputException(INVALID_ESCAPE);
  }
}
View Full Code Here

      int start = this.currentPosition;
      consumeDigits(16, true);
      int end = this.currentPosition;
      if (getNextChar('l', 'L') >= 0) {
        if (end == start) {
          throw new InvalidInputException(INVALID_HEXA);
        }
        return TokenNameLongLiteral;
      } else if (getNextChar('.')) {
        // hexadecimal floating point literal
        // read decimal part
        boolean hasNoDigitsBeforeDot = end == start;
        start = this.currentPosition;
        consumeDigits(16, true);
        end = this.currentPosition;
        if (hasNoDigitsBeforeDot && end == start) {
          if (this.sourceLevel < ClassFileConstants.JDK1_5) {
            throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
          }
          throw new InvalidInputException(INVALID_HEXA);
        }

        if (getNextChar('p', 'P') >= 0) { // consume next character
          this.unicodeAsBackSlash = false;
          if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
              && (this.source[this.currentPosition] == 'u')) {
            getNextUnicodeChar();
          } else {
            if (this.withoutUnicodePtr != 0) {
              unicodeStore();
            }
          }

          if ((this.currentCharacter == '-')
              || (this.currentCharacter == '+')) { // consume next character
            this.unicodeAsBackSlash = false;
            if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
                && (this.source[this.currentPosition] == 'u')) {
              getNextUnicodeChar();
            } else {
              if (this.withoutUnicodePtr != 0) {
                unicodeStore();
              }
            }
          }
          if (!ScannerHelper.isDigit(this.currentCharacter)) {
            if (this.sourceLevel < ClassFileConstants.JDK1_5) {
              throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
            }
            if (this.currentCharacter == '_') {
              // wrongly place '_'
              consumeDigits(10);
              throw new InvalidInputException(INVALID_UNDERSCORE);
            }
            throw new InvalidInputException(INVALID_HEXA);
          }
          consumeDigits(10);
          if (getNextChar('f', 'F') >= 0) {
            if (this.sourceLevel < ClassFileConstants.JDK1_5) {
              throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
            }
            return TokenNameFloatingPointLiteral;
          }
          if (getNextChar('d', 'D') >= 0) {
            if (this.sourceLevel < ClassFileConstants.JDK1_5) {
              throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
            }
            return TokenNameDoubleLiteral;
          }
          if (getNextChar('l', 'L') >= 0) {
            if (this.sourceLevel < ClassFileConstants.JDK1_5) {
              throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
            }
            throw new InvalidInputException(INVALID_HEXA);
          }
          if (this.sourceLevel < ClassFileConstants.JDK1_5) {
            throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
          }
          return TokenNameDoubleLiteral;
        } else {
          if (this.sourceLevel < ClassFileConstants.JDK1_5) {
            throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
          }
          throw new InvalidInputException(INVALID_HEXA);
        }
      } else if (getNextChar('p', 'P') >= 0) { // consume next character
        this.unicodeAsBackSlash = false;
        if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
            && (this.source[this.currentPosition] == 'u')) {
          getNextUnicodeChar();
        } else {
          if (this.withoutUnicodePtr != 0) {
            unicodeStore();
          }
        }

        if ((this.currentCharacter == '-')
            || (this.currentCharacter == '+')) { // consume next character
          this.unicodeAsBackSlash = false;
          if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
              && (this.source[this.currentPosition] == 'u')) {
            getNextUnicodeChar();
          } else {
            if (this.withoutUnicodePtr != 0) {
              unicodeStore();
            }
          }
        }
        if (!ScannerHelper.isDigit(this.currentCharacter)) {
          if (this.sourceLevel < ClassFileConstants.JDK1_5) {
            throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
          }
          if (this.currentCharacter == '_') {
            // wrongly place '_'
            consumeDigits(10);
            throw new InvalidInputException(INVALID_UNDERSCORE);
          }
          throw new InvalidInputException(INVALID_FLOAT);
        }
        consumeDigits(10);
        if (getNextChar('f', 'F') >= 0) {
          if (this.sourceLevel < ClassFileConstants.JDK1_5) {
            throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
          }
          return TokenNameFloatingPointLiteral;
        }
        if (getNextChar('d', 'D') >= 0) {
          if (this.sourceLevel < ClassFileConstants.JDK1_5) {
            throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
          }
          return TokenNameDoubleLiteral;
        }
        if (getNextChar('l', 'L') >= 0) {
          if (this.sourceLevel < ClassFileConstants.JDK1_5) {
            throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
          }
          throw new InvalidInputException(INVALID_HEXA);
        }
        if (this.sourceLevel < ClassFileConstants.JDK1_5) {
          throw new InvalidInputException(ILLEGAL_HEXA_LITERAL);
        }
        return TokenNameDoubleLiteral;
      } else {
        if (end == start)
          throw new InvalidInputException(INVALID_HEXA);
        return TokenNameIntegerLiteral;
      }
    } else if (getNextChar('b', 'B') >= 0) { //----------binary-----------------
      int start = this.currentPosition;
      consumeDigits(2, true);
      int end = this.currentPosition;
      if (end == start) {
        if (this.sourceLevel < ClassFileConstants.JDK1_7) {
          throw new InvalidInputException(BINARY_LITERAL_NOT_BELOW_17);
        }
        throw new InvalidInputException(INVALID_BINARY);
      }
      if (getNextChar('l', 'L') >= 0) {
        if (this.sourceLevel < ClassFileConstants.JDK1_7) {
          throw new InvalidInputException(BINARY_LITERAL_NOT_BELOW_17);
        }
        return TokenNameLongLiteral;
      }
      if (this.sourceLevel < ClassFileConstants.JDK1_7) {
        throw new InvalidInputException(BINARY_LITERAL_NOT_BELOW_17);
      }
      return TokenNameIntegerLiteral;
    }

    //there is no x or X nor b or B in the number
    //potential octal
    if (getNextCharAsDigit()) { //-------------potential octal-----------------
      consumeDigits(10);

      if (getNextChar('l', 'L') >= 0) {
        return TokenNameLongLiteral;
      }

      if (getNextChar('f', 'F') >= 0) {
        return TokenNameFloatingPointLiteral;
      }

      if (getNextChar('d', 'D') >= 0) {
        return TokenNameDoubleLiteral;
      } else { //make the distinction between octal and float ....
        boolean isInteger = true;
        if (getNextChar('.')) {
          isInteger = false;
          consumeDigits(10);
        }
        if (getNextChar('e', 'E') >= 0) { // consume next character
          isInteger = false;
          this.unicodeAsBackSlash = false;
          if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
              && (this.source[this.currentPosition] == 'u')) {
            getNextUnicodeChar();
          } else {
            if (this.withoutUnicodePtr != 0) {
              unicodeStore();
            }
          }

          if ((this.currentCharacter == '-')
              || (this.currentCharacter == '+')) { // consume next character
            this.unicodeAsBackSlash = false;
            if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
                && (this.source[this.currentPosition] == 'u')) {
              getNextUnicodeChar();
            } else {
              if (this.withoutUnicodePtr != 0) {
                unicodeStore();
              }
            }
          }
          if (!ScannerHelper.isDigit(this.currentCharacter)) {
            if (this.currentCharacter == '_') {
              // wrongly place '_'
              consumeDigits(10);
              throw new InvalidInputException(INVALID_UNDERSCORE);
            }
            throw new InvalidInputException(INVALID_FLOAT);
          }
          consumeDigits(10);
        }
        if (getNextChar('f', 'F') >= 0)
          return TokenNameFloatingPointLiteral;
        if (getNextChar('d', 'D') >= 0 || !isInteger)
          return TokenNameDoubleLiteral;
        return TokenNameIntegerLiteral;
      }
    } else {
      /* carry on */
    }
  }

  consumeDigits(10);

  if ((!dotPrefix) && (getNextChar('l', 'L') >= 0))
    return TokenNameLongLiteral;

  if ((!dotPrefix) && (getNextChar('.'))) { //decimal part that can be empty
    consumeDigits(10, true);
    floating = true;
  }

  //if floating is true both exponant and suffix may be optional

  if (getNextChar('e', 'E') >= 0) {
    floating = true;
    // consume next character
    this.unicodeAsBackSlash = false;
    if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
        && (this.source[this.currentPosition] == 'u')) {
      getNextUnicodeChar();
    } else {
      if (this.withoutUnicodePtr != 0) {
        unicodeStore();
      }
    }

    if ((this.currentCharacter == '-')
        || (this.currentCharacter == '+')) { // consume next character
      this.unicodeAsBackSlash = false;
      if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
          && (this.source[this.currentPosition] == 'u')) {
        getNextUnicodeChar();
      } else {
        if (this.withoutUnicodePtr != 0) {
          unicodeStore();
        }
      }
    }
    if (!ScannerHelper.isDigit(this.currentCharacter)) {
      if (this.currentCharacter == '_') {
        // wrongly place '_'
        consumeDigits(10);
        throw new InvalidInputException(INVALID_UNDERSCORE);
      }
      throw new InvalidInputException(INVALID_FLOAT);
    }
    // current character is a digit so we expect no digit first (the next character could be an underscore)
    consumeDigits(10);
  }

View Full Code Here

}

private MethodBinding [] getInterfaceAbstractContracts(Scope scope) throws InvalidInputException {
 
  if (!isInterface() || !isValidBinding()) {
    throw new InvalidInputException("Not a functional interface"); //$NON-NLS-1$
  }
 
  MethodBinding [] methods = methods();
  MethodBinding [] contracts = new MethodBinding[0];
  int contractsCount = 0;
  int contractsLength = 0;
 
  ReferenceBinding [] superInterfaces = superInterfaces();
  for (int i = 0, length = superInterfaces.length; i < length; i++) {
    MethodBinding [] superInterfaceContracts = superInterfaces[i].getInterfaceAbstractContracts(scope);
    final int superInterfaceContractsLength = superInterfaceContracts == null  ? 0 : superInterfaceContracts.length;
    if (superInterfaceContractsLength == 0) continue;
    if (contractsLength < contractsCount + superInterfaceContractsLength) {
      System.arraycopy(contracts, 0, contracts = new MethodBinding[contractsLength = contractsCount + superInterfaceContractsLength], 0, contractsCount);
    }
    System.arraycopy(superInterfaceContracts, 0, contracts, contractsCount,  superInterfaceContractsLength);
    contractsCount += superInterfaceContractsLength;
  }

  for (int i = 0, length = methods == null ? 0 : methods.length; i < length; i++) {
    final MethodBinding method = methods[i];
    if (method == null || method.isStatic() || method.redeclaresPublicObjectMethod(scope))
      continue;
    if (!method.isValidBinding())
      throw new InvalidInputException("Not a functional interface"); //$NON-NLS-1$
    if (method.isDefaultMethod()) {
      for (int j = 0; j < contractsCount; j++) {
        if (contracts[j] == null)
          continue;
        if (MethodVerifier.doesMethodOverride(method, contracts[j], scope.environment())) {
View Full Code Here

public static boolean isDigit(char c) throws InvalidInputException {
  if(c < ScannerHelper.MAX_OBVIOUS) {
    return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0;
  }
  if (Character.isDigit(c)) {
    throw new InvalidInputException(Scanner.INVALID_DIGIT);
  }
  return false;
}
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.compiler.InvalidInputException

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.