本文整理匯總了Java中org.eclipse.jdt.internal.compiler.ast.LambdaExpression類的典型用法代碼示例。如果您正苦於以下問題:Java LambdaExpression類的具體用法?Java LambdaExpression怎麽用?Java LambdaExpression使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LambdaExpression類屬於org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了LambdaExpression類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: add
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
public RecoveredElement add(Statement stmt, int bracketBalanceValue, boolean delegatedByParent) {
if (stmt instanceof LambdaExpression) // lambdas are recovered up to the containing statement anyways.
return this;
resetPendingModifiers();
/* do not consider a nested block starting passed the block end (if set)
it must be belonging to an enclosing block */
if (this.blockDeclaration.sourceEnd != 0
&& stmt.sourceStart > this.blockDeclaration.sourceEnd){
if (delegatedByParent) return this; //ignore
return this.parent.add(stmt, bracketBalanceValue);
}
RecoveredStatement element = new RecoveredStatement(stmt, this, bracketBalanceValue);
attach(element);
if (stmt.sourceEnd == 0) return element;
return this;
}
示例2: missingTypeInLambda
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
public void missingTypeInLambda(LambdaExpression lambda, MethodBinding method) {
int nameSourceStart = lambda.sourceStart();
int nameSourceEnd = lambda.diagnosticsSourceEnd();
List missingTypes = method.collectMissingTypes(null);
if (missingTypes == null) {
System.err.println("The lambda expression " + method + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
TypeBinding missingType = (TypeBinding) missingTypes.get(0);
this.handle(
IProblem.MissingTypeInLambda,
new String[] {
new String(missingType.readableName()),
},
new String[] {
new String(missingType.shortReadableName()),
},
nameSourceStart,
nameSourceEnd);
}
示例3: inferFunctionalInterfaceParameterization
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
/**
* 18.5.3 Functional Interface Parameterization Inference
*/
public ReferenceBinding inferFunctionalInterfaceParameterization(LambdaExpression lambda, BlockScope blockScope,
ParameterizedTypeBinding targetTypeWithWildCards)
{
TypeBinding[] q = createBoundsForFunctionalInterfaceParameterizationInference(targetTypeWithWildCards);
if (q == null || q.length != lambda.arguments().length) {
// fail TODO: can this still happen here?
} else {
if (reduceWithEqualityConstraints(lambda.argumentTypes(), q)) {
ReferenceBinding genericType = targetTypeWithWildCards.genericType();
TypeBinding[] a = targetTypeWithWildCards.arguments; // a is not-null by construction of parameterizedWithWildcard()
TypeBinding[] aprime = getFunctionInterfaceArgumentSolutions(a);
// TODO If F<A'1, ..., A'm> is a well-formed type, ...
return blockScope.environment().createParameterizedType(genericType, aprime, genericType.enclosingType());
}
}
return targetTypeWithWildCards;
}
示例4: reset
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
public void reset(LambdaExpression lambda, ClassFile targetClassFile) {
init(targetClassFile);
this.lambdaExpression = lambda;
this.methodDeclaration = null;
int[] lineSeparatorPositions2 = this.lineSeparatorPositions;
if (lineSeparatorPositions2 != null) {
int length = lineSeparatorPositions2.length;
int lineSeparatorPositionsEnd = length - 1;
int start = Util.getLineNumber(lambda.body().sourceStart, lineSeparatorPositions2, 0, lineSeparatorPositionsEnd);
this.lineNumberStart = start;
if (start > lineSeparatorPositionsEnd) {
this.lineNumberEnd = start;
} else {
int end = Util.getLineNumber(lambda.body().sourceEnd, lineSeparatorPositions2, start - 1, lineSeparatorPositionsEnd);
if (end >= lineSeparatorPositionsEnd) {
end = length;
}
this.lineNumberEnd = end == 0 ? 1 : end;
}
}
this.preserveUnusedLocals = lambda.scope.compilerOptions().preserveAllLocalVariables;
initializeMaxLocals(lambda.binding);
}
示例5: createLambdaTypeElement
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
/** Returns a handle denoting the lambda type identified by its scope. */
public IJavaElement createLambdaTypeElement(
LambdaExpression expression,
ICompilationUnit unit,
HashSet existingElements,
HashMap knownScopes) {
return createElement(
expression.scope, expression.sourceStart(), unit, existingElements, knownScopes)
.getParent();
}
示例6: consumeLambdaExpression
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
@Override
protected void consumeLambdaExpression() {
super.consumeLambdaExpression();
LambdaExpression expression = (LambdaExpression) this.expressionStack[this.expressionPtr];
int arrowEnd = expression.arrowPosition();
int arrowStart = arrowEnd - 1;
if (this.selectionStart == arrowStart || this.selectionStart == arrowEnd) {
if (this.selectionEnd == arrowStart || this.selectionEnd == arrowEnd) {
this.expressionStack[this.expressionPtr] = new SelectionOnLambdaExpression(expression);
}
}
}
示例7: SelectionOnLambdaExpression
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
public SelectionOnLambdaExpression(LambdaExpression expression) {
// Where is object derivation when I need it ???
super(expression.compilationResult(), true);
// copy all state created by the parser.
this.sourceStart = expression.sourceStart;
this.sourceEnd = expression.sourceEnd;
this.hasParentheses = expression.hasParentheses;
this.statementEnd = expression.statementEnd;
this.setBody(expression.body());
this.setArguments(expression.arguments());
this.setArrowPosition(expression.arrowPosition());
}
示例8: visit
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
/**
* @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.LambdaExpression, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
*/
public boolean visit(LambdaExpression lambdaExpression, BlockScope scope) {
final int numberOfParens = (lambdaExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
if (numberOfParens > 0) {
manageOpeningParenthesizedExpression(lambdaExpression, numberOfParens);
}
if (isNextToken(TerminalTokens.TokenNameLPAREN)) {
// Format arguments
formatMethodArguments(
null,
lambdaExpression.arguments(),
lambdaExpression.getScope(),
this.preferences.insert_space_before_opening_paren_in_method_declaration,
this.preferences.insert_space_between_empty_parens_in_method_declaration,
this.preferences.insert_space_before_closing_paren_in_method_declaration,
this.preferences.insert_space_after_opening_paren_in_method_declaration,
this.preferences.insert_space_before_comma_in_method_declaration_parameters,
this.preferences.insert_space_after_comma_in_method_declaration_parameters,
this.preferences.alignment_for_parameters_in_method_declaration);
} else {
// This MUST be a single, untyped parameter
this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier);
}
if (this.preferences.insert_space_before_lambda_arrow) this.scribe.space();
this.scribe.printNextToken(TerminalTokens.TokenNameARROW);
if (this.preferences.insert_space_after_lambda_arrow) this.scribe.space();
final Statement body = lambdaExpression.body();
if (body instanceof Block) {
formatBlock((Block) body, scope, this.preferences.brace_position_for_lambda_body, this.preferences.insert_space_before_opening_brace_in_block);
} else {
body.traverse(this, scope);
}
if (numberOfParens > 0) {
manageClosingParenthesizedExpression(lambdaExpression, numberOfParens);
}
return false;
}
示例9: match
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
public int match(LambdaExpression node, MatchingNodeSet nodeSet) {
int level = IMPOSSIBLE_MATCH;
for (int i = 0, length = this.patternLocators.length; i < length; i++) {
int newLevel = this.patternLocators[i].match(node, nodeSet);
if (newLevel > level) {
if (newLevel == ACCURATE_MATCH) return ACCURATE_MATCH;
level = newLevel;
}
}
return level;
}
示例10: findLocalElement
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
protected IJavaElement findLocalElement(int pos, MethodScope scope) {
if (scope != null && scope.isLambdaScope()) {
IJavaElement parent = findLocalElement(pos, scope.enclosingMethodScope());
LambdaExpression expression = (LambdaExpression) scope.originalReferenceContext();
if (expression != null && expression.resolvedType != null && expression.resolvedType.isValidBinding()) {
org.eclipse.jdt.internal.core.LambdaExpression lambdaElement = LambdaFactory.createLambdaExpression((JavaElement) parent, expression);
return lambdaElement.getMethod();
}
return parent;
}
return findLocalElement(pos);
}
示例11: consumeNestedLambda
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
protected void consumeNestedLambda() {
// NestedLambda ::= $empty - we get here just after the type+parenthesis elided singleton parameter or just before the '(' of the parameter list.
consumeNestedType();
this.nestedMethod[this.nestedType] ++;
LambdaExpression lambda = new LambdaExpression(this.compilationUnit.compilationResult, isAssistParser());
pushOnAstStack(lambda);
this.processingLambdaParameterList = true;
}
示例12: consumeLambdaHeader
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
protected void consumeLambdaHeader() {
// LambdaHeader ::= LambdaParameters '->' Synthetic/fake production with a synthetic non-terminal. Body not seen yet.
int arrowPosition = this.scanner.currentPosition - 1;
Argument [] arguments = null;
int length = this.astLengthStack[this.astLengthPtr--];
this.astPtr -= length;
//arguments
if (length != 0) {
System.arraycopy(
this.astStack,
this.astPtr + 1,
arguments = new Argument[length],
0,
length);
}
for (int i = 0; i < length; i++) {
final Argument argument = arguments[i];
if (argument.isReceiver()) {
problemReporter().illegalThis(argument);
}
if (argument.name.length == 1 && argument.name[0] == '_')
problemReporter().illegalUseOfUnderscoreAsAnIdentifier(argument.sourceStart, argument.sourceEnd, true); // true == lambdaParameter
}
LambdaExpression lexp = (LambdaExpression) this.astStack[this.astPtr];
lexp.setArguments(arguments);
lexp.setArrowPosition(arrowPosition);
lexp.sourceEnd = this.intStack[this.intPtr--]; // ')' position or identifier position.
lexp.sourceStart = this.intStack[this.intPtr--]; // '(' position or identifier position.
lexp.hasParentheses = (this.scanner.getSource()[lexp.sourceStart] == '(');
this.listLength -= arguments == null ? 0 : arguments.length; // not necessary really.
this.processingLambdaParameterList = false;
if (this.currentElement != null) {
this.lastCheckPoint = arrowPosition + 1; // we don't want the typed formal parameters to be processed by recovery.
}
}
示例13: bytecodeExceeds64KLimit
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
public void bytecodeExceeds64KLimit(LambdaExpression location) {
MethodBinding method = location.binding;
this.handle(
IProblem.BytecodeExceeds64KLimit,
new String[] {new String(method.selector), typesAsString(method, false)},
new String[] {new String(method.selector), typesAsString(method, true)},
ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
location.sourceStart,
location.diagnosticsSourceEnd());
}
示例14: lambdaSignatureMismatched
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
public void lambdaSignatureMismatched(LambdaExpression target) {
this.handle(
IProblem.lambdaSignatureMismatched,
new String[] { new String(target.descriptor.readableName()) },
new String[] { new String(target.descriptor.shortReadableName()) },
target.sourceStart,
target.diagnosticsSourceEnd());
}
示例15: lambdaExpressionCannotImplementGenericMethod
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; //導入依賴的package包/類
public void lambdaExpressionCannotImplementGenericMethod(LambdaExpression lambda, MethodBinding sam) {
final String selector = new String(sam.selector);
this.handle(
IProblem.NoGenericLambda,
new String[] { selector, new String(sam.declaringClass.readableName())},
new String[] { selector, new String(sam.declaringClass.shortReadableName())},
lambda.sourceStart,
lambda.diagnosticsSourceEnd());
}