本文整理汇总了Java中org.eclipse.jdt.internal.corext.dom.ASTNodes.getEnclosingType方法的典型用法代码示例。如果您正苦于以下问题:Java ASTNodes.getEnclosingType方法的具体用法?Java ASTNodes.getEnclosingType怎么用?Java ASTNodes.getEnclosingType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.dom.ASTNodes
的用法示例。
在下文中一共展示了ASTNodes.getEnclosingType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReceiver
import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
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;
}
示例2: initializeDestinations
import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
private void initializeDestinations() {
List<ASTNode> result = new ArrayList<ASTNode>();
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];
}
示例3: checkInput
import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
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));
}
}