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


Java TypeVariable2类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2的典型用法代码示例。如果您正苦于以下问题:Java TypeVariable2类的具体用法?Java TypeVariable2怎么用?Java TypeVariable2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TypeVariable2类属于org.eclipse.jdt.internal.corext.refactoring.typeconstraints2包,在下文中一共展示了TypeVariable2类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rewriteConstraintVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
private static ParameterizedType rewriteConstraintVariable(
    ConstraintVariable2 cv,
    CompilationUnitRewrite rewrite,
    InferTypeArgumentsTCModel tCModel,
    boolean leaveUnconstraindRaw,
    SimpleType[] types) {
  if (cv instanceof CollectionElementVariable2) {
    ConstraintVariable2 parentElement =
        ((CollectionElementVariable2) cv).getParentConstraintVariable();
    if (parentElement instanceof TypeVariable2) {
      TypeVariable2 typeCv = (TypeVariable2) parentElement;
      return rewriteTypeVariable(typeCv, rewrite, tCModel, leaveUnconstraindRaw, types);
    } else {
      // only rewrite type variables
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:InferTypeArgumentsRefactoring.java

示例2: makeTypeVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
public TypeVariable2 makeTypeVariable(Type type) {
  ICompilationUnit cu = RefactoringASTParser.getCompilationUnit(type);
  TType ttype = getBoxedType(type.resolveBinding(), /*no boxing*/ null);
  if (ttype == null) return null;

  CompilationUnitRange range = new CompilationUnitRange(cu, type);
  TypeVariable2 typeVariable = new TypeVariable2(ttype, range);
  TypeVariable2 storedCv = (TypeVariable2) storedCv(typeVariable);
  if (storedCv == typeVariable) {
    fCuScopedConstraintVariables.add(storedCv);
    if (isAGenericType(ttype)) makeElementVariables(storedCv, ttype);
    makeArrayElementVariable(storedCv);
    if (fStoreToString) storedCv.setData(ConstraintVariable2.TO_STRING, type.toString());
  }
  return storedCv;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:InferTypeArgumentsTCModel.java

示例3: makeTypeVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
public TypeVariable2 makeTypeVariable(Type type) {
	ICompilationUnit cu= RefactoringASTParser.getCompilationUnit(type);
	TType ttype= getBoxedType(type.resolveBinding(), /*no boxing*/null);
	if (ttype == null)
		return null;

	CompilationUnitRange range= new CompilationUnitRange(cu, type);
	TypeVariable2 typeVariable= new TypeVariable2(ttype, range);
	TypeVariable2 storedCv= (TypeVariable2) storedCv(typeVariable);
	if (storedCv == typeVariable) {
		fCuScopedConstraintVariables.add(storedCv);
		if (isAGenericType(ttype))
			makeElementVariables(storedCv, ttype);
		makeArrayElementVariable(storedCv);
		if (fStoreToString)
			storedCv.setData(ConstraintVariable2.TO_STRING, type.toString());
	}
	return storedCv;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:InferTypeArgumentsTCModel.java

示例4: endVisit

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
@Override
public void endVisit(ArrayCreation node) {
  ArrayType arrayType = node.getType();
  TypeVariable2 arrayTypeCv = (TypeVariable2) getConstraintVariable(arrayType);
  if (arrayTypeCv == null) return;
  setConstraintVariable(node, arrayTypeCv);
  // TODO: constraints for array initializer?
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:InferTypeArgumentsConstraintCreator.java

示例5: createExceptionVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
/**
 * Creates an exception variable.
 *
 * @param name the name of the thrown exception
 * @return the created exception variable, or <code>null</code>
 */
public final ConstraintVariable2 createExceptionVariable(final Name name) {
	final ITypeBinding binding= name.resolveTypeBinding();
	if (isConstrainedType(binding))
		return fConstraintVariables.addExisting(new TypeVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(name), name)));
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:SuperTypeConstraintsModel.java

示例6: createTypeVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
/**
 * Creates a type variable.
 *
 * @param type the type binding
 * @param range the compilation unit range
 * @return the created type variable, or <code>null</code>
 */
public final ConstraintVariable2 createTypeVariable(ITypeBinding type, final CompilationUnitRange range) {
	if (type.isArray())
		type= type.getElementType();
	if (isConstrainedType(type))
		return fConstraintVariables.addExisting(new TypeVariable2(createTType(type), range));
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:SuperTypeConstraintsModel.java

示例7: rewriteConstraintVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
private static ParameterizedType rewriteConstraintVariable(ConstraintVariable2 cv, CompilationUnitRewrite rewrite, InferTypeArgumentsTCModel tCModel, boolean leaveUnconstraindRaw, SimpleType[] types) {
	if (cv instanceof CollectionElementVariable2) {
		ConstraintVariable2 parentElement= ((CollectionElementVariable2) cv).getParentConstraintVariable();
		if (parentElement instanceof TypeVariable2) {
			TypeVariable2 typeCv= (TypeVariable2) parentElement;
			return rewriteTypeVariable(typeCv, rewrite, tCModel, leaveUnconstraindRaw, types);
		} else {
			//only rewrite type variables
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:InferTypeArgumentsRefactoring.java

示例8: rewriteTypeVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
private static ParameterizedType rewriteTypeVariable(TypeVariable2 typeCv, CompilationUnitRewrite rewrite, InferTypeArgumentsTCModel tCModel, boolean leaveUnconstraindRaw, SimpleType[] types) {
	ASTNode node= typeCv.getRange().getNode(rewrite.getRoot());
	if (node instanceof Name && node.getParent() instanceof Type) {
		Type originalType= (Type) node.getParent();

		if (types != null && !has(types, originalType))
			return null;

		// Must rewrite all type arguments in one batch. Do the rewrite when the first one is encountered; skip the others.
		Object rewritten= originalType.getProperty(REWRITTEN);
		if (rewritten == REWRITTEN)
			return null;
		originalType.setProperty(REWRITTEN, REWRITTEN);

		ArrayList<CollectionElementVariable2> typeArgumentCvs= getTypeArgumentCvs(typeCv, tCModel);
		Type[] typeArguments= getTypeArguments(originalType, typeArgumentCvs, rewrite, tCModel, leaveUnconstraindRaw);
		if (typeArguments == null)
			return null;

		Type movingType= (Type) rewrite.getASTRewrite().createMoveTarget(originalType);
		ParameterizedType newType= rewrite.getAST().newParameterizedType(movingType);

		for (int i= 0; i < typeArguments.length; i++) {
			newType.typeArguments().add(typeArguments[i]);
		}

		rewrite.getASTRewrite().replace(originalType, newType, rewrite.createGroupDescription(RefactoringCoreMessages.InferTypeArgumentsRefactoring_addTypeArguments));
		return newType;
	}  else {//TODO: other node types?
		return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:33,代码来源:InferTypeArgumentsRefactoring.java

示例9: endVisit

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
@Override
public void endVisit(ArrayCreation node) {
	ArrayType arrayType= node.getType();
	TypeVariable2 arrayTypeCv= (TypeVariable2) getConstraintVariable(arrayType);
	if (arrayTypeCv == null)
		return;
	setConstraintVariable(node, arrayTypeCv);
	//TODO: constraints for array initializer?
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:InferTypeArgumentsConstraintCreator.java

示例10: createExceptionVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
/**
 * Creates an exception variable.
 *
 * @param name the name of the thrown exception
 * @return the created exception variable
 */
public final ConstraintVariable2 createExceptionVariable(final Name name) {
	final ITypeBinding binding= name.resolveTypeBinding();
	if (isConstrainedType(binding))
		return fConstraintVariables.addExisting(new TypeVariable2(createTType(binding), new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(name), name)));
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:13,代码来源:SuperTypeConstraintsModel.java

示例11: createTypeVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
/**
 * Creates a type variable.
 *
 * @param type the type binding
 * @param range the compilation unit range
 * @return the created type variable
 */
public final ConstraintVariable2 createTypeVariable(ITypeBinding type, final CompilationUnitRange range) {
	if (type.isArray())
		type= type.getElementType();
	if (isConstrainedType(type))
		return fConstraintVariables.addExisting(new TypeVariable2(createTType(type), range));
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:15,代码来源:SuperTypeConstraintsModel.java

示例12: rewriteTypeVariable

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2; //导入依赖的package包/类
private static ParameterizedType rewriteTypeVariable(
    TypeVariable2 typeCv,
    CompilationUnitRewrite rewrite,
    InferTypeArgumentsTCModel tCModel,
    boolean leaveUnconstraindRaw,
    SimpleType[] types) {
  ASTNode node = typeCv.getRange().getNode(rewrite.getRoot());
  if (node instanceof Name && node.getParent() instanceof Type) {
    Type originalType = (Type) node.getParent();

    if (types != null && !has(types, originalType)) return null;

    // Must rewrite all type arguments in one batch. Do the rewrite when the first one is
    // encountered; skip the others.
    Object rewritten = originalType.getProperty(REWRITTEN);
    if (rewritten == REWRITTEN) return null;
    originalType.setProperty(REWRITTEN, REWRITTEN);

    ArrayList<CollectionElementVariable2> typeArgumentCvs = getTypeArgumentCvs(typeCv, tCModel);
    Type[] typeArguments =
        getTypeArguments(originalType, typeArgumentCvs, rewrite, tCModel, leaveUnconstraindRaw);
    if (typeArguments == null) return null;

    Type movingType = (Type) rewrite.getASTRewrite().createMoveTarget(originalType);
    ParameterizedType newType = rewrite.getAST().newParameterizedType(movingType);

    for (int i = 0; i < typeArguments.length; i++) {
      newType.typeArguments().add(typeArguments[i]);
    }

    rewrite
        .getASTRewrite()
        .replace(
            originalType,
            newType,
            rewrite.createGroupDescription(
                RefactoringCoreMessages.InferTypeArgumentsRefactoring_addTypeArguments));
    return newType;
  } else { // TODO: other node types?
    return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:43,代码来源:InferTypeArgumentsRefactoring.java


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