本文整理汇总了Java中org.eclipse.jdt.core.dom.SwitchCase.isDefault方法的典型用法代码示例。如果您正苦于以下问题:Java SwitchCase.isDefault方法的具体用法?Java SwitchCase.isDefault怎么用?Java SwitchCase.isDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.SwitchCase
的用法示例。
在下文中一共展示了SwitchCase.isDefault方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.eclipse.jdt.core.dom.SwitchCase; //导入方法依赖的package包/类
@Override
public boolean visit(SwitchCase node) {
// switch on enum allows to use enum constants without qualification
if (hasFlag(VARIABLES, fFlags) && !node.isDefault() && isInside(node.getExpression())) {
SwitchStatement switchStatement = (SwitchStatement) node.getParent();
ITypeBinding binding = switchStatement.getExpression().resolveTypeBinding();
if (binding != null && binding.isEnum()) {
IVariableBinding[] declaredFields = binding.getDeclaredFields();
for (int i = 0; i < declaredFields.length; i++) {
IVariableBinding curr = declaredFields[i];
if (curr.isEnumConstant()) {
fBreak = fRequestor.acceptBinding(curr);
if (fBreak) return false;
}
}
}
}
return false;
}
示例2: visit
import org.eclipse.jdt.core.dom.SwitchCase; //导入方法依赖的package包/类
@Override
public boolean visit(SwitchCase node) {
// switch on enum allows to use enum constants without qualification
if (hasFlag(VARIABLES, fFlags) && !node.isDefault() && isInside(node.getExpression())) {
SwitchStatement switchStatement= (SwitchStatement) node.getParent();
ITypeBinding binding= switchStatement.getExpression().resolveTypeBinding();
if (binding != null && binding.isEnum()) {
IVariableBinding[] declaredFields= binding.getDeclaredFields();
for (int i= 0; i < declaredFields.length; i++) {
IVariableBinding curr= declaredFields[i];
if (curr.isEnumConstant()) {
fBreak= fRequestor.acceptBinding(curr);
if (fBreak)
return false;
}
}
}
}
return false;
}
示例3: visit
import org.eclipse.jdt.core.dom.SwitchCase; //导入方法依赖的package包/类
@Override
public boolean visit(SwitchCase node) {
//System.out.println("Found: " + node.getClass());
if (node.isDefault()) {
println("default:");
} else {
print("case ");
node.getExpression().accept(this);
println(":");
}
// Case fallthrough
SwitchStatement ss = (SwitchStatement)node.getParent();
List statements = ss.statements();
if (statements.indexOf(node) < statements.size() - 1) {
Object nextSibling = statements.get(statements.indexOf(node) + 1);
if (nextSibling instanceof SwitchCase) {
//indent++;
println("goto " + (((SwitchCase)nextSibling).isDefault() ? "default;" : "case;" ));
//indent--;
return false;
}
}
// TODO Get indentation right
//indent++;
return false;
}
示例4: visit
import org.eclipse.jdt.core.dom.SwitchCase; //导入方法依赖的package包/类
/**
* @see ASTVisitor#visit(SwitchCase)
*/
@Override
public boolean visit(SwitchCase node) {
if (!node.isDefault()){
cyclomaticComplexityIndex++;
sumCyclomaticComplexity++;
}
return true;
}
示例5: createSwitchData
import org.eclipse.jdt.core.dom.SwitchCase; //导入方法依赖的package包/类
protected SwitchData createSwitchData(SwitchStatement node) {
SwitchData result = new SwitchData();
List<Statement> statements = node.statements();
if (statements.isEmpty()) {
return result;
}
int start = -1, end = -1;
GenericSequentialFlowInfo info = null;
for (Iterator<Statement> iter = statements.iterator(); iter.hasNext();) {
Statement statement = iter.next();
if (statement instanceof SwitchCase) {
SwitchCase switchCase = (SwitchCase) statement;
if (switchCase.isDefault()) {
result.setHasDefaultCase();
}
if (info == null) {
info = createSequential();
start = statement.getStartPosition();
} else {
if (info.isReturn() || info.isPartialReturn() || info.branches()) {
result.add(new Region(start, end - start + 1), info);
info = createSequential();
start = statement.getStartPosition();
}
}
} else {
info.merge(getFlowInfo(statement), fFlowContext);
}
end = statement.getStartPosition() + statement.getLength() - 1;
}
result.add(new Region(start, end - start + 1), info);
return result;
}
示例6: createSwitchData
import org.eclipse.jdt.core.dom.SwitchCase; //导入方法依赖的package包/类
protected SwitchData createSwitchData(SwitchStatement node) {
SwitchData result= new SwitchData();
List<Statement> statements= node.statements();
if (statements.isEmpty())
return result;
int start= -1, end= -1;
GenericSequentialFlowInfo info= null;
for (Iterator<Statement> iter= statements.iterator(); iter.hasNext(); ) {
Statement statement= iter.next();
if (statement instanceof SwitchCase) {
SwitchCase switchCase= (SwitchCase)statement;
if (switchCase.isDefault()) {
result.setHasDefaultCase();
}
if (info == null) {
info= createSequential();
start= statement.getStartPosition();
} else {
if (info.isReturn() || info.isPartialReturn() || info.branches()) {
result.add(new Region(start, end - start + 1), info);
info= createSequential();
start= statement.getStartPosition();
}
}
} else {
info.merge(getFlowInfo(statement), fFlowContext);
}
end= statement.getStartPosition() + statement.getLength() - 1;
}
result.add(new Region(start, end - start + 1), info);
return result;
}
示例7: visit
import org.eclipse.jdt.core.dom.SwitchCase; //导入方法依赖的package包/类
@Override
public boolean visit(SwitchCase node) {
if (node.isDefault()) {
this.fBuffer.append("default :");//$NON-NLS-1$
} else {
this.fBuffer.append("case ");//$NON-NLS-1$
node.getExpression().accept(this);
this.fBuffer.append(":");//$NON-NLS-1$
}
return false;
}
示例8: visit
import org.eclipse.jdt.core.dom.SwitchCase; //导入方法依赖的package包/类
public boolean visit(SwitchCase node) {
if (node.isDefault()) {
this.buffer.append("default :\n");//$NON-NLS-1$
} else {
this.buffer.append("case ");//$NON-NLS-1$
node.getExpression().accept(this);
this.buffer.append(":\n");//$NON-NLS-1$
}
this.indent++; //decremented in visit(SwitchStatement)
return false;
}
示例9: visit
import org.eclipse.jdt.core.dom.SwitchCase; //导入方法依赖的package包/类
@Override
public boolean visit(SwitchCase node) {
if (node.isDefault()) {
statements.add(new AbstractStatement(NodeType.SWITCH_DEFAULT, null));
} else {
statements.add(new AbstractStatement(NodeType.SWITCH_CASE, node.getExpression().toString()));
}
return true;
}