當前位置: 首頁>>代碼示例>>Java>>正文


Java List.get方法代碼示例

本文整理匯總了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;
}
 
開發者ID:denis-zhdanov,項目名稱:traute,代碼行數:21,代碼來源:ParameterInstrumentator.java

示例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();
            }
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:TList.java

示例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;
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:19,代碼來源:SrcClassUtil.java

示例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;
}
 
開發者ID:denis-zhdanov,項目名稱:traute,代碼行數:34,代碼來源:MethodReturnInstrumentator.java

示例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;
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:57,代碼來源:ExtensionTransformer.java


注:本文中的com.sun.tools.javac.util.List.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。