Java 类org.eclipse.jdt.internal.compiler.ast.SwitchStatement 实例源码
项目:Eclipse-Postfix-Code-Completion
文件:ProblemReporter.java
public void missingDefaultCase(SwitchStatement switchStatement, boolean isEnumSwitch, TypeBinding expressionType) {
if (isEnumSwitch) {
this.handle(
IProblem.MissingEnumDefaultCase,
new String[] {new String(expressionType.readableName())},
new String[] {new String(expressionType.shortReadableName())},
switchStatement.expression.sourceStart,
switchStatement.expression.sourceEnd);
} else {
this.handle(
IProblem.MissingDefaultCase,
NoArgument,
NoArgument,
switchStatement.expression.sourceStart,
switchStatement.expression.sourceEnd);
}
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:ProblemReporter.java
public void missingDefaultCase(SwitchStatement switchStatement, boolean isEnumSwitch, TypeBinding expressionType) {
if (isEnumSwitch) {
this.handle(
IProblem.MissingEnumDefaultCase,
new String[] {new String(expressionType.readableName())},
new String[] {new String(expressionType.shortReadableName())},
switchStatement.expression.sourceStart,
switchStatement.expression.sourceEnd);
} else {
this.handle(
IProblem.MissingDefaultCase,
NoArgument,
NoArgument,
switchStatement.expression.sourceStart,
switchStatement.expression.sourceEnd);
}
}
项目:xapi
文件:GwtAstBuilder.java
@Override
public void endVisit(SwitchStatement x, BlockScope scope) {
try {
SourceInfo info = makeSourceInfo(x);
JBlock block = popBlock(info, x.statements);
JExpression expression = pop(x.expression);
if (x.expression.resolvedType.isEnum()) {
// synthesize a call to ordinal().
ReferenceBinding javaLangEnum = scope.getJavaLangEnum();
MethodBinding ordinal = javaLangEnum.getMethods(ORDINAL)[0];
expression = new JMethodCall(info, expression, typeMap.get(ordinal));
}
push(new JSwitchStatement(info, expression, block));
} catch (Throwable e) {
throw translateException(x, e);
}
}
项目:Eclipse-Postfix-Code-Completion
文件:Parser.java
protected void consumeStatementSwitch() {
// SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock
//OpenBlock just makes the semantic action blockStart()
//the block is inlined but a scope need to be created
//if some declaration occurs.
int length;
SwitchStatement switchStatement = new SwitchStatement();
this.expressionLengthPtr--;
switchStatement.expression = this.expressionStack[this.expressionPtr--];
if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
this.astPtr -= length;
System.arraycopy(
this.astStack,
this.astPtr + 1,
switchStatement.statements = new Statement[length],
0,
length);
}
switchStatement.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
pushOnAstStack(switchStatement);
switchStatement.blockStart = this.intStack[this.intPtr--];
switchStatement.sourceStart = this.intStack[this.intPtr--];
switchStatement.sourceEnd = this.endStatementPosition;
if (length == 0 && !containsComment(switchStatement.blockStart, switchStatement.sourceEnd)) {
switchStatement.bits |= ASTNode.UndocumentedEmptyBlock;
}
}
项目:Eclipse-Postfix-Code-Completion
文件:ProblemReporter.java
public void missingEnumConstantCase(SwitchStatement switchStatement, FieldBinding enumConstant) {
this.handle(
switchStatement.defaultCase == null ? IProblem.MissingEnumConstantCase : IProblem.MissingEnumConstantCaseDespiteDefault,
new String[] {new String(enumConstant.declaringClass.readableName()), new String(enumConstant.name) },
new String[] {new String(enumConstant.declaringClass.shortReadableName()), new String(enumConstant.name) },
switchStatement.expression.sourceStart,
switchStatement.expression.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:ProblemReporter.java
public void missingEnumConstantCase(SwitchStatement switchStatement, FieldBinding enumConstant) {
this.handle(
switchStatement.defaultCase == null ? IProblem.MissingEnumConstantCase : IProblem.MissingEnumConstantCaseDespiteDefault,
new String[] {new String(enumConstant.declaringClass.readableName()), new String(enumConstant.name) },
new String[] {new String(enumConstant.declaringClass.shortReadableName()), new String(enumConstant.name) },
switchStatement.expression.sourceStart,
switchStatement.expression.sourceEnd);
}
项目:lombok-ianchiu
文件:HandleHelper.java
private Statement[] getStatementsFromAstNode(ASTNode node) {
if (node instanceof Block) return ((Block) node).statements;
if (node instanceof AbstractMethodDeclaration) return ((AbstractMethodDeclaration) node).statements;
if (node instanceof SwitchStatement) return ((SwitchStatement) node).statements;
return null;
}
项目:lombok-ianchiu
文件:HandleHelper.java
private void setStatementsOfAstNode(ASTNode node, Statement[] statements) {
if (node instanceof Block) ((Block) node).statements = statements;
else if (node instanceof AbstractMethodDeclaration) ((AbstractMethodDeclaration) node).statements = statements;
else if (node instanceof SwitchStatement) ((SwitchStatement) node).statements = statements;
else throw new IllegalArgumentException("Can't set statements on node type: " + node.getClass());
}
项目:lombok-ianchiu
文件:SetGeneratedByVisitor.java
private void fixPositions(SwitchStatement node) {
node.sourceEnd = sourceEnd;
node.sourceStart = sourceStart;
node.blockStart = sourceStart;
}
项目:lombok-ianchiu
文件:SetGeneratedByVisitor.java
@Override public boolean visit(SwitchStatement node, BlockScope scope) {
fixPositions(setGeneratedBy(node, source));
return super.visit(node, scope);
}
项目:EasyMPermission
文件:SetGeneratedByVisitor.java
private void fixPositions(SwitchStatement node) {
node.sourceEnd = sourceEnd;
node.sourceStart = sourceStart;
node.blockStart = sourceStart;
}
项目:EasyMPermission
文件:SetGeneratedByVisitor.java
@Override public boolean visit(SwitchStatement node, BlockScope scope) {
fixPositions(setGeneratedBy(node, source));
return super.visit(node, scope);
}
项目:Eclipse-Postfix-Code-Completion
文件:SelectionParser.java
private void buildMoreCompletionContext(Expression expression) {
ASTNode parentNode = null;
int kind = topKnownElementKind(SELECTION_OR_ASSIST_PARSER);
if(kind != 0) {
int info = topKnownElementInfo(SELECTION_OR_ASSIST_PARSER);
nextElement : switch (kind) {
case K_BETWEEN_CASE_AND_COLON :
if(this.expressionPtr > 0) {
SwitchStatement switchStatement = new SwitchStatement();
switchStatement.expression = this.expressionStack[this.expressionPtr - 1];
if(this.astLengthPtr > -1 && this.astPtr > -1) {
int length = this.astLengthStack[this.astLengthPtr];
int newAstPtr = this.astPtr - length;
ASTNode firstNode = this.astStack[newAstPtr + 1];
if(length != 0 && firstNode.sourceStart > switchStatement.expression.sourceEnd) {
switchStatement.statements = new Statement[length + 1];
System.arraycopy(
this.astStack,
newAstPtr + 1,
switchStatement.statements,
0,
length);
}
}
CaseStatement caseStatement = new CaseStatement(expression, expression.sourceStart, expression.sourceEnd);
if(switchStatement.statements == null) {
switchStatement.statements = new Statement[]{caseStatement};
} else {
switchStatement.statements[switchStatement.statements.length - 1] = caseStatement;
}
parentNode = switchStatement;
this.assistNodeParent = parentNode;
}
break nextElement;
case K_INSIDE_RETURN_STATEMENT :
if(info == this.bracketDepth) {
ReturnStatement returnStatement = new ReturnStatement(expression, expression.sourceStart, expression.sourceEnd);
parentNode = returnStatement;
this.assistNodeParent = parentNode;
}
break nextElement;
case K_CAST_STATEMENT :
Expression castType;
if(this.expressionPtr > 0
&& ((castType = this.expressionStack[this.expressionPtr-1]) instanceof TypeReference)) {
CastExpression cast = new CastExpression(expression, (TypeReference) castType);
cast.sourceStart = castType.sourceStart;
cast.sourceEnd= expression.sourceEnd;
parentNode = cast;
this.assistNodeParent = parentNode;
}
break nextElement;
}
}
// Do not add assist node/parent into the recovery system if we are inside a lambda. The lambda will be fully recovered including the containing statement and added.
if (lastIndexOfElement(K_LAMBDA_EXPRESSION_DELIMITER) < 0) {
if(parentNode != null) {
this.currentElement = this.currentElement.add((Statement)parentNode, 0);
} else {
this.currentElement = this.currentElement.add((Statement)wrapWithExplicitConstructorCallIfNeeded(expression), 0);
if(this.lastCheckPoint < expression.sourceEnd) {
this.lastCheckPoint = expression.sourceEnd + 1;
}
}
}
}
项目:xapi
文件:GwtAstBuilder.java
@Override
public boolean visit(SwitchStatement x, BlockScope scope) {
x.statements = reduceToReachable(x.statements);
return true;
}
项目:lombok
文件:SetGeneratedByVisitor.java
@Override public boolean visit(SwitchStatement node, BlockScope scope) {
setGeneratedBy(node, source);
applyOffsetASTNode(node);
node.blockStart = newSourceStart;
return super.visit(node, scope);
}