本文整理汇总了Java中com.sun.tools.javac.util.List.size方法的典型用法代码示例。如果您正苦于以下问题:Java List.size方法的具体用法?Java List.size怎么用?Java List.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.util.List
的用法示例。
在下文中一共展示了List.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_retainAll_Collection
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void test_retainAll_Collection() {
System.err.println("test retainAll(Collection)");
for (List<String> l: examples.values()) {
int l_size = l.size();
for (java.util.List<String> arg: examples.keySet()) {
try {
boolean modified = l.retainAll(arg);
if (modified)
throw new AssertionError();
} catch (UnsupportedOperationException e) {
}
if (l.size() != l_size)
throw new AssertionError();
}
}
}
示例2: test_addAll_Collection
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void test_addAll_Collection() {
System.err.println("test addAll(Collection)");
for (List<String> l: examples.values()) {
int l_size = l.size();
for (java.util.List<String> arg: examples.keySet()) {
try {
boolean modified = l.addAll(arg);
if (modified)
throw new AssertionError();
} catch (UnsupportedOperationException e) {
}
if (l.size() != l_size)
throw new AssertionError();
}
}
}
示例3: test_addAll_int_Collection
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void test_addAll_int_Collection() {
System.err.println("test addAll(int,Collection)");
for (List<String> l: examples.values()) {
int l_size = l.size();
for (java.util.List<String> arg: examples.keySet()) {
try {
boolean modified = l.addAll(0, arg);
if (modified)
throw new AssertionError();
} catch (UnsupportedOperationException e) {
}
if (l.size() != l_size)
throw new AssertionError();
}
}
}
示例4: test_removeAll_Collection
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void test_removeAll_Collection() {
System.err.println("test removeAll(Collection)");
for (List<String> l: examples.values()) {
int l_size = l.size();
for (java.util.List<String> arg: examples.keySet()) {
try {
boolean modified = l.removeAll(arg);
if (modified)
throw new AssertionError();
} catch (UnsupportedOperationException e) {
}
if (l.size() != l_size)
throw new AssertionError();
}
}
}
示例5: test_size
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void test_size() {
System.err.println("test size()");
for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
java.util.List<String> ref = e.getKey();
List<String> l = e.getValue();
int expect = ref.size();
int found = l.size();
if (expect != found)
throw new AssertionError();
}
}
示例6: mayBeInstrument
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
@Override
protected boolean mayBeInstrument(@NotNull ReturnToInstrumentInfo info) {
ReturnInstrumentationAstParent parent
= info.getParent().accept(new MethodInstrumentationParentFinder(info), null);
if (parent == null) {
return false;
}
Optional<List<JCTree.JCStatement>> returnCheckOptional = buildReturnCheck(info);
if (!returnCheckOptional.isPresent()) {
return false;
}
List<JCTree.JCStatement> statements = parent.getStatements();
for (int i = 0; i < statements.size(); i++) {
JCTree.JCStatement statement = statements.get(i);
if (statement == info.getReturnExpression()) {
List<JCTree.JCStatement> newStatements = returnCheckOptional.get();
for (int j = i + 1; j < statements.size(); j++) {
newStatements = newStatements.append(statements.get(j));
}
for (int j = i - 1; j >= 0; j--) {
newStatements = newStatements.prepend(statements.get(j));
}
parent.setStatements(newStatements);
mayBeLogInstrumentation(info);
return true;
}
}
// When control flow reaches this place, that means that the AST parent doesn't contain any statments, so,
// we just populate it with new instructions.
parent.setStatements(returnCheckOptional.get());
mayBeLogInstrumentation(info);
return true;
}
示例7: test
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void test(List<String> list) {
int n = list.size();
if (n > 0)
test(list, new String[0]);
if (n > 1)
test(list, new String[n - 1]);
test(list, new String[n]);
test(list, new String[n + 1]);
test(list, new String[n + 5]);
}
示例8: catchClause
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** CatchClause = CATCH "(" FormalParameter ")" Block
* TODO: the "FormalParameter" is not correct, it uses the special "catchTypes" rule below.
*/
protected JCCatch catchClause() {
int pos = token.pos;
accept(CATCH);
accept(LPAREN);
JCModifiers mods = optFinal(Flags.PARAMETER);
List<JCExpression> catchTypes = catchTypes();
JCExpression paramType = catchTypes.size() > 1 ?
toP(F.at(catchTypes.head.getStartPosition()).TypeUnion(catchTypes)) :
catchTypes.head;
JCVariableDecl formal = variableDeclaratorId(mods, paramType);
accept(RPAREN);
JCBlock body = block();
return F.at(pos).Catch(formal, body);
}
示例9: test_reverse
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void test_reverse() {
System.err.println("test reverse()");
for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
java.util.List<String> ref = e.getKey();
List<String> l = e.getValue();
java.util.List<String> expect = reverse(ref);
List<String> found = l.reverse();
if (l.size() < 2 && found != l) // reverse of empty or singleton list is itself
throw new AssertionError();
if (!equal(l, ref)) // orginal should be unchanged
throw new AssertionError();
if (!equal(expect, found))
throw new AssertionError();
}
}
示例10: hasParameterTypes
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** @see com.sun.tools.javadoc.ClassDocImpl */
private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) {
if (paramTypes == null)
return true;
if (method.params().size() != paramTypes.size())
return false;
List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes();
return (Type.isErroneous(paramTypes))
? fuzzyMatch(paramTypes, methodParamTypes)
: types.isSameTypes(paramTypes, methodParamTypes);
}
示例11: checkDefaultMethodClashes
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void checkDefaultMethodClashes(DiagnosticPosition pos, Type site) {
DefaultMethodClashFilter dcf = new DefaultMethodClashFilter(site);
for (Symbol m : types.membersClosure(site, false).getElements(dcf)) {
Assert.check(m.kind == MTH);
List<MethodSymbol> prov = types.interfaceCandidates(site, (MethodSymbol)m);
if (prov.size() > 1) {
ListBuffer<Symbol> abstracts = new ListBuffer<>();
ListBuffer<Symbol> defaults = new ListBuffer<>();
for (MethodSymbol provSym : prov) {
if ((provSym.flags() & DEFAULT) != 0) {
defaults = defaults.append(provSym);
} else if ((provSym.flags() & ABSTRACT) != 0) {
abstracts = abstracts.append(provSym);
}
if (defaults.nonEmpty() && defaults.size() + abstracts.size() >= 2) {
//strong semantics - issue an error if two sibling interfaces
//have two override-equivalent defaults - or if one is abstract
//and the other is default
String errKey;
Symbol s1 = defaults.first();
Symbol s2;
if (defaults.size() > 1) {
errKey = "types.incompatible.unrelated.defaults";
s2 = defaults.toList().tail.head;
} else {
errKey = "types.incompatible.abstract.default";
s2 = abstracts.first();
}
log.error(pos, errKey,
Kinds.kindName(site.tsym), site,
m.name, types.memberType(site, m).getParameterTypes(),
s1.location(), s2.location());
break;
}
}
}
}
}
示例12: visitNewArray
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
public void visitNewArray(JCNewArray tree) {
try {
if (tree.elemtype != null) {
print("new ");
JCTree elem = tree.elemtype;
printBaseElementType(elem);
if (!tree.annotations.isEmpty()) {
print(' ');
printTypeAnnotations(tree.annotations);
}
if (tree.elems != null) {
print("[]");
}
int i = 0;
List<List<JCAnnotation>> da = tree.dimAnnotations;
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
if (da.size() > i && !da.get(i).isEmpty()) {
print(' ');
printTypeAnnotations(da.get(i));
}
print("[");
i++;
printExpr(l.head);
print("]");
}
printBrackets(elem);
}
if (tree.elems != null) {
print("{");
printExprs(tree.elems);
print("}");
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例13: checkDefaultMethodClashes
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void checkDefaultMethodClashes(DiagnosticPosition pos, Type site) {
DefaultMethodClashFilter dcf = new DefaultMethodClashFilter(site);
for (Symbol m : types.membersClosure(site, false).getSymbols(dcf)) {
Assert.check(m.kind == MTH);
List<MethodSymbol> prov = types.interfaceCandidates(site, (MethodSymbol)m);
if (prov.size() > 1) {
ListBuffer<Symbol> abstracts = new ListBuffer<>();
ListBuffer<Symbol> defaults = new ListBuffer<>();
for (MethodSymbol provSym : prov) {
if ((provSym.flags() & DEFAULT) != 0) {
defaults = defaults.append(provSym);
} else if ((provSym.flags() & ABSTRACT) != 0) {
abstracts = abstracts.append(provSym);
}
if (defaults.nonEmpty() && defaults.size() + abstracts.size() >= 2) {
//strong semantics - issue an error if two sibling interfaces
//have two override-equivalent defaults - or if one is abstract
//and the other is default
String errKey;
Symbol s1 = defaults.first();
Symbol s2;
if (defaults.size() > 1) {
errKey = "types.incompatible.unrelated.defaults";
s2 = defaults.toList().tail.head;
} else {
errKey = "types.incompatible.abstract.default";
s2 = abstracts.first();
}
log.error(pos, errKey,
Kinds.kindName(site.tsym), site,
m.name, types.memberType(site, m).getParameterTypes(),
s1.location(), s2.location());
break;
}
}
}
}
}
示例14: isApplicable
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
boolean isApplicable(TypeConfiguration that) {
List<TypeKind> actuals = that.typeKindList;
List<TypeKind> formals = parameterTypes.typeKindList;
if ((actuals.size() - formals.size()) < -1)
return false; //not enough args
for (TypeKind actual : actuals) {
if (!actual.isSubtypeOf(formals.head))
return false; //type mismatch
formals = formals.tail.isEmpty() ?
formals :
formals.tail;
}
return true;
}
示例15: test_clear
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void test_clear() {
System.err.println("test clear()");
for (List<String> l: examples.values()) {
int l_size = l.size();
try {
l.clear();
if (l_size > 0)
throw new AssertionError();
} catch (UnsupportedOperationException e) {
}
if (l.size() != l_size)
throw new AssertionError();
}
}