下面列出了org.eclipse.jdt.core.dom.SuperMethodReference#org.eclipse.jdt.core.dom.VariableDeclaration 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static VariableDeclaration findFieldDeclaration(AbstractVariable variable, TypeDeclaration typeDeclaration) {
for(FieldDeclaration fieldDeclaration : typeDeclaration.getFields()) {
List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments();
for(VariableDeclarationFragment fragment : fragments) {
if(variable.getVariableBindingKey().equals(fragment.resolveBinding().getKey())) {
return fragment;
}
}
}
//fragment was not found in typeDeclaration
Type superclassType = typeDeclaration.getSuperclassType();
if(superclassType != null) {
String superclassQualifiedName = superclassType.resolveBinding().getQualifiedName();
SystemObject system = ASTReader.getSystemObject();
ClassObject superclassObject = system.getClassObject(superclassQualifiedName);
if(superclassObject != null) {
AbstractTypeDeclaration superclassTypeDeclaration = superclassObject.getAbstractTypeDeclaration();
if(superclassTypeDeclaration instanceof TypeDeclaration) {
return findFieldDeclaration(variable, (TypeDeclaration)superclassTypeDeclaration);
}
}
}
return null;
}
private boolean duplicatedSliceNodeWithClassInstantiationHasDependenceOnRemovableNode() {
Set<PDGNode> duplicatedNodes = new LinkedHashSet<PDGNode>();
duplicatedNodes.addAll(sliceNodes);
duplicatedNodes.retainAll(indispensableNodes);
for(PDGNode duplicatedNode : duplicatedNodes) {
if(duplicatedNode.containsClassInstanceCreation()) {
Map<VariableDeclaration, ClassInstanceCreation> classInstantiations = duplicatedNode.getClassInstantiations();
for(VariableDeclaration variableDeclaration : classInstantiations.keySet()) {
for(GraphEdge edge : duplicatedNode.outgoingEdges) {
PDGDependence dependence = (PDGDependence)edge;
if(subgraph.edgeBelongsToBlockBasedRegion(dependence) && dependence instanceof PDGDependence) {
PDGDependence dataDependence = (PDGDependence)dependence;
PDGNode dstPDGNode = (PDGNode)dataDependence.dst;
if(removableNodes.contains(dstPDGNode)) {
if(dstPDGNode.changesStateOfReference(variableDeclaration) ||
dstPDGNode.assignsReference(variableDeclaration) || dstPDGNode.accessesReference(variableDeclaration))
return true;
}
}
}
}
}
}
return false;
}
private boolean duplicatedSliceNodeWithClassInstantiationHasDependenceOnRemovableNode() {
Set<PDGNode> duplicatedNodes = new LinkedHashSet<PDGNode>();
duplicatedNodes.addAll(sliceNodes);
duplicatedNodes.retainAll(indispensableNodes);
for(PDGNode duplicatedNode : duplicatedNodes) {
if(duplicatedNode.containsClassInstanceCreation()) {
Map<VariableDeclaration, ClassInstanceCreation> classInstantiations = duplicatedNode.getClassInstantiations();
for(VariableDeclaration variableDeclaration : classInstantiations.keySet()) {
for(GraphEdge edge : duplicatedNode.outgoingEdges) {
PDGDependence dependence = (PDGDependence)edge;
if(edges.contains(dependence) && dependence instanceof PDGDependence) {
PDGDependence dataDependence = (PDGDependence)dependence;
PDGNode dstPDGNode = (PDGNode)dataDependence.dst;
if(removableNodes.contains(dstPDGNode)) {
if(dstPDGNode.changesStateOfReference(variableDeclaration) ||
dstPDGNode.assignsReference(variableDeclaration) || dstPDGNode.accessesReference(variableDeclaration))
return true;
}
}
}
}
}
}
return false;
}
public CodeFragmentDecomposer(Set<PDGNode> nodes, Set<VariableDeclaration> accessedFields) {
this.objectNodeMap = new LinkedHashMap<PlainVariable, Set<PDGNode>>();
Set<PlainVariable> declaredVariables = getDeclaredVariables(nodes);
for(PlainVariable objectReference : declaredVariables) {
Set<PDGNode> nodesDefiningAttributes = getNodesDefiningAttributesOfReference(objectReference, nodes);
if(!nodesDefiningAttributes.isEmpty()) {
Set<PDGNode> objectNodes = new LinkedHashSet<PDGNode>();
PDGNode nodeDeclaringReference = getNodeDeclaringReference(objectReference, nodes);
if(nodeDeclaringReference != null)
objectNodes.add(nodeDeclaringReference);
objectNodes.addAll(nodesDefiningAttributes);
objectNodeMap.put(objectReference, objectNodes);
}
}
Map<PlainVariable, Set<PDGNode>> definedFieldMap = getDefinedFieldMap(nodes, accessedFields);
objectNodeMap.putAll(definedFieldMap);
}
public Set<String> variableFeatures(final Set<ASTNode> boundNodesOfVariable) {
// Find the declaration and extract features
final Set<String> features = Sets.newHashSet();
for (final ASTNode node : boundNodesOfVariable) {
if (!(node.getParent() instanceof VariableDeclaration)) {
continue;
}
getDeclarationFeatures(features, node);
if (activeFeatures
.contains(AvailableFeatures.IMPLEMENTOR_VOCABULARY)) {
JavaFeatureExtractor.addImplementorVocab(node, features);
}
break;
}
return features;
}
public Set<String> variableFeatures(final Set<ASTNode> boundNodesOfVariable) {
// Find the declaration and extract features
final Set<String> features = Sets.newHashSet();
for (final ASTNode node : boundNodesOfVariable) {
if (!(node.getParent() instanceof VariableDeclaration)) {
continue;
}
getDeclarationFeatures(features, node);
if (activeFeatures
.contains(AvailableFeatures.IMPLEMENTOR_VOCABULARY)) {
JavaFeatureExtractor.addImplementorVocab(node, features);
}
break;
}
return features;
}
public ITypeBinding getReturnTypeBinding() {
List<VariableDeclaration> returnedVariables1 = new ArrayList<VariableDeclaration>(getVariablesToBeReturnedG1());
List<VariableDeclaration> returnedVariables2 = new ArrayList<VariableDeclaration>(getVariablesToBeReturnedG2());
ITypeBinding returnTypeBinding = null;
if(returnedVariables1.size() == 1 && returnedVariables2.size() == 1) {
ITypeBinding returnTypeBinding1 = extractTypeBinding(returnedVariables1.get(0));
ITypeBinding returnTypeBinding2 = extractTypeBinding(returnedVariables2.get(0));
if(returnTypeBinding1.isEqualTo(returnTypeBinding2) && returnTypeBinding1.getQualifiedName().equals(returnTypeBinding2.getQualifiedName()))
returnTypeBinding = returnTypeBinding1;
else
returnTypeBinding = ASTNodeMatcher.commonSuperType(returnTypeBinding1, returnTypeBinding2);
}
else {
returnTypeBinding = findReturnTypeBinding();
}
return returnTypeBinding;
}
@Override
public boolean visit(SimpleName node){
if (node.getParent() instanceof VariableDeclaration){
if (((VariableDeclaration)node.getParent()).getName() == node)
return true; //don't include declaration
}
if (fTempBinding != null && fTempBinding == node.resolveBinding()) {
if (fIsInJavadoc)
fJavadocNodes.add(node);
else
fReferenceNodes.add(node);
}
return true;
}
/**
* Returns the type node for the given declaration.
*
* @param declaration the declaration
* @return the type node or <code>null</code> if the given declaration represents a type
* inferred parameter in lambda expression
*/
public static Type getType(VariableDeclaration declaration) {
if (declaration instanceof SingleVariableDeclaration) {
return ((SingleVariableDeclaration)declaration).getType();
} else if (declaration instanceof VariableDeclarationFragment) {
ASTNode parent= ((VariableDeclarationFragment)declaration).getParent();
if (parent instanceof VariableDeclarationExpression)
return ((VariableDeclarationExpression)parent).getType();
else if (parent instanceof VariableDeclarationStatement)
return ((VariableDeclarationStatement)parent).getType();
else if (parent instanceof FieldDeclaration)
return ((FieldDeclaration)parent).getType();
else if (parent instanceof LambdaExpression)
return null;
}
Assert.isTrue(false, "Unknown VariableDeclaration"); //$NON-NLS-1$
return null;
}
public static int getDimensions(VariableDeclaration declaration) {
int dim= declaration.getExtraDimensions();
if (declaration instanceof VariableDeclarationFragment && declaration.getParent() instanceof LambdaExpression) {
LambdaExpression lambda= (LambdaExpression) declaration.getParent();
IMethodBinding methodBinding= lambda.resolveMethodBinding();
if (methodBinding != null) {
ITypeBinding[] parameterTypes= methodBinding.getParameterTypes();
int index= lambda.parameters().indexOf(declaration);
ITypeBinding typeBinding= parameterTypes[index];
return typeBinding.getDimensions();
}
} else {
Type type= getType(declaration);
if (type instanceof ArrayType) {
dim+= ((ArrayType) type).getDimensions();
}
}
return dim;
}
private static Type extractType(VariableDeclaration variableDeclaration) {
Type returnedVariableType = null;
if(variableDeclaration instanceof SingleVariableDeclaration) {
SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration)variableDeclaration;
returnedVariableType = singleVariableDeclaration.getType();
}
else if(variableDeclaration instanceof VariableDeclarationFragment) {
VariableDeclarationFragment fragment = (VariableDeclarationFragment)variableDeclaration;
if(fragment.getParent() instanceof VariableDeclarationStatement) {
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement)fragment.getParent();
returnedVariableType = variableDeclarationStatement.getType();
}
else if(fragment.getParent() instanceof VariableDeclarationExpression) {
VariableDeclarationExpression variableDeclarationExpression = (VariableDeclarationExpression)fragment.getParent();
returnedVariableType = variableDeclarationExpression.getType();
}
else if(fragment.getParent() instanceof FieldDeclaration) {
FieldDeclaration fieldDeclaration = (FieldDeclaration)fragment.getParent();
returnedVariableType = fieldDeclaration.getType();
}
}
return returnedVariableType;
}
private RefactoringStatus checkSelection(VariableDeclaration decl) {
ASTNode parent= decl.getParent();
if (parent instanceof MethodDeclaration) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_method_parameter);
}
if (parent instanceof CatchClause) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_exceptions_declared);
}
if (parent instanceof VariableDeclarationExpression && parent.getLocationInParent() == ForStatement.INITIALIZERS_PROPERTY) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_for_initializers);
}
if (parent instanceof VariableDeclarationExpression && parent.getLocationInParent() == TryStatement.RESOURCES_PROPERTY) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_resource_in_try_with_resources);
}
if (decl.getInitializer() == null) {
String message= Messages.format(RefactoringCoreMessages.InlineTempRefactoring_not_initialized, BasicElementLabels.getJavaElementName(decl.getName().getIdentifier()));
return RefactoringStatus.createFatalErrorStatus(message);
}
return checkAssignments(decl);
}
/**
* Creates a new promote temp to field refactoring.
* @param declaration the variable declaration node to convert to a field
*/
public PromoteTempToFieldRefactoring(VariableDeclaration declaration) {
Assert.isTrue(declaration != null);
fTempDeclarationNode= declaration;
IVariableBinding resolveBinding= declaration.resolveBinding();
Assert.isTrue(resolveBinding != null && !resolveBinding.isParameter() && !resolveBinding.isField());
ASTNode root= declaration.getRoot();
Assert.isTrue(root instanceof CompilationUnit);
fCompilationUnitNode= (CompilationUnit) root;
IJavaElement input= fCompilationUnitNode.getJavaElement();
Assert.isTrue(input instanceof ICompilationUnit);
fCu= (ICompilationUnit) input;
fSelectionStart= declaration.getStartPosition();
fSelectionLength= declaration.getLength();
fFieldName= ""; //$NON-NLS-1$
fVisibility= Modifier.PRIVATE;
fDeclareStatic= false;
fDeclareFinal= false;
fInitializeIn= INITIALIZE_IN_METHOD;
fLinkedProposalModel= null;
}
private void initializeParameterInfos() {
IVariableBinding[] arguments= fAnalyzer.getArguments();
fParameterInfos= new ArrayList<ParameterInfo>(arguments.length);
ASTNode root= fAnalyzer.getEnclosingBodyDeclaration();
ParameterInfo vararg= null;
for (int i= 0; i < arguments.length; i++) {
IVariableBinding argument= arguments[i];
if (argument == null)
continue;
VariableDeclaration declaration= ASTNodes.findVariableDeclaration(argument, root);
boolean isVarargs= declaration instanceof SingleVariableDeclaration
? ((SingleVariableDeclaration)declaration).isVarargs()
: false;
ParameterInfo info= new ParameterInfo(argument, getType(declaration, isVarargs), argument.getName(), i);
if (isVarargs) {
vararg= info;
} else {
fParameterInfos.add(info);
}
}
if (vararg != null) {
fParameterInfos.add(vararg);
}
}
@Override
public boolean visit(VariableDeclaration node) {
if (inFrame) {
AbstractDebugVariableCodeMining<IJavaStackFrame> m = new JavaDebugElementCodeMining(node.getName(), fFrame,
viewer, provider);
minings.add(m);
}
return super.visit(node);
}
public TypeCheckElimination() {
this.typeCheckMap = new LinkedHashMap<Expression, ArrayList<Statement>>();
this.defaultCaseStatements = new ArrayList<Statement>();
this.staticFieldMap = new LinkedHashMap<Expression, List<SimpleName>>();
this.subclassTypeMap = new LinkedHashMap<Expression, List<Type>>();
this.typeField = null;
this.typeFieldGetterMethod = null;
this.typeFieldSetterMethod = null;
this.typeCheckCodeFragment = null;
this.typeCheckMethod = null;
this.typeCheckClass = null;
this.additionalStaticFields = new LinkedHashSet<SimpleName>();
this.accessedFields = new LinkedHashSet<VariableDeclarationFragment>();
this.assignedFields = new LinkedHashSet<VariableDeclarationFragment>();
this.superAccessedFieldMap = new LinkedHashMap<VariableDeclarationFragment, MethodDeclaration>();
this.superAccessedFieldBindingMap = new LinkedHashMap<IVariableBinding, IMethodBinding>();
this.superAssignedFieldMap = new LinkedHashMap<VariableDeclarationFragment, MethodDeclaration>();
this.superAssignedFieldBindingMap = new LinkedHashMap<IVariableBinding, IMethodBinding>();
this.accessedParameters = new LinkedHashSet<SingleVariableDeclaration>();
this.assignedParameters = new LinkedHashSet<SingleVariableDeclaration>();
this.accessedLocalVariables = new LinkedHashSet<VariableDeclaration>();
this.assignedLocalVariables = new LinkedHashSet<VariableDeclaration>();
this.accessedMethods = new LinkedHashSet<MethodDeclaration>();
this.superAccessedMethods = new LinkedHashSet<IMethodBinding>();
this.typeLocalVariable = null;
this.typeMethodInvocation = null;
this.foreignTypeField = null;
this.existingInheritanceTree = null;
this.inheritanceTreeMatchingWithStaticTypes = null;
this.staticFieldSubclassTypeMap = new LinkedHashMap<SimpleName, String>();
this.remainingIfStatementExpressionMap = new LinkedHashMap<Expression, DefaultMutableTreeNode>();
this.abstractMethodName = null;
}
static VariableDeclaration name2decl(SimpleName sn, CompilationUnit cu, IResource resource){
DeclarationInfoManager.DeclarationInfo info = DeclarationInfoManager.retrieveDeclarationInfo(cu);
//System.out.println(info);
VariableDeclaration decl = info.getVariableDeclaration(sn);
if(decl == null) {
logError("decl == null for " + sn);
}
return decl;
}
public static boolean isWriteAccess(Name selectedNode) {
ASTNode curr= selectedNode;
ASTNode parent= curr.getParent();
while (parent != null) {
switch (parent.getNodeType()) {
case ASTNode.QUALIFIED_NAME:
if (((QualifiedName) parent).getQualifier() == curr) {
return false;
}
break;
case ASTNode.FIELD_ACCESS:
if (((FieldAccess) parent).getExpression() == curr) {
return false;
}
break;
case ASTNode.SUPER_FIELD_ACCESS:
break;
case ASTNode.ASSIGNMENT:
return ((Assignment) parent).getLeftHandSide() == curr;
case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
case ASTNode.SINGLE_VARIABLE_DECLARATION:
return ((VariableDeclaration) parent).getName() == curr;
case ASTNode.POSTFIX_EXPRESSION:
return true;
case ASTNode.PREFIX_EXPRESSION:
PrefixExpression.Operator op= ((PrefixExpression) parent).getOperator();
return op == PrefixExpression.Operator.DECREMENT || op == PrefixExpression.Operator.INCREMENT;
default:
return false;
}
curr= parent;
parent= curr.getParent();
}
return false;
}
private Variable createVariable(VariableDeclaration variableDeclaration) {
IVariableBinding variableBinding = variableDeclaration.resolveBinding();
Variable variable =
JdtUtils.createVariable(
getSourcePosition(variableBinding.getName(), variableDeclaration.getName()),
variableBinding);
variableByJdtBinding.put(variableBinding, variable);
recordEnclosingType(variable, getCurrentType());
return variable;
}
private Variable convert(org.eclipse.jdt.core.dom.VariableDeclaration variableDeclaration) {
if (variableDeclaration instanceof org.eclipse.jdt.core.dom.SingleVariableDeclaration) {
return convert((org.eclipse.jdt.core.dom.SingleVariableDeclaration) variableDeclaration);
} else {
return convert((org.eclipse.jdt.core.dom.VariableDeclarationFragment) variableDeclaration)
.getVariable();
}
}
@Override
public boolean consumes(SemanticToken token) {
SimpleName node = token.getNode();
StructuralPropertyDescriptor location = node.getLocationInParent();
if (location == VariableDeclarationFragment.NAME_PROPERTY || location == SingleVariableDeclaration.NAME_PROPERTY) {
ASTNode parent = node.getParent();
if (parent instanceof VariableDeclaration) {
parent = parent.getParent();
return parent == null || !(parent instanceof FieldDeclaration);
}
}
return false;
}
private void initAST() {
if (!fIsComposite) {
fCompilationUnitNode= RefactoringASTParser.parseWithASTProvider(fCu, true, null);
}
ISourceRange sourceRange= fLocalVariable.getNameRange();
ASTNode name= NodeFinder.perform(fCompilationUnitNode, sourceRange);
if (name == null) {
return;
}
if (name.getParent() instanceof VariableDeclaration) {
fTempDeclarationNode= (VariableDeclaration) name.getParent();
}
}
public SplitSelectedOperator(List<VariableDeclaration> inside, List<VariableDeclarationFragment> after, ListRewrite blockRewrite, ASTRewrite rewrite, List<ASTNode> statements) {
super();
fAccessedInside= inside;
fStatements= statements;
fAccessedAfter= after;
fRewrite= rewrite;
fBlockRewrite= blockRewrite;
}
/**
* This method analyzes a set of local variable renames inside one cu. It checks whether
* any new compile errors have been introduced by the rename(s) and whether the correct
* node(s) has/have been renamed.
*
* @param analyzePackages the LocalAnalyzePackages containing the information about the local renames
* @param cuChange the TextChange containing all local variable changes to be applied.
* @param oldCUNode the fully (incl. bindings) resolved AST node of the original compilation unit
* @param recovery whether statements and bindings recovery should be performed when parsing the changed CU
* @return a RefactoringStatus containing errors if compile errors or wrongly renamed nodes are found
* @throws CoreException thrown if there was an error greating the preview content of the change
*/
public static RefactoringStatus analyzeLocalRenames(LocalAnalyzePackage[] analyzePackages, TextChange cuChange, CompilationUnit oldCUNode, boolean recovery) throws CoreException {
RefactoringStatus result= new RefactoringStatus();
ICompilationUnit compilationUnit= (ICompilationUnit) oldCUNode.getJavaElement();
String newCuSource= cuChange.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode= new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL).parse(newCuSource, compilationUnit, true, recovery, null);
result.merge(analyzeCompileErrors(newCuSource, newCUNode, oldCUNode));
if (result.hasError()) {
return result;
}
for (int i= 0; i < analyzePackages.length; i++) {
ASTNode enclosing= getEnclosingBlockOrMethodOrLambda(analyzePackages[i].fDeclarationEdit, cuChange, newCUNode);
// get new declaration
IRegion newRegion= RefactoringAnalyzeUtil.getNewTextRange(analyzePackages[i].fDeclarationEdit, cuChange);
ASTNode newDeclaration= NodeFinder.perform(newCUNode, newRegion.getOffset(), newRegion.getLength());
Assert.isTrue(newDeclaration instanceof Name);
VariableDeclaration declaration= getVariableDeclaration((Name) newDeclaration);
Assert.isNotNull(declaration);
SimpleName[] problemNodes= ProblemNodeFinder.getProblemNodes(enclosing, declaration, analyzePackages[i].fOccurenceEdits, cuChange);
result.merge(RefactoringAnalyzeUtil.reportProblemNodes(newCuSource, problemNodes));
}
return result;
}
private static VariableDeclaration getVariableDeclaration(Name node) {
IBinding binding= node.resolveBinding();
if (binding == null && node.getParent() instanceof VariableDeclaration) {
return (VariableDeclaration) node.getParent();
}
if (binding != null && binding.getKind() == IBinding.VARIABLE) {
CompilationUnit cu= ASTNodes.getParent(node, CompilationUnit.class);
return ASTNodes.findVariableDeclaration( ((IVariableBinding) binding), cu);
}
return null;
}
protected ExtractClassRefactoringDescriptor(String project, String description, String comment,
CompilationUnit sourceCompilationUnit, TypeDeclaration sourceTypeDeclaration, IFile sourceFile,
Set<VariableDeclaration> extractedFieldFragments, Set<MethodDeclaration> extractedMethods,
Set<MethodDeclaration> delegateMethods, String extractedTypeName) {
super(REFACTORING_ID, project, description, comment, RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE);
this.sourceCompilationUnit = sourceCompilationUnit;
this.sourceTypeDeclaration = sourceTypeDeclaration;
this.sourceFile = sourceFile;
this.extractedFieldFragments = extractedFieldFragments;
this.extractedMethods = extractedMethods;
this.delegateMethods = delegateMethods;
this.extractedTypeName = extractedTypeName;
}
private boolean matchesLocationInEnclosingBodyDecl(BodyDeclaration originalEnclosingBodyDeclaration, BodyDeclaration duplicateEnclosingBodyDeclaration, VariableDeclaration originalReturnNode, VariableDeclaration duplicateReturnNode) {
boolean matches = true;
ASTNode original = originalReturnNode;
ASTNode dupliacte = duplicateReturnNode;
// walk up the parent chains to check if the location of the return nodes in their respective parent chains is same
do {
ASTNode originalParent = original.getParent();
ASTNode duplicateParent = dupliacte.getParent();
StructuralPropertyDescriptor originalLoc = original.getLocationInParent();
StructuralPropertyDescriptor duplicateLoc = dupliacte.getLocationInParent();
if (originalParent != null && duplicateParent != null && originalLoc.getNodeClass().equals(duplicateLoc.getNodeClass()) && originalLoc.getId().equals(duplicateLoc.getId())) {
if (originalLoc.isChildListProperty() && duplicateLoc.isChildListProperty()) {
int indexOfOriginal = ((List<?>) originalParent.getStructuralProperty(originalLoc)).indexOf(original);
int indexOfDuplicate = ((List<?>) duplicateParent.getStructuralProperty(duplicateLoc)).indexOf(dupliacte);
if (indexOfOriginal != indexOfDuplicate) {
matches = false;
break;
}
}
} else {
matches = false;
break;
}
original = originalParent;
dupliacte = duplicateParent;
if ((originalEnclosingBodyDeclaration.equals(original) && !duplicateEnclosingBodyDeclaration.equals(dupliacte)) || (!originalEnclosingBodyDeclaration.equals(original) && duplicateEnclosingBodyDeclaration.equals(dupliacte))) {
matches = false;
break;
}
} while (!originalEnclosingBodyDeclaration.equals(original) && !duplicateEnclosingBodyDeclaration.equals(dupliacte));
return matches;
}
private String getType(VariableDeclaration declaration, boolean isVarargs) {
String type = ASTNodes.asString(ASTNodeFactory.newType(declaration.getAST(), declaration, fImportRewriter, new ContextSensitiveImportRewriteContext(declaration, fImportRewriter)));
if (isVarargs) {
return type + ParameterInfo.ELLIPSIS;
} else {
return type;
}
}
private List<ASTNode> getSpecialVariableDeclarationStatements() {
List<ASTNode> result = new ArrayList<>(3);
VariableDeclaration[] locals = fAnalyzer.getAffectedLocals();
for (int i = 0; i < locals.length; i++) {
ASTNode parent = locals[i].getParent();
if (parent instanceof VariableDeclarationStatement && !result.contains(parent)) {
result.add(parent);
}
}
return result;
}
public Iterable<Expression> findAssignmentsInBlock(final Block scope, final VariableDeclaration varDecl) {
final Function1<Expression, Boolean> _function = (Expression it) -> {
Expression name = null;
boolean _matched = false;
if (it instanceof Assignment) {
_matched=true;
name = ((Assignment)it).getLeftHandSide();
}
if (!_matched) {
if (it instanceof PrefixExpression) {
_matched=true;
name = ((PrefixExpression)it).getOperand();
}
}
if (!_matched) {
if (it instanceof PostfixExpression) {
_matched=true;
name = ((PostfixExpression)it).getOperand();
}
}
if ((name instanceof Name)) {
final IBinding binding = ((Name)name).resolveBinding();
if ((binding instanceof IVariableBinding)) {
final IVariableBinding declBinding = varDecl.resolveBinding();
return Boolean.valueOf((varDecl.getName().getIdentifier().equals(this.toSimpleName(((Name)name))) && ((IVariableBinding)binding).equals(declBinding)));
}
}
return Boolean.valueOf(false);
};
return this.findAssignmentsInBlock(scope, _function);
}