private void initializeDestinations() { List result= new ArrayList(); BodyDeclaration decl= fAnalyzer.getEnclosingBodyDeclaration(); ASTNode current= getNextParent(decl); result.add(current); if (decl instanceof MethodDeclaration) { ITypeBinding binding= ASTNodes.getEnclosingType(current); ASTNode next= getNextParent(current); while (next != null && binding != null && binding.isNested() && !Modifier.isStatic(binding.getDeclaredModifiers())) { result.add(next); current= next; binding= ASTNodes.getEnclosingType(current); next= getNextParent(next); } } fDestinations= (ASTNode[])result.toArray(new ASTNode[result.size()]); fDestination= fDestinations[fDestinationIndex]; }
private String getReceiver(CallContext context, int modifiers, ImportRewriteContext importRewriteContext) { String receiver= context.receiver; ITypeBinding invocationType= ASTNodes.getEnclosingType(context.invocation); ITypeBinding sourceType= fDeclaration.resolveBinding().getDeclaringClass(); if (!context.receiverIsStatic && Modifier.isStatic(modifiers)) { if ("this".equals(receiver) && invocationType != null && Bindings.equals(invocationType, sourceType)) { //$NON-NLS-1$ receiver= null; } else { receiver= context.importer.addImport(sourceType, importRewriteContext); } } return receiver; }
private void initializeDestinations() { List<ASTNode> result= new ArrayList<>(); BodyDeclaration decl= fAnalyzer.getEnclosingBodyDeclaration(); ASTNode current= ASTResolving.findParentType(decl.getParent()); if (fAnalyzer.isValidDestination(current)) { result.add(current); } if (current != null && (decl instanceof MethodDeclaration || decl instanceof Initializer || decl instanceof FieldDeclaration)) { ITypeBinding binding= ASTNodes.getEnclosingType(current); ASTNode next= ASTResolving.findParentType(current.getParent()); while (next != null && binding != null && binding.isNested()) { if (fAnalyzer.isValidDestination(next)) { result.add(next); } current= next; binding= ASTNodes.getEnclosingType(current); next= ASTResolving.findParentType(next.getParent()); } } fDestinations= result.toArray(new ASTNode[result.size()]); fDestination= fDestinations[fDestinationIndex]; }
private void initializeDestinations() { List<ASTNode> result = new ArrayList<>(); BodyDeclaration decl = fAnalyzer.getEnclosingBodyDeclaration(); ASTNode current = ASTResolving.findParentType(decl.getParent()); if (fAnalyzer.isValidDestination(current)) { result.add(current); } if (current != null && (decl instanceof MethodDeclaration || decl instanceof Initializer || decl instanceof FieldDeclaration)) { ITypeBinding binding = ASTNodes.getEnclosingType(current); ASTNode next = ASTResolving.findParentType(current.getParent()); while (next != null && binding != null && binding.isNested()) { if (fAnalyzer.isValidDestination(next)) { result.add(next); } current = next; binding = ASTNodes.getEnclosingType(current); next = ASTResolving.findParentType(next.getParent()); } } fDestinations = result.toArray(new ASTNode[result.size()]); fDestination = fDestinations[fDestinationIndex]; }
private String getReceiver(CallContext context, int modifiers) { String receiver= context.receiver; ITypeBinding invocationType= ASTNodes.getEnclosingType(context.invocation); ITypeBinding sourceType= fDeclaration.resolveBinding().getDeclaringClass(); if (!context.receiverIsStatic && Modifier.isStatic(modifiers)) { if ("this".equals(receiver) && invocationType != null && Bindings.equals(invocationType, sourceType)) { //$NON-NLS-1$ receiver= null; } else { receiver= context.importer.addImport(sourceType); } } return receiver; }
private String getReceiver(CallContext context, int modifiers, ImportRewriteContext importRewriteContext) { String receiver= context.receiver; ITypeBinding invocationType= ASTNodes.getEnclosingType(context.invocation); ITypeBinding sourceType= fDeclaration.resolveBinding().getDeclaringClass(); if (!context.receiverIsStatic && Modifier.isStatic(modifiers)) { if ("this".equals(receiver) && invocationType != null && Bindings.equals(invocationType, sourceType)) { //$NON-NLS-1$ receiver= null; } else { receiver= context.importer.addImport(sourceType, importRewriteContext); } } return receiver; }
private void initializeDestinations() { List<ASTNode> result= new ArrayList<>(); BodyDeclaration decl= fAnalyzer.getEnclosingBodyDeclaration(); ASTNode current= ASTResolving.findParentType(decl.getParent()); if (fAnalyzer.isValidDestination(current)) { result.add(current); } if (current != null && (decl instanceof MethodDeclaration || decl instanceof Initializer || decl instanceof FieldDeclaration)) { ITypeBinding binding= ASTNodes.getEnclosingType(current); ASTNode next= ASTResolving.findParentType(current.getParent()); while (next != null && binding != null && binding.isNested()) { if (fAnalyzer.isValidDestination(next)) { result.add(next); } current= next; binding= ASTNodes.getEnclosingType(current); next= ASTResolving.findParentType(next.getParent()); } } fDestinations= result.toArray(new ASTNode[result.size()]); fDestination= fDestinations[fDestinationIndex]; }
public void checkInput(RefactoringStatus status, String methodName, AST ast) { ITypeBinding[] arguments= getArgumentTypes(); ITypeBinding type= ASTNodes.getEnclosingType(fEnclosingBodyDeclaration); status.merge(Checks.checkMethodInType(type, methodName, arguments)); status.merge(Checks.checkMethodInHierarchy(type.getSuperclass(), methodName, null, arguments)); }
public void checkInput(RefactoringStatus status, String methodName, ASTNode destination) { ITypeBinding[] arguments = getArgumentTypes(); ITypeBinding type = ASTNodes.getEnclosingType(destination); status.merge(Checks.checkMethodInType(type, methodName, arguments)); ITypeBinding superClass = type.getSuperclass(); if (superClass != null) { status.merge(Checks.checkMethodInHierarchy(superClass, methodName, null, arguments)); } for (ITypeBinding superInterface : type.getInterfaces()) { status.merge(Checks.checkMethodInHierarchy(superInterface, methodName, null, arguments)); } }
public void checkInput(RefactoringStatus status, String methodName, ASTNode destination) { ITypeBinding[] arguments= getArgumentTypes(); ITypeBinding type= ASTNodes.getEnclosingType(destination); status.merge(Checks.checkMethodInType(type, methodName, arguments)); ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { status.merge(Checks.checkMethodInHierarchy(superClass, methodName, null, arguments)); } for (ITypeBinding superInterface : type.getInterfaces()) { status.merge(Checks.checkMethodInHierarchy(superInterface, methodName, null, arguments)); } }
public void checkInput(RefactoringStatus status, String methodName, ASTNode destination) { ITypeBinding[] arguments= getArgumentTypes(); ITypeBinding type= ASTNodes.getEnclosingType(destination); status.merge(Checks.checkMethodInType(type, methodName, arguments)); ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { status.merge(Checks.checkMethodInHierarchy(superClass, methodName, null, arguments)); } for (ITypeBinding superInterface : type.getInterfaces()) { status.merge(Checks.checkMethodInHierarchy(superInterface, methodName, null, arguments)); } }
currentTypeBinding= methodBinding.getDeclaringClass(); else currentTypeBinding= ASTNodes.getEnclosingType(originalInvocation); } else { currentTypeBinding= ASTNodes.getEnclosingType(currentTypeDeclaration); while (currentTypeDeclaration != null && (Bindings.findMethodInHierarchy(currentTypeBinding, methodBinding.getName(), methodBinding.getParameterTypes()) == null)) { currentTypeDeclaration= getEnclosingTypeDeclaration(currentTypeDeclaration.getParent()); currentTypeBinding= ASTNodes.getEnclosingType(currentTypeDeclaration); ITypeBinding typeOfCall= ASTNodes.getEnclosingType(originalInvocation); if (!typeOfCall.equals(currentTypeBinding)) { if (currentTypeBinding.isAnonymous()) {
currentTypeBinding= methodBinding.getDeclaringClass(); else currentTypeBinding= ASTNodes.getEnclosingType(originalInvocation); } else { currentTypeBinding= ASTNodes.getEnclosingType(currentTypeDeclaration); while (currentTypeDeclaration != null && (Bindings.findMethodInHierarchy(currentTypeBinding, methodBinding.getName(), methodBinding.getParameterTypes()) == null)) { currentTypeDeclaration= getEnclosingTypeDeclaration(currentTypeDeclaration.getParent()); currentTypeBinding= ASTNodes.getEnclosingType(currentTypeDeclaration); ITypeBinding typeOfCall= ASTNodes.getEnclosingType(originalInvocation); if (!typeOfCall.equals(currentTypeBinding)) { if (currentTypeBinding.isAnonymous()) {
ITypeBinding enclosingType= getEnclosingType(invocationNode); if (enclosingType != null && invocationNode instanceof SuperMethodInvocation) { enclosingType= enclosingType.getSuperclass();
fAnalyzer.checkInput(status, fMethodName, typeNode); if (!status.isOK()) { SimpleName destinationTypeName= fAST.newSimpleName(ASTNodes.getEnclosingType(fDestination).getName()); if ((modifiers & Modifier.STATIC) == 0) { ThisExpression thisExpression= fAST.newThisExpression();
fAnalyzer.checkInput(status, fMethodName, typeNode); if (!status.isOK()) { SimpleName destinationTypeName = fAST.newSimpleName(ASTNodes.getEnclosingType(fDestination).getName()); if ((modifiers & Modifier.STATIC) == 0) { ThisExpression thisExpression = fAST.newThisExpression();
ITypeBinding enclosingType= getEnclosingType(invocationNode); if (enclosingType != null && invocationNode instanceof SuperMethodInvocation) { enclosingType= enclosingType.getSuperclass();
ITypeBinding targetType= variable.getDeclaringClass(); if (variable.isField()) { ITypeBinding enclosingType= ASTNodes.getEnclosingType(node); if (enclosingType != null) { IVariableBinding fieldInHierarchy= Bindings.findFieldInHierarchy(enclosingType, node.getIdentifier());
ITypeBinding targetType= variable.getDeclaringClass(); if (variable.isField()) { ITypeBinding enclosingType= ASTNodes.getEnclosingType(node); if (enclosingType != null) { IVariableBinding fieldInHierarchy= Bindings.findFieldInHierarchy(enclosingType, node.getIdentifier());
status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_only_method_body); break superCall; } else if (ASTNodes.getEnclosingType(fEnclosingBodyDeclaration) == null) { status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_compile_errors_no_parent_binding); break superCall;