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 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 JavaMethodParameterCodeMining(ASTNode node, Expression parameter, int parameterIndex, CompilationUnit cu, ICodeMiningProvider provider, boolean showName, boolean showType, boolean showParameterByUsingFilters) { super(new Position(parameter.getStartPosition(), 1), provider, null); this.cu = cu; this.node = node; this.parameter = parameter; this.parameterIndex = parameterIndex; this.showName = showName; this.showType = showType; this.showParameterByUsingFilters = showParameterByUsingFilters; }
@Override public int compare(ToStaticAccessOperation o1, ToStaticAccessOperation o2) { if (ASTNodes.isParent(o1.fQualifier, o2.fQualifier)) { return -1; } else if (ASTNodes.isParent(o2.fQualifier, o1.fQualifier)) { return 1; } else { return o1.fQualifier.getStartPosition() - o2.fQualifier.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 initializeExcludedParameterNames(CompilationUnitRewrite cuRewrite) { IBinding[] bindings= new ScopeAnalyzer(cuRewrite.getRoot()).getDeclarationsInScope( fSelectedExpression.getStartPosition(), ScopeAnalyzer.VARIABLES); fExcludedParameterNames= new String[bindings.length]; for (int i= 0; i < fExcludedParameterNames.length; i++) { fExcludedParameterNames[i]= bindings[i].getName(); } }
private void initializeExcludedParameterNames(CompilationUnitRewrite cuRewrite) { IBinding[] bindings= new ScopeAnalyzer(cuRewrite.getRoot()).getDeclarationsInScope( fSelectedExpression.getStartPosition(), ScopeAnalyzer.VARIABLES); fExcludedParameterNames= new String[bindings.length]; for (int i= 0; i < fExcludedParameterNames.length; i++) { fExcludedParameterNames[i]= bindings[i].getName(); } }
private void setSelectionRanges(Expression exp){ fEffectiveSelectionStart= exp.getStartPosition(); fEffectiveSelectionLength= exp.getLength(); fSelectionBinding= ExpressionVariable.resolveBinding(exp); setOriginalType(exp.resolveTypeBinding()); }
private void initializeExcludedParameterNames(CompilationUnitRewrite cuRewrite) { IBinding[] bindings= new ScopeAnalyzer(cuRewrite.getRoot()).getDeclarationsInScope( fSelectedExpression.getStartPosition(), ScopeAnalyzer.VARIABLES); fExcludedParameterNames= new String[bindings.length]; for (int i= 0; i < fExcludedParameterNames.length; i++) { fExcludedParameterNames[i]= bindings[i].getName(); } }
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 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; }
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; }