本文整理匯總了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());
}