当前位置: 首页>>代码示例>>Java>>正文


Java JCTree.JCMethodDecl方法代码示例

本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCMethodDecl方法的典型用法代码示例。如果您正苦于以下问题:Java JCTree.JCMethodDecl方法的具体用法?Java JCTree.JCMethodDecl怎么用?Java JCTree.JCMethodDecl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.tree.JCTree的用法示例。


在下文中一共展示了JCTree.JCMethodDecl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitMethod

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
@CheckForNull
public Void visitMethod(@NonNull final MethodTree node, @NonNull final Map<Pair<BinaryName,String>, UsagesData<String>> p) {
    Element old = enclosingElement;
    try {
        enclosingElement = ((JCTree.JCMethodDecl) node).sym;
        if (enclosingElement != null && enclosingElement.getKind() == ElementKind.METHOD) {
            mainMethod |= SourceUtils.isMainMethod((ExecutableElement) enclosingElement);
            // do not add idents for constructors, they always match their class' name, which is added as an ident separately
            addIdent(activeClass.peek(), node.getName(), p, true);
        }
        return super.visitMethod(node, p);
    } finally {
        enclosingElement = old;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SourceAnalyzerFactory.java

示例2: runMethod

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private void runMethod(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.JCMethodDecl meth =
                    (JCTree.JCMethodDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
            checkMatch(code, meth);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TypeAnnotationsPretty.java

示例3: isSynthetic

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
static boolean isSynthetic(CompilationInfo info, CompilationUnitTree cut, Tree leaf) throws NullPointerException {
    JCTree tree = (JCTree) leaf;
    
    if (tree.pos == (-1))
        return true;
    
    if (leaf.getKind() == Kind.METHOD) {
        //check for synthetic constructor:
        return (((JCTree.JCMethodDecl)leaf).mods.flags & Flags.GENERATEDCONSTR) != 0L;
    }
    
    //check for synthetic superconstructor call:
    if (leaf.getKind() == Kind.EXPRESSION_STATEMENT) {
        ExpressionStatementTree est = (ExpressionStatementTree) leaf;
        
        if (est.getExpression().getKind() == Kind.METHOD_INVOCATION) {
            MethodInvocationTree mit = (MethodInvocationTree) est.getExpression();
            
            if (mit.getMethodSelect().getKind() == Kind.IDENTIFIER) {
                IdentifierTree it = (IdentifierTree) mit.getMethodSelect();
                
                if ("super".equals(it.getName().toString())) {
                    SourcePositions sp = info.getTrees().getSourcePositions();
                    
                    return sp.getEndPosition(cut, leaf) == (-1);
                }
            }
        }
    }
    
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:JavaPluginUtils.java

示例4: visitMethodDef

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
/**
 * Issue errors/warnings if an extension method violates extension method grammar or conflicts with an existing method
 */
@Override
public void visitMethodDef( JCTree.JCMethodDecl tree )
{
  if( isBridgeMethod( tree ) )
  {
    // we process bridge methods during Generation, since they don't exist prior to Generation
    _bridgeMethod = true;
  }
  try
  {
    super.visitMethodDef( tree );
  }
  finally
  {
    _bridgeMethod = false;
  }

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

  if( tree.sym.owner.isAnonymous() )
  {
    // Keep track of anonymous classes so we can process any bridge methods added to them
    JCTree.JCClassDecl anonymousClassDef = (JCTree.JCClassDecl)_tp.getTreeUtil().getTree( tree.sym.owner );
    _tp.preserveInnerClassForGenerationPhase( anonymousClassDef );
  }

  verifyExtensionMethod( tree );
  result = tree;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:37,代码来源:ExtensionTransformer.java

示例5: isFromExtensionClass

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private boolean isFromExtensionClass( JCTree.JCMethodDecl tree )
{
  Tree parent = _tp.getParent( tree );
  if( parent instanceof JCTree.JCClassDecl )
  {
    if( hasAnnotation( ((JCTree.JCClassDecl)parent).getModifiers().getAnnotations(), Extension.class ) )
    {
      return true;
    }
  }
  return false;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:13,代码来源:ExtensionTransformer.java

示例6: isBridgeMethod

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private boolean isBridgeMethod( JCTree.JCMethodDecl tree )
{
  long modifiers = tree.getModifiers().flags;
  return (Flags.BRIDGE & modifiers) != 0;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:6,代码来源:ExtensionTransformer.java


注:本文中的com.sun.tools.javac.tree.JCTree.JCMethodDecl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。