本文整理匯總了Java中com.sun.tools.javac.util.List類的典型用法代碼示例。如果您正苦於以下問題:Java List類的具體用法?Java List怎麽用?Java List使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
List類屬於com.sun.tools.javac.util包,在下文中一共展示了List類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: replaceExtCall
import com.sun.tools.javac.util.List; //導入依賴的package包/類
private void replaceExtCall( JCTree.JCMethodInvocation tree, Symbol.MethodSymbol method )
{
JCExpression methodSelect = tree.getMethodSelect();
if( methodSelect instanceof JCTree.JCFieldAccess )
{
JCTree.JCFieldAccess m = (JCTree.JCFieldAccess)methodSelect;
boolean isStatic = m.sym.getModifiers().contains( javax.lang.model.element.Modifier.STATIC );
TreeMaker make = _tp.getTreeMaker();
JavacElements javacElems = _tp.getElementUtil();
JCExpression thisArg = m.selected;
String extensionFqn = method.getEnclosingElement().asType().tsym.toString();
m.selected = memberAccess( make, javacElems, extensionFqn );
BasicJavacTask javacTask = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getJavacTask();
Symbol.ClassSymbol extensionClassSym = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getClassSymbol( javacTask, extensionFqn ).getFirst();
assignTypes( m.selected, extensionClassSym );
m.sym = method;
m.type = method.type;
if( !isStatic )
{
ArrayList<JCExpression> newArgs = new ArrayList<>( tree.args );
newArgs.add( 0, thisArg );
tree.args = List.from( newArgs );
}
}
}
示例2: printImportsBlock
import com.sun.tools.javac.util.List; //導入依賴的package包/類
public void printImportsBlock(java.util.List<? extends JCTree> imports, boolean maybeAppendNewLine) {
boolean hasImports = !imports.isEmpty();
CodeStyle.ImportGroups importGroups = null;
if (hasImports) {
blankLines(Math.max(cs.getBlankLinesBeforeImports(), diffContext.origUnit.getPackageName() != null ? cs.getBlankLinesAfterPackage() : 0));
if (cs.separateImportGroups())
importGroups = cs.getImportGroups();
}
int lastGroup = -1;
for (JCTree importStat : imports) {
if (importGroups != null) {
Name name = fullName(((JCImport)importStat).qualid);
int group = name != null ? importGroups.getGroupId(name.toString(), ((JCImport)importStat).staticImport) : -1;
if (lastGroup >= 0 && lastGroup != group)
blankline();
lastGroup = group;
}
printStat(importStat);
newline();
}
if (hasImports && maybeAppendNewLine) {
blankLines(cs.getBlankLinesAfterImports());
}
}
示例3: classOrInterfaceBody
import com.sun.tools.javac.util.List; //導入依賴的package包/類
/** ClassBody = "{" {ClassBodyDeclaration} "}"
* InterfaceBody = "{" {InterfaceBodyDeclaration} "}"
*/
List<JCTree> classOrInterfaceBody(Name className, boolean isInterface) {
accept(LBRACE);
if (S.pos() <= errorEndPos) {
// error recovery
skip(false, true, false, false);
if (S.token() == LBRACE)
S.nextToken();
}
ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
while (S.token() != RBRACE && S.token() != EOF) {
defs.appendList(classOrInterfaceBodyDeclaration(className, isInterface));
if (S.pos() <= errorEndPos) {
// error recovery
skip(false, true, true, false);
}
}
accept(RBRACE);
return defs.toList();
}
示例4: addOverrideBridges
import com.sun.tools.javac.util.List; //導入依賴的package包/類
private void addOverrideBridges(DiagnosticPosition pos,
MethodSymbol impl,
MethodSymbol member,
ClassSymbol c,
ListBuffer<JCTree> bridges) {
Type implErasure = impl.erasure(types);
long flags = (impl.flags() & AccessFlags) | SYNTHETIC | BRIDGE | OVERRIDE_BRIDGE;
member = new MethodSymbol(flags, member.name, member.type, c);
JCMethodDecl md = make.MethodDef(member, null);
JCExpression receiver = make.Super(types.supertype(c.type).tsym.erasure(types), c);
Type calltype = erasure(impl.type.getReturnType());
JCExpression call =
make.Apply(null,
make.Select(receiver, impl).setType(calltype),
translateArgs(make.Idents(md.params),
implErasure.getParameterTypes(), null))
.setType(calltype);
JCStatement stat = (member.getReturnType().tag == VOID)
? make.Exec(call)
: make.Return(coerce(call, member.erasure(types).getReturnType()));
md.body = make.Block(0, List.of(stat));
c.members().enter(member);
bridges.append(md);
}
示例5: solveLegacy
import com.sun.tools.javac.util.List; //導入依賴的package包/類
/**
* Instantiate inference variables in legacy mode (JLS 15.12.2.7, 15.12.2.8).
* During overload resolution, instantiation is done by doing a partial
* inference process using eq/lower bound instantiation. During check,
* we also instantiate any remaining vars by repeatedly using eq/upper
* instantiation, until all variables are solved.
*/
public void solveLegacy(boolean partial, Warner warn, EnumSet<InferenceStep> steps) {
while (true) {
List<Type> solvedVars = solveBasic(steps);
if (restvars().isEmpty() || partial) {
//all variables have been instantiated - exit
break;
} else if (solvedVars.isEmpty()) {
//some variables could not be instantiated because of cycles in
//upper bounds - provide a (possibly recursive) default instantiation
infer.instantiateAsUninferredVars(restvars(), this);
break;
} else {
//some variables have been instantiated - replace newly instantiated
//variables in remaining upper bounds and continue
for (Type t : undetvars) {
UndetVar uv = (UndetVar)t;
uv.substBounds(solvedVars, asInstTypes(solvedVars), types);
}
}
}
infer.doIncorporation(this, warn);
}
示例6: notifyChange
import com.sun.tools.javac.util.List; //導入依賴的package包/類
void notifyChange(List<Type> inferredVars) {
InferenceException thrownEx = null;
for (Map.Entry<FreeTypeListener, List<Type>> entry :
new HashMap<FreeTypeListener, List<Type>>(freeTypeListeners).entrySet()) {
if (!Type.containsAny(entry.getValue(), inferencevars.diff(inferredVars))) {
try {
entry.getKey().typesInferred(this);
freeTypeListeners.remove(entry.getKey());
} catch (InferenceException ex) {
if (thrownEx == null) {
thrownEx = ex;
}
}
}
}
//inference exception multiplexing - present any inference exception
//thrown when processing listeners as a single one
if (thrownEx != null) {
throw thrownEx;
}
}
示例7: list
import com.sun.tools.javac.util.List; //導入依賴的package包/類
@Override
public Iterable<JavaFileObject> list(Location location,
String packageName, Set<Kind> kinds, boolean recurse)
throws IOException {
// validatePackageName(packageName);
nullCheck(packageName);
nullCheck(kinds);
Iterable<? extends Path> paths = getLocation(location);
if (paths == null)
return List.nil();
ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>();
for (Path path : paths)
list(path, packageName, kinds, recurse, results);
return results.toList();
}
示例8: translateArgs
import com.sun.tools.javac.util.List; //導入依賴的package包/類
/** Translate method argument list, casting each argument
* to its corresponding type in a list of target types.
* @param _args The method argument list.
* @param parameters The list of target types.
* @param varargsElement The erasure of the varargs element type,
* or null if translating a non-varargs invocation
*/
<T extends JCTree> List<T> translateArgs(List<T> _args,
List<Type> parameters,
Type varargsElement) {
if (parameters.isEmpty()) return _args;
List<T> args = _args;
while (parameters.tail.nonEmpty()) {
args.head = translate(args.head, parameters.head);
args = args.tail;
parameters = parameters.tail;
}
Type parameter = parameters.head;
Assert.check(varargsElement != null || args.length() == 1);
if (varargsElement != null) {
while (args.nonEmpty()) {
args.head = translate(args.head, varargsElement);
args = args.tail;
}
} else {
args.head = translate(args.head, parameter);
}
return _args;
}
示例9: maximizeInst
import com.sun.tools.javac.util.List; //導入依賴的package包/類
/** Instantiate undetermined type variable to its minimal upper bound.
* Throw a NoInstanceException if this not possible.
*/
void maximizeInst(UndetVar that, Warner warn) throws NoInstanceException {
List<Type> hibounds = Type.filter(that.hibounds, errorFilter);
if (that.inst == null) {
if (hibounds.isEmpty())
that.inst = syms.objectType;
else if (hibounds.tail.isEmpty())
that.inst = hibounds.head;
else
that.inst = types.glb(hibounds);
}
if (that.inst == null ||
that.inst.isErroneous())
throw ambiguousNoInstanceException
.setMessage("no.unique.maximal.instance.exists",
that.qtype, hibounds);
}
示例10: isFirstStatementThisOrSuperCall
import com.sun.tools.javac.util.List; //導入依賴的package包/類
private static boolean isFirstStatementThisOrSuperCall(@NotNull JCTree.JCBlock body) {
List<JCTree.JCStatement> statements = body.getStatements();
if (statements.isEmpty()) {
return false;
}
JCTree.JCStatement expressionCandidate = statements.get(0);
if (expressionCandidate instanceof ExpressionStatementTree) {
ExpressionStatementTree expression = (ExpressionStatementTree) expressionCandidate;
ExpressionTree methodInvocationCandidate = expression.getExpression();
if (methodInvocationCandidate instanceof MethodInvocationTree) {
MethodInvocationTree methodInvocation = (MethodInvocationTree) methodInvocationCandidate;
ExpressionTree methodSelect = methodInvocation.getMethodSelect();
if (methodSelect != null) {
String select = methodSelect.toString();
return "this".equals(select) || "super".equals(select);
}
}
}
return false;
}
示例11: switchBlockStatementGroups
import com.sun.tools.javac.util.List; //導入依賴的package包/類
/** SwitchBlockStatementGroups = { SwitchBlockStatementGroup }
* SwitchBlockStatementGroup = SwitchLabel BlockStatements
* SwitchLabel = CASE ConstantExpression ":" | DEFAULT ":"
*/
List<JCCase> switchBlockStatementGroups() {
ListBuffer<JCCase> cases = new ListBuffer<JCCase>();
while (true) {
int pos = token.pos;
switch (token.kind) {
case CASE:
case DEFAULT:
cases.append(switchBlockStatementGroup());
break;
case RBRACE: case EOF:
return cases.toList();
default:
nextToken(); // to ensure progress
syntaxError(pos, "expected3",
CASE, DEFAULT, RBRACE);
}
}
}
示例12: implementInterfaceMethods
import com.sun.tools.javac.util.List; //導入依賴的package包/類
/**
* Add abstract methods for all methods defined in one of
* the interfaces of a given class,
* provided they are not already implemented in the class.
*
* @param c The class whose interfaces are searched for methods
* for which Miranda methods should be added.
* @param site The class in which a definition may be needed.
*/
void implementInterfaceMethods(ClassSymbol c, ClassSymbol site) {
for (List<Type> l = types.interfaces(c.type); l.nonEmpty(); l = l.tail) {
ClassSymbol i = (ClassSymbol) l.head.tsym;
for (Scope.Entry e = i.members().elems;
e != null;
e = e.sibling) {
if (e.sym.kind == MTH && (e.sym.flags() & STATIC) == 0) {
MethodSymbol absMeth = (MethodSymbol) e.sym;
MethodSymbol implMeth = absMeth.binaryImplementation(site, types);
if (implMeth == null)
addAbstractMethod(site, absMeth);
else if ((implMeth.flags() & IPROXY) != 0)
adjustAbstractMethod(site, implMeth, absMeth);
}
}
implementInterfaceMethods(i, site);
}
}
示例13: JCMethodInvocation
import com.sun.tools.javac.util.List; //導入依賴的package包/類
protected JCMethodInvocation(List<JCExpression> typeargs,
JCExpression meth,
List<JCExpression> args)
{
this.typeargs = (typeargs == null) ? List.nil()
: typeargs;
this.meth = meth;
this.args = args;
}
示例14: makeOwnerThisN
import com.sun.tools.javac.util.List; //導入依賴的package包/類
/**
* Similar to makeOwnerThis but will never pick "this".
*/
JCExpression makeOwnerThisN(DiagnosticPosition pos, Symbol sym, boolean preciseMatch) {
Symbol c = sym.owner;
List<VarSymbol> ots = outerThisStack;
if (ots.isEmpty()) {
log.error(pos, Errors.NoEnclInstanceOfTypeInScope(c));
Assert.error();
return makeNull();
}
VarSymbol ot = ots.head;
JCExpression tree = access(make.at(pos).Ident(ot));
TypeSymbol otc = ot.type.tsym;
while (!(preciseMatch ? sym.isMemberOf(otc, types) : otc.isSubClass(sym.owner, types))) {
do {
ots = ots.tail;
if (ots.isEmpty()) {
log.error(pos, Errors.NoEnclInstanceOfTypeInScope(c));
Assert.error();
return tree;
}
ot = ots.head;
} while (ot.owner != otc);
tree = access(make.at(pos).Select(tree, ot));
otc = ot.type.tsym;
}
return tree;
}
示例15: typeVarToString
import com.sun.tools.javac.util.List; //導入依賴的package包/類
/**
* Return the string form of a type variable along with any
* "extends" clause. Class names are qualified if "full" is true.
*/
static String typeVarToString(DocEnv env, TypeVar v, boolean full) {
StringBuilder s = new StringBuilder(v.toString());
List<Type> bounds = getBounds(v, env);
if (bounds.nonEmpty()) {
boolean first = true;
for (Type b : bounds) {
s.append(first ? " extends " : " & ");
s.append(TypeMaker.getTypeString(env, b, full));
first = false;
}
}
return s.toString();
}