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


Java JCTree.JCVariableDecl方法代碼示例

本文整理匯總了Java中com.sun.tools.javac.tree.JCTree.JCVariableDecl方法的典型用法代碼示例。如果您正苦於以下問題:Java JCTree.JCVariableDecl方法的具體用法?Java JCTree.JCVariableDecl怎麽用?Java JCTree.JCVariableDecl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sun.tools.javac.tree.JCTree的用法示例。


在下文中一共展示了JCTree.JCVariableDecl方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: runField

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
private void runField(String code) throws IOException {
    String src = prefix +
            code + "; }" +
            postfix;

    try (JavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, fm, null, null,
                null, Arrays.asList(new MyFileObject(src)));

        for (CompilationUnitTree cut : ct.parse()) {
            JCTree.JCVariableDecl var =
                    (JCTree.JCVariableDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
            checkMatch(code, var);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:TypeAnnotationsPretty.java

示例2: run

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
void run(String code) throws IOException {
    String src = "public class Test {" + code + ";}";

    JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
            null, Arrays.asList(new MyFileObject(src)));

    for (CompilationUnitTree cut : ct.parse()) {
        JCTree.JCVariableDecl var =
                (JCTree.JCVariableDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);

        if (!code.equals(var.toString())) {
            System.err.println("Expected: " + code);
            System.err.println("Obtained: " + var.toString());
            throw new RuntimeException("strings do not match!");
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:NewArrayPretty.java

示例3: visitVarDef

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
@Override public void visitVarDef(JCTree.JCVariableDecl jcVariableDecl) {
  if ("int".equals(jcVariableDecl.getType().toString())) {
    int id = Integer.valueOf(jcVariableDecl.getInitializer().toString());
    String resourceName = jcVariableDecl.getName().toString();
    QualifiedId qualifiedId = new QualifiedId(respectivePackageName, id);
    ids.put(qualifiedId, new Id(id, className, resourceName));
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:ButterKnifeProcessor.java

示例4: visitVariable

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
@Override
@CheckForNull
public Void visitVariable(@NonNull final VariableTree node, @NonNull final Map<Pair<BinaryName, String>, UsagesData<String>> p) {
    Symbol s = ((JCTree.JCVariableDecl)node).sym;
    if (s != null && s.owner != null && (s.owner.getKind().isClass() || s.owner.getKind().isInterface())) {
        addIdent(activeClass.peek(), node.getName(), p, true);
    }
    return super.visitVariable(node, p);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:SourceAnalyzerFactory.java

示例5: visitVarDef

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
@Override
public void visitVarDef(JCTree.JCVariableDecl jcVariableDecl) {
    if ("int".equals(jcVariableDecl.getType().toString())) {
        int id = Integer.valueOf(jcVariableDecl.getInitializer().toString());
        String resourceName = jcVariableDecl.getName().toString();
        QualifiedId qualifiedId = new QualifiedId(respectivePackageName, id);
        ids.put(qualifiedId, new Id(id, className, resourceName));
    }
}
 
開發者ID:hendraanggrian,項目名稱:r-parser,代碼行數:10,代碼來源:VarScanner.java

示例6: visitIdent

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
/**
 * Erase all structural interface type literals to Object
 */
@Override
public void visitIdent( JCTree.JCIdent tree )
{
  super.visitIdent( tree );

  if( _tp.isGenerate() && !shouldProcessForGeneration() )
  {
    // Don't process tree during GENERATE, unless the tree was generated e.g., a bridge method
    return;
  }

  if( tree.sym != null && TypeUtil.isStructuralInterface( _tp, tree.sym ) && !isReceiver( tree ) )
  {
    Symbol.ClassSymbol objectSym = getObjectClass();
    Tree parent = _tp.getParent( tree );
    JCTree.JCIdent objIdent = _tp.getTreeMaker().Ident( objectSym );
    if( parent instanceof JCTree.JCVariableDecl )
    {
      ((JCTree.JCVariableDecl)parent).type = objectSym.type;

      long parameterModifier = 8589934592L; // Flag.Flag.PARAMETER.value
      if( (((JCTree.JCVariableDecl)parent).mods.flags & parameterModifier) != 0 )
      {
        objIdent.type = objectSym.type;
        ((JCTree.JCVariableDecl)parent).sym.type = objectSym.type;
        ((JCTree.JCVariableDecl)parent).vartype = objIdent;
      }
    }
    else if( parent instanceof JCTree.JCWildcard )
    {
      JCTree.JCWildcard wildcard = (JCTree.JCWildcard)parent;
      wildcard.type = new Type.WildcardType( objectSym.type, wildcard.kind.kind, wildcard.type.tsym );
    }
    tree = objIdent;
    tree.type = objectSym.type;
  }
  result = tree;
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:42,代碼來源:ExtensionTransformer.java

示例7: visitSelect

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
/**
 * Erase all structural interface type literals to Object
 */
@Override
public void visitSelect( JCTree.JCFieldAccess tree )
{
  super.visitSelect( tree );

  if( _tp.isGenerate() && !shouldProcessForGeneration() )
  {
    // Don't process tree during GENERATE, unless the tree was generated e.g., a bridge method
    return;
  }

  if( TypeUtil.isStructuralInterface( _tp, tree.sym ) && !isReceiver( tree ) )
  {
    Symbol.ClassSymbol objectSym = getObjectClass();
    JCTree.JCIdent objIdent = _tp.getTreeMaker().Ident( objectSym );
    Tree parent = _tp.getParent( tree );
    if( parent instanceof JCTree.JCVariableDecl )
    {
      ((JCTree.JCVariableDecl)parent).type = objectSym.type;
      long parameterModifier = 8589934592L; // Flag.Flag.PARAMETER.value
      if( (((JCTree.JCVariableDecl)parent).mods.flags & parameterModifier) != 0 )
      {
        objIdent.type = objectSym.type;
        ((JCTree.JCVariableDecl)parent).sym.type = objectSym.type;
        ((JCTree.JCVariableDecl)parent).vartype = objIdent;
      }
    }
    else if( parent instanceof JCTree.JCWildcard )
    {
      JCTree.JCWildcard wildcard = (JCTree.JCWildcard)parent;
      wildcard.type = new Type.WildcardType( objectSym.type, wildcard.kind.kind, wildcard.type.tsym );
    }
    result = objIdent;
  }
  else
  {
    result = tree;
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:43,代碼來源:ExtensionTransformer.java


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