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


Java ClassInstanceCreation.resolveConstructorBinding方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.ClassInstanceCreation.resolveConstructorBinding方法的典型用法代码示例。如果您正苦于以下问题:Java ClassInstanceCreation.resolveConstructorBinding方法的具体用法?Java ClassInstanceCreation.resolveConstructorBinding怎么用?Java ClassInstanceCreation.resolveConstructorBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.ClassInstanceCreation的用法示例。


在下文中一共展示了ClassInstanceCreation.resolveConstructorBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
public boolean visit(ClassInstanceCreation node) {
	IMethodBinding mmtb = node.resolveConstructorBinding();

	if (mtbStack.isEmpty()) // not part of a method
		return true;

	// make field access fact
	try {
		facts.add(Fact.makeCallsFact(getQualifiedName(mtbStack.peek()),
				getQualifiedName(mmtb)));
	} catch (Exception e) {
		System.err.println("Cannot resolve class instance creation \""
				+ node.getType().toString() + "\"");
	}
	return true;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:17,代码来源:ASTVisitorAtomicChange.java

示例2: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
public boolean visit(ClassInstanceCreation node)
{
  IMethodBinding mmtb = node.resolveConstructorBinding();
  if (this.mtbStack.isEmpty()) {
    return true;
  }
  try
  {
    this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding)this.mtbStack.peek()), 
      getQualifiedName(mmtb)));
  }
  catch (Exception e)
  {
    System.err.println("Cannot resolve class instance creation \"" + 
      node.getType().toString() + "\"");
  }
  return true;
}
 
开发者ID:SEAL-UCLA,项目名称:Ref-Finder,代码行数:19,代码来源:ASTVisitorAtomicChange.java

示例3: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
public boolean visit(ClassInstanceCreation node)
{
  IMethodBinding mmtb = node.resolveConstructorBinding();
  if (this.mtbStack.isEmpty()) {
    return true;
  }
  try
  {
    this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding)this.mtbStack.peek()), 
      getQualifiedName(mmtb)));
  }
  catch (Exception localException)
  {
    System.err.println("Cannot resolve class instance creation \"" + 
      node.getType().toString() + "\"");
  }
  return true;
}
 
开发者ID:SEAL-UCLA,项目名称:Ref-Finder,代码行数:19,代码来源:ASTVisitorAtomicChange.java

示例4: endVisit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public void endVisit(ClassInstanceCreation node) {
  Expression receiver = node.getExpression();
  Type createdType = node.getType();

  ConstraintVariable2 typeCv;
  if (node.getAnonymousClassDeclaration() == null) {
    typeCv = getConstraintVariable(createdType);
  } else {
    typeCv = fTCModel.makeImmutableTypeVariable(createdType.resolveBinding(), null);
    setConstraintVariable(createdType, typeCv);
  }
  setConstraintVariable(node, typeCv);

  IMethodBinding methodBinding = node.resolveConstructorBinding();
  Map<String, IndependentTypeVariable2> methodTypeVariables =
      createMethodTypeArguments(methodBinding);
  List<Expression> arguments = node.arguments();
  doVisitMethodInvocationArguments(
      methodBinding, arguments, receiver, methodTypeVariables, createdType);
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:InferTypeArgumentsConstraintCreator.java

示例5: create

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public ITypeConstraint[] create(ClassInstanceCreation instanceCreation) {
  List<Expression> arguments = instanceCreation.arguments();
  List<ITypeConstraint> result = new ArrayList<ITypeConstraint>(arguments.size());
  IMethodBinding methodBinding = instanceCreation.resolveConstructorBinding();
  result.addAll(Arrays.asList(getArgumentConstraints(arguments, methodBinding)));
  if (instanceCreation.getAnonymousClassDeclaration() == null) {
    ConstraintVariable constructorVar =
        fConstraintVariableFactory.makeExpressionOrTypeVariable(instanceCreation, getContext());
    ConstraintVariable typeVar =
        fConstraintVariableFactory.makeRawBindingVariable(instanceCreation.resolveTypeBinding());
    result.addAll(
        Arrays.asList(fTypeConstraintFactory.createDefinesConstraint(constructorVar, typeVar)));
  }
  return result.toArray(new ITypeConstraint[result.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:FullConstraintCreator.java

示例6: resolveBinding

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
private static IBinding resolveBinding(ASTNode node) {
  if (node instanceof SimpleName) {
    SimpleName simpleName = (SimpleName) node;
    // workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not
    // method)
    ASTNode normalized = ASTNodes.getNormalizedNode(simpleName);
    if (normalized.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) {
      ClassInstanceCreation cic = (ClassInstanceCreation) normalized.getParent();
      IMethodBinding constructorBinding = cic.resolveConstructorBinding();
      if (constructorBinding == null) return null;
      ITypeBinding declaringClass = constructorBinding.getDeclaringClass();
      if (!declaringClass.isAnonymous()) return constructorBinding;
      ITypeBinding superTypeDeclaration = declaringClass.getSuperclass().getTypeDeclaration();
      return resolveSuperclassConstructor(superTypeDeclaration, constructorBinding);
    }
    return simpleName.resolveBinding();

  } else if (node instanceof SuperConstructorInvocation) {
    return ((SuperConstructorInvocation) node).resolveConstructorBinding();
  } else if (node instanceof ConstructorInvocation) {
    return ((ConstructorInvocation) node).resolveConstructorBinding();
  } else {
    return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:JavadocFinder.java

示例7: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
/**
 * handles
 * 		new Class()
 */
@SuppressWarnings("unchecked")
@Override
public boolean visit(ClassInstanceCreation node) {
	IMethodBinding binding = node.resolveConstructorBinding();
	if (binding != null)
		importer.createInvocationFromMethodBinding(binding, node.toString().trim());
	else {
		String name = node.getType().toString();
		importer.ensureBasicMethod(
				name, 
				name, 
				importer.ensureTypeNamedInUnknownNamespace(name), 
				m -> importer.createInvocationToMethod(m, node.toString().trim()));
	}
	node.arguments().stream().forEach(arg -> importer.createAccessFromExpression((Expression) arg));
	return true;
}
 
开发者ID:feenkcom,项目名称:jdt2famix,代码行数:22,代码来源:AstVisitor.java

示例8: endVisit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public void endVisit(ClassInstanceCreation node) {
	Expression receiver= node.getExpression();
	Type createdType= node.getType();

	ConstraintVariable2 typeCv;
	if (node.getAnonymousClassDeclaration() == null) {
		typeCv= getConstraintVariable(createdType);
	} else {
		typeCv= fTCModel.makeImmutableTypeVariable(createdType.resolveBinding(), null);
		setConstraintVariable(createdType, typeCv);
	}
	setConstraintVariable(node, typeCv);

	IMethodBinding methodBinding= node.resolveConstructorBinding();
	Map<String, IndependentTypeVariable2> methodTypeVariables= createMethodTypeArguments(methodBinding);
	List<Expression> arguments= node.arguments();
	doVisitMethodInvocationArguments(methodBinding, arguments, receiver, methodTypeVariables, createdType);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:InferTypeArgumentsConstraintCreator.java

示例9: resolveBinding

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
private static IBinding resolveBinding(ASTNode node) {
	if (node instanceof SimpleName) {
		SimpleName simpleName= (SimpleName) node;
		// workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
		ASTNode normalized= ASTNodes.getNormalizedNode(simpleName);
		if (normalized.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) {
			ClassInstanceCreation cic= (ClassInstanceCreation) normalized.getParent();
			IMethodBinding constructorBinding= cic.resolveConstructorBinding();
			if (constructorBinding == null)
				return null;
			ITypeBinding declaringClass= constructorBinding.getDeclaringClass();
			if (!declaringClass.isAnonymous())
				return constructorBinding;
			ITypeBinding superTypeDeclaration= declaringClass.getSuperclass().getTypeDeclaration();
			return resolveSuperclassConstructor(superTypeDeclaration, constructorBinding);
		}
		return simpleName.resolveBinding();
		
	} else if (node instanceof SuperConstructorInvocation) {
		return ((SuperConstructorInvocation) node).resolveConstructorBinding();
	} else if (node instanceof ConstructorInvocation) {
		return ((ConstructorInvocation) node).resolveConstructorBinding();
	} else {
		return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:JavadocHover.java

示例10: transfer

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public OOGContext transfer(NewObjectInstruction instr, OOGContext value) {
	ITypeBinding instantiatedType = instr.resolveInstantiatedType();
	ASTNode node = instr.getNode();
	ITypeBinding newExprEnclosingClassBinding = Utils.findEnclosingClassBinding(node);
	IMethodBinding newExprEnclosingMethodBinding = Utils.findEnclosingMethodBinding(node);
	if(node instanceof ClassInstanceCreation){
		ClassInstanceCreation cicNode = (ClassInstanceCreation)node;
		IMethodBinding constructorBinding = cicNode.resolveConstructorBinding();
		final TACNewExpr newExprVar = new TACNewExpr(constructorBinding, newExprEnclosingClassBinding, newExprEnclosingMethodBinding, instantiatedType);
		context.putAllBindingKeyToVariableMap(constructorBinding.getKey(), newExprVar);
		Variable newExprVarInMap = this.tm.getVarBindingMap(constructorBinding);
		
		// Build a mapping from the synthetic new expression variable to its left hand side variable
		Variable lhsVariable = instr.getTarget();
		value.addNewExprVarToLhsVar(newExprVar, lhsVariable);
		
		if(newExprVarInMap==null){
			this.tm.putVarBindingMap(constructorBinding, newExprVar);
		}
		String newExprEncClassName = newExprEnclosingClassBinding.getQualifiedName();
		Set<OType> newExprTypingSet = this.tm.getTypeMapping(newExprVar);
		if(newExprTypingSet==null){
			boolean isMainClass = newExprEncClassName.equals(Config.MAINCLASS);
			newExprTypingSet = this.tm.initTypeMapping(isMainClass,newExprVar, false,true);
			this.tm.putTypeMapping(newExprVar, newExprTypingSet);
		}
	}
	return value;
}
 
开发者ID:aroog,项目名称:code,代码行数:31,代码来源:InitializationTransferFunctions.java

示例11: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public boolean visit(ClassInstanceCreation loc) {
	if (currentMethod == null)
		return false;
	if (loc.resolveConstructorBinding() == null)
		return false;
	if (loc.resolveConstructorBinding().getMethodDeclaration() == null || loc.resolveConstructorBinding().getMethodDeclaration().getJavaElement() == null)
		return true;
	if (loc.resolveConstructorBinding().getMethodDeclaration().getJavaElement().isReadOnly())
		return true;
	addCalledMethod(loc.resolveConstructorBinding());
	return true;
}
 
开发者ID:ioanaverebi,项目名称:Sparrow,代码行数:14,代码来源:OutCodeVisitor.java

示例12: create

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public ITypeConstraint[] create(ClassInstanceCreation instanceCreation){
	List<Expression> arguments= instanceCreation.arguments();
	List<ITypeConstraint> result= new ArrayList<ITypeConstraint>(arguments.size());
	IMethodBinding methodBinding= instanceCreation.resolveConstructorBinding();
	result.addAll(Arrays.asList(getArgumentConstraints(arguments, methodBinding)));
	if (instanceCreation.getAnonymousClassDeclaration() == null){
		ConstraintVariable constructorVar= fConstraintVariableFactory.makeExpressionOrTypeVariable(instanceCreation, getContext());
		ConstraintVariable typeVar= fConstraintVariableFactory.makeRawBindingVariable(instanceCreation.resolveTypeBinding());
		result.addAll(Arrays.asList(fTypeConstraintFactory.createDefinesConstraint(constructorVar, typeVar)));
	}
	return result.toArray(new ITypeConstraint[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:FullConstraintCreator.java

示例13: resolveBinding

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
private static IBinding resolveBinding(ASTNode node) {
	if (node instanceof SimpleName) {
		// workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
		SimpleName simpleName= (SimpleName) node;
		StructuralPropertyDescriptor loc= simpleName.getLocationInParent();
		while (loc == QualifiedType.NAME_PROPERTY || loc == QualifiedName.NAME_PROPERTY|| loc == SimpleType.NAME_PROPERTY || loc == ParameterizedType.TYPE_PROPERTY) {
			node= node.getParent();
			loc= node.getLocationInParent();
		}
		if (loc == ClassInstanceCreation.TYPE_PROPERTY) {
			ClassInstanceCreation cic= (ClassInstanceCreation) node.getParent();
			IMethodBinding constructorBinding= cic.resolveConstructorBinding();
			if (constructorBinding == null)
				return null;
			ITypeBinding declaringClass= constructorBinding.getDeclaringClass();
			if (!declaringClass.isAnonymous())
				return constructorBinding;
			ITypeBinding superTypeDeclaration= declaringClass.getSuperclass().getTypeDeclaration();
			return resolveSuperclassConstructor(superTypeDeclaration, constructorBinding);
		}
		return simpleName.resolveBinding();
		
	} else if (node instanceof SuperConstructorInvocation) {
		return ((SuperConstructorInvocation) node).resolveConstructorBinding();
	} else if (node instanceof ConstructorInvocation) {
		return ((ConstructorInvocation) node).resolveConstructorBinding();
	} else {
		return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:31,代码来源:JavadocHover.java

示例14: make

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
public static QMethodAndArgs make(ClassInstanceCreation node) {
    String qtype = node.getType().resolveBinding().getQualifiedName();
    String method = CONSTRUCTOR_METHOD;
    // can't use node.arguments() because those are the concrete types, not necessarily
    // the types of the methods
    IMethodBinding constructor = node.resolveConstructorBinding();
    return new QMethodAndArgs(qtype, method, expressionsToTypeStrings(constructor.getParameterTypes()));
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:9,代码来源:QMethodAndArgs.java

示例15: checkSelection

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
/**
 * Determines what kind of AST node was selected, and returns an error status if the kind of node
 * is inappropriate for this refactoring.
 *
 * @param pm
 * @return a RefactoringStatus indicating whether the selection is valid
 * @throws JavaModelException
 */
private RefactoringStatus checkSelection(IProgressMonitor pm) throws JavaModelException {
  try {
    pm.beginTask(RefactoringCoreMessages.IntroduceFactory_examiningSelection, 2);

    fSelectedNode = getTargetNode(fCUHandle, fSelectionStart, fSelectionLength);

    if (fSelectedNode == null)
      return RefactoringStatus.createFatalErrorStatus(
          RefactoringCoreMessages.IntroduceFactory_notAConstructorInvocation);

    // getTargetNode() must return either a ClassInstanceCreation or a
    // constructor MethodDeclaration; nothing else.
    if (fSelectedNode instanceof ClassInstanceCreation) {
      ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) fSelectedNode;
      fCtorBinding = classInstanceCreation.resolveConstructorBinding();
    } else if (fSelectedNode instanceof MethodDeclaration) {
      MethodDeclaration methodDeclaration = (MethodDeclaration) fSelectedNode;
      fCtorBinding = methodDeclaration.resolveBinding();
    }

    if (fCtorBinding == null)
      return RefactoringStatus.createFatalErrorStatus(
          RefactoringCoreMessages.IntroduceFactory_unableToResolveConstructorBinding);

    // If this constructor is of a generic type, get the generic version,
    // not some instantiation thereof.
    fCtorBinding = fCtorBinding.getMethodDeclaration();

    pm.worked(1);

    // We don't handle constructors of nested types at the moment
    if (fCtorBinding.getDeclaringClass().isNested())
      return RefactoringStatus.createFatalErrorStatus(
          RefactoringCoreMessages.IntroduceFactory_unsupportedNestedTypes);

    ITypeBinding ctorType = fCtorBinding.getDeclaringClass();
    IType ctorOwningType = (IType) ctorType.getJavaElement();

    if (ctorOwningType.isBinary())
      // Can't modify binary CU; don't know what CU to put factory method
      return RefactoringStatus.createFatalErrorStatus(
          RefactoringCoreMessages.IntroduceFactory_constructorInBinaryClass);
    if (ctorOwningType.isEnum())
      // Doesn't make sense to encapsulate enum constructors
      return RefactoringStatus.createFatalErrorStatus(
          RefactoringCoreMessages.IntroduceFactory_constructorInEnum);

    // Put the generated factory method inside the type that owns the constructor
    fFactoryUnitHandle = ctorOwningType.getCompilationUnit();
    fFactoryCU = getASTFor(fFactoryUnitHandle);

    Name ctorOwnerName = (Name) NodeFinder.perform(fFactoryCU, ctorOwningType.getNameRange());

    fCtorOwningClass =
        (AbstractTypeDeclaration)
            ASTNodes.getParent(ctorOwnerName, AbstractTypeDeclaration.class);
    fFactoryOwningClass = fCtorOwningClass;

    pm.worked(1);

    if (fNewMethodName == null)
      return setNewMethodName("create" + fCtorBinding.getName()); // $NON-NLS-1$
    else return new RefactoringStatus();
  } finally {
    pm.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:76,代码来源:IntroduceFactoryRefactoring.java


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