当前位置: 首页>>代码示例>>Java>>正文


Java ClassInstanceCreation.resolveTypeBinding方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:ConvertAnonymousToNestedRefactoring.java

示例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);
}
 
开发者ID:aroog,项目名称:code,代码行数:8,代码来源:NoAnnotatMetrics.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:LambdaExpressionsFix.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:41,代码来源:LambdaExpressionsFix.java

示例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);
}
 
开发者ID:vogellacompany,项目名称:codemodify,代码行数:10,代码来源:LambdaConverterFix.java

示例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();
}
 
开发者ID:vogellacompany,项目名称:codemodify,代码行数:14,代码来源:LambdaConverterFix.java

示例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;
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:21,代码来源:JavaAssignment.java

示例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"));
}
 
开发者ID:vogellacompany,项目名称:codemodify,代码行数:52,代码来源:LambdaConverterFix.java


注:本文中的org.eclipse.jdt.core.dom.ClassInstanceCreation.resolveTypeBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。