org.eclipse.jdt.core.dom.ASTNode#SWITCH_STATEMENT源码实例Demo

下面列出了org.eclipse.jdt.core.dom.ASTNode#SWITCH_STATEMENT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdt-codemining   文件: JavaCodeMiningASTVisitor.java
@Override
public void endVisit(Statement node) {
	super.endVisit(node);
	if (node.getNodeType() == ASTNode.IF_STATEMENT || node.getNodeType() == ASTNode.WHILE_STATEMENT
			|| node.getNodeType() == ASTNode.FOR_STATEMENT || node.getNodeType() == ASTNode.DO_STATEMENT
			|| node.getNodeType() == ASTNode.SWITCH_STATEMENT) {
		if (showEndStatement) {
			minings.add(new EndStatementCodeMining(node, textEditor, viewer, endStatementMinLineNumber, provider));
		}
	}
}
 
源代码2 项目: eclipse.jdt.ls   文件: SnippetFinder.java
public boolean hasCorrectNesting(ASTNode node) {
	if (fNodes.size() == 0) {
		return true;
	}
	ASTNode parent = node.getParent();
	if (fNodes.get(0).getParent() != parent) {
		return false;
	}
	// Here we know that we have two elements. In this case the
	// parent must be a block or a switch statement. Otherwise a
	// snippet like "if (true) foo(); else foo();" would match
	// the pattern "foo(); foo();"
	int nodeType = parent.getNodeType();
	return nodeType == ASTNode.BLOCK || nodeType == ASTNode.SWITCH_STATEMENT;
}
 
public boolean hasCorrectNesting(ASTNode node) {
	if (fNodes.size() == 0)
		return true;
	ASTNode parent= node.getParent();
	if(fNodes.get(0).getParent() != parent)
		return false;
	// Here we know that we have two elements. In this case the
	// parent must be a block or a switch statement. Otherwise a
	// snippet like "if (true) foo(); else foo();" would match
	// the pattern "foo(); foo();"
	int nodeType= parent.getNodeType();
	return nodeType == ASTNode.BLOCK || nodeType == ASTNode.SWITCH_STATEMENT;
}
 
private static boolean isNotInBlock(ASTNode parent) {
	ASTNode statement= parent.getParent();
	boolean isStatement= statement.getNodeType() != ASTNode.EXPRESSION_STATEMENT;
	ASTNode block= statement.getParent();
	boolean isBlock= block.getNodeType() == ASTNode.BLOCK || block.getNodeType() == ASTNode.SWITCH_STATEMENT;
	boolean isControlStatemenBody= ASTNodes.isControlStatementBody(statement.getLocationInParent());
	return isStatement || !(isBlock || isControlStatemenBody);
}
 
源代码5 项目: j2cl   文件: CompilationUnitBuilder.java
private Statement convertStatement(org.eclipse.jdt.core.dom.Statement statement) {
  switch (statement.getNodeType()) {
    case ASTNode.ASSERT_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.AssertStatement) statement);
    case ASTNode.BLOCK:
      return convert((org.eclipse.jdt.core.dom.Block) statement);
    case ASTNode.BREAK_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.BreakStatement) statement);
    case ASTNode.CONSTRUCTOR_INVOCATION:
      return convert((org.eclipse.jdt.core.dom.ConstructorInvocation) statement);
    case ASTNode.CONTINUE_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.ContinueStatement) statement);
    case ASTNode.DO_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.DoStatement) statement);
    case ASTNode.EMPTY_STATEMENT:
      return new EmptyStatement(getSourcePosition(statement));
    case ASTNode.EXPRESSION_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.ExpressionStatement) statement);
    case ASTNode.FOR_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.ForStatement) statement);
    case ASTNode.ENHANCED_FOR_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.EnhancedForStatement) statement);
    case ASTNode.IF_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.IfStatement) statement);
    case ASTNode.LABELED_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.LabeledStatement) statement);
    case ASTNode.RETURN_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.ReturnStatement) statement);
    case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
      return convert((org.eclipse.jdt.core.dom.SuperConstructorInvocation) statement);
    case ASTNode.SWITCH_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.SwitchStatement) statement);
    case ASTNode.SYNCHRONIZED_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.SynchronizedStatement) statement);
    case ASTNode.THROW_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.ThrowStatement) statement);
    case ASTNode.TRY_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.TryStatement) statement);
    case ASTNode.TYPE_DECLARATION_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.TypeDeclarationStatement) statement);
    case ASTNode.VARIABLE_DECLARATION_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.VariableDeclarationStatement) statement);
    case ASTNode.WHILE_STATEMENT:
      return convert((org.eclipse.jdt.core.dom.WhileStatement) statement);
    default:
      throw internalCompilerError(
          "Unexpected type for Statement: %s", statement.getClass().getName());
  }
}