Java 类org.eclipse.jdt.core.dom.SuperMethodInvocation 实例源码

项目:che    文件:Invocations.java   
public static ChildListPropertyDescriptor getArgumentsProperty(ASTNode invocation) {
  switch (invocation.getNodeType()) {
    case ASTNode.METHOD_INVOCATION:
      return MethodInvocation.ARGUMENTS_PROPERTY;
    case ASTNode.SUPER_METHOD_INVOCATION:
      return SuperMethodInvocation.ARGUMENTS_PROPERTY;

    case ASTNode.CONSTRUCTOR_INVOCATION:
      return ConstructorInvocation.ARGUMENTS_PROPERTY;
    case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
      return SuperConstructorInvocation.ARGUMENTS_PROPERTY;

    case ASTNode.CLASS_INSTANCE_CREATION:
      return ClassInstanceCreation.ARGUMENTS_PROPERTY;
    case ASTNode.ENUM_CONSTANT_DECLARATION:
      return EnumConstantDeclaration.ARGUMENTS_PROPERTY;

    default:
      throw new IllegalArgumentException(invocation.toString());
  }
}
项目:RefDiff    文件:ASTVisitorAtomicChange.java   
public boolean visit(SuperMethodInvocation node) {
    IMethodBinding mmtb = node.resolveMethodBinding();

    if (mtbStack.isEmpty()) // not part of a method
        return true;

    // make field access fact
    try {
        facts.add(Fact.makeCallsFact(getQualifiedName(mtbStack.peek()),
                getQualifiedName(mmtb)));
    } catch (Exception e) {
        System.err.println("Cannot resolve method invocation \""
                + node.getName().toString() + "\"");
    }
    return true;
}
项目:code    文件:MethodInvocation.java   
public static MethodInvocation createFrom(ASTNode node) {
    MethodInvocation retNode = null;

    if(node instanceof org.eclipse.jdt.core.dom.MethodInvocation
            || node instanceof SuperMethodInvocation){
        Adapter factory = Adapter.getInstance();

        AstNode astNode = factory.get(node);
        if ( astNode instanceof MethodInvocation ) {
            retNode = (MethodInvocation)astNode;
        }
        else {
            retNode = MethodInvocation.create();
            ast.MethodDeclaration methDec = TraceabilityFactory.getMethodDeclaration(node);
            if(methDec!= null){
                retNode.methodDeclaration = methDec;
            }
            retNode.complexExpression = node.toString();
            factory.map(node, retNode);
        }
    }else{
        throw new IllegalArgumentException(node.toString());
    }

    return retNode;
}
项目:Ref-Finder    文件:ASTVisitorAtomicChange.java   
public boolean visit(SuperMethodInvocation node)
{
  IMethodBinding mmtb = node.resolveMethodBinding();
  if (this.mtbStack.isEmpty()) {
    return true;
  }
  try
  {
    this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding)this.mtbStack.peek()), 
      getQualifiedName(mmtb)));
  }
  catch (Exception e)
  {
    System.err.println("Cannot resolve method invocation \"" + 
      node.getName().toString() + "\"");
  }
  return true;
}
项目:Ref-Finder    文件:ASTVisitorAtomicChange.java   
public boolean visit(SuperMethodInvocation node) {
    IMethodBinding mmtb = node.resolveMethodBinding();

    if (mtbStack.isEmpty()) // not part of a method
        return true;

    // make field access fact
    try {
        facts.add(Fact.makeCallsFact(getQualifiedName(mtbStack.peek()),
                getQualifiedName(mmtb)));
    } catch (Exception e) {
        System.err.println("Cannot resolve method invocation \""
                + node.getName().toString() + "\"");
    }
    return true;
}
项目:Ref-Finder    文件:ASTVisitorAtomicChange.java   
public boolean visit(SuperMethodInvocation node)
{
  IMethodBinding mmtb = node.resolveMethodBinding();
  if (this.mtbStack.isEmpty()) {
    return true;
  }
  try
  {
    this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding)this.mtbStack.peek()), 
      getQualifiedName(mmtb)));
  }
  catch (Exception localException)
  {
    System.err.println("Cannot resolve method invocation \"" + 
      node.getName().toString() + "\"");
  }
  return true;
}
项目:che    文件:RefactoringAvailabilityTester.java   
private static ASTNode getInlineableMethodNode(ASTNode node, IJavaElement unit) {
  if (node == null) return null;
  switch (node.getNodeType()) {
    case ASTNode.SIMPLE_NAME:
      StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
      if (locationInParent == MethodDeclaration.NAME_PROPERTY) {
        return node.getParent();
      } else if (locationInParent == MethodInvocation.NAME_PROPERTY
          || locationInParent == SuperMethodInvocation.NAME_PROPERTY) {
        return unit instanceof ICompilationUnit
            ? node.getParent()
            : null; // don't start on invocations in binary
      }
      return null;
    case ASTNode.EXPRESSION_STATEMENT:
      node = ((ExpressionStatement) node).getExpression();
  }
  switch (node.getNodeType()) {
    case ASTNode.METHOD_DECLARATION:
      return node;
    case ASTNode.METHOD_INVOCATION:
    case ASTNode.SUPER_METHOD_INVOCATION:
    case ASTNode.CONSTRUCTOR_INVOCATION:
      return unit instanceof ICompilationUnit
          ? node
          : null; // don't start on invocations in binary
  }
  return null;
}
项目:che    文件:Invocations.java   
public static List<Expression> getArguments(ASTNode invocation) {
  switch (invocation.getNodeType()) {
    case ASTNode.METHOD_INVOCATION:
      return ((MethodInvocation) invocation).arguments();
    case ASTNode.SUPER_METHOD_INVOCATION:
      return ((SuperMethodInvocation) invocation).arguments();

    case ASTNode.CONSTRUCTOR_INVOCATION:
      return ((ConstructorInvocation) invocation).arguments();
    case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
      return ((SuperConstructorInvocation) invocation).arguments();

    case ASTNode.CLASS_INSTANCE_CREATION:
      return ((ClassInstanceCreation) invocation).arguments();
    case ASTNode.ENUM_CONSTANT_DECLARATION:
      return ((EnumConstantDeclaration) invocation).arguments();

    default:
      throw new IllegalArgumentException(invocation.toString());
  }
}
项目:che    文件:Invocations.java   
public static IMethodBinding resolveBinding(ASTNode invocation) {
  switch (invocation.getNodeType()) {
    case ASTNode.METHOD_INVOCATION:
      return ((MethodInvocation) invocation).resolveMethodBinding();
    case ASTNode.SUPER_METHOD_INVOCATION:
      return ((SuperMethodInvocation) invocation).resolveMethodBinding();

    case ASTNode.CONSTRUCTOR_INVOCATION:
      return ((ConstructorInvocation) invocation).resolveConstructorBinding();
    case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
      return ((SuperConstructorInvocation) invocation).resolveConstructorBinding();

    case ASTNode.CLASS_INSTANCE_CREATION:
      return ((ClassInstanceCreation) invocation).resolveConstructorBinding();
    case ASTNode.ENUM_CONSTANT_DECLARATION:
      return ((EnumConstantDeclaration) invocation).resolveConstructorBinding();

    default:
      throw new IllegalArgumentException(invocation.toString());
  }
}
项目:che    文件:Invocations.java   
public static ITypeBinding[] getInferredTypeArguments(Expression invocation) {
  IMethodBinding methodBinding;
  switch (invocation.getNodeType()) {
    case ASTNode.METHOD_INVOCATION:
      methodBinding = ((MethodInvocation) invocation).resolveMethodBinding();
      return methodBinding == null ? null : methodBinding.getTypeArguments();
    case ASTNode.SUPER_METHOD_INVOCATION:
      methodBinding = ((SuperMethodInvocation) invocation).resolveMethodBinding();
      return methodBinding == null ? null : methodBinding.getTypeArguments();
    case ASTNode.CLASS_INSTANCE_CREATION:
      Type type = ((ClassInstanceCreation) invocation).getType();
      ITypeBinding typeBinding = type.resolveBinding();
      return typeBinding == null ? null : typeBinding.getTypeArguments();

    default:
      throw new IllegalArgumentException(invocation.toString());
  }
}
项目:che    文件:InlineMethodRefactoring.java   
/**
 * Creates a new inline method refactoring
 *
 * @param unit the compilation unit or class file
 * @param node the compilation unit node
 * @param selectionStart start
 * @param selectionLength length
 * @return returns the refactoring
 */
public static InlineMethodRefactoring create(
    ITypeRoot unit, CompilationUnit node, int selectionStart, int selectionLength) {
  ASTNode target =
      RefactoringAvailabilityTester.getInlineableMethodNode(
          unit, node, selectionStart, selectionLength);
  if (target == null) return null;
  if (target.getNodeType() == ASTNode.METHOD_DECLARATION) {

    return new InlineMethodRefactoring(
        unit, (MethodDeclaration) target, selectionStart, selectionLength);
  } else {
    ICompilationUnit cu = (ICompilationUnit) unit;
    if (target.getNodeType() == ASTNode.METHOD_INVOCATION) {
      return new InlineMethodRefactoring(
          cu, (MethodInvocation) target, selectionStart, selectionLength);
    } else if (target.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION) {
      return new InlineMethodRefactoring(
          cu, (SuperMethodInvocation) target, selectionStart, selectionLength);
    } else if (target.getNodeType() == ASTNode.CONSTRUCTOR_INVOCATION) {
      return new InlineMethodRefactoring(
          cu, (ConstructorInvocation) target, selectionStart, selectionLength);
    }
  }
  return null;
}
项目:che    文件:InlineMethodRefactoring.java   
public RefactoringStatus setCurrentMode(Mode mode) throws JavaModelException {
  if (fCurrentMode == mode) return new RefactoringStatus();
  Assert.isTrue(getInitialMode() == Mode.INLINE_SINGLE);
  fCurrentMode = mode;
  if (mode == Mode.INLINE_SINGLE) {
    if (fInitialNode instanceof MethodInvocation)
      fTargetProvider =
          TargetProvider.create(
              (ICompilationUnit) fInitialTypeRoot, (MethodInvocation) fInitialNode);
    else if (fInitialNode instanceof SuperMethodInvocation)
      fTargetProvider =
          TargetProvider.create(
              (ICompilationUnit) fInitialTypeRoot, (SuperMethodInvocation) fInitialNode);
    else if (fInitialNode instanceof ConstructorInvocation)
      fTargetProvider =
          TargetProvider.create(
              (ICompilationUnit) fInitialTypeRoot, (ConstructorInvocation) fInitialNode);
    else throw new IllegalStateException(String.valueOf(fInitialNode));
  } else {
    fTargetProvider = TargetProvider.create(fSourceProvider.getDeclaration());
  }
  return fTargetProvider.checkActivation();
}
项目:che    文件:ExpressionVariable.java   
public static IBinding resolveBinding(Expression expression) {
  if (expression instanceof Name) return ((Name) expression).resolveBinding();
  if (expression instanceof ParenthesizedExpression)
    return resolveBinding(((ParenthesizedExpression) expression).getExpression());
  else if (expression instanceof Assignment)
    return resolveBinding(((Assignment) expression).getLeftHandSide()); // TODO ???
  else if (expression instanceof MethodInvocation)
    return ((MethodInvocation) expression).resolveMethodBinding();
  else if (expression instanceof SuperMethodInvocation)
    return ((SuperMethodInvocation) expression).resolveMethodBinding();
  else if (expression instanceof FieldAccess)
    return ((FieldAccess) expression).resolveFieldBinding();
  else if (expression instanceof SuperFieldAccess)
    return ((SuperFieldAccess) expression).resolveFieldBinding();
  else if (expression instanceof ConditionalExpression)
    return resolveBinding(((ConditionalExpression) expression).getThenExpression());
  return null;
}
项目:che    文件:NewMethodCorrectionProposal.java   
@Override
protected SimpleName getNewName(ASTRewrite rewrite) {
  ASTNode invocationNode = getInvocationNode();
  String name;
  if (invocationNode instanceof MethodInvocation) {
    name = ((MethodInvocation) invocationNode).getName().getIdentifier();
  } else if (invocationNode instanceof SuperMethodInvocation) {
    name = ((SuperMethodInvocation) invocationNode).getName().getIdentifier();
  } else {
    name = getSenderBinding().getName(); // name of the class
  }
  AST ast = rewrite.getAST();
  SimpleName newNameNode = ast.newSimpleName(name);
  addLinkedPosition(rewrite.track(newNameNode), false, KEY_NAME);

  ASTNode invocationName = getInvocationNameNode();
  if (invocationName != null && invocationName.getAST() == ast) { // in the same CU
    addLinkedPosition(rewrite.track(invocationName), true, KEY_NAME);
  }
  return newNameNode;
}
项目:evosuite    文件:TestExtractingVisitor.java   
private VariableReference retrieveResultReference(
        SuperMethodInvocation superMethodInvocation) {
    // TODO Duplicate code from retrieveResultReference(MethodInvocation)
    // too bad they don't have a common matching interface
    VariableReference result = calleeResultMap.get(superMethodInvocation.toString());
    if (result != null) {
        return result;
    }
    ASTNode parent = superMethodInvocation.getParent();
    if (parent instanceof VariableDeclarationFragment) {
        return retrieveVariableReference(parent, null);
    }
    if (parent instanceof Assignment) {
        Assignment assignment = (Assignment) parent;
        return retrieveVariableReference(assignment.getLeftHandSide(), null);
    }
    IMethodBinding methodBinding = superMethodInvocation.resolveMethodBinding();
    result = retrieveVariableReference(methodBinding.getReturnType(), null);
    calleeResultMap.put(superMethodInvocation.toString(), result);
    return result;
}
项目:Eclipse-Postfix-Code-Completion    文件:SuperTypeConstraintsCreator.java   
@Override
public final void endVisit(final SuperMethodInvocation node) {
    final IMethodBinding superBinding= node.resolveMethodBinding();
    if (superBinding != null) {
        endVisit(node.arguments(), superBinding);
        final MethodDeclaration declaration= fCurrentMethods.peek();
        if (declaration != null) {
            final IMethodBinding subBinding= declaration.resolveBinding();
            if (subBinding != null) {
                final ConstraintVariable2 ancestor= fModel.createReturnTypeVariable(superBinding);
                if (ancestor != null) {
                    node.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor);
                    final ConstraintVariable2 descendant= fModel.createReturnTypeVariable(subBinding);
                    if (descendant != null)
                        fModel.createEqualityConstraint(descendant, ancestor);
                }
            }
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:IntroduceParameterObjectProcessor.java   
@Override
protected boolean shouldReport(IProblem problem, CompilationUnit cu) {
    if (!super.shouldReport(problem, cu))
        return false;
    ASTNode node= ASTNodeSearchUtil.getAstNode(cu, problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1);
    if (node instanceof Type) {
        Type type= (Type) node;
        if (problem.getID() == IProblem.UndefinedType && getClassName().equals(ASTNodes.getTypeName(type))) {
            return false;
        }
    }
    if (node instanceof Name) {
        Name name= (Name) node;
        if (problem.getID() == IProblem.ImportNotFound && getPackage().indexOf(name.getFullyQualifiedName()) != -1)
            return false;
        if (problem.getID() == IProblem.MissingTypeInMethod) {
            StructuralPropertyDescriptor locationInParent= name.getLocationInParent();
            String[] arguments= problem.getArguments();
            if ((locationInParent == MethodInvocation.NAME_PROPERTY || locationInParent == SuperMethodInvocation.NAME_PROPERTY)
                    && arguments.length > 3
                    && arguments[3].endsWith(getClassName()))
                return false;
        }
    }
    return true;
}
项目:Eclipse-Postfix-Code-Completion    文件:RefactoringAvailabilityTester.java   
private static ASTNode getInlineableMethodNode(ASTNode node, IJavaElement unit) {
    if (node == null)
        return null;
    switch (node.getNodeType()) {
        case ASTNode.SIMPLE_NAME:
            StructuralPropertyDescriptor locationInParent= node.getLocationInParent();
            if (locationInParent == MethodDeclaration.NAME_PROPERTY) {
                return node.getParent();
            } else if (locationInParent == MethodInvocation.NAME_PROPERTY
                    || locationInParent == SuperMethodInvocation.NAME_PROPERTY) {
                return unit instanceof ICompilationUnit ? node.getParent() : null; // don't start on invocations in binary
            }
            return null;
        case ASTNode.EXPRESSION_STATEMENT:
            node= ((ExpressionStatement)node).getExpression();
    }
    switch (node.getNodeType()) {
        case ASTNode.METHOD_DECLARATION:
            return node;
        case ASTNode.METHOD_INVOCATION:
        case ASTNode.SUPER_METHOD_INVOCATION:
        case ASTNode.CONSTRUCTOR_INVOCATION:
            return unit instanceof ICompilationUnit ? node : null; // don't start on invocations in binary
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:Invocations.java   
public static List<Expression> getArguments(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation)invocation).arguments();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation)invocation).arguments();

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ((ConstructorInvocation)invocation).arguments();
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return ((SuperConstructorInvocation)invocation).arguments();

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation)invocation).arguments();
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return ((EnumConstantDeclaration)invocation).arguments();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Invocations.java   
public static ChildListPropertyDescriptor getArgumentsProperty(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return MethodInvocation.ARGUMENTS_PROPERTY;
        case ASTNode.SUPER_METHOD_INVOCATION:
            return SuperMethodInvocation.ARGUMENTS_PROPERTY;

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ConstructorInvocation.ARGUMENTS_PROPERTY;
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return SuperConstructorInvocation.ARGUMENTS_PROPERTY;

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ClassInstanceCreation.ARGUMENTS_PROPERTY;
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return EnumConstantDeclaration.ARGUMENTS_PROPERTY;

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Invocations.java   
public static IMethodBinding resolveBinding(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation)invocation).resolveMethodBinding();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation)invocation).resolveMethodBinding();

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ((ConstructorInvocation)invocation).resolveConstructorBinding();
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return ((SuperConstructorInvocation)invocation).resolveConstructorBinding();

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation)invocation).resolveConstructorBinding();
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return ((EnumConstantDeclaration)invocation).resolveConstructorBinding();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Invocations.java   
public static boolean isResolvedTypeInferredFromExpectedType(Expression invocation) {
    if (invocation == null)
        return false;

    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation) invocation).isResolvedTypeInferredFromExpectedType();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation) invocation).isResolvedTypeInferredFromExpectedType();
        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation) invocation).isResolvedTypeInferredFromExpectedType();

        default:
            return false;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Invocations.java   
public static ITypeBinding[] getInferredTypeArguments(Expression invocation) {
    IMethodBinding methodBinding;
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            methodBinding= ((MethodInvocation) invocation).resolveMethodBinding();
            return methodBinding == null ? null : methodBinding.getTypeArguments();
        case ASTNode.SUPER_METHOD_INVOCATION:
            methodBinding= ((SuperMethodInvocation) invocation).resolveMethodBinding();
            return methodBinding == null ? null : methodBinding.getTypeArguments();
        case ASTNode.CLASS_INSTANCE_CREATION:
            Type type= ((ClassInstanceCreation) invocation).getType();
            ITypeBinding typeBinding= type.resolveBinding();
            return typeBinding == null ? null : typeBinding.getTypeArguments();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:InlineMethodRefactoring.java   
/**
 * Creates a new inline method refactoring
 * @param unit the compilation unit or class file
 * @param node the compilation unit node
 * @param selectionStart start
 * @param selectionLength length
 * @return returns the refactoring
 */
public static InlineMethodRefactoring create(ITypeRoot unit, CompilationUnit node, int selectionStart, int selectionLength) {
    ASTNode target= RefactoringAvailabilityTester.getInlineableMethodNode(unit, node, selectionStart, selectionLength);
    if (target == null)
        return null;
    if (target.getNodeType() == ASTNode.METHOD_DECLARATION) {

        return new InlineMethodRefactoring(unit, (MethodDeclaration)target, selectionStart, selectionLength);
    } else {
        ICompilationUnit cu= (ICompilationUnit) unit;
        if (target.getNodeType() == ASTNode.METHOD_INVOCATION) {
            return new InlineMethodRefactoring(cu, (MethodInvocation)target, selectionStart, selectionLength);
        } else if (target.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION) {
            return new InlineMethodRefactoring(cu, (SuperMethodInvocation)target, selectionStart, selectionLength);
        } else if (target.getNodeType() == ASTNode.CONSTRUCTOR_INVOCATION) {
            return new InlineMethodRefactoring(cu, (ConstructorInvocation)target, selectionStart, selectionLength);
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:InlineMethodRefactoring.java   
public RefactoringStatus setCurrentMode(Mode mode) throws JavaModelException {
    if (fCurrentMode == mode)
        return new RefactoringStatus();
    Assert.isTrue(getInitialMode() == Mode.INLINE_SINGLE);
    fCurrentMode= mode;
    if (mode == Mode.INLINE_SINGLE) {
        if (fInitialNode instanceof MethodInvocation)
            fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (MethodInvocation)fInitialNode);
        else if (fInitialNode instanceof SuperMethodInvocation)
            fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (SuperMethodInvocation)fInitialNode);
        else if (fInitialNode instanceof ConstructorInvocation)
            fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (ConstructorInvocation)fInitialNode);
        else
            throw new IllegalStateException(String.valueOf(fInitialNode));
    } else {
        fTargetProvider= TargetProvider.create(fSourceProvider.getDeclaration());
    }
    return fTargetProvider.checkActivation();
}
项目:Eclipse-Postfix-Code-Completion    文件:ExpressionVariable.java   
public static IBinding resolveBinding(Expression expression){
    if (expression instanceof Name)
        return ((Name)expression).resolveBinding();
    if (expression instanceof ParenthesizedExpression)
        return resolveBinding(((ParenthesizedExpression)expression).getExpression());
    else if (expression instanceof Assignment)
        return resolveBinding(((Assignment)expression).getLeftHandSide());//TODO ???
    else if (expression instanceof MethodInvocation)
        return ((MethodInvocation)expression).resolveMethodBinding();
    else if (expression instanceof SuperMethodInvocation)
        return ((SuperMethodInvocation)expression).resolveMethodBinding();
    else if (expression instanceof FieldAccess)
        return ((FieldAccess)expression).resolveFieldBinding();
    else if (expression instanceof SuperFieldAccess)
        return ((SuperFieldAccess)expression).resolveFieldBinding();
    else if (expression instanceof ConditionalExpression)
        return resolveBinding(((ConditionalExpression)expression).getThenExpression());
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:NewMethodCorrectionProposal.java   
@Override
protected SimpleName getNewName(ASTRewrite rewrite) {
    ASTNode invocationNode= getInvocationNode();
    String name;
    if (invocationNode instanceof MethodInvocation) {
        name= ((MethodInvocation)invocationNode).getName().getIdentifier();
    } else if (invocationNode instanceof SuperMethodInvocation) {
        name= ((SuperMethodInvocation)invocationNode).getName().getIdentifier();
    } else {
        name= getSenderBinding().getName(); // name of the class
    }
    AST ast= rewrite.getAST();
    SimpleName newNameNode= ast.newSimpleName(name);
    addLinkedPosition(rewrite.track(newNameNode), false, KEY_NAME);

    ASTNode invocationName= getInvocationNameNode();
    if (invocationName != null && invocationName.getAST() == ast) { // in the same CU
        addLinkedPosition(rewrite.track(invocationName), true, KEY_NAME);
    }
    return newNameNode;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SuperTypeConstraintsCreator.java   
@Override
public final void endVisit(final SuperMethodInvocation node) {
    final IMethodBinding superBinding= node.resolveMethodBinding();
    if (superBinding != null) {
        endVisit(node.arguments(), superBinding);
        final MethodDeclaration declaration= fCurrentMethods.peek();
        if (declaration != null) {
            final IMethodBinding subBinding= declaration.resolveBinding();
            if (subBinding != null) {
                final ConstraintVariable2 ancestor= fModel.createReturnTypeVariable(superBinding);
                if (ancestor != null) {
                    node.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor);
                    final ConstraintVariable2 descendant= fModel.createReturnTypeVariable(subBinding);
                    if (descendant != null)
                        fModel.createEqualityConstraint(descendant, ancestor);
                }
            }
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:IntroduceParameterObjectProcessor.java   
@Override
protected boolean shouldReport(IProblem problem, CompilationUnit cu) {
    if (!super.shouldReport(problem, cu))
        return false;
    ASTNode node= ASTNodeSearchUtil.getAstNode(cu, problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1);
    if (node instanceof Type) {
        Type type= (Type) node;
        if (problem.getID() == IProblem.UndefinedType && getClassName().equals(ASTNodes.getTypeName(type))) {
            return false;
        }
    }
    if (node instanceof Name) {
        Name name= (Name) node;
        if (problem.getID() == IProblem.ImportNotFound && getPackage().indexOf(name.getFullyQualifiedName()) != -1)
            return false;
        if (problem.getID() == IProblem.MissingTypeInMethod) {
            StructuralPropertyDescriptor locationInParent= name.getLocationInParent();
            String[] arguments= problem.getArguments();
            if ((locationInParent == MethodInvocation.NAME_PROPERTY || locationInParent == SuperMethodInvocation.NAME_PROPERTY)
                    && arguments.length > 3
                    && arguments[3].endsWith(getClassName()))
                return false;
        }
    }
    return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:RefactoringAvailabilityTester.java   
private static ASTNode getInlineableMethodNode(ASTNode node, IJavaElement unit) {
    if (node == null)
        return null;
    switch (node.getNodeType()) {
        case ASTNode.SIMPLE_NAME:
            StructuralPropertyDescriptor locationInParent= node.getLocationInParent();
            if (locationInParent == MethodDeclaration.NAME_PROPERTY) {
                return node.getParent();
            } else if (locationInParent == MethodInvocation.NAME_PROPERTY
                    || locationInParent == SuperMethodInvocation.NAME_PROPERTY) {
                return unit instanceof ICompilationUnit ? node.getParent() : null; // don't start on invocations in binary
            }
            return null;
        case ASTNode.EXPRESSION_STATEMENT:
            node= ((ExpressionStatement)node).getExpression();
    }
    switch (node.getNodeType()) {
        case ASTNode.METHOD_DECLARATION:
            return node;
        case ASTNode.METHOD_INVOCATION:
        case ASTNode.SUPER_METHOD_INVOCATION:
        case ASTNode.CONSTRUCTOR_INVOCATION:
            return unit instanceof ICompilationUnit ? node : null; // don't start on invocations in binary
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Invocations.java   
public static List<Expression> getArguments(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation)invocation).arguments();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation)invocation).arguments();

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ((ConstructorInvocation)invocation).arguments();
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return ((SuperConstructorInvocation)invocation).arguments();

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation)invocation).arguments();
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return ((EnumConstantDeclaration)invocation).arguments();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Invocations.java   
public static ChildListPropertyDescriptor getArgumentsProperty(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return MethodInvocation.ARGUMENTS_PROPERTY;
        case ASTNode.SUPER_METHOD_INVOCATION:
            return SuperMethodInvocation.ARGUMENTS_PROPERTY;

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ConstructorInvocation.ARGUMENTS_PROPERTY;
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return SuperConstructorInvocation.ARGUMENTS_PROPERTY;

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ClassInstanceCreation.ARGUMENTS_PROPERTY;
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return EnumConstantDeclaration.ARGUMENTS_PROPERTY;

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Invocations.java   
public static IMethodBinding resolveBinding(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation)invocation).resolveMethodBinding();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation)invocation).resolveMethodBinding();

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ((ConstructorInvocation)invocation).resolveConstructorBinding();
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return ((SuperConstructorInvocation)invocation).resolveConstructorBinding();

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation)invocation).resolveConstructorBinding();
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return ((EnumConstantDeclaration)invocation).resolveConstructorBinding();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Invocations.java   
public static boolean isResolvedTypeInferredFromExpectedType(Expression invocation) {
    if (invocation == null)
        return false;

    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation) invocation).isResolvedTypeInferredFromExpectedType();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation) invocation).isResolvedTypeInferredFromExpectedType();
        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation) invocation).isResolvedTypeInferredFromExpectedType();

        default:
            return false;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Invocations.java   
public static ITypeBinding[] getInferredTypeArguments(Expression invocation) {
    IMethodBinding methodBinding;
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            methodBinding= ((MethodInvocation) invocation).resolveMethodBinding();
            return methodBinding == null ? null : methodBinding.getTypeArguments();
        case ASTNode.SUPER_METHOD_INVOCATION:
            methodBinding= ((SuperMethodInvocation) invocation).resolveMethodBinding();
            return methodBinding == null ? null : methodBinding.getTypeArguments();
        case ASTNode.CLASS_INSTANCE_CREATION:
            Type type= ((ClassInstanceCreation) invocation).getType();
            ITypeBinding typeBinding= type.resolveBinding();
            return typeBinding == null ? null : typeBinding.getTypeArguments();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:InlineMethodRefactoring.java   
/**
 * Creates a new inline method refactoring
 * @param unit the compilation unit or class file
 * @param node the compilation unit node
 * @param selectionStart start
 * @param selectionLength length
 * @return returns the refactoring
 */
public static InlineMethodRefactoring create(ITypeRoot unit, CompilationUnit node, int selectionStart, int selectionLength) {
    ASTNode target= RefactoringAvailabilityTester.getInlineableMethodNode(unit, node, selectionStart, selectionLength);
    if (target == null)
        return null;
    if (target.getNodeType() == ASTNode.METHOD_DECLARATION) {

        return new InlineMethodRefactoring(unit, (MethodDeclaration)target, selectionStart, selectionLength);
    } else {
        ICompilationUnit cu= (ICompilationUnit) unit;
        if (target.getNodeType() == ASTNode.METHOD_INVOCATION) {
            return new InlineMethodRefactoring(cu, (MethodInvocation)target, selectionStart, selectionLength);
        } else if (target.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION) {
            return new InlineMethodRefactoring(cu, (SuperMethodInvocation)target, selectionStart, selectionLength);
        } else if (target.getNodeType() == ASTNode.CONSTRUCTOR_INVOCATION) {
            return new InlineMethodRefactoring(cu, (ConstructorInvocation)target, selectionStart, selectionLength);
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:InlineMethodRefactoring.java   
public RefactoringStatus setCurrentMode(Mode mode) throws JavaModelException {
    if (fCurrentMode == mode)
        return new RefactoringStatus();
    Assert.isTrue(getInitialMode() == Mode.INLINE_SINGLE);
    fCurrentMode= mode;
    if (mode == Mode.INLINE_SINGLE) {
        if (fInitialNode instanceof MethodInvocation)
            fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (MethodInvocation)fInitialNode);
        else if (fInitialNode instanceof SuperMethodInvocation)
            fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (SuperMethodInvocation)fInitialNode);
        else if (fInitialNode instanceof ConstructorInvocation)
            fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (ConstructorInvocation)fInitialNode);
        else
            throw new IllegalStateException(String.valueOf(fInitialNode));
    } else {
        fTargetProvider= TargetProvider.create(fSourceProvider.getDeclaration());
    }
    return fTargetProvider.checkActivation();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExpressionVariable.java   
public static IBinding resolveBinding(Expression expression){
    if (expression instanceof Name)
        return ((Name)expression).resolveBinding();
    if (expression instanceof ParenthesizedExpression)
        return resolveBinding(((ParenthesizedExpression)expression).getExpression());
    else if (expression instanceof Assignment)
        return resolveBinding(((Assignment)expression).getLeftHandSide());//TODO ???
    else if (expression instanceof MethodInvocation)
        return ((MethodInvocation)expression).resolveMethodBinding();
    else if (expression instanceof SuperMethodInvocation)
        return ((SuperMethodInvocation)expression).resolveMethodBinding();
    else if (expression instanceof FieldAccess)
        return ((FieldAccess)expression).resolveFieldBinding();
    else if (expression instanceof SuperFieldAccess)
        return ((SuperFieldAccess)expression).resolveFieldBinding();
    else if (expression instanceof ConditionalExpression)
        return resolveBinding(((ConditionalExpression)expression).getThenExpression());
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NewMethodCorrectionProposal.java   
@Override
protected SimpleName getNewName(ASTRewrite rewrite) {
    ASTNode invocationNode= getInvocationNode();
    String name;
    if (invocationNode instanceof MethodInvocation) {
        name= ((MethodInvocation)invocationNode).getName().getIdentifier();
    } else if (invocationNode instanceof SuperMethodInvocation) {
        name= ((SuperMethodInvocation)invocationNode).getName().getIdentifier();
    } else {
        name= getSenderBinding().getName(); // name of the class
    }
    AST ast= rewrite.getAST();
    SimpleName newNameNode= ast.newSimpleName(name);
    addLinkedPosition(rewrite.track(newNameNode), false, KEY_NAME);

    ASTNode invocationName= getInvocationNameNode();
    if (invocationName != null && invocationName.getAST() == ast) { // in the same CU
        addLinkedPosition(rewrite.track(invocationName), true, KEY_NAME);
    }
    return newNameNode;
}
项目:FindBug-for-Domino-Designer    文件:CreateSuperCallResolution.java   
@Override
protected void repairBug(ASTRewrite rewrite, CompilationUnit workingUnit, BugInstance bug) throws BugResolutionException {
    Assert.isNotNull(rewrite);
    Assert.isNotNull(workingUnit);
    Assert.isNotNull(bug);

    TypeDeclaration type = getTypeDeclaration(workingUnit, bug.getPrimaryClass());
    MethodDeclaration method = getMethodDeclaration(type, bug.getPrimaryMethod());

    AST ast = rewrite.getAST();

    SuperMethodInvocation superCall = createSuperMethodInvocation(rewrite, method);
    ExpressionStatement statement = ast.newExpressionStatement(superCall);
    Block methodBody = method.getBody();
    ListRewrite listRewrite = rewrite.getListRewrite(methodBody, Block.STATEMENTS_PROPERTY);
    if (isInsertFirst()) {
        listRewrite.insertFirst(statement, null);
    } else {
        listRewrite.insertLast(statement, null);
    }
}