当前位置: 首页>>代码示例>>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;未经允许,请勿转载。