public StatementAnalyzer(ICompilationUnit cunit, Selection selection, boolean traverseSelectedNode) throws CoreException { super(selection, traverseSelectedNode); Assert.isNotNull(cunit); fCUnit= cunit; fStatus= new RefactoringStatus(); fScanner= new TokenScanner(fCUnit); }
public StatementAnalyzer(ICompilationUnit cunit, Selection selection, boolean traverseSelectedNode) throws JavaModelException { super(selection, traverseSelectedNode); Assert.isNotNull(cunit); fCUnit= cunit; fStatus= new RefactoringStatus(); fScanner= new TokenScanner(fCUnit); }
public StatementAnalyzer(ICompilationUnit cunit, Selection selection, boolean traverseSelectedNode) throws CoreException { super(selection, traverseSelectedNode); Assert.isNotNull(cunit); fCUnit= cunit; fStatus= new RefactoringStatus(); fScanner= new TokenScanner(fCUnit); }
private int getNextElseOffset(Statement then, ITypeRoot editorInput) { int thenEnd= ASTNodes.getExclusiveEnd(then); try { TokenScanner scanner= new TokenScanner(editorInput); return scanner.getNextStartOffset(thenEnd, true); } catch (CoreException e) { // ignore } return -1; }
private int getNextElseOffset(Statement then, ITypeRoot editorInput) { int thenEnd= ASTNodes.getExclusiveEnd(then); try { TokenScanner scanner= new TokenScanner(editorInput); return scanner.getNextStartOffset(thenEnd, true); } catch (CoreException e) { // ignore } return -1; }
private int getMemberStartOffset(IMember curr, IDocument document) throws JavaModelException { int offset= curr.getSourceRange().getOffset(); TokenScanner scanner= new TokenScanner(document, curr.getJavaProject()); try { return scanner.getNextStartOffset(offset, true); // read to the first real non comment token } catch (CoreException e) { // ignore } return offset; }
private int getMemberStartOffset(IMember curr, IDocument document) throws JavaModelException { int offset= curr.getSourceRange().getOffset(); TokenScanner scanner= new TokenScanner(document, curr.getJavaProject()); try { return scanner.getNextStartOffset(offset, true); // read to the first real non comment token } catch (CoreException e) { // ignore } return offset; }
private int getMemberStartOffset(IMember curr, IDocument document) throws JavaModelException { int offset= curr.getSourceRange().getOffset(); TokenScanner scanner= new TokenScanner(document, curr.getJavaProject()); try { return scanner.getNextStartOffset(offset, true); // read to the first real non comment token } catch (CoreException e) { // ignore } return offset; }
private boolean needsSemicolon(Expression expression) { if ((expression.getParent().getFlags() & ASTNode.RECOVERED) != 0) { try { TokenScanner scanner= new TokenScanner(getCompilationUnit()); return scanner.readNext(expression.getStartPosition() + expression.getLength(), true) != ITerminalSymbols.TokenNameSEMICOLON; } catch (CoreException e) { // ignore } } return false; }
private boolean needsSemicolon(Expression expression) { if ((expression.getParent().getFlags() & ASTNode.RECOVERED) != 0) { try { TokenScanner scanner= new TokenScanner(getCompilationUnit()); return scanner.readNext(expression.getStartPosition() + expression.getLength(), true) != ITerminalSymbols.TokenNameSEMICOLON; } catch (CoreException e) { // ignore } } return false; }
/** * Checks whether the given <code>exprStatement</code> has a semicolon at the end. * * @param exprStatement the {@link ExpressionStatement} to check the semicolon * @param cu the compilation unit * @return <code>true</code> if the given <code>exprStatement</code> has a semicolon at the end, * <code>false</code> otherwise */ public static boolean hasSemicolon(ExpressionStatement exprStatement, ICompilationUnit cu) { boolean hasSemicolon= true; if ((exprStatement.getFlags() & ASTNode.RECOVERED) != 0) { try { Expression expression= exprStatement.getExpression(); TokenScanner scanner= new TokenScanner(cu); hasSemicolon= scanner.readNext(expression.getStartPosition() + expression.getLength(), true) == ITerminalSymbols.TokenNameSEMICOLON; } catch (CoreException e) { hasSemicolon= false; } } return hasSemicolon; } }
/** * Checks whether the given <code>exprStatement</code> has a semicolon at the end. * * @param exprStatement the {@link ExpressionStatement} to check the semicolon * @param cu the compilation unit * @return <code>true</code> if the given <code>exprStatement</code> has a semicolon at the end, * <code>false</code> otherwise */ public static boolean hasSemicolon(ExpressionStatement exprStatement, ICompilationUnit cu) { boolean hasSemicolon= true; if ((exprStatement.getFlags() & ASTNode.RECOVERED) != 0) { try { Expression expression= exprStatement.getExpression(); TokenScanner scanner= new TokenScanner(cu); hasSemicolon= scanner.readNext(expression.getStartPosition() + expression.getLength(), true) == ITerminalSymbols.TokenNameSEMICOLON; } catch (CoreException e) { hasSemicolon= false; } } return hasSemicolon; }
String documentPortionToScan= fDocument.get(fSelectionStart, fSelectionLength); scanner.setSource(documentPortionToScan.toCharArray()); TokenScanner tokenizer= new TokenScanner(scanner); int pos= tokenizer.getNextStartOffset(0, false);
private OccurrenceLocation getLocationForFirstToken(ASTNode node) { try { int nextEndOffset= new TokenScanner(fASTRoot.getTypeRoot()).getNextEndOffset(node.getStartPosition(), true); return new OccurrenceLocation(node.getStartPosition(), nextEndOffset - node.getStartPosition(), 0, fDescription); } catch (CoreException e) { // ignore } return new OccurrenceLocation(node.getStartPosition(), node.getLength(), 0, fDescription); }
private OccurrenceLocation getLocationForFirstToken(ASTNode node) { try { int nextEndOffset= new TokenScanner(fASTRoot.getTypeRoot()).getNextEndOffset(node.getStartPosition(), true); return new OccurrenceLocation(node.getStartPosition(), nextEndOffset - node.getStartPosition(), 0, fDescription); } catch (CoreException e) { // ignore } return new OccurrenceLocation(node.getStartPosition(), node.getLength(), 0, fDescription); }
TokenScanner tokenizer = new TokenScanner(scanner); int pos = tokenizer.getNextStartOffset(0, false);
TokenScanner scanner = new TokenScanner(cu); int curr = scanner.readNext(0, true); int previous = curr;
} else if (body instanceof Expression) { try { TokenScanner scanner = new TokenScanner(fCUnit); int arrowExclusiveEnd = scanner.getTokenEndOffset(ITerminalSymbols.TokenNameARROW, lambdaStart); if (selectionStart >= arrowExclusiveEnd) {
} else if (body instanceof Expression) { try { TokenScanner scanner= new TokenScanner(fCUnit); int arrowExclusiveEnd= scanner.getTokenEndOffset(ITerminalSymbols.TokenNameARROW, lambdaStart); if (selectionStart >= arrowExclusiveEnd) {
} else if (body instanceof Expression) { try { TokenScanner scanner= new TokenScanner(fCUnit); int arrowExclusiveEnd= scanner.getTokenEndOffset(ITerminalSymbols.TokenNameARROW, lambdaStart); if (selectionStart >= arrowExclusiveEnd) {