List of usage examples for org.eclipse.jdt.internal.compiler.ast LambdaExpression arguments
Argument[] arguments
To view the source code for org.eclipse.jdt.internal.compiler.ast LambdaExpression arguments.
Click Source Link
From source file:org.eclipse.che.jdt.internal.core.search.matching.MethodLocator.java
License:Open Source License
public int match(LambdaExpression node, MatchingNodeSet nodeSet) { if (!this.pattern.findDeclarations) return IMPOSSIBLE_MATCH; if (this.pattern.parameterSimpleNames != null && this.pattern.parameterSimpleNames.length != node.arguments().length) return IMPOSSIBLE_MATCH; nodeSet.mustResolve = true;// www .ja v a2 s . c om return nodeSet.addMatch(node, POSSIBLE_MATCH); }
From source file:spoon.support.compiler.jdt.JDTTreeBuilder.java
License:Open Source License
@Override public boolean visit(LambdaExpression lambdaExpression, BlockScope blockScope) { CtLambda<?> lambda = factory.Core().createLambda(); final MethodBinding methodBinding = lambdaExpression.getMethodBinding(); if (methodBinding != null) { lambda.setSimpleName(String.valueOf(methodBinding.constantPoolName())); }/* w w w .j a va 2s . c o m*/ context.enter(lambda, lambdaExpression); final Argument[] arguments = lambdaExpression.arguments(); if (arguments != null && arguments.length > 0) { for (Argument e : arguments) { e.traverse(this, blockScope); } } if (lambdaExpression.body() != null) { lambdaExpression.body().traverse(this, blockScope); } return false; }
From source file:spoon.support.compiler.jdt.ReferenceBuilder.java
License:Open Source License
/** * In noclasspath, lambda doesn't have always a binding for their variables accesses in their block/expression. * Here, we make the job of JDT and bind their variables accesses to their parameters. * * @param singleNameReference Name of the variable access. * @return executable reference which corresponds to the lambda. *//*from w w w . java 2 s. c om*/ public CtExecutableReference<?> getLambdaExecutableReference(SingleNameReference singleNameReference) { ASTPair potentialLambda = null; for (ASTPair astPair : jdtTreeBuilder.getContextBuilder().stack) { if (astPair.node instanceof LambdaExpression) { potentialLambda = astPair; // stop at innermost lambda, fixes #1100 break; } } if (potentialLambda == null) { return null; } LambdaExpression lambdaJDT = (LambdaExpression) potentialLambda.node; for (Argument argument : lambdaJDT.arguments()) { if (CharOperation.equals(argument.name, singleNameReference.token)) { CtTypeReference<?> declaringType = null; if (lambdaJDT.enclosingScope instanceof MethodScope) { declaringType = jdtTreeBuilder.getReferencesBuilder().getTypeReference( ((MethodScope) lambdaJDT.enclosingScope).parent.enclosingSourceType()); } CtLambda<?> ctLambda = (CtLambda<?>) potentialLambda.element; List<CtTypeReference<?>> parametersType = new ArrayList<>(); List<CtParameter<?>> parameters = ctLambda.getParameters(); for (CtParameter<?> parameter : parameters) { parametersType.add(getMethodParameterType(parameter)); } return jdtTreeBuilder.getFactory().Executable().createReference(declaringType, ctLambda.getType(), ctLambda.getSimpleName(), parametersType); } } return null; }