Java Code Examples for com.sun.tools.javac.tree.JCTree#JCLambda

The following examples show how to use com.sun.tools.javac.tree.JCTree#JCLambda . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SourceAnalyzerFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Void visitLambdaExpression(
        @NonNull final LambdaExpressionTree node,
        @NonNull final Map<Pair<BinaryName, String>, UsagesData<String>> p) {
    final Type type = ((JCTree.JCLambda)node).type;
    if (type != null) {
        final Symbol sym = type.tsym;
        if (sym != null) {
            if (sym != null && sym.getKind().isInterface()) {
                addUsage(sym,
                    activeClass.peek(),
                    p,
                    ClassIndexImpl.UsageType.FUNCTIONAL_IMPLEMENTORS);
            }
        }
    }
    return super.visitLambdaExpression(node, p);
}
 
Example 2
Source File: ExtensionTransformer.java    From manifold with Apache License 2.0 6 votes vote down vote up
@Override
public void visitLambda( JCTree.JCLambda tree )
{
  super.visitLambda( tree );

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

  tree.type = eraseStructureType( tree.type );
  ArrayList<Type> types = new ArrayList<>();
  for( Type target: IDynamicJdk.instance().getTargets( tree ) )
  {
    types.add( eraseStructureType( target ) );
  }
  IDynamicJdk.instance().setTargets( tree, List.from( types ) );
}
 
Example 3
Source File: TreeAnalyzer.java    From meghanada-server with GNU General Public License v3.0 5 votes vote down vote up
private static void analyzeLambda(SourceContext context, JCTree.JCLambda lambda)
    throws IOException {
  boolean isParameter = context.parameter;
  boolean isArgument = context.argument;
  int argumentIndex = context.argumentIndex;

  java.util.List<? extends VariableTree> parameters = lambda.getParameters();
  if (nonNull(parameters)) {
    for (VariableTree v : parameters) {
      if (v instanceof JCTree.JCVariableDecl) {
        analyzeParsedTree(context, (JCTree.JCVariableDecl) v);
      }
    }
  }
  JCTree body = lambda.getBody();
  if (nonNull(body)) {
    context.setArgumentIndex(-1);
    analyzeParsedTree(context, body);
    context.setArgumentIndex(argumentIndex);
  }

  context.parameter = isParameter;
  Type lambdaType = lambda.type;
  if (nonNull(lambdaType)) {
    Source src = context.source;
    getTypeString(src, lambdaType)
        .ifPresent(
            fqcn -> {
              context.argument = isArgument;
              // TODO
              context.setArgumentFQCN(fqcn);
            });
  }
}
 
Example 4
Source File: StrictJavaDepsPlugin.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Override
public void visitLambda(JCTree.JCLambda tree) {
  if (tree.paramKind != JCTree.JCLambda.ParameterKind.IMPLICIT) {
    // don't record type uses for implicitly typed lambda parameters
    scan(tree.params);
  }
  scan(tree.body);
}
 
Example 5
Source File: JavaDynamicJdk_8.java    From manifold with Apache License 2.0 4 votes vote down vote up
@Override
public List<Type> getTargets( JCTree.JCLambda tree )
{
  return tree.targets;
}
 
Example 6
Source File: JavaDynamicJdk_8.java    From manifold with Apache License 2.0 4 votes vote down vote up
@Override
public void setTargets( JCTree.JCLambda tree, List<Type> targets )
{
  tree.targets = targets;
}
 
Example 7
Source File: IDynamicJdk.java    From manifold with Apache License 2.0 votes vote down vote up
List<Type> getTargets( JCTree.JCLambda tree ); 
Example 8
Source File: IDynamicJdk.java    From manifold with Apache License 2.0 votes vote down vote up
void setTargets( JCTree.JCLambda tree, List<Type> targets );