本文整理汇总了Java中org.eclipse.jdt.core.dom.MethodRef类的典型用法代码示例。如果您正苦于以下问题:Java MethodRef类的具体用法?Java MethodRef怎么用?Java MethodRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MethodRef类属于org.eclipse.jdt.core.dom包,在下文中一共展示了MethodRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createOccurrenceUpdate
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
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);
}
示例2: changeParamgumentType
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
@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);
}
示例3: visit
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
@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);
}
示例4: createOccurrenceUpdate
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
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);
}
示例5: addDelegate
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
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();
}
示例6: changeParamgumentType
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
@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);
}
示例7: createOccurrenceUpdate
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
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);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:ChangeSignatureProcessor.java
示例8: changeParamgumentType
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
@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);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:25,代码来源:ChangeSignatureProcessor.java
示例9: visit
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
@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;
}
示例10: visit
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
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;
}
示例11: visit
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
@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;
}
示例12: visit
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
@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;
}
示例13: addDelegate
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
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();
}
示例14: updateNode
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
@Override
public void updateNode() {
if (fNode instanceof MethodRef) {
changeParamguments();
reshuffleElements();
}
if (canChangeNameAndReturnType()) changeMethodName();
}
示例15: getMethodNameNode
import org.eclipse.jdt.core.dom.MethodRef; //导入依赖的package包/类
@Override
protected SimpleName getMethodNameNode() {
if (fNode instanceof MemberRef) return ((MemberRef) fNode).getName();
if (fNode instanceof MethodRef) return ((MethodRef) fNode).getName();
return null;
}