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


Java JCTree.JCClassDecl方法代碼示例

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


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

示例1: visitClassDef

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
@Override
public void visitClassDef( JCTree.JCClassDecl tree )
{
  super.visitClassDef( tree );
  if( tree.sym != null && !tree.sym.isInner() )
  {
    if( !hasNoBootstrap( tree.getModifiers().getAnnotations() ) )
    {
      JCTree.JCStatement newNode = buildBootstrapStaticBlock();
      ArrayList<JCTree> newDefs = new ArrayList<>( tree.defs );
      newDefs.add( 0, newNode );
      tree.defs = List.from( newDefs );
    }
  }
  result = tree;
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:17,代碼來源:BootstrapInserter.java

示例2: makeStubFromSource

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
private SrcClass makeStubFromSource()
{
  List<CompilationUnitTree> trees = new ArrayList<>();
  JavaParser.instance().parseText( _existingSource, trees, null, null, null );
  JCTree.JCClassDecl classDecl = (JCTree.JCClassDecl)trees.get( 0 ).getTypeDecls().get( 0 );
  SrcClass srcExtended = new SrcClass( _fqn, classDecl.getKind() == Tree.Kind.CLASS ? SrcClass.Kind.Class : SrcClass.Kind.Interface )
    .modifiers( classDecl.getModifiers().getFlags() );
  if( classDecl.extending != null )
  {
    srcExtended.superClass( classDecl.extending.toString() );
  }
  for( JCTree.JCExpression iface : classDecl.implementing )
  {
    srcExtended.addInterface( iface.toString() );
  }
  return srcExtended;
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:18,代碼來源:ExtCodeGen.java

示例3: getClassDecl

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
private JCTree.JCClassDecl getClassDecl( Model model )
{
  JCTree.JCClassDecl classDecl = model.getClassDecl();
  if( classDecl != null )
  {
    return classDecl;
  }

  List<CompilationUnitTree> trees = new ArrayList<>();
  JavaParser.instance().parseText( getSource( model ), trees, null, null, null );
  if( trees.isEmpty() )
  {
    return null;
  }
  classDecl = (JCTree.JCClassDecl)trees.get( 0 ).getTypeDecls().get( 0 );
  model.setClassDecl( classDecl );
  return classDecl;
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:19,代碼來源:DarkJavaTypeManifold.java

示例4: addInputFile

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
private void addInputFile( TaskEvent e )
{
  if( !_initialized )
  {
    CompilationUnitTree compilationUnit = e.getCompilationUnit();
    ExpressionTree pkg = compilationUnit.getPackageName();
    String packageQualifier = pkg == null ? "" : (pkg.toString() + '.');
    for( Tree classDecl : compilationUnit.getTypeDecls() )
    {
      if( classDecl instanceof JCTree.JCClassDecl )
      {
        _javaInputFiles.add( new Pair<>( packageQualifier + ((JCTree.JCClassDecl)classDecl).getSimpleName(), compilationUnit.getSourceFile() ) );
      }
    }
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:17,代碼來源:JavacPlugin.java

示例5: visitClassDef

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
@Override public void visitClassDef(JCTree.JCClassDecl jcClassDecl) {
  for (JCTree tree : jcClassDecl.defs) {
    if (tree instanceof ClassTree) {
      ClassTree classTree = (ClassTree) tree;
      String className = classTree.getSimpleName().toString();
      if (SUPPORTED_TYPES.contains(className)) {
        ClassName rClassName = ClassName.get(rPackageName, "R", className);
        VarScanner scanner = new VarScanner(ids, rClassName, respectivePackageName);
        ((JCTree) classTree).accept(scanner);
      }
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:ButterKnifeProcessor.java

示例6: visitClassDef

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
@Override
public void visitClassDef(JCTree.JCClassDecl jcClassDecl) {
    for (JCTree tree : jcClassDecl.defs) {
        if (tree instanceof ClassTree) {
            ClassTree classTree = (ClassTree) tree;
            String className = classTree.getSimpleName().toString();
            if (supportedTypes.contains(className)) {
                ClassName rClassName = ClassName.get(rPackageName, "R", className);
                VarScanner scanner = new VarScanner(ids, rClassName, respectivePackageName);
                ((JCTree) classTree).accept(scanner);
            }
        }
    }
}
 
開發者ID:hendraanggrian,項目名稱:r-parser,代碼行數:15,代碼來源:IdScanner.java

示例7: preserveInnerClassesForGeneration

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
private void preserveInnerClassesForGeneration( JCTree.JCClassDecl tree )
{
  for( JCTree def: tree.defs )
  {
    if( def instanceof JCTree.JCClassDecl )
    {
      JCTree.JCClassDecl classDecl = (JCTree.JCClassDecl)def;

      preserveInnerClassForGenerationPhase( classDecl );
      preserveInnerClassesForGeneration( classDecl );
    }
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:14,代碼來源:CompiledTypeProcessor.java

示例8: visitClassDef

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
@Override
public void visitClassDef( JCTree.JCClassDecl tree )
{
  super.visitClassDef( tree );

  verifyExtensionInterfaces( tree );
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:8,代碼來源:ExtensionTransformer.java

示例9: verifyExtensionInterfaces

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
private void verifyExtensionInterfaces( JCTree.JCClassDecl tree )
{
  if( !hasAnnotation( tree.getModifiers().getAnnotations(), Extension.class ) )
  {
    return;
  }

  outer:
  for( JCExpression iface: tree.getImplementsClause() )
  {
    final Symbol.TypeSymbol ifaceSym = iface.type.tsym;
    if( ifaceSym == _tp.getSymtab().objectType.tsym )
    {
      continue;
    }

    for( Attribute.Compound anno: ifaceSym.getAnnotationMirrors() )
    {
      if( anno.type.toString().equals( Structural.class.getName() ) )
      {
        continue outer;
      }
    }
    // extension interfaces must be structural
    _tp.report( iface, Diagnostic.Kind.ERROR, ExtIssueMsg.MSG_ONLY_STRUCTURAL_INTERFACE_ALLOWED_HERE.get( iface.toString() ) );
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:28,代碼來源:ExtensionTransformer.java

示例10: 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

示例11: 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

示例12: isInnerType

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
@Override
protected boolean isInnerType( String topLevel, String relativeInner )
{
  if( isAnonymous( relativeInner ) )
  {
    return true;
  }

  Model model = getModel( topLevel );
  if( model == null )
  {
    return false;
  }

  JCTree.JCClassDecl classDecl = getClassDecl( model );
  if( classDecl == null )
  {
    return false;
  }

  for( JCTree m: classDecl.getMembers() )
  {
    if( m instanceof JCTree.JCClassDecl )
    {
      return isInnerClass( (JCTree.JCClassDecl)m, relativeInner );
    }
  }

  return false;
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:31,代碼來源:DarkJavaTypeManifold.java

示例13: process

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
private void process( TaskEvent e )
{
  Set<String> typesToProcess = new HashSet<>();
  ExpressionTree pkg = e.getCompilationUnit().getPackageName();
  String packageQualifier = pkg == null ? "" : (pkg.toString() + '.');
  for( Tree classDecl : e.getCompilationUnit().getTypeDecls() )
  {
    if( classDecl instanceof JCTree.JCClassDecl )
    {
      typesToProcess.add( packageQualifier + ((JCTree.JCClassDecl)classDecl).getSimpleName() );
      insertBootstrap( (JCTree.JCClassDecl)classDecl );
    }
  }
  _typeProcessor.addTypesToProcess( typesToProcess );
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:16,代碼來源:JavacPlugin.java

示例14: getClassDecl

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
public JCTree.JCClassDecl getClassDecl( Tree node )
{
  if( node == null || node instanceof JCTree.JCCompilationUnit )
  {
    return null;
  }

  if( node instanceof JCTree.JCClassDecl )
  {
    return (JCTree.JCClassDecl)node;
  }

  return getClassDecl( getParent( node ) );
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:15,代碼來源:CompiledTypeProcessor.java

示例15: AnonymousClassListener

import com.sun.tools.javac.tree.JCTree; //導入方法依賴的package包/類
public AnonymousClassListener( JCTree.JCClassDecl tree )
{
  _tree = tree;
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:5,代碼來源:CompiledTypeProcessor.java


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