本文整理汇总了Java中com.google.errorprone.refaster.UTypeVar.TypeWithExpression类的典型用法代码示例。如果您正苦于以下问题:Java TypeWithExpression类的具体用法?Java TypeWithExpression怎么用?Java TypeWithExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeWithExpression类属于com.google.errorprone.refaster.UTypeVar包,在下文中一共展示了TypeWithExpression类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultAction
import com.google.errorprone.refaster.UTypeVar.TypeWithExpression; //导入依赖的package包/类
@Override
@Nullable
protected Unifier defaultAction(Tree target, @Nullable Unifier unifier) {
if (unifier != null) {
JCExpression expr = (JCExpression) target;
Type targetType = expr.type;
@Nullable
TypeWithExpression boundType = unifier.getBinding(key());
if (boundType == null) {
unifier.putBinding(key(), TypeWithExpression.create(targetType, expr));
return unifier;
} else if (unifier.types().isSameType(targetType, boundType.type())) {
return unifier;
}
}
return null;
}
示例2: defaultAction
import com.google.errorprone.refaster.UTypeVar.TypeWithExpression; //导入依赖的package包/类
@Override
protected Choice<Unifier> defaultAction(Tree target, Unifier unifier) {
JCExpression expr = (JCExpression) target;
Type targetType = expr.type;
if (targetType == null) {
return Choice.none();
}
@Nullable TypeWithExpression boundType = unifier.getBinding(key());
if (boundType == null) {
unifier.putBinding(
key(),
expr.accept(QUALIFIED_FROM_PACKAGE, null)
? TypeWithExpression.create(
targetType) /* use the ImportPolicy to refer to this type */
: TypeWithExpression.create(targetType, expr));
return Choice.of(unifier);
} else if (unifier.types().isSameType(targetType, boundType.type())) {
return Choice.of(unifier);
}
return Choice.none();
}
示例3: inlineTypeVar
import com.google.errorprone.refaster.UTypeVar.TypeWithExpression; //导入依赖的package包/类
Type inlineTypeVar(UTypeVar var) throws CouldNotResolveImportException {
Optional<TypeWithExpression> typeVarBinding = getOptionalBinding(var.key());
if (typeVarBinding.isPresent()) {
return typeVarBinding.get().type();
} else {
return inlineAsVar(var);
}
}
示例4: inline
import com.google.errorprone.refaster.UTypeVar.TypeWithExpression; //导入依赖的package包/类
@Test
public void inline() {
ImportPolicy.bind(context, ImportPolicy.IMPORT_TOP_LEVEL);
Symtab symtab = Symtab.instance(context);
Type listType = symtab.listType;
bind(new UTypeVar.Key("E"), TypeWithExpression.create(new ClassType(
listType, List.<Type>of(symtab.stringType), listType.tsym)));
assertInlines("List<String>", UTypeVarIdent.create("E"));
assertEquals(ImmutableSet.of("java.util.List"), inliner.getImportsToAdd());
}
示例5: inline
import com.google.errorprone.refaster.UTypeVar.TypeWithExpression; //导入依赖的package包/类
@Test
public void inline() {
ImportPolicy.bind(context, ImportPolicy.IMPORT_TOP_LEVEL);
Symtab symtab = Symtab.instance(context);
Type listType = symtab.listType;
bind(
new UTypeVar.Key("E"),
TypeWithExpression.create(
new ClassType(listType, List.<Type>of(symtab.stringType), listType.tsym)));
assertInlines("List<String>", UTypeVarIdent.create("E"));
assertEquals(ImmutableSet.of("java.util.List"), inliner.getImportsToAdd());
}