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


Java JCTree.JCFieldAccess方法代码示例

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


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

示例1: replaceExtCall

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private void replaceExtCall( JCTree.JCMethodInvocation tree, Symbol.MethodSymbol method )
{
  JCExpression methodSelect = tree.getMethodSelect();
  if( methodSelect instanceof JCTree.JCFieldAccess )
  {
    JCTree.JCFieldAccess m = (JCTree.JCFieldAccess)methodSelect;
    boolean isStatic = m.sym.getModifiers().contains( javax.lang.model.element.Modifier.STATIC );
    TreeMaker make = _tp.getTreeMaker();
    JavacElements javacElems = _tp.getElementUtil();
    JCExpression thisArg = m.selected;
    String extensionFqn = method.getEnclosingElement().asType().tsym.toString();
    m.selected = memberAccess( make, javacElems, extensionFqn );
    BasicJavacTask javacTask = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getJavacTask();
    Symbol.ClassSymbol extensionClassSym = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getClassSymbol( javacTask, extensionFqn ).getFirst();
    assignTypes( m.selected, extensionClassSym );
    m.sym = method;
    m.type = method.type;

    if( !isStatic )
    {
      ArrayList<JCExpression> newArgs = new ArrayList<>( tree.args );
      newArgs.add( 0, thisArg );
      tree.args = List.from( newArgs );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:27,代码来源:ExtensionTransformer.java

示例2: isStructuralMethod

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private boolean isStructuralMethod( JCTree.JCMethodInvocation tree )
{
  JCExpression methodSelect = tree.getMethodSelect();
  if( methodSelect instanceof JCTree.JCFieldAccess )
  {
    JCTree.JCFieldAccess m = (JCTree.JCFieldAccess)methodSelect;
    if( m.sym != null && !m.sym.getModifiers().contains( javax.lang.model.element.Modifier.STATIC ) )
    {
      JCExpression thisArg = m.selected;
      if( TypeUtil.isStructuralInterface( _tp, thisArg.type.tsym ) )
      {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:18,代码来源:ExtensionTransformer.java

示例3: visitSelect

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override public void visitSelect(JCTree.JCFieldAccess jcFieldAccess) {
  Symbol symbol = jcFieldAccess.sym;
  if (symbol != null
      && symbol.getEnclosingElement() != null
      && symbol.getEnclosingElement().getEnclosingElement() != null
      && symbol.getEnclosingElement().getEnclosingElement().enclClass() != null) {
    Set<String> rClassSet = rClasses.get(currentPackageName);
    if (rClassSet == null) {
      rClassSet = new HashSet<>();
      rClasses.put(currentPackageName, rClassSet);
    }
    rClassSet.add(symbol.getEnclosingElement().getEnclosingElement().enclClass().className());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ButterKnifeProcessor.java

示例4: buildExceptionClassExpression

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@NotNull
public static JCTree.JCExpression buildExceptionClassExpression(@NotNull String exceptionClass,
                                                                @NotNull TreeMaker factory,
                                                                @NotNull Names symbolsTable)
{
    String[] parts = exceptionClass.split("\\.");
    JCTree.JCIdent identifier = factory.Ident(symbolsTable.fromString(parts[0]));
    JCTree.JCFieldAccess selector = null;
    for (int i = 1; i < parts.length; i++) {
        selector = factory.Select(selector == null ? identifier : selector, symbolsTable.fromString(parts[i]));
    }
    return selector == null ? identifier : selector;
}
 
开发者ID:denis-zhdanov,项目名称:traute,代码行数:14,代码来源:InstrumentationUtil.java

示例5: visitSelect

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
public void visitSelect(JCTree.JCFieldAccess jcFieldAccess) {
    Symbol symbol = jcFieldAccess.sym;
    if (symbol != null
            && symbol.getEnclosingElement() != null
            && symbol.getEnclosingElement().getEnclosingElement() != null
            && symbol.getEnclosingElement().getEnclosingElement().enclClass() != null) {
        Set<String> rClassSet = rClasses.get(currentPackageName);
        if (rClassSet == null) {
            rClassSet = new HashSet<>();
            rClasses.put(currentPackageName, rClassSet);
        }
        rClassSet.add(symbol.getEnclosingElement().getEnclosingElement().enclClass().className());
    }
}
 
开发者ID:hendraanggrian,项目名称:r-parser,代码行数:16,代码来源:RClassScanner.java

示例6: visitSelect

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
public void visitSelect(JCTree.JCFieldAccess jcFieldAccess) {
    final Symbol symbol = jcFieldAccess.sym;

    if (symbol != null
            && symbol.getEnclosingElement() != null
            && symbol.getEnclosingElement().getEnclosingElement() != null
            && symbol.getEnclosingElement().getEnclosingElement().enclClass() != null) {
        className = symbol.getEnclosingElement().getEnclosingElement().enclClass().className();
    }
}
 
开发者ID:chRyNaN,项目名称:glimpse,代码行数:12,代码来源:RClassFinder.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

示例8: isConstructProxyCall

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private boolean isConstructProxyCall( JCExpression expression )
{
  if( expression instanceof JCTree.JCMethodInvocation )
  {
    // don't erase cast if we generated it here e.g.., for structural call cast on constructProxy

    JCExpression meth = ((JCTree.JCMethodInvocation)expression).meth;
    return meth instanceof JCTree.JCFieldAccess && ((JCTree.JCFieldAccess)meth).getIdentifier().toString().equals( "constructProxy" );
  }
  return expression instanceof JCTypeCast && isConstructProxyCall( ((JCTypeCast)expression).getExpression() );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:12,代码来源:ExtensionTransformer.java

示例9: isReceiver

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

示例10: replaceCastExpression

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private JCExpression replaceCastExpression( JCExpression expression, Type type )
{
  TreeMaker make = _tp.getTreeMaker();
  Symtab symbols = _tp.getSymtab();
  Names names = Names.instance( _tp.getContext() );
  JavacElements elementUtils = JavacElements.instance( _tp.getContext() );
  Symbol.ClassSymbol reflectMethodClassSym = elementUtils.getTypeElement( getClass().getName() );

  Symbol.MethodSymbol makeInterfaceProxyMethod = resolveMethod( expression.pos(), names.fromString( "assignStructuralIdentity" ), reflectMethodClassSym.type,
                                                                List.from( new Type[]{symbols.objectType, symbols.classType} ) );

  JavacElements javacElems = _tp.getElementUtil();
  ArrayList<JCExpression> newArgs = new ArrayList<>();
  newArgs.add( expression );
  JCTree.JCFieldAccess ifaceClassExpr = (JCTree.JCFieldAccess)memberAccess( make, javacElems, type.tsym.getQualifiedName().toString() + ".class" );
  ifaceClassExpr.type = symbols.classType;
  ifaceClassExpr.sym = symbols.classType.tsym;
  assignTypes( ifaceClassExpr.selected, type.tsym );
  newArgs.add( ifaceClassExpr );

  JCTree.JCMethodInvocation makeProxyCall = make.Apply( List.nil(), memberAccess( make, javacElems, ExtensionTransformer.class.getName() + ".assignStructuralIdentity" ), List.from( newArgs ) );
  makeProxyCall.type = symbols.objectType;
  JCTree.JCFieldAccess newMethodSelect = (JCTree.JCFieldAccess)makeProxyCall.getMethodSelect();
  newMethodSelect.sym = makeInterfaceProxyMethod;
  newMethodSelect.type = makeInterfaceProxyMethod.type;
  assignTypes( newMethodSelect.selected, reflectMethodClassSym );

  JCTypeCast castCall = make.TypeCast( symbols.objectType, makeProxyCall );
  castCall.type = symbols.objectType;

  return castCall;

}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:34,代码来源:ExtensionTransformer.java

示例11: visitSelect

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
public void visitSelect(JCTree.JCFieldAccess tree) {
    scan(tree.selected);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:JavadocMemberEnter.java

示例12: replaceStructuralCall

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private JCTree replaceStructuralCall( JCTree.JCMethodInvocation theCall )
{
  JCExpression methodSelect = theCall.getMethodSelect();
  if( methodSelect instanceof JCTree.JCFieldAccess )
  {
    Symtab symbols = _tp.getSymtab();
    Names names = Names.instance( _tp.getContext() );
    JavacElements elementUtils = JavacElements.instance( _tp.getContext() );
    Symbol.ClassSymbol reflectMethodClassSym = elementUtils.getTypeElement( getClass().getName() );
    Symbol.MethodSymbol makeInterfaceProxyMethod = resolveMethod( theCall.pos(), names.fromString( "constructProxy" ), reflectMethodClassSym.type,
                                                                  List.from( new Type[]{symbols.objectType, symbols.classType} ) );

    JCTree.JCFieldAccess m = (JCTree.JCFieldAccess)methodSelect;
    TreeMaker make = _tp.getTreeMaker();
    JavacElements javacElems = _tp.getElementUtil();
    JCExpression thisArg = m.selected;

    ArrayList<JCExpression> newArgs = new ArrayList<>();
    newArgs.add( thisArg );
    JCTree.JCFieldAccess ifaceClassExpr = (JCTree.JCFieldAccess)memberAccess( make, javacElems, thisArg.type.tsym.getQualifiedName().toString() + ".class" );
    ifaceClassExpr.type = symbols.classType;
    ifaceClassExpr.sym = symbols.classType.tsym;
    assignTypes( ifaceClassExpr.selected, thisArg.type.tsym );
    newArgs.add( ifaceClassExpr );

    JCTree.JCMethodInvocation makeProxyCall = make.Apply( List.nil(), memberAccess( make, javacElems, ExtensionTransformer.class.getName() + ".constructProxy" ), List.from( newArgs ) );
    makeProxyCall.setPos( theCall.pos );
    makeProxyCall.type = thisArg.type;
    JCTree.JCFieldAccess newMethodSelect = (JCTree.JCFieldAccess)makeProxyCall.getMethodSelect();
    newMethodSelect.sym = makeInterfaceProxyMethod;
    newMethodSelect.type = makeInterfaceProxyMethod.type;
    assignTypes( newMethodSelect.selected, reflectMethodClassSym );

    JCTypeCast cast = make.TypeCast( thisArg.type, makeProxyCall );
    cast.type = thisArg.type;

    ((JCTree.JCFieldAccess)theCall.meth).selected = cast;
    return theCall;
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:42,代码来源:ExtensionTransformer.java

示例13: findExtMethod

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private Symbol.MethodSymbol findExtMethod( JCTree.JCMethodInvocation tree )
{
  JCExpression methodSelect = tree.getMethodSelect();
  if( methodSelect instanceof MemberSelectTree )
  {
    JCTree.JCFieldAccess meth = (JCTree.JCFieldAccess)tree.meth;
    if( meth.sym == null || !meth.sym.hasAnnotations() )
    {
      return null;
    }
    for( Attribute.Compound annotation : meth.sym.getAnnotationMirrors() )
    {
      if( annotation.type.toString().equals( ExtensionMethod.class.getName() ) )
      {
        String extensionClass = (String)annotation.values.get( 0 ).snd.getValue();
        boolean isStatic = (boolean)annotation.values.get( 1 ).snd.getValue();
        BasicJavacTask javacTask = (BasicJavacTask)_tp.getJavacTask(); //JavacHook.instance() != null ? (JavacTaskImpl)JavacHook.instance().getJavacTask() : ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getJavacTask();
        Symbol.ClassSymbol extClassSym = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getClassSymbol( javacTask, extensionClass ).getFirst();
        if( extClassSym == null )
        {
          // This can happen during bootstrapping with Dark Java classes from Manifold itself
          // e.g., ManResolve is a darkj class Manifold uses, ManResolve uses String, which may have an extension class which needs ManResole...
          // So we short-circuit that here (ManResolve or any other darkj class used during bootstrapping doesn't really need to use extensions)
          return null;
        }
        Types types = Types.instance( javacTask.getContext() );
        outer:
        for( Symbol elem : IDynamicJdk.instance().getMembers( extClassSym ) )
        {
          if( elem instanceof Symbol.MethodSymbol && elem.flatName().toString().equals( meth.sym.name.toString() ) )
          {
            Symbol.MethodSymbol extMethodSym = (Symbol.MethodSymbol)elem;
            List<Symbol.VarSymbol> extParams = extMethodSym.getParameters();
            List<Symbol.VarSymbol> calledParams = ((Symbol.MethodSymbol)meth.sym).getParameters();
            int thisOffset = isStatic ? 0 : 1;
            if( extParams.size() - thisOffset != calledParams.size() )
            {
              continue;
            }
            for( int i = thisOffset; i < extParams.size(); i++ )
            {
              Symbol.VarSymbol extParam = extParams.get( i );
              Symbol.VarSymbol calledParam = calledParams.get( i - thisOffset );
              if( !types.isSameType( types.erasure( extParam.type ), types.erasure( calledParam.type ) ) )
              {
                continue outer;
              }
            }
            return extMethodSym;
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:57,代码来源:ExtensionTransformer.java


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