private static SourceRange getRangeOfOperands(List/*<Expression>*/ operands) { Expression first= (Expression) operands.get(0); Expression last= (Expression) operands.get(operands.size() - 1); return new SourceRange(first.getStartPosition(), last.getStartPosition() + last.getLength() - first.getStartPosition()); }
private static ISourceRange getRangeOfOperands(List<Expression> operands) { Expression first = operands.get(0); Expression last = operands.get(operands.size() - 1); return new SourceRange(first.getStartPosition(), last.getStartPosition() + last.getLength() - first.getStartPosition()); }
private static ISourceRange getRangeOfOperands(List<Expression> operands) { Expression first= operands.get(0); Expression last= operands.get(operands.size() - 1); return new SourceRange(first.getStartPosition(), last.getStartPosition() + last.getLength() - first.getStartPosition()); }
private static ISourceRange getRangeOfOperands(List<Expression> operands) { Expression first= operands.get(0); Expression last= operands.get(operands.size() - 1); return new SourceRange(first.getStartPosition(), last.getStartPosition() + last.getLength() - first.getStartPosition()); }
private void setInfixSourcePositions(InfixExpression infixExpression, int sourceStart) { int n = infixExpression.extendedOperands().size(); Expression rightMostExp = n <= 0 ? infixExpression.getRightOperand() : (Expression) infixExpression.extendedOperands().get(n - 1); int rightSourceEnd = rightMostExp.getStartPosition() + rightMostExp.getLength() - 1; int infixSourceEnd = infixExpression.getStartPosition() + infixExpression.getLength() - 1; infixSourceEnd = rightSourceEnd > infixSourceEnd ? rightSourceEnd : infixSourceEnd; infixExpression.setSourceRange(sourceStart, infixSourceEnd - sourceStart + 1); }
private void setSelectionRanges(Expression exp){ fEffectiveSelectionStart= exp.getStartPosition(); fEffectiveSelectionLength= exp.getLength(); fSelectionBinding= ExpressionVariable.resolveBinding(exp); setOriginalType(exp.resolveTypeBinding()); }
private void setInfixSourcePositions(InfixExpression infixExpression, int sourceStart) { int n = infixExpression.extendedOperands().size(); Expression rightMostExp = n <= 0 ? infixExpression.getRightOperand() : (Expression) infixExpression.extendedOperands().get(n - 1); int rightSourceEnd = rightMostExp.getStartPosition() + rightMostExp.getLength() - 1; int infixSourceEnd = infixExpression.getStartPosition() + infixExpression.getLength() - 1; infixSourceEnd = rightSourceEnd > infixSourceEnd ? rightSourceEnd : infixSourceEnd; infixExpression.setSourceRange(sourceStart, infixSourceEnd - sourceStart + 1); }
private void setSelectionRanges(Expression exp){ fEffectiveSelectionStart= exp.getStartPosition(); fEffectiveSelectionLength= exp.getLength(); fSelectionBinding= ExpressionVariable.resolveBinding(exp); setOriginalType(exp.resolveTypeBinding()); }
private void setSelectionRanges(Expression exp){ fEffectiveSelectionStart= exp.getStartPosition(); fEffectiveSelectionLength= exp.getLength(); fSelectionBinding= ExpressionVariable.resolveBinding(exp); setOriginalType(exp.resolveTypeBinding()); }
private void setInfixSourcePositions(InfixExpression infixExpression, int sourceStart) { int n = infixExpression.extendedOperands().size(); Expression rightMostExp = n <= 0 ? infixExpression.getRightOperand() : (Expression) infixExpression.extendedOperands().get(n - 1); int rightSourceEnd = rightMostExp.getStartPosition() + rightMostExp.getLength() - 1; int infixSourceEnd = infixExpression.getStartPosition() + infixExpression.getLength() - 1; infixSourceEnd = rightSourceEnd > infixSourceEnd ? rightSourceEnd : infixSourceEnd; infixExpression.setSourceRange(sourceStart, infixSourceEnd - sourceStart + 1); }
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; }
public void endVisit(SingleMemberAnnotation node) { endVisitNode(node); // is inside diet part of the ast if(this.blockDepth < 1) { Expression value = node.getValue(); int annotationEnd = node.getStartPosition() + node.getLength(); int valueEnd = value.getStartPosition() + value.getLength(); if (annotationEnd == valueEnd) { node.setFlags(node.getFlags() | ASTNode.RECOVERED); } } } }
public void endVisit(SingleMemberAnnotation node) { endVisitNode(node); // is inside diet part of the ast if(this.blockDepth < 1) { Expression value = node.getValue(); int annotationEnd = node.getStartPosition() + node.getLength(); int valueEnd = value.getStartPosition() + value.getLength(); if (annotationEnd == valueEnd) { node.setFlags(node.getFlags() | ASTNode.RECOVERED); } } } }
private void replaceSelectedExpression(CompilationUnitRewrite cuRewrite) { if (! fSourceCU.equals(cuRewrite.getCu())) return; // TODO: do for all methodDeclarations and replace matching fragments? // cannot use fSelectedExpression here, since it could be from another AST (if method was replaced by overridden): Expression expression= (Expression) NodeFinder.perform(cuRewrite.getRoot(), fSelectedExpression.getStartPosition(), fSelectedExpression.getLength()); ASTNode newExpression= cuRewrite.getRoot().getAST().newSimpleName(fParameter.getNewName()); String description= RefactoringCoreMessages.IntroduceParameterRefactoring_replace; cuRewrite.getASTRewrite().replace(expression, newExpression, cuRewrite.createGroupDescription(description)); }
private void replaceSelectedExpression(CompilationUnitRewrite cuRewrite) { if (! fSourceCU.equals(cuRewrite.getCu())) return; // TODO: do for all methodDeclarations and replace matching fragments? // cannot use fSelectedExpression here, since it could be from another AST (if method was replaced by overridden): Expression expression= (Expression) NodeFinder.perform(cuRewrite.getRoot(), fSelectedExpression.getStartPosition(), fSelectedExpression.getLength()); ASTNode newExpression= cuRewrite.getRoot().getAST().newSimpleName(fParameter.getNewName()); String description= RefactoringCoreMessages.IntroduceParameterRefactoring_replace; cuRewrite.getASTRewrite().replace(expression.getParent() instanceof ParenthesizedExpression ? expression.getParent() : expression, newExpression, cuRewrite.createGroupDescription(description)); }
private void replaceSelectedExpression(CompilationUnitRewrite cuRewrite) { if (! fSourceCU.equals(cuRewrite.getCu())) return; // TODO: do for all methodDeclarations and replace matching fragments? // cannot use fSelectedExpression here, since it could be from another AST (if method was replaced by overridden): Expression expression= (Expression) NodeFinder.perform(cuRewrite.getRoot(), fSelectedExpression.getStartPosition(), fSelectedExpression.getLength()); ASTNode newExpression= cuRewrite.getRoot().getAST().newSimpleName(fParameter.getNewName()); String description= RefactoringCoreMessages.IntroduceParameterRefactoring_replace; cuRewrite.getASTRewrite().replace(expression.getParent() instanceof ParenthesizedExpression ? expression.getParent() : expression, newExpression, cuRewrite.createGroupDescription(description)); }
public ConditionalExpression convert(org.eclipse.jdt.internal.compiler.ast.ConditionalExpression expression) { ConditionalExpression conditionalExpression = new ConditionalExpression(this.ast); if (this.resolveBindings) { recordNodes(conditionalExpression, expression); } conditionalExpression.setExpression(convert(expression.condition)); conditionalExpression.setThenExpression(convert(expression.valueIfTrue)); Expression elseExpression = convert(expression.valueIfFalse); conditionalExpression.setElseExpression(elseExpression); conditionalExpression.setSourceRange(expression.sourceStart, elseExpression.getStartPosition() + elseExpression.getLength() - expression.sourceStart); return conditionalExpression; }
public ConditionalExpression convert(org.eclipse.jdt.internal.compiler.ast.ConditionalExpression expression) { ConditionalExpression conditionalExpression = new ConditionalExpression(this.ast); if (this.resolveBindings) { recordNodes(conditionalExpression, expression); } conditionalExpression.setExpression(convert(expression.condition)); conditionalExpression.setThenExpression(convert(expression.valueIfTrue)); Expression elseExpression = convert(expression.valueIfFalse); conditionalExpression.setElseExpression(elseExpression); conditionalExpression.setSourceRange(expression.sourceStart, elseExpression.getStartPosition() + elseExpression.getLength() - expression.sourceStart); return conditionalExpression; }
public ConditionalExpression convert(org.eclipse.jdt.internal.compiler.ast.ConditionalExpression expression) { ConditionalExpression conditionalExpression = new ConditionalExpression(this.ast); if (this.resolveBindings) { recordNodes(conditionalExpression, expression); } conditionalExpression.setExpression(convert(expression.condition)); conditionalExpression.setThenExpression(convert(expression.valueIfTrue)); Expression elseExpression = convert(expression.valueIfFalse); conditionalExpression.setElseExpression(elseExpression); conditionalExpression.setSourceRange(expression.sourceStart, elseExpression.getStartPosition() + elseExpression.getLength() - expression.sourceStart); return conditionalExpression; }