本文整理汇总了Java中com.sun.tools.javac.util.ListBuffer类的典型用法代码示例。如果您正苦于以下问题:Java ListBuffer类的具体用法?Java ListBuffer怎么用?Java ListBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListBuffer类属于com.sun.tools.javac.util包,在下文中一共展示了ListBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClasses
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
/**
* Return a list of all classes contained in this package, including
* member classes of those classes, and their member classes, etc.
*/
private List<ClassDocImpl> getClasses(boolean filtered) {
if (allClasses != null && !filtered) {
return allClasses;
}
if (allClassesFiltered != null && filtered) {
return allClassesFiltered;
}
ListBuffer<ClassDocImpl> classes = new ListBuffer<>();
for (Symbol enumerated : sym.members().getSymbols(NON_RECURSIVE)) {
if (enumerated != null) {
ClassSymbol s = (ClassSymbol)enumerated;
ClassDocImpl c = env.getClassDoc(s);
if (c != null && !c.isSynthetic())
c.addAllClasses(classes, filtered);
}
}
if (filtered)
return allClassesFiltered = classes.toList();
else
return allClasses = classes.toList();
}
示例2: processConstants
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
ListBuffer<JCTree> processConstants(Element constNode, HashMap<String, Integer> scope) {
String baseName = constNode.getAttribute("basename");
int count = 1;
try {
count = Integer.parseInt(constNode.getAttribute("count"));
} catch (Exception e) {} // nothing to do, will use count = 1
long declFlags = Flags.PUBLIC | Flags.STATIC | Flags.FINAL | Flags.ENUM;
ListBuffer<JCTree> fields = new ListBuffer<>();
for (int i = 0; i < count; i++) {
String declName = baseName +
((count == 1) ? "" : getUniqIndex(scope, baseName));
JCVariableDecl constDecl = make.VarDef(
make.Modifiers(declFlags),
names.fromString(declName),
null, // no need for type in enum decl
null); // no init
fields.append(constDecl);
}
return fields;
}
示例3: parse
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
/**
* Process Win32-style command files for the specified command line
* arguments and return the resulting arguments. A command file argument
* is of the form '@file' where 'file' is the name of the file whose
* contents are to be parsed for additional arguments. The contents of
* the command file are parsed using StreamTokenizer and the original
* '@file' argument replaced with the resulting tokens. Recursive command
* files are not supported. The '@' character itself can be quoted with
* the sequence '@@'.
*/
public static String[] parse(String[] args)
throws IOException {
ListBuffer<String> newArgs = new ListBuffer<String>();
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.length() > 1 && arg.charAt(0) == '@') {
arg = arg.substring(1);
if (arg.charAt(0) == '@') {
newArgs.append(arg);
} else {
loadCmdFile(arg, newArgs);
}
} else {
newArgs.append(arg);
}
}
return newArgs.toList().toArray(new String[newArgs.length()]);
}
示例4: parseFiles
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
/**
* Parses a list of files.
*/
public List<JCCompilationUnit> parseFiles(Iterable<JavaFileObject> fileObjects) {
if (shouldStop(CompileState.PARSE))
return List.nil();
//parse all files
ListBuffer<JCCompilationUnit> trees = lb();
Set<JavaFileObject> filesSoFar = new HashSet<JavaFileObject>();
for (JavaFileObject fileObject : fileObjects) {
if (!filesSoFar.contains(fileObject)) {
filesSoFar.add(fileObject);
trees.append(parse(fileObject));
}
}
return trees.toList();
}
示例5: list
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
@Override
public Iterable<JavaFileObject> list(Location location,
String packageName,
Set<Kind> kinds,
boolean recurse)
throws IOException
{
// Acquire the list of files.
Iterable<JavaFileObject> files = super.list(location, packageName, kinds, recurse);
if (visibleSources.isEmpty()) {
return files;
}
// Now filter!
ListBuffer<JavaFileObject> filteredFiles = new ListBuffer<JavaFileObject>();
for (JavaFileObject f : files) {
URI uri = f.toUri();
String t = uri.toString();
if (t.startsWith("jar:")
|| t.endsWith(".class")
|| visibleSources.contains(uri))
{
filteredFiles.add(f);
}
}
return filteredFiles;
}
示例6: getClassLoader
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public ClassLoader getClassLoader(Location location) {
checkNotModuleOrientedLocation(location);
Iterable<? extends File> path = getLocation(location);
if (path == null)
return null;
ListBuffer<URL> lb = new ListBuffer<>();
for (File f: path) {
try {
lb.append(f.toURI().toURL());
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
}
return getClassLoader(lb.toArray(new URL[lb.size()]));
}
示例7: processParams
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
List<JCVariableDecl> processParams(String paramTypes) {
if ("none".equals(paramTypes))
return List.<JCVariableDecl>nil(); // empty
String[] typesArr = paramTypes.split(",(?!(\\w+,)*\\w+>)");
ListBuffer<JCVariableDecl> paramsDecls = new ListBuffer<>();
int i = 0;
for (String typeName : typesArr) {
String paramName = "param"
+ (typesArr.length == 1 ? "" : String.valueOf(i));
paramsDecls.add(
make.VarDef(make.Modifiers(0),
names.fromString(paramName),
make.Type(getTypeByName(typeName)),
null));
i++;
}
return paramsDecls.toList();
}
示例8: closureMin
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
/**
* Return the minimum types of a closure, suitable for computing
* compoundMin or glb.
*/
private List<Type> closureMin(List<Type> cl) {
ListBuffer<Type> classes = lb();
ListBuffer<Type> interfaces = lb();
while (!cl.isEmpty()) {
Type current = cl.head;
if (current.isInterface())
interfaces.append(current);
else
classes.append(current);
ListBuffer<Type> candidates = lb();
for (Type t : cl.tail) {
if (!isSubtypeNoCapture(current, t))
candidates.append(t);
}
cl = candidates.toList();
}
return classes.appendList(interfaces).toList();
}
示例9: freshTypeVariables
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
public List<Type> freshTypeVariables(List<Type> types) {
ListBuffer<Type> result = lb();
for (Type t : types) {
if (t.tag == WILDCARD) {
Type bound = ((WildcardType)t).getExtendsBound();
if (bound == null)
bound = syms.objectType;
result.append(new CapturedType(capturedName,
syms.noSymbol,
bound,
syms.botType,
(WildcardType)t));
} else {
result.append(t);
}
}
return result.toList();
}
示例10: visitClassType
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
@Override
public Type visitClassType(ClassType t, Void s) {
ListBuffer<Type> rewritten = new ListBuffer<Type>();
boolean changed = false;
for (Type arg : t.allparams()) {
Type bound = visit(arg);
if (arg != bound) {
changed = true;
}
rewritten.append(bound);
}
if (changed)
return subst(t.tsym.type,
t.tsym.type.allparams(),
rewritten.toList());
else
return t;
}
示例11: testRemove
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
private static void testRemove() {
ListBuffer<String> lb1 = new ListBuffer<>();
lb1.add("a");
lb1.add("b");
lb1.add("c");
assertListEquals(lb1.toList(), "a", "b", "c");
assertEquals(lb1.next(), "a");
assertListEquals(lb1.toList(), "b", "c");
assertEquals(lb1.next(), "b");
assertListEquals(lb1.toList(), "c");
assertEquals(lb1.next(), "c");
assertListEquals(lb1.toList());
assertEquals(lb1.next(), null);
lb1.add("d");
assertEquals(lb1.next(), "d");
}
示例12: list
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
public Iterable<JavaFileObject> list(Location location,
String packageName,
Set<JavaFileObject.Kind> kinds,
boolean recurse)
throws IOException {
// validatePackageName(packageName);
nullCheck(packageName);
nullCheck(kinds);
Iterable<? extends File> path = getLocation(location);
if (path == null)
return List.nil();
RelativeDirectory subdirectory = RelativeDirectory.forPackage(packageName);
ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>();
for (File directory : path)
listContainer(directory, subdirectory, kinds, recurse, results);
return results.toList();
}
示例13: loadCmdFile
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
private static void loadCmdFile(String name, ListBuffer<String> args)
throws IOException
{
Reader r = new BufferedReader(new FileReader(name));
StreamTokenizer st = new StreamTokenizer(r);
st.resetSyntax();
st.wordChars(' ', 255);
st.whitespaceChars(0, ' ');
st.commentChar('#');
st.quoteChar('"');
st.quoteChar('\'');
while (st.nextToken() != StreamTokenizer.TT_EOF) {
args.append(st.sval);
}
r.close();
}
示例14: getClasses
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
/**
* Return a list of all classes contained in this package, including
* member classes of those classes, and their member classes, etc.
*/
private List<ClassDocImpl> getClasses(boolean filtered) {
if (allClasses != null && !filtered) {
return allClasses;
}
if (allClassesFiltered != null && filtered) {
return allClassesFiltered;
}
ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
if (e.sym != null) {
ClassSymbol s = (ClassSymbol)e.sym;
ClassDocImpl c = env.getClassDoc(s);
if (c != null && !c.isSynthetic())
c.addAllClasses(classes, filtered);
}
}
if (filtered)
return allClassesFiltered = classes.toList();
else
return allClasses = classes.toList();
}
示例15: getClassLoader
import com.sun.tools.javac.util.ListBuffer; //导入依赖的package包/类
public ClassLoader getClassLoader(Location location) {
nullCheck(location);
Iterable<? extends File> path = getLocation(location);
if (path == null)
return null;
ListBuffer<URL> lb = new ListBuffer<URL>();
for (File f: path) {
try {
lb.append(f.toURI().toURL());
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
}
return getClassLoader(lb.toArray(new URL[lb.size()]));
}