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


Java SwitchStatement类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.SwitchStatement的典型用法代码示例。如果您正苦于以下问题:Java SwitchStatement类的具体用法?Java SwitchStatement怎么用?Java SwitchStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SwitchStatement类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了SwitchStatement类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: missingDefaultCase

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
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);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:ProblemReporter.java

示例2: endVisit

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:20,代码来源:GwtAstBuilder.java

示例3: consumeStatementSwitch

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
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;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:Parser.java

示例4: missingEnumConstantCase

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ProblemReporter.java

示例5: getStatementsFromAstNode

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
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;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:7,代码来源:HandleHelper.java

示例6: setStatementsOfAstNode

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
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());
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:7,代码来源:HandleHelper.java

示例7: fixPositions

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
private void fixPositions(SwitchStatement node) {
	node.sourceEnd = sourceEnd;
	node.sourceStart = sourceStart;
	node.blockStart = sourceStart;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:6,代码来源:SetGeneratedByVisitor.java

示例8: visit

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
@Override public boolean visit(SwitchStatement node, BlockScope scope) {
	fixPositions(setGeneratedBy(node, source));
	return super.visit(node, scope);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:5,代码来源:SetGeneratedByVisitor.java

示例9: buildMoreCompletionContext

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
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;
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:68,代码来源:SelectionParser.java

示例10: visit

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
@Override
public boolean visit(SwitchStatement x, BlockScope scope) {
  x.statements = reduceToReachable(x.statements);
  return true;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:6,代码来源:GwtAstBuilder.java

示例11: visit

import org.eclipse.jdt.internal.compiler.ast.SwitchStatement; //导入依赖的package包/类
@Override public boolean visit(SwitchStatement node, BlockScope scope) {
	setGeneratedBy(node, source);
	applyOffsetASTNode(node);
	node.blockStart = newSourceStart;
	return super.visit(node, scope);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:7,代码来源:SetGeneratedByVisitor.java


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