本文整理了Java中com.sun.tools.javac.util.List.length()
方法的一些代码示例,展示了List.length()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.length()
方法的具体详情如下:
包路径:com.sun.tools.javac.util.List
类名称:List
方法名:length
[英]Return the number of elements in this list.
[中]返回此列表中的元素数。
代码示例来源:origin: uber/NullAway
private boolean thriftIsSetCall(Symbol.MethodSymbol symbol, Types types) {
Preconditions.checkNotNull(tbaseType);
// noinspection ConstantConditions
return tbaseType.isPresent()
&& symbol.getSimpleName().toString().startsWith("isSet")
// weeds out the isSet() method in TBase itself
&& symbol.getParameters().length() == 0
&& types.isSubtype(symbol.owner.type, tbaseType.get());
}
}
代码示例来源:origin: uber/NullAway
if (streamType.isFilterMethod(methodSymbol) && methodSymbol.getParameters().length() == 1) {
ExpressionTree argTree = tree.getArguments().get(0);
if (argTree instanceof NewClassTree) {
&& methodSymbol.getParameters().length() == 1) {
ExpressionTree argTree = tree.getArguments().get(0);
if (argTree instanceof NewClassTree) {
代码示例来源:origin: google/error-prone
int varargsPosition = params.length() - 1;
ArrayType varargsParamType = (ArrayType) params.last().type;
List<JCExpression> arguments = methodInvocation.getArguments();
Types types = state.getTypes();
if (arguments.size() != params.length()) {
return false;
代码示例来源:origin: cincheo/jsweet
/**
* Tells if the given method has varargs.
*/
public static boolean hasVarargs(MethodSymbol methodSymbol) {
return methodSymbol != null && methodSymbol.getParameters().length() > 0
&& (methodSymbol.flags() & Flags.VARARGS) != 0;
}
代码示例来源:origin: cincheo/jsweet
/**
* Tells if the method uses a type parameter.
*/
public static boolean hasTypeParameters(MethodSymbol methodSymbol) {
if (methodSymbol != null && methodSymbol.getParameters().length() > 0) {
for (VarSymbol p : methodSymbol.getParameters()) {
if (p.type instanceof TypeVar) {
return true;
}
}
}
return false;
}
代码示例来源:origin: cincheo/jsweet
/**
* Transforms a list of source files to Java file objects (used by javac).
*/
public static com.sun.tools.javac.util.List<JavaFileObject> toJavaFileObjects(JavaFileManager fileManager,
Collection<File> sourceFiles) throws IOException {
com.sun.tools.javac.util.List<JavaFileObject> fileObjects = com.sun.tools.javac.util.List.nil();
JavacFileManager javacFileManager = (JavacFileManager) fileManager;
for (JavaFileObject fo : javacFileManager.getJavaFileObjectsFromFiles(sourceFiles)) {
fileObjects = fileObjects.append(fo);
}
if (fileObjects.length() != sourceFiles.size()) {
throw new IOException("invalid file list");
}
return fileObjects;
}
代码示例来源:origin: cincheo/jsweet
/**
* Tells if a method can be invoked with some given parameter types.
*
* @param types
* a reference to the types in the compilation scope
* @param from
* the caller method signature to test (contains the parameter types)
* @param target
* the callee method signature
* @return true if the callee can be invoked by the caller
*/
public static boolean isInvocable(Types types, MethodType from, MethodType target) {
if (from.getParameterTypes().length() != target.getParameterTypes().length()) {
return false;
}
for (int i = 0; i < from.getParameterTypes().length(); i++) {
if (!types.isAssignable(types.erasure(from.getParameterTypes().get(i)),
types.erasure(target.getParameterTypes().get(i)))) {
return false;
}
}
return true;
}
代码示例来源:origin: cincheo/jsweet
for (int i = 0; i < compilationUnits.length(); i++) {
try {
JCCompilationUnit cu = compilationUnits.get(i);
代码示例来源:origin: cincheo/jsweet
.print(",");
if (typeApply.arguments.length() > 0) {
removeLastChar();
print("|");
if (typeApply.arguments.length() > 0) {
removeLastChar();
print("p0 : number");
} else {
printArguments(typeApply.arguments.subList(0, typeApply.arguments.length() - 1));
substituteAndPrintType(typeApply.arguments.get(typeApply.arguments.length() - 1),
arrayComponent, inTypeParameters, completeRawTypes, false);
if (arrayComponent) {
substituteAndPrintType(argument, arrayComponent, false, completeRawTypes, false).print(", ");
if (typeApply.arguments.length() > 0) {
removeLastChars(2);
for (int i = 0; i < typeTree.type.tsym.getTypeParameters().length(); i++) {
print("any, ");
代码示例来源:origin: cincheo/jsweet
defaultValues.put(i, expr);
} else {
if (!(expr instanceof JCIdent && i < methodDecl.params.length()
&& methodDecl.params.get(i).name
.equals(((JCIdent) expr).name))) {
代码示例来源:origin: cincheo/jsweet
if (newClass.args.length() >= 3) {
getPrinter().print("((str, index, len) => ").print("str.substring(index, index + len))((")
.print(newClass.args.head).print(")");
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
private void adaptRecursive(List<Type> source, List<Type> target) {
if (source.length() == target.length()) {
while (source.nonEmpty()) {
adaptRecursive(source.head, target.head);
source = source.tail;
target = target.tail;
}
}
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public UndetVar(TypeVar origin, Types types) {
super(UNDETVAR, origin);
bounds = new EnumMap<InferenceBound, List<Type>>(InferenceBound.class);
List<Type> declaredBounds = types.getBounds(origin);
declaredCount = declaredBounds.length();
bounds.put(InferenceBound.UPPER, declaredBounds);
bounds.put(InferenceBound.LOWER, List.<Type>nil());
bounds.put(InferenceBound.EQ, List.<Type>nil());
}
代码示例来源:origin: cincheo/jsweet
if (anonymousClassIndex != -1) {
for (int i = 0; i < getScope(1).anonymousClassesConstructors.get(anonymousClassIndex).args
.length(); i++) {
if (!hasArgs) {
hasArgs = true;
.length(); i++) {
if (hasArg) {
print(", ");
代码示例来源:origin: cincheo/jsweet
for (int i = 0; i < newClass.args.length() - 1; i++) {
print(", ").print(newClass.args.get(i));
printAnyTypeArguments(((ClassSymbol) newClass.clazz.type.tsym).getTypeParameters().length());
代码示例来源:origin: sc.fiji/javac
public void visitArrayAttributeProxy(ArrayAttributeProxy proxy) {
int length = proxy.values.length();
Attribute[] ats = new Attribute[length];
Type elemtype = types.elemtype(type);
int i = 0;
for (List<Attribute> p = proxy.values; p.nonEmpty(); p = p.tail) {
ats[i++] = deproxy(elemtype, p.head);
}
result = new Attribute.Array(type, ats);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public void visitArrayAttributeProxy(ArrayAttributeProxy proxy) {
int length = proxy.values.length();
Attribute[] ats = new Attribute[length];
Type elemtype = types.elemtype(type);
int i = 0;
for (List<Attribute> p = proxy.values; p.nonEmpty(); p = p.tail) {
ats[i++] = deproxy(elemtype, p.head);
}
result = new Attribute.Array(type, ats);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/** Write a compound attribute excluding the '@' marker. */
void writeCompoundAttribute(Attribute.Compound c) {
databuf.appendChar(pool.put(typeSig(c.type)));
databuf.appendChar(c.values.length());
for (Pair<Symbol.MethodSymbol,Attribute> p : c.values) {
databuf.appendChar(pool.put(p.fst.name));
p.snd.accept(awriter);
}
}
代码示例来源:origin: sc.fiji/javac
/** Write a compound attribute excluding the '@' marker. */
void writeCompoundAttribute(Attribute.Compound c) {
databuf.appendChar(pool.put(typeSig(c.type)));
databuf.appendChar(c.values.length());
for (Pair<Symbol.MethodSymbol,Attribute> p : c.values) {
databuf.appendChar(pool.put(p.fst.name));
p.snd.accept(awriter);
}
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/** Write a compound attribute excluding the '@' marker. */
void writeCompoundAttribute(Attribute.Compound c) {
databuf.appendChar(pool.put(typeSig(c.type)));
databuf.appendChar(c.values.length());
for (Pair<Symbol.MethodSymbol,Attribute> p : c.values) {
databuf.appendChar(pool.put(p.fst.name));
p.snd.accept(awriter);
}
}
内容来源于网络,如有侵权,请联系作者删除!