本文整理汇总了Java中com.sun.tools.javac.util.List.get方法的典型用法代码示例。如果您正苦于以下问题:Java List.get方法的具体用法?Java List.get怎么用?Java List.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.util.List
的用法示例。
在下文中一共展示了List.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: test_get_int
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
void test_get_int() {
System.err.println("test get(int)");
for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
java.util.List<String> ref = e.getKey();
List<String> l = e.getValue();
for (int i = -1; i <= ref.size(); i++) {
boolean expectException = i < 0 || i >= ref.size();
String expectValue = (expectException ? null : ref.get(i));
try {
String foundValue = l.get(i);
if (expectException || !equal(expectValue, foundValue))
throw new AssertionError();
} catch (IndexOutOfBoundsException ex) {
if (!expectException)
throw new AssertionError();
}
}
}
}
示例3: genSuperCtorCall
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private String genSuperCtorCall( Symbol.MethodSymbol superCtor )
{
String bodyStmt;
StringBuilder sb = new StringBuilder( "super(" );
List<Symbol.VarSymbol> parameters = superCtor.getParameters();
for( int i = 0; i < parameters.size(); i++ )
{
Symbol.VarSymbol param = parameters.get( i );
if( i > 0 )
{
sb.append( ", " );
}
sb.append( getValueForType( param.type ) );
}
sb.append( ");" );
bodyStmt = sb.toString();
return bodyStmt;
}
示例4: 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;
}
示例5: findExtMethod
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private Symbol.MethodSymbol findExtMethod( JCTree.JCMethodInvocation tree )
{
JCExpression methodSelect = tree.getMethodSelect();
if( methodSelect instanceof MemberSelectTree )
{
JCTree.JCFieldAccess meth = (JCTree.JCFieldAccess)tree.meth;
if( meth.sym == null || !meth.sym.hasAnnotations() )
{
return null;
}
for( Attribute.Compound annotation : meth.sym.getAnnotationMirrors() )
{
if( annotation.type.toString().equals( ExtensionMethod.class.getName() ) )
{
String extensionClass = (String)annotation.values.get( 0 ).snd.getValue();
boolean isStatic = (boolean)annotation.values.get( 1 ).snd.getValue();
BasicJavacTask javacTask = (BasicJavacTask)_tp.getJavacTask(); //JavacHook.instance() != null ? (JavacTaskImpl)JavacHook.instance().getJavacTask() : ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getJavacTask();
Symbol.ClassSymbol extClassSym = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getClassSymbol( javacTask, extensionClass ).getFirst();
if( extClassSym == null )
{
// This can happen during bootstrapping with Dark Java classes from Manifold itself
// e.g., ManResolve is a darkj class Manifold uses, ManResolve uses String, which may have an extension class which needs ManResole...
// So we short-circuit that here (ManResolve or any other darkj class used during bootstrapping doesn't really need to use extensions)
return null;
}
Types types = Types.instance( javacTask.getContext() );
outer:
for( Symbol elem : IDynamicJdk.instance().getMembers( extClassSym ) )
{
if( elem instanceof Symbol.MethodSymbol && elem.flatName().toString().equals( meth.sym.name.toString() ) )
{
Symbol.MethodSymbol extMethodSym = (Symbol.MethodSymbol)elem;
List<Symbol.VarSymbol> extParams = extMethodSym.getParameters();
List<Symbol.VarSymbol> calledParams = ((Symbol.MethodSymbol)meth.sym).getParameters();
int thisOffset = isStatic ? 0 : 1;
if( extParams.size() - thisOffset != calledParams.size() )
{
continue;
}
for( int i = thisOffset; i < extParams.size(); i++ )
{
Symbol.VarSymbol extParam = extParams.get( i );
Symbol.VarSymbol calledParam = calledParams.get( i - thisOffset );
if( !types.isSameType( types.erasure( extParam.type ), types.erasure( calledParam.type ) ) )
{
continue outer;
}
}
return extMethodSym;
}
}
}
}
}
return null;
}