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

项目:che    文件:ChangeSignatureProcessor.java   
private OccurrenceUpdate<? extends ASTNode> createOccurrenceUpdate(
    ASTNode node, CompilationUnitRewrite cuRewrite, RefactoringStatus result) {
  if (BUG_89686
      && node instanceof SimpleName
      && node.getParent() instanceof EnumConstantDeclaration) node = node.getParent();

  if (Invocations.isInvocationWithArguments(node))
    return new ReferenceUpdate(node, cuRewrite, result);
  else if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration)
    return new DeclarationUpdate((MethodDeclaration) node.getParent(), cuRewrite, result);
  else if (node instanceof MemberRef || node instanceof MethodRef)
    return new DocReferenceUpdate(node, cuRewrite, result);
  else if (ASTNodes.getParent(node, ImportDeclaration.class) != null)
    return new StaticImportUpdate(
        (ImportDeclaration) ASTNodes.getParent(node, ImportDeclaration.class), cuRewrite, result);
  else if (node instanceof LambdaExpression)
    return new LambdaExpressionUpdate((LambdaExpression) node, cuRewrite, result);
  else if (node.getLocationInParent() == ExpressionMethodReference.NAME_PROPERTY)
    return new ExpressionMethodRefUpdate(
        (ExpressionMethodReference) node.getParent(), cuRewrite, result);
  else return new NullOccurrenceUpdate(node, cuRewrite, result);
}
项目:che    文件:ChangeSignatureProcessor.java   
@Override
protected void changeParamgumentType(ParameterInfo info) {
  if (!(fNode instanceof MethodRef)) return;

  MethodRefParameter oldParam =
      (MethodRefParameter) ((MethodRef) fNode).parameters().get(info.getOldIndex());
  Type oldTypeNode = oldParam.getType();
  Type newTypeNode = createNewDocRefType(info);
  if (info.isNewVarargs()) {
    if (info.isOldVarargs() && !oldParam.isVarargs()) {
      // leave as array reference if old reference was not vararg
      newTypeNode = ASTNodeFactory.newArrayType(newTypeNode);
    } else {
      getASTRewrite()
          .set(oldParam, MethodRefParameter.VARARGS_PROPERTY, Boolean.TRUE, fDescription);
    }
  } else {
    if (oldParam.isVarargs()) {
      getASTRewrite()
          .set(oldParam, MethodRefParameter.VARARGS_PROPERTY, Boolean.FALSE, fDescription);
    }
  }

  getASTRewrite().replace(oldTypeNode, newTypeNode, fDescription);
  registerImportRemoveNode(oldTypeNode);
}
项目:Eclipse-Postfix-Code-Completion    文件:MovedMemberAnalyzer.java   
@Override
public boolean visit(MethodRef node) {
    IBinding binding= node.resolveBinding();
    if (isSourceAccess(binding)) {
        if (isMovedMember(binding)) {
            if (node.getQualifier() != null)
                rewrite(node, fTarget);
        } else
            rewrite(node, fSource);

    } else if (isTargetAccess(binding)) {
        // remove qualifier:
        SimpleName replace= (SimpleName)fCuRewrite.getASTRewrite().createCopyTarget(node.getName());
        fCuRewrite.getASTRewrite().replace(node, replace, null);
        fCuRewrite.getImportRemover().registerRemovedNode(node);
    }
    return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:ChangeSignatureProcessor.java   
private OccurrenceUpdate<? extends ASTNode> createOccurrenceUpdate(ASTNode node, CompilationUnitRewrite cuRewrite, RefactoringStatus result) {
    if (BUG_89686 && node instanceof SimpleName && node.getParent() instanceof EnumConstantDeclaration)
        node= node.getParent();

    if (Invocations.isInvocationWithArguments(node))
        return new ReferenceUpdate(node, cuRewrite, result);

    else if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration)
        return new DeclarationUpdate((MethodDeclaration) node.getParent(), cuRewrite, result);

    else if (node instanceof MemberRef || node instanceof MethodRef)
        return new DocReferenceUpdate(node, cuRewrite, result);

    else if (ASTNodes.getParent(node, ImportDeclaration.class) != null)
        return new StaticImportUpdate((ImportDeclaration) ASTNodes.getParent(node, ImportDeclaration.class), cuRewrite, result);

    else if (node instanceof LambdaExpression)
        return new LambdaExpressionUpdate((LambdaExpression) node, cuRewrite, result);

    else if (node.getLocationInParent() == ExpressionMethodReference.NAME_PROPERTY)
        return new ExpressionMethodRefUpdate((ExpressionMethodReference) node.getParent(), cuRewrite, result);

    else
        return new NullOccurrenceUpdate(node, cuRewrite, result);
}
项目:Eclipse-Postfix-Code-Completion    文件:ChangeSignatureProcessor.java   
private void addDelegate() throws JavaModelException {

            DelegateMethodCreator creator= new DelegateMethodCreator();
            creator.setDeclaration(fMethDecl);
            creator.setDeclareDeprecated(fDelegateDeprecation);
            creator.setSourceRewrite(fCuRewrite);
            creator.prepareDelegate();

            /*
             * The delegate now contains a call and a javadoc reference to the
             * old method (i.e., to itself).
             *
             * Use ReferenceUpdate() / DocReferenceUpdate() to update these
             * references like any other reference.
             */
            final ASTNode delegateInvocation= creator.getDelegateInvocation();
            if (delegateInvocation != null)
                // may be null if the delegate is an interface method or
                // abstract -> no body
                new ReferenceUpdate(delegateInvocation, creator.getDelegateRewrite(), fResult).updateNode();
            MethodRef javadocReference= creator.getJavadocReference();
            if (javadocReference != null)
                new DocReferenceUpdate(javadocReference, creator.getDelegateRewrite(), fResult).updateNode();

            creator.createEdit();
        }
项目:Eclipse-Postfix-Code-Completion    文件:ChangeSignatureProcessor.java   
@Override
protected void changeParamgumentType(ParameterInfo info) {
    if (! (fNode instanceof MethodRef))
        return;

    MethodRefParameter oldParam= (MethodRefParameter) ((MethodRef) fNode).parameters().get(info.getOldIndex());
    Type oldTypeNode= oldParam.getType();
    Type newTypeNode= createNewDocRefType(info);
    if (info.isNewVarargs()) {
        if (info.isOldVarargs() && ! oldParam.isVarargs()) {
            // leave as array reference if old reference was not vararg
            newTypeNode= ASTNodeFactory.newArrayType(newTypeNode);
        } else {
            getASTRewrite().set(oldParam, MethodRefParameter.VARARGS_PROPERTY, Boolean.TRUE, fDescription);
        }
    } else {
        if (oldParam.isVarargs()) {
            getASTRewrite().set(oldParam, MethodRefParameter.VARARGS_PROPERTY, Boolean.FALSE, fDescription);
        }
    }

    getASTRewrite().replace(oldTypeNode, newTypeNode, fDescription);
    registerImportRemoveNode(oldTypeNode);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:MovedMemberAnalyzer.java   
@Override
public boolean visit(MethodRef node) {
    IBinding binding= node.resolveBinding();
    if (isSourceAccess(binding)) {
        if (isMovedMember(binding)) {
            if (node.getQualifier() != null)
                rewrite(node, fTarget);
        } else
            rewrite(node, fSource);

    } else if (isTargetAccess(binding)) {
        // remove qualifier:
        SimpleName replace= (SimpleName)fCuRewrite.getASTRewrite().createCopyTarget(node.getName());
        fCuRewrite.getASTRewrite().replace(node, replace, null);
        fCuRewrite.getImportRemover().registerRemovedNode(node);
    }
    return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ChangeSignatureProcessor.java   
private OccurrenceUpdate<? extends ASTNode> createOccurrenceUpdate(ASTNode node, CompilationUnitRewrite cuRewrite, RefactoringStatus result) {
    if (BUG_89686 && node instanceof SimpleName && node.getParent() instanceof EnumConstantDeclaration)
        node= node.getParent();

    if (Invocations.isInvocationWithArguments(node))
        return new ReferenceUpdate(node, cuRewrite, result);

    else if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration)
        return new DeclarationUpdate((MethodDeclaration) node.getParent(), cuRewrite, result);

    else if (node instanceof MemberRef || node instanceof MethodRef)
        return new DocReferenceUpdate(node, cuRewrite, result);

    else if (ASTNodes.getParent(node, ImportDeclaration.class) != null)
        return new StaticImportUpdate((ImportDeclaration) ASTNodes.getParent(node, ImportDeclaration.class), cuRewrite, result);

    else
        return new NullOccurrenceUpdate(node, cuRewrite, result);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ChangeSignatureProcessor.java   
private void addDelegate() throws JavaModelException {

            DelegateMethodCreator creator= new DelegateMethodCreator();
            creator.setDeclaration(fMethDecl);
            creator.setDeclareDeprecated(fDelegateDeprecation);
            creator.setSourceRewrite(fCuRewrite);
            creator.prepareDelegate();

            /*
             * The delegate now contains a call and a javadoc reference to the
             * old method (i.e., to itself).
             *
             * Use ReferenceUpdate() / DocReferenceUpdate() to update these
             * references like any other reference.
             */
            final ASTNode delegateInvocation= creator.getDelegateInvocation();
            if (delegateInvocation != null)
                // may be null if the delegate is an interface method or
                // abstract -> no body
                new ReferenceUpdate(delegateInvocation, creator.getDelegateRewrite(), fResult).updateNode();
            MethodRef javadocReference= creator.getJavadocReference();
            if (javadocReference != null)
                new DocReferenceUpdate(javadocReference, creator.getDelegateRewrite(), fResult).updateNode();

            creator.createEdit();
        }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ChangeSignatureProcessor.java   
@Override
protected void changeParamgumentType(ParameterInfo info) {
    if (! (fNode instanceof MethodRef))
        return;

    MethodRefParameter oldParam= (MethodRefParameter) ((MethodRef) fNode).parameters().get(info.getOldIndex());
    Type oldTypeNode= oldParam.getType();
    Type newTypeNode= createNewDocRefType(info);
    if (info.isNewVarargs()) {
        if (info.isOldVarargs() && ! oldParam.isVarargs()) {
            // leave as array reference of old reference was not vararg
            newTypeNode= getASTRewrite().getAST().newArrayType(newTypeNode);
        } else {
            getASTRewrite().set(oldParam, MethodRefParameter.VARARGS_PROPERTY, Boolean.TRUE, fDescription);
        }
    } else {
        if (oldParam.isVarargs()) {
            getASTRewrite().set(oldParam, MethodRefParameter.VARARGS_PROPERTY, Boolean.FALSE, fDescription);
        }
    }

    getASTRewrite().replace(oldTypeNode, newTypeNode, fDescription);
    registerImportRemoveNode(oldTypeNode);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTFlattener.java   
@Override
public boolean visit(MethodRef node) {
    if (node.getQualifier() != null) {
        node.getQualifier().accept(this);
    }
    this.fBuffer.append("#");//$NON-NLS-1$
    node.getName().accept(this);
    this.fBuffer.append("(");//$NON-NLS-1$
    for (Iterator<MethodRefParameter> it= node.parameters().iterator(); it.hasNext();) {
        MethodRefParameter e= it.next();
        e.accept(this);
        if (it.hasNext()) {
            this.fBuffer.append(",");//$NON-NLS-1$
        }
    }
    this.fBuffer.append(")");//$NON-NLS-1$
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NaiveASTFlattener.java   
public boolean visit(MethodRef node) {
    if (node.getQualifier() != null) {
        node.getQualifier().accept(this);
    }
    this.buffer.append("#");//$NON-NLS-1$
    node.getName().accept(this);
    this.buffer.append("(");//$NON-NLS-1$
    for (Iterator it = node.parameters().iterator(); it.hasNext(); ) {
        MethodRefParameter e = (MethodRefParameter) it.next();
        e.accept(this);
        if (it.hasNext()) {
            this.buffer.append(",");//$NON-NLS-1$
        }
    }
    this.buffer.append(")");//$NON-NLS-1$
    return false;
}
项目:eclipse.jdt.ls    文件:ImportReferencesCollector.java   
@Override
public boolean visit(MethodRef node) {
    Name qualifier= node.getQualifier();
    if (qualifier != null) {
        typeRefFound(qualifier);
    }
    List<MethodRefParameter> list= node.parameters();
    if (list != null) {
        doVisitChildren(list); // visit MethodRefParameter with Type
    }
    return false;
}
项目:che    文件:ImportReferencesCollector.java   
@Override
public boolean visit(MethodRef node) {
  Name qualifier = node.getQualifier();
  if (qualifier != null) {
    typeRefFound(qualifier);
  }
  List<MethodRefParameter> list = node.parameters();
  if (list != null) {
    doVisitChildren(list); // visit MethodRefParameter with Type
  }
  return false;
}
项目:che    文件:ChangeSignatureProcessor.java   
private void addDelegate() throws JavaModelException {

      DelegateMethodCreator creator = new DelegateMethodCreator();
      creator.setDeclaration(fMethDecl);
      creator.setDeclareDeprecated(fDelegateDeprecation);
      creator.setSourceRewrite(fCuRewrite);
      creator.prepareDelegate();

      /*
       * The delegate now contains a call and a javadoc reference to the
       * old method (i.e., to itself).
       *
       * Use ReferenceUpdate() / DocReferenceUpdate() to update these
       * references like any other reference.
       */
      final ASTNode delegateInvocation = creator.getDelegateInvocation();
      if (delegateInvocation != null)
        // may be null if the delegate is an interface method or
        // abstract -> no body
        new ReferenceUpdate(delegateInvocation, creator.getDelegateRewrite(), fResult).updateNode();
      MethodRef javadocReference = creator.getJavadocReference();
      if (javadocReference != null)
        new DocReferenceUpdate(javadocReference, creator.getDelegateRewrite(), fResult)
            .updateNode();

      creator.createEdit();
    }
项目:che    文件:ChangeSignatureProcessor.java   
@Override
public void updateNode() {
  if (fNode instanceof MethodRef) {
    changeParamguments();
    reshuffleElements();
  }
  if (canChangeNameAndReturnType()) changeMethodName();
}
项目:che    文件:ChangeSignatureProcessor.java   
@Override
protected SimpleName getMethodNameNode() {
  if (fNode instanceof MemberRef) return ((MemberRef) fNode).getName();

  if (fNode instanceof MethodRef) return ((MethodRef) fNode).getName();

  return null;
}
项目:che    文件:ChangeSignatureProcessor.java   
@Override
protected void changeParamgumentName(ParameterInfo info) {
  if (!(fNode instanceof MethodRef)) return;

  MethodRefParameter oldParam =
      (MethodRefParameter) ((MethodRef) fNode).parameters().get(info.getOldIndex());
  SimpleName oldParamName = oldParam.getName();
  if (oldParamName != null)
    getASTRewrite()
        .set(oldParamName, SimpleName.IDENTIFIER_PROPERTY, info.getNewName(), fDescription);
}
项目:Eclipse-Postfix-Code-Completion    文件:MoveStaticMemberAnalyzer.java   
protected void rewrite(MethodRef node, ITypeBinding type) {
    Name qualifier= node.getQualifier();
    if (qualifier == null) {
        ImportRewriteContext context= new ContextSensitiveImportRewriteContext(node, fCuRewrite.getImportRewrite());
        Type result= fCuRewrite.getImportRewrite().addImport(type, fCuRewrite.getAST(), context);
        fCuRewrite.getImportRemover().registerAddedImport(type.getQualifiedName());
        qualifier= ASTNodeFactory.newName(fCuRewrite.getAST(), ASTFlattener.asString(result));
        fCuRewrite.getASTRewrite().set(node, MethodRef.QUALIFIER_PROPERTY, qualifier, fCuRewrite.createGroupDescription(REFERENCE_UPDATE));
        fNeedsImport= true;
    } else {
        rewriteName(qualifier, type);
    }
    fProcessed.add(node.getName());
}
项目:Eclipse-Postfix-Code-Completion    文件:MoveInstanceMethodProcessor.java   
/**
 * Creates the necessary change to updated a comment reference represented
 * by a search match.
 *
 * @param rewrite
 *            the current compilation unit rewrite
 * @param declaration
 *            the source method declaration
 * @param match
 *            the search match representing the method reference
 * @param status
 *            the refactoring status
 */
protected void createMethodJavadocReference(CompilationUnitRewrite rewrite, MethodDeclaration declaration, SearchMatch match, RefactoringStatus status) {
    Assert.isNotNull(rewrite);
    Assert.isNotNull(declaration);
    Assert.isNotNull(match);
    Assert.isNotNull(status);
    final ASTNode node= ASTNodeSearchUtil.findNode(match, rewrite.getRoot());
    if (node instanceof MethodRef) {
        final AST ast= node.getAST();
        final MethodRef successor= ast.newMethodRef();

        rewrite.getASTRewrite().replace(node, successor, null);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ChangeSignatureProcessor.java   
@Override
public void updateNode() {
    if (fNode instanceof MethodRef) {
        changeParamguments();
        reshuffleElements();
    }
    if (canChangeNameAndReturnType())
        changeMethodName();
}
项目:Eclipse-Postfix-Code-Completion    文件:ChangeSignatureProcessor.java   
@Override
protected SimpleName getMethodNameNode() {
    if (fNode instanceof MemberRef)
        return ((MemberRef) fNode).getName();

    if (fNode instanceof MethodRef)
        return ((MethodRef) fNode).getName();

    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:ChangeSignatureProcessor.java   
@Override
protected void changeParamgumentName(ParameterInfo info) {
    if (! (fNode instanceof MethodRef))
        return;

    MethodRefParameter oldParam= (MethodRefParameter) ((MethodRef) fNode).parameters().get(info.getOldIndex());
    SimpleName oldParamName= oldParam.getName();
    if (oldParamName != null)
        getASTRewrite().set(oldParamName, SimpleName.IDENTIFIER_PROPERTY, info.getNewName(), fDescription);
}
项目:Eclipse-Postfix-Code-Completion    文件:ImportReferencesCollector.java   
@Override
public boolean visit(MethodRef node) {
    Name qualifier= node.getQualifier();
    if (qualifier != null) {
        typeRefFound(qualifier);
    }
    List<MethodRefParameter> list= node.parameters();
    if (list != null) {
        doVisitChildren(list); // visit MethodRefParameter with Type
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:MoveStaticMemberAnalyzer.java   
protected void rewrite(MethodRef node, ITypeBinding type) {
    Name qualifier= node.getQualifier();
    if (qualifier == null) {
        ImportRewriteContext context= new ContextSensitiveImportRewriteContext(node, fCuRewrite.getImportRewrite());
        Type result= fCuRewrite.getImportRewrite().addImport(type, fCuRewrite.getAST(), context);
        fCuRewrite.getImportRemover().registerAddedImport(type.getQualifiedName());
        qualifier= ASTNodeFactory.newName(fCuRewrite.getAST(), ASTFlattener.asString(result));
        fCuRewrite.getASTRewrite().set(node, MethodRef.QUALIFIER_PROPERTY, qualifier, fCuRewrite.createGroupDescription(REFERENCE_UPDATE));
        fNeedsImport= true;
    } else {
        rewriteName(qualifier, type);
    }
    fProcessed.add(node.getName());
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ChangeSignatureProcessor.java   
@Override
public void updateNode() {
    if (fNode instanceof MethodRef) {
        changeParamguments();
        reshuffleElements();
    }
    if (canChangeNameAndReturnType())
        changeMethodName();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ChangeSignatureProcessor.java   
@Override
protected SimpleName getMethodNameNode() {
    if (fNode instanceof MemberRef)
        return ((MemberRef) fNode).getName();

    if (fNode instanceof MethodRef)
        return ((MethodRef) fNode).getName();

    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ChangeSignatureProcessor.java   
@Override
protected void changeParamgumentName(ParameterInfo info) {
    if (! (fNode instanceof MethodRef))
        return;

    MethodRefParameter oldParam= (MethodRefParameter) ((MethodRef) fNode).parameters().get(info.getOldIndex());
    SimpleName oldParamName= oldParam.getName();
    if (oldParamName != null)
        getASTRewrite().set(oldParamName, SimpleName.IDENTIFIER_PROPERTY, info.getNewName(), fDescription);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ImportReferencesCollector.java   
@Override
public boolean visit(MethodRef node) {
    Name qualifier= node.getQualifier();
    if (qualifier != null) {
        typeRefFound(qualifier);
    }
    List<MethodRefParameter> list= node.parameters();
    if (list != null) {
        doVisitChildren(list); // visit MethodRefParameter with Type
    }
    return false;
}
项目:che    文件:ChangeSignatureProcessor.java   
/** @return {@inheritDoc} (element type: MethodRefParameter) */
@Override
protected ListRewrite getParamgumentsRewrite() {
  return getASTRewrite().getListRewrite(fNode, MethodRef.PARAMETERS_PROPERTY);
}
项目:che    文件:IntroduceFactoryRefactoring.java   
private void rewriteJavadocReference(
    MethodRef javadocRef, ASTRewrite unitRewriter, TextEditGroup gd) {
  AST ast = unitRewriter.getAST();
  unitRewriter.replace(javadocRef.getName(), ast.newSimpleName(fNewMethodName), gd);
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public void endVisit(MethodRef node) {
    logger.warn("Method endVisitMethodRef for " + node + " for " + node + " not implemented!");
    super.endVisit(node);
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public boolean visit(MethodRef node) {
    logger.warn("Method visitMethodRef for " + node + " not implemented!");
    return super.visit(node);
}
项目:Beagle    文件:NotRecursingAstVisitor.java   
@Override
public boolean visit(final MethodRef node) {
    return false;
}
项目:Beagle    文件:InstrumentableAstNodeLister.java   
@Override
public boolean visit(final MethodRef node) {
    // will never be visited
    assert false;
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:ReferenceAnalyzer.java   
@Override
public boolean visit(MethodRef node) {
    if (isMovedMember(node.resolveBinding()))
        rewrite(node, fTarget);
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:ChangeSignatureProcessor.java   
/** @return {@inheritDoc} (element type: MethodRefParameter) */
@Override
protected ListRewrite getParamgumentsRewrite() {
    return getASTRewrite().getListRewrite(fNode, MethodRef.PARAMETERS_PROPERTY);
}
项目:Eclipse-Postfix-Code-Completion    文件:AstMatchingNodeFinder.java   
@Override
public boolean visit(MethodRef node) {
    if (node.subtreeMatch(fMatcher, fNodeToMatch))
        return matches(node);
    return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:IntroduceFactoryRefactoring.java   
private void rewriteJavadocReference(MethodRef javadocRef, ASTRewrite unitRewriter, TextEditGroup gd) {
    AST ast= unitRewriter.getAST();
    unitRewriter.replace(javadocRef.getName(), ast.newSimpleName(fNewMethodName), gd);
}
项目:Eclipse-Postfix-Code-Completion    文件:IntroduceFactoryRefactoring.java   
/**
 * Look "in the vicinity" of the given range to find the <code>ClassInstanceCreation</code>
 * node that this search hit identified. Necessary because the <code>SearchEngine</code>
 * doesn't always cough up text extents that <code>NodeFinder.perform()</code> agrees with.
 * @param start
 * @param length
 * @param unitAST
 * @return return a {@link ClassInstanceCreation} or a {@link MethodRef} or <code>null</code> if this is really a constructor->constructor call (e.g. "this(...)")
 * @throws CoreException
 */
private ASTNode getCtorCallAt(int start, int length, CompilationUnit unitAST) throws CoreException {
    ICompilationUnit unitHandle= ASTCreator.getCu(unitAST);
    ASTNode node= NodeFinder.perform(unitAST, start, length);

    if (node == null)
        throw new CoreException(JavaUIStatus.createError(IStatus.ERROR,
                Messages.format(RefactoringCoreMessages.IntroduceFactory_noASTNodeForConstructorSearchHit,
                        new Object[] { Integer.toString(start), Integer.toString(start + length),
                            BasicElementLabels.getJavaCodeString(unitHandle.getSource().substring(start, start + length)),
                            BasicElementLabels.getFileName(unitHandle) }),
                null));

    if (node instanceof ClassInstanceCreation) {
        if (((ClassInstanceCreation)node).getAnonymousClassDeclaration() != null) {
            // Cannot replace anonymous inner class, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=250660
            fConstructorVisibility= Modifier.PROTECTED;
            return null;
        }
        return node;
    } else if (node instanceof VariableDeclaration) {
        Expression  init= ((VariableDeclaration) node).getInitializer();

        if (init instanceof ClassInstanceCreation) {
            return init;
        } else if (init != null)
            throw new CoreException(JavaUIStatus.createError(IStatus.ERROR,
                    Messages.format(RefactoringCoreMessages.IntroduceFactory_unexpectedInitializerNodeType,
                            new Object[] { BasicElementLabels.getJavaCodeString(init.toString()), BasicElementLabels.getFileName(unitHandle) }),
                    null));
        else
            throw new CoreException(JavaUIStatus.createError(IStatus.ERROR,
                    Messages.format(RefactoringCoreMessages.IntroduceFactory_noConstructorCallNodeInsideFoundVarbleDecl,
                            BasicElementLabels.getJavaCodeString(node.toString())),
                    null));
    } else if (node instanceof ConstructorInvocation) {
        // This is a call we can bypass; it's from one constructor flavor
        // to another flavor on the same class.
        return null;
    } else if (node instanceof SuperConstructorInvocation) {
        // This is a call we can bypass; it's from one constructor flavor
        // to another flavor on the same class.
        fConstructorVisibility= Modifier.PROTECTED;
        return null;
    } else if (node instanceof ExpressionStatement) {
        Expression  expr= ((ExpressionStatement) node).getExpression();

        if (expr instanceof ClassInstanceCreation)
            return expr;
        else
            throw new CoreException(JavaUIStatus.createError(IStatus.ERROR,
                    Messages.format(RefactoringCoreMessages.IntroduceFactory_unexpectedASTNodeTypeForConstructorSearchHit,
                            new Object[] { BasicElementLabels.getJavaCodeString(expr.toString()), BasicElementLabels.getFileName(unitHandle) }),
                    null));
    } else if (node instanceof SimpleName && (node.getParent() instanceof MethodDeclaration || node.getParent() instanceof AbstractTypeDeclaration)) {
        // We seem to have been given a hit for an implicit call to the base-class constructor.
        // Do nothing with this (implicit) call, but have to make sure we make the derived class
        // doesn't lose access to the base-class constructor (so make it 'protected', not 'private').
        fConstructorVisibility= Modifier.PROTECTED;
        return null;
    } else if (node instanceof MethodRef) {
        return node;
    } else
        throw new CoreException(JavaUIStatus.createError(IStatus.ERROR,
                Messages.format(RefactoringCoreMessages.IntroduceFactory_unexpectedASTNodeTypeForConstructorSearchHit,
                        new Object[] { BasicElementLabels.getJavaElementName(node.getClass().getName() + "('" + node.toString() + "')"), BasicElementLabels.getFileName(unitHandle) }), //$NON-NLS-1$ //$NON-NLS-2$
                null));
}