當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。