本文整理汇总了Java中com.sun.tools.javac.util.List.prepend方法的典型用法代码示例。如果您正苦于以下问题:Java List.prepend方法的具体用法?Java List.prepend怎么用?Java List.prepend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.util.List
的用法示例。
在下文中一共展示了List.prepend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addZipEntry
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
@Override
void addZipEntry(ZipEntry entry) {
String name = entry.getName();
if (!name.startsWith(prefix.path)) {
return;
}
name = name.substring(prefix.path.length());
int i = name.lastIndexOf('/');
RelativeDirectory dirname = new RelativeDirectory(name.substring(0, i+1));
String basename = name.substring(i + 1);
if (basename.length() == 0) {
return;
}
List<String> list = map.get(dirname);
if (list == null)
list = List.nil();
list = list.prepend(basename);
map.put(dirname, list);
}
示例2: enterClassFiles
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Enter a set of generated class files. */
private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
ClassReader reader = ClassReader.instance(context);
Names names = Names.instance(context);
List<ClassSymbol> list = List.nil();
for (Map.Entry<String,JavaFileObject> entry : classFiles.entrySet()) {
Name name = names.fromString(entry.getKey());
JavaFileObject file = entry.getValue();
if (file.getKind() != JavaFileObject.Kind.CLASS)
throw new AssertionError(file);
ClassSymbol cs;
if (isPkgInfo(file, JavaFileObject.Kind.CLASS)) {
Name packageName = Convert.packagePart(name);
PackageSymbol p = reader.enterPackage(packageName);
if (p.package_info == null)
p.package_info = reader.enterClass(Convert.shortName(name), p);
cs = p.package_info;
if (cs.classfile == null)
cs.classfile = file;
} else
cs = reader.enterClass(name, file);
list = list.prepend(cs);
}
return list.reverse();
}
示例3: retrieveRequiresTransitive
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private Set<ModuleSymbol> retrieveRequiresTransitive(ModuleSymbol msym) {
Set<ModuleSymbol> requiresTransitive = requiresTransitiveCache.get(msym);
if (requiresTransitive == null) {
//the module graph may contain cycles involving automatic modules or --add-reads edges
requiresTransitive = new HashSet<>();
Set<ModuleSymbol> seen = new HashSet<>();
List<ModuleSymbol> todo = List.of(msym);
while (todo.nonEmpty()) {
ModuleSymbol current = todo.head;
todo = todo.tail;
if (!seen.add(current))
continue;
requiresTransitive.add(current);
current.complete();
Iterable<? extends RequiresDirective> requires;
if (current != syms.unnamedModule) {
Assert.checkNonNull(current.requires, () -> current + ".requires == null; " + msym);
requires = current.requires;
for (RequiresDirective rd : requires) {
if (rd.isTransitive())
todo = todo.prepend(rd.module);
}
} else {
for (ModuleSymbol mod : allModules()) {
todo = todo.prepend(mod);
}
}
}
requiresTransitive.remove(msym);
}
return requiresTransitive;
}
示例4: addZipEntry
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void addZipEntry(ZipEntry entry) {
String name = entry.getName();
int i = name.lastIndexOf('/');
RelativeDirectory dirname = new RelativeDirectory(name.substring(0, i+1));
String basename = name.substring(i+1);
if (basename.length() == 0)
return;
List<String> list = map.get(dirname);
if (list == null)
list = List.nil();
list = list.prepend(basename);
map.put(dirname, list);
}
示例5: checkVisible
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private void checkVisible(DiagnosticPosition pos, Symbol what, PackageSymbol inPackage, boolean inSuperType) {
if (!isAPISymbol(what) && !inSuperType) { //package private/private element
log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessible(kindName(what), what, what.packge().modle));
return ;
}
PackageSymbol whatPackage = what.packge();
ExportsDirective whatExport = findExport(whatPackage);
ExportsDirective inExport = findExport(inPackage);
if (whatExport == null) { //package not exported:
log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleUnexported(kindName(what), what, what.packge().modle));
return ;
}
if (whatExport.modules != null) {
if (inExport.modules == null || !whatExport.modules.containsAll(inExport.modules)) {
log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleUnexportedQualified(kindName(what), what, what.packge().modle));
}
}
if (whatPackage.modle != inPackage.modle && whatPackage.modle != syms.java_base) {
//check that relativeTo.modle requires transitive what.modle, somehow:
List<ModuleSymbol> todo = List.of(inPackage.modle);
while (todo.nonEmpty()) {
ModuleSymbol current = todo.head;
todo = todo.tail;
if (current == whatPackage.modle)
return ; //OK
for (RequiresDirective req : current.requires) {
if (req.isTransitive()) {
todo = todo.prepend(req.module);
}
}
}
log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleNotRequiredTransitive(kindName(what), what, what.packge().modle));
}
}
示例6: DefaultConstructor
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Generate default constructor for given class. For classes different
* from java.lang.Object, this is:
*
* c(argtype_0 x_0, ..., argtype_n x_n) throws thrown {
* super(x_0, ..., x_n)
* }
*
* or, if based == true:
*
* c(argtype_0 x_0, ..., argtype_n x_n) throws thrown {
* x_0.super(x_1, ..., x_n)
* }
*
* @param make The tree factory.
* @param c The class owning the default constructor.
* @param argtypes The parameter types of the constructor.
* @param thrown The thrown exceptions of the constructor.
* @param based Is first parameter a this$n?
*/
JCTree DefaultConstructor(TreeMaker make,
ClassSymbol c,
List<Type> typarams,
List<Type> argtypes,
List<Type> thrown,
long flags,
boolean based) {
List<JCVariableDecl> params = make.Params(argtypes, syms.noSymbol);
List<JCStatement> stats = List.nil();
if (c.type != syms.objectType)
stats = stats.prepend(SuperCall(make, typarams, params, based));
if ((c.flags() & ENUM) != 0 &&
(types.supertype(c.type).tsym == syms.enumSym ||
target.compilerBootstrap(c))) {
// constructors of true enums are private
flags = (flags & ~AccessFlags) | PRIVATE | GENERATEDCONSTR;
} else
flags |= (c.flags() & AccessFlags) | GENERATEDCONSTR;
if (c.name.isEmpty()) flags |= ANONCONSTR;
JCTree result = make.MethodDef(
make.Modifiers(flags),
names.init,
null,
make.TypeParams(typarams),
params,
make.Types(thrown),
make.Block(0, stats),
null);
return result;
}
示例7: insert
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/**
* Insert a type in a closure
*/
public List<Type> insert(List<Type> cl, Type t) {
if (cl.isEmpty() || t.tsym.precedes(cl.head.tsym, this)) {
return cl.prepend(t);
} else if (cl.head.tsym.precedes(t.tsym, this)) {
return insert(cl.tail, t).prepend(cl.head);
} else {
return cl;
}
}
示例8: listPackageModules
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
public List<ModuleSymbol> listPackageModules(Name packageName) {
if (packageName.isEmpty())
return List.nil();
List<ModuleSymbol> result = List.nil();
Map<ModuleSymbol,PackageSymbol> map = packages.get(packageName);
if (map != null) {
for (Map.Entry<ModuleSymbol, PackageSymbol> e: map.entrySet()) {
if (!e.getValue().members().isEmpty()) {
result = result.prepend(e.getKey());
}
}
}
return result;
}
示例9: checkNonCyclic1
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private void checkNonCyclic1(DiagnosticPosition pos, Type t, List<TypeVar> seen) {
final TypeVar tv;
if (t.hasTag(TYPEVAR) && (t.tsym.flags() & UNATTRIBUTED) != 0)
return;
if (seen.contains(t)) {
tv = (TypeVar)t.unannotatedType();
tv.bound = types.createErrorType(t);
log.error(pos, "cyclic.inheritance", t);
} else if (t.hasTag(TYPEVAR)) {
tv = (TypeVar)t.unannotatedType();
seen = seen.prepend(tv);
for (Type b : types.getBounds(tv))
checkNonCyclic1(pos, b, seen);
}
}
示例10: excl
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Remove type set from type set list.
*/
List<Type> excl(Type t, List<Type> ts) {
if (ts.isEmpty()) {
return ts;
} else {
List<Type> ts1 = excl(t, ts.tail);
if (types.isSubtype(ts.head, t)) return ts1;
else if (ts1 == ts.tail) return ts;
else return ts1.prepend(ts.head);
}
}
示例11: visitClassDef
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
@Override
public void visitClassDef(JCClassDecl tree) {
List<JCTree> supertypes = List.nil();
if (tree.getExtendsClause() != null) {
supertypes = supertypes.prepend(tree.getExtendsClause());
}
if (tree.getImplementsClause() != null) {
for (JCTree intf : tree.getImplementsClause()) {
supertypes = supertypes.prepend(intf);
}
}
checkClass(tree.pos(), tree.sym, supertypes);
}
示例12: visitExports
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
@Override
public void visitExports(JCExports tree) {
Iterable<Symbol> packageContent = tree.directive.packge.members().getSymbols();
List<JavaFileObject> filesToCheck = List.nil();
boolean packageNotEmpty = false;
for (Symbol sym : packageContent) {
if (sym.kind != Kinds.Kind.TYP)
continue;
ClassSymbol csym = (ClassSymbol) sym;
if (sym.completer.isTerminal() ||
csym.classfile.getKind() == Kind.CLASS) {
packageNotEmpty = true;
filesToCheck = List.nil();
break;
}
if (csym.classfile.getKind() == Kind.SOURCE) {
filesToCheck = filesToCheck.prepend(csym.classfile);
}
}
for (JavaFileObject jfo : filesToCheck) {
if (findPackageInFile.findPackageNameOf(jfo) == tree.directive.packge.fullname) {
packageNotEmpty = true;
break;
}
}
if (!packageNotEmpty) {
log.error(tree.qualid.pos(), Errors.PackageEmptyOrNotFound(tree.directive.packge));
}
msym.directives = msym.directives.prepend(tree.directive);
}
示例13: getTopLevelClasses
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) {
List<ClassSymbol> classes = List.nil();
for (JCCompilationUnit unit : units) {
for (JCTree node : unit.defs) {
if (node.hasTag(JCTree.Tag.CLASSDEF)) {
ClassSymbol sym = ((JCClassDecl) node).sym;
Assert.checkNonNull(sym);
classes = classes.prepend(sym);
}
}
}
return classes.reverse();
}
示例14: getTopLevelClassesFromClasses
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private List<ClassSymbol> getTopLevelClassesFromClasses(List<? extends ClassSymbol> syms) {
List<ClassSymbol> classes = List.nil();
for (ClassSymbol sym : syms) {
if (!isPkgInfo(sym)) {
classes = classes.prepend(sym);
}
}
return classes.reverse();
}
示例15: checkOverrideClashes
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Check that all non-override equivalent methods accessible from 'site'
* are mutually compatible (JLS 8.4.8/9.4.1).
*
* @param pos Position to be used for error reporting.
* @param site The class whose methods are checked.
* @param sym The method symbol to be checked.
*/
void checkOverrideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) {
ClashFilter cf = new ClashFilter(site);
//for each method m1 that is overridden (directly or indirectly)
//by method 'sym' in 'site'...
List<MethodSymbol> potentiallyAmbiguousList = List.nil();
boolean overridesAny = false;
for (Symbol m1 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) {
if (!sym.overrides(m1, site.tsym, types, false)) {
if (m1 == sym) {
continue;
}
if (!overridesAny) {
potentiallyAmbiguousList = potentiallyAmbiguousList.prepend((MethodSymbol)m1);
}
continue;
}
if (m1 != sym) {
overridesAny = true;
potentiallyAmbiguousList = List.nil();
}
//...check each method m2 that is a member of 'site'
for (Symbol m2 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) {
if (m2 == m1) continue;
//if (i) the signature of 'sym' is not a subsignature of m1 (seen as
//a member of 'site') and (ii) m1 has the same erasure as m2, issue an error
if (!types.isSubSignature(sym.type, types.memberType(site, m2), allowStrictMethodClashCheck) &&
types.hasSameArgs(m2.erasure(types), m1.erasure(types))) {
sym.flags_field |= CLASH;
String key = m1 == sym ?
"name.clash.same.erasure.no.override" :
"name.clash.same.erasure.no.override.1";
log.error(pos,
key,
sym, sym.location(),
m2, m2.location(),
m1, m1.location());
return;
}
}
}
if (!overridesAny) {
for (MethodSymbol m: potentiallyAmbiguousList) {
checkPotentiallyAmbiguousOverloads(pos, site, sym, m);
}
}
}