本文整理汇总了Java中com.github.javaparser.ast.stmt.SwitchStmt.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java SwitchStmt.getEntries方法的具体用法?Java SwitchStmt.getEntries怎么用?Java SwitchStmt.getEntries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.stmt.SwitchStmt
的用法示例。
在下文中一共展示了SwitchStmt.getEntries方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override
public void visit(final SwitchStmt n, final Void arg) {
if (canAddNewLine(n)) printer.println();
printJavaComment(n.getComment(), arg);
printer.print("switch (");
n.getSelector().accept(this, arg);
printer.println(") {");
if (n.getEntries() != null) {
for (final SwitchEntryStmt e : n.getEntries()) {
e.accept(this, arg);
}
}
printer.print("}");
if (getNext(n) != null) printer.println();
}
示例2: visit
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override
public void visit(final SwitchStmt n, final Object arg) {
printer.printLn("SwitchStmt");
printJavaComment(n.getComment(), arg);
printer.print("switch(");
n.getSelector().accept(this, arg);
printer.printLn(") {");
if (n.getEntries() != null) {
printer.indent();
for (final SwitchEntryStmt e : n.getEntries()) {
e.accept(this, arg);
}
printer.unindent();
}
printer.print("}");
}
示例3: visit
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override
public JCTree visit(final SwitchStmt n, final Object arg) {
//ARG0: JCExpression selector
JCExpression arg0 = (JCExpression) n.getSelector().accept(this, arg);
//ARG1: List<JCCase> cases
List<JCCase> arg1 = List.<JCCase>nil();
if (n.getEntries() != null) {
for (final SwitchEntryStmt e : n.getEntries()) {
arg1 = arg1.append((JCCase) e.accept(this, arg));
}
}
return new AJCSwitch(make.Switch(arg0, arg1), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
示例4: parseSwitchStatement
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
/**
*
* @param switchStmt
* a github javaparser SwithStatement
* @param attributes
* the list of attributes of the class,
* to potentially get a type from the name
* @param bd
* a body declaration
* @return
* a SwitchStatement structure
*/
private SwitchStatement parseSwitchStatement(SwitchStmt switchStmt, List<Attribute> attributes, BodyDeclaration bd) {
SwitchStatement switchStatement = new SwitchStatement();
switchStatement.setCondition(parseExpression(switchStmt.getSelector(), attributes, bd.getBeginLine()));
if (switchStmt.getEntries() != null) {
List<CaseClause> caseClauses = new ArrayList<>();
for (SwitchEntryStmt switchEntry : switchStmt.getEntries()) {
CaseClause caseClause = new CaseClause();
List<Expr> conditions = new ArrayList<>();
if (switchEntry.getLabel() != null) {
conditions.add(parseExpression(switchEntry.getLabel(), attributes, bd.getBeginLine()));
caseClause.setConditions(conditions);
} else {
if (switchEntry.getStmts() != null) {
switchStatement.setDefaultStmt(parseListStmt(switchEntry.getStmts(), attributes, bd));
}
}
if (switchEntry.getStmts() != null) {
List<Stmt> body = new ArrayList<>();
body.addAll(parseListStmt(switchEntry.getStmts(), attributes, bd));
caseClause.setBody(body);
}
caseClauses.add(caseClause);
}
switchStatement.setCaseClauses(caseClauses);
}
return switchStatement;
}
示例5: visit
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override public void visit(final SwitchStmt n, final Object arg) {
printJavaComment(n.getComment(), arg);
printer.print("switch(");
n.getSelector().accept(this, arg);
printer.printLn(") {");
if (n.getEntries() != null) {
printer.indent();
for (final SwitchEntryStmt e : n.getEntries()) {
e.accept(this, arg);
}
printer.unindent();
}
printer.print("}");
}
示例6: visit
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override public void visit(final SwitchStmt n, final A arg) {
visitComment(n.getComment(), arg);
n.getSelector().accept(this, arg);
if (n.getEntries() != null) {
for (final SwitchEntryStmt e : n.getEntries()) {
e.accept(this, arg);
}
}
}
示例7: visit
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override public void visit(final SwitchStmt n, final A arg) {
jw.write(n);
visitComment(n.getComment(), arg);
n.getSelector().accept(this, arg);
if (n.getEntries() != null) {
for (final SwitchEntryStmt e : n.getEntries()) {
e.accept(this, arg);
}
}
}
示例8: visit
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override public Node visit(final SwitchStmt n, final A arg) {
n.setSelector((Expression) n.getSelector().accept(this, arg));
final List<SwitchEntryStmt> entries = n.getEntries();
if (entries != null) {
for (int i = 0; i < entries.size(); i++) {
entries.set(i, (SwitchEntryStmt) entries.get(i).accept(this, arg));
}
removeNulls(entries);
}
return n;
}
示例9: visit
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override public Node visit(final SwitchStmt n, final A arg) {
visitComment(n, arg);
n.setSelector((Expression) n.getSelector().accept(this, arg));
final List<SwitchEntryStmt> entries = n.getEntries();
if (entries != null) {
for (int i = 0; i < entries.size(); i++) {
entries.set(i, (SwitchEntryStmt) entries.get(i).accept(this, arg));
}
removeNulls(entries);
}
return n;
}
示例10: solveSymbol
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override
public SymbolReference<? extends ValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
SwitchStmt switchStmt = (SwitchStmt) getParentNode(wrappedNode);
Type type = JavaParserFacade.get(typeSolver).getType(switchStmt.getSelector());
if (type.isReferenceType() && type.asReferenceType().getTypeDeclaration().isEnum()) {
if (type instanceof ReferenceTypeImpl) {
ReferenceTypeImpl typeUsageOfTypeDeclaration = (ReferenceTypeImpl) type;
if (typeUsageOfTypeDeclaration.getTypeDeclaration().hasField(name)) {
return SymbolReference.solved(typeUsageOfTypeDeclaration.getTypeDeclaration().getField(name));
}
} else {
throw new UnsupportedOperationException();
}
}
// look for declaration in other switch statements
for (SwitchEntryStmt seStmt : switchStmt.getEntries()) {
if (!seStmt.equals(wrappedNode)) {
for (Statement stmt : seStmt.getStatements()) {
SymbolDeclarator symbolDeclarator = JavaParserFactory.getSymbolDeclarator(stmt, typeSolver);
SymbolReference<? extends ValueDeclaration> symbolReference = solveWith(symbolDeclarator, name);
if (symbolReference.isSolved()) {
return symbolReference;
}
}
}
}
return getParent().solveSymbol(name, typeSolver);
}
示例11: visit
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override public void visit(final SwitchStmt n, final Object arg) {
printJavaComment(n.getComment(), arg);
printer.print("switch(");
n.getSelector().accept(this, arg);
printer.printLn(") {");
if (n.getEntries() != null) {
printer.indent();
for (final SwitchEntryStmt e : n.getEntries()) {
e.accept(this, arg);
}
printer.unindent();
}
printer.print("}");
}
示例12: solveSymbol
import com.github.javaparser.ast.stmt.SwitchStmt; //导入方法依赖的package包/类
@Override
public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
SwitchStmt switchStmt = (SwitchStmt) getParentNode(wrappedNode);
ResolvedType type = JavaParserFacade.get(typeSolver).getType(switchStmt.getSelector());
if (type.isReferenceType() && type.asReferenceType().getTypeDeclaration().isEnum()) {
if (type instanceof ReferenceTypeImpl) {
ReferenceTypeImpl typeUsageOfTypeDeclaration = (ReferenceTypeImpl) type;
if (typeUsageOfTypeDeclaration.getTypeDeclaration().hasField(name)) {
return SymbolReference.solved(typeUsageOfTypeDeclaration.getTypeDeclaration().getField(name));
}
} else {
throw new UnsupportedOperationException();
}
}
// look for declaration in other switch statements
for (SwitchEntryStmt seStmt : switchStmt.getEntries()) {
if (!seStmt.equals(wrappedNode)) {
for (Statement stmt : seStmt.getStatements()) {
SymbolDeclarator symbolDeclarator = JavaParserFactory.getSymbolDeclarator(stmt, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> symbolReference = solveWith(symbolDeclarator, name);
if (symbolReference.isSolved()) {
return symbolReference;
}
}
}
}
return getParent().solveSymbol(name, typeSolver);
}