本文整理汇总了Java中org.eclipse.jdt.core.dom.ClassInstanceCreation.resolveTypeBinding方法的典型用法代码示例。如果您正苦于以下问题:Java ClassInstanceCreation.resolveTypeBinding方法的具体用法?Java ClassInstanceCreation.resolveTypeBinding怎么用?Java ClassInstanceCreation.resolveTypeBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.ClassInstanceCreation
的用法示例。
在下文中一共展示了ClassInstanceCreation.resolveTypeBinding方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSuperType
import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
private void setSuperType(TypeDeclaration declaration) {
ClassInstanceCreation classInstanceCreation =
(ClassInstanceCreation) fAnonymousInnerClassNode.getParent();
ITypeBinding binding = classInstanceCreation.resolveTypeBinding();
if (binding == null) return;
Type newType =
(Type)
ASTNode.copySubtree(fAnonymousInnerClassNode.getAST(), classInstanceCreation.getType());
if (binding.getSuperclass().getQualifiedName().equals("java.lang.Object")) { // $NON-NLS-1$
Assert.isTrue(binding.getInterfaces().length <= 1);
if (binding.getInterfaces().length == 0) return;
declaration.superInterfaceTypes().add(0, newType);
} else {
declaration.setSuperclassType(newType);
}
}
示例2: visit
import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public boolean visit(ClassInstanceCreation node) {
ITypeBinding newExpr = node.resolveTypeBinding();
// System.out.println("newExpr" + newExpr.getQualifiedName());
newExpression.add(newExpr);
return super.visit(node);
}
示例3: isFunctionalAnonymous
import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
static boolean isFunctionalAnonymous(ClassInstanceCreation node) {
ITypeBinding typeBinding = node.resolveTypeBinding();
if (typeBinding == null) return false;
ITypeBinding[] interfaces = typeBinding.getInterfaces();
if (interfaces.length != 1) return false;
if (interfaces[0].getFunctionalInterfaceMethod() == null) return false;
AnonymousClassDeclaration anonymTypeDecl = node.getAnonymousClassDeclaration();
if (anonymTypeDecl == null || anonymTypeDecl.resolveBinding() == null) return false;
List<BodyDeclaration> bodyDeclarations = anonymTypeDecl.bodyDeclarations();
// cannot convert if there are fields or additional methods
if (bodyDeclarations.size() != 1) return false;
BodyDeclaration bodyDeclaration = bodyDeclarations.get(0);
if (!(bodyDeclaration instanceof MethodDeclaration)) return false;
MethodDeclaration methodDecl = (MethodDeclaration) bodyDeclaration;
IMethodBinding methodBinding = methodDecl.resolveBinding();
if (methodBinding == null) return false;
// generic lambda expressions are not allowed
if (methodBinding.isGenericMethod()) return false;
// lambda cannot refer to 'this'/'super' literals
if (SuperThisReferenceFinder.hasReference(methodDecl)) return false;
if (!isInTargetTypeContext(node)) return false;
return true;
}
示例4: setSuperType
import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
private void setSuperType(TypeDeclaration declaration) {
ClassInstanceCreation classInstanceCreation= (ClassInstanceCreation) fAnonymousInnerClassNode.getParent();
ITypeBinding binding= classInstanceCreation.resolveTypeBinding();
if (binding == null)
return;
Type newType= (Type) ASTNode.copySubtree(fAnonymousInnerClassNode.getAST(), classInstanceCreation.getType());
if (binding.getSuperclass().getQualifiedName().equals("java.lang.Object")) { //$NON-NLS-1$
Assert.isTrue(binding.getInterfaces().length <= 1);
if (binding.getInterfaces().length == 0)
return;
declaration.superInterfaceTypes().add(0, newType);
} else {
declaration.setSuperclassType(newType);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:ConvertAnonymousToNestedRefactoring.java
示例5: isFunctionalAnonymous
import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
static boolean isFunctionalAnonymous(ClassInstanceCreation node) {
ITypeBinding typeBinding= node.resolveTypeBinding();
if (typeBinding == null)
return false;
ITypeBinding[] interfaces= typeBinding.getInterfaces();
if (interfaces.length != 1)
return false;
if (interfaces[0].getFunctionalInterfaceMethod() == null)
return false;
AnonymousClassDeclaration anonymTypeDecl= node.getAnonymousClassDeclaration();
if (anonymTypeDecl == null || anonymTypeDecl.resolveBinding() == null)
return false;
List<BodyDeclaration> bodyDeclarations= anonymTypeDecl.bodyDeclarations();
// cannot convert if there are fields or additional methods
if (bodyDeclarations.size() != 1)
return false;
BodyDeclaration bodyDeclaration= bodyDeclarations.get(0);
if (!(bodyDeclaration instanceof MethodDeclaration))
return false;
MethodDeclaration methodDecl= (MethodDeclaration) bodyDeclaration;
IMethodBinding methodBinding= methodDecl.resolveBinding();
if (methodBinding == null)
return false;
// generic lambda expressions are not allowed
if (methodBinding.isGenericMethod())
return false;
// lambda cannot refer to 'this'/'super' literals
if (SuperThisReferenceFinder.hasReference(methodDecl))
return false;
if (!isInTargetTypeContext(node))
return false;
return true;
}
示例6: prepareChanges
import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
private void prepareChanges(CompilationUnit cu, ASTRewrite rewriter, ImportRewrite importRewrite,
ClassInstanceCreation classInstanceCreation, TextEditGroup group, IMethodBinding methodInInterface,
MethodInvocation methodInvocation) throws CoreException, MalformedTreeException, BadLocationException {
rewriter.replace(classInstanceCreation, methodInvocation, group);
importRewrite.addStaticImport(methodInInterface);
ITypeBinding typeBinding = classInstanceCreation.resolveTypeBinding();
ITypeBinding superclass = typeBinding.getSuperclass();
handleImportRemoval(cu, rewriter, importRewrite, superclass);
}
示例7: findMethodInInterface
import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
private Optional<IMethodBinding> findMethodInInterface(ClassInstanceCreation classInstanceCreation, SimpleName methodName, List<SingleVariableDeclaration> parameters) {
ITypeBinding typeBinding = classInstanceCreation.resolveTypeBinding();
ITypeBinding superclass = typeBinding.getSuperclass();
for (ITypeBinding interFace : superclass.getInterfaces()) {
IMethodBinding[] declaredMethods = interFace.getDeclaredMethods();
for (IMethodBinding declaredMethod : declaredMethods) {
if (declaredMethod.getName().toString().equals(methodName.toString())) {
return Optional.of(declaredMethod);
}
}
}
return Optional.empty();
}
示例8: JavaAssignment
import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
/**
* Constructor for this class if on the right hand side is a constructor call.
* @param parent The parent of this artifact.
* @param expression The Statement expression, which may be edited.
* @param attributeName then name of the attribute as string
* @param typeBinding The type of the LHS (qualified name),
* i.e. to which <b>TYPE</b> it is assigned <b>TO</b>.
* @param rhs The creation of the assignment of the right hand side (a constructor call).
*/
JavaAssignment(IJavaParent parent, ExpressionStatement expression, String attributeName, ITypeBinding typeBinding,
ClassInstanceCreation rhs) {
super(parent, expression, attributeName, typeBinding);
if (null != rhs) {
ITypeBinding rhsBinding = rhs.resolveTypeBinding();
arguments = rhs.arguments();
if (null != rhsBinding) {
this.fromType = (null != rhs && null != rhsBinding) ? rhsBinding.getQualifiedName() : null;
}
}
}
示例9: isFunctionalAnonymous
import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
static boolean isFunctionalAnonymous(ClassInstanceCreation node) {
ITypeBinding typeBinding= node.resolveTypeBinding();
if (typeBinding == null) {
return false;
}
// TODO(fap): remove hardcoding for SelectionAdapter
if (!CLASS_INSTANCE_CREATION_TYPE.equals(node.getType().toString())) {
return false;
}
AnonymousClassDeclaration anonymTypeDecl = node.getAnonymousClassDeclaration();
if (anonymTypeDecl == null || anonymTypeDecl.resolveBinding() == null) {
return false;
}
List<BodyDeclaration> bodyDeclarations = anonymTypeDecl.bodyDeclarations();
// cannot convert if there are fields or additional methods
if (bodyDeclarations.size() != 1) {
return false;
}
BodyDeclaration bodyDeclaration = bodyDeclarations.get(0);
if (!(bodyDeclaration instanceof MethodDeclaration)) {
return false;
}
MethodDeclaration methodDecl = (MethodDeclaration) bodyDeclaration;
IMethodBinding methodBinding = methodDecl.resolveBinding();
if (methodBinding == null) {
return false;
}
// generic lambda expressions are not allowed
if (methodBinding.isGenericMethod()) {
return false;
}
int modifiers= methodBinding.getModifiers();
if (Modifier.isSynchronized(modifiers) || Modifier.isStrictfp(modifiers)) {
return false;
}
// lambda cannot refer to 'this'/'super' literals
if (SuperThisReferenceFinder.hasReference(methodDecl)) {
return false;
}
// if (ASTNodes.getTargetType(node) == null) // #isInTargetTypeContext
// return false;
return !hasAnnotationExcept(methodBinding, Stream.of("java.lang.Override", "java.lang.Deprecated"));
}