public void initializeScanner(){ this.scanner = new Scanner( false /*comment*/, false /*whitespace*/, false, /* will be set in initialize(boolean) */ this.options.sourceLevel /*sourceLevel*/, this.options.complianceLevel /*complianceLevel*/, this.options.taskTags/*taskTags*/, this.options.taskPriorities/*taskPriorities*/, this.options.isTaskCaseSensitive/*taskCaseSensitive*/); } public void jumpOverMethodBody() {
@Override protected Object createReturnStatement() { return new JavadocReturnStatement(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition()); }
private boolean isNextTokenPunctuation() { this.localScanner.resetTo(this.scribe.scanner.currentPosition, this.scribe.scannerEndPosition - 1); try { int token = this.localScanner.getNextToken(); return !(Scanner.isLiteral(token) || Scanner.isKeyword(token) || Scanner.isIdentifier(token)); } catch(InvalidInputException e) { // ignore } return false; }
private int consumeInvalidToken(int end) { this.scanner.resetTo(this.scanner.startPosition, end); // In case of invalid unicode character, consume the current backslash character before continuing // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=233228 if (this.scanner.currentCharacter == '\\') { this.scanner.currentPosition = this.scanner.startPosition+1; } int previousPosition = this.scanner.currentPosition; char ch = (char) this.scanner.getNextChar(); if (this.scanner.atEnd()) { // avoid infinite loop return INVALID_TOKEN; } while (!this.scanner.atEnd() && ch != '*' && !ScannerHelper.isWhitespace(ch)) { previousPosition = this.scanner.currentPosition; ch = (char) this.scanner.getNextChar(); } // restore last whitespace this.scanner.currentPosition = previousPosition; return INVALID_TOKEN; }
public int getNextToken() throws InvalidInputException { this.wasAcr = false; if (this.diet) { jumpOverMethodBody(); this.diet = false; return this.currentPosition > this.eofPosition ? TokenNameEOF : TokenNameRBRACE; isWhiteSpace = jumpOverUnicodeWhiteSpace(); offset = this.currentPosition - offset; } else { if ((this.currentCharacter == '\r') || (this.currentCharacter == '\n')) { if (this.recordLineSeparator) { pushLineSeparator(); } else if (checkIfUnicode) { this.withoutUnicodePtr = 0; unicodeStore(); } else { this.withoutUnicodePtr = 0; return TokenNameCOMMA; case '.' : if (getNextCharAsDigit()) { return scanNumber(true); if (getNextChar('.')) { if (getNextChar('.')) { return TokenNameELLIPSIS; } else {
scanner.setSource(source); scanner.resetTo(start, end); int lineStart = start; try { scanner.resetTo(lineStart, end); while (!scanner.atEnd()) { if (scanner.getNextToken() == TerminalTokens.TokenNameLESS) { start = scanner.getCurrentTokenStartPosition(); break linesUp;
scanner.setSource(source); scanner.resetTo(end, source.length-1); int depth = 0; for (int i=typeArguments.length-1; i>=0; i--) { long lastTypeArgInfo = findLastTypeArgumentInfo(typeArguments[i]); depth = (int) (lastTypeArgInfo >>> 32)+1; scanner.resetTo(((int)lastTypeArgInfo)+1, scanner.eofPosition-1); break; while (!scanner.atEnd()) { if (scanner.getNextChar() == '>') { end = scanner.currentPosition - 1; break;
private static enum LocalTypeKind { LOCAL, METHOD_REFERENCE, LAMBDA, }
protected void checkNonNLSAfterBodyEnd(int declarationEnd){ if(this.scanner.currentPosition - 1 <= declarationEnd) { this.scanner.eofPosition = declarationEnd < Integer.MAX_VALUE ? declarationEnd + 1 : declarationEnd; try { while(this.scanner.getNextToken() != TokenNameEOF){/*empty*/} } catch (InvalidInputException e) { // Nothing to do } } } protected void classInstanceCreation(boolean isQualified) {
@Override public char[] getCurrentTokenSource() { if(this.fakeTokenSource != null) return this.fakeTokenSource; return super.getCurrentTokenSource(); }
@Override public char[] getCurrentIdentifierSource() { if(this.fakeTokenSource != null) return this.fakeTokenSource; return super.getCurrentIdentifierSource(); }
final int currentLine = currentLinePtr + 1; try { currentTag = new NLSTag(pos + sourceDelta, end + sourceDelta, currentLine, extractInt(s, start, end)); } catch (NumberFormatException e) { currentTag = new NLSTag(pos + sourceDelta, end + sourceDelta, currentLine, -1);
protected ASTNode parseBlockStatements(CompilationUnitDeclaration unit, int position) { int length = unit.types.length; for (int i = 0; i < length; i++) { TypeDeclaration type = unit.types[i]; if (type.declarationSourceStart < position && type.declarationSourceEnd >= position) { getParser().scanner.setSource(unit.compilationResult); return parseBlockStatements(type, unit, position); } } return null; }
static class IntArrayList { public int[] list = new int[5]; public int length = 0; public void add(int i) { if (this.list.length == this.length) { System.arraycopy(this.list, 0, this.list = new int[this.length*2], 0, this.length); } this.list[this.length++] = i; } }
/** * @return Returns the offset after the current token */ public int getCurrentEndOffset() { return this.scanner.getCurrentTokenEndPosition() + 1; }
/** * @return Returns the start offset of the current token */ public int getCurrentStartOffset() { return this.scanner.getCurrentTokenStartPosition(); }
protected int getNextToken0() throws InvalidInputException { this.wasAcr = false; if (this.diet) { jumpOverMethodBody(); this.diet = false; return this.currentPosition > this.eofPosition ? TokenNameEOF : TokenNameRBRACE; isWhiteSpace = jumpOverUnicodeWhiteSpace(); offset = this.currentPosition - offset; } else { if ((this.currentCharacter == '\r') || (this.currentCharacter == '\n')) { if (this.recordLineSeparator) { pushLineSeparator(); } else if (checkIfUnicode) { this.withoutUnicodePtr = 0; unicodeStore(); } else { this.withoutUnicodePtr = 0; return TokenNameCOMMA; case '.' : if (getNextCharAsDigit()) { return scanNumber(true); if (getNextChar('.')) { if (getNextChar('.')) { return TokenNameELLIPSIS; } else {
scanner.setSource(source); scanner.resetTo(start, end); int lineStart = start; try { scanner.resetTo(lineStart, end); while (!scanner.atEnd()) { if (scanner.getNextToken() == TerminalTokens.TokenNameLESS) { start = scanner.getCurrentTokenStartPosition(); break linesUp;
private int consumeInvalidToken(int end) { this.scanner.resetTo(this.scanner.startPosition, end); // In case of invalid unicode character, consume the current backslash character before continuing // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=233228 if (this.scanner.currentCharacter == '\\') { this.scanner.currentPosition = this.scanner.startPosition+1; } int previousPosition = this.scanner.currentPosition; char ch = (char) this.scanner.getNextChar(); if (this.scanner.atEnd()) { // avoid infinite loop return INVALID_TOKEN; } while (!this.scanner.atEnd() && ch != '*' && !ScannerHelper.isWhitespace(ch)) { previousPosition = this.scanner.currentPosition; ch = (char) this.scanner.getNextChar(); } // restore last whitespace this.scanner.currentPosition = previousPosition; return INVALID_TOKEN; }
scanner.setSource(source); scanner.resetTo(end, source.length-1); int depth = 0; for (int i=typeArguments.length-1; i>=0; i--) { long lastTypeArgInfo = findLastTypeArgumentInfo(typeArguments[i]); depth = (int) (lastTypeArgInfo >>> 32)+1; scanner.resetTo(((int)lastTypeArgInfo)+1, scanner.eofPosition-1); break; while (!scanner.atEnd()) { if (scanner.getNextChar() == '>') { end = scanner.currentPosition - 1; break;