Java Code Examples for org.eclipse.jdt.core.dom.ASTNode#ENHANCED_FOR_STATEMENT

The following examples show how to use org.eclipse.jdt.core.dom.ASTNode#ENHANCED_FOR_STATEMENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoopFragmentExporter.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean preNext(Statement curElement) {
	switch (curElement.getNodeType()) {
	case ASTNode.WHILE_STATEMENT:
		exportWhile((WhileStatement) curElement);
		break;
	case ASTNode.FOR_STATEMENT:
		exportFor((ForStatement) curElement);
		break;
	case ASTNode.ENHANCED_FOR_STATEMENT:
		exportForEach((EnhancedForStatement) curElement);
		break;
	case ASTNode.DO_STATEMENT:
		exportDoWhileStatement((DoStatement) curElement);
		break;
	}

	return true;
}
 
Example 2
Source File: ExporterBase.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the appropriate exporter implementation based on the type of the
 * given node.
 * 
 * @param <T>
 *            The node type which is parsed by the exporter.
 */
@SuppressWarnings("unchecked")
public static <T extends ASTNode> ExporterBase<T> createExporter(T curElement, PlantUmlCompiler compiler) {
	switch (curElement.getNodeType()) {
	case ASTNode.TYPE_DECLARATION:
		return (ExporterBase<T>) new InteractionExporter(compiler);
	case ASTNode.METHOD_INVOCATION:
		return (ExporterBase<T>) MethodInvocationExporter.createExporter(curElement, compiler);
	case ASTNode.WHILE_STATEMENT:
	case ASTNode.FOR_STATEMENT:
	case ASTNode.ENHANCED_FOR_STATEMENT:
	case ASTNode.DO_STATEMENT:
		return (ExporterBase<T>) new LoopFragmentExporter(compiler);
	case ASTNode.IF_STATEMENT:
		return (ExporterBase<T>) new OptAltFragmentExporter(compiler);
	}
	return null;
}
 
Example 3
Source File: CombinedFragmentExporter.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean validElement(ASTNode curElement) {
	int nodeType = curElement.getNodeType();
	return nodeType == ASTNode.DO_STATEMENT || nodeType == ASTNode.ENHANCED_FOR_STATEMENT
			|| nodeType == ASTNode.WHILE_STATEMENT || nodeType == ASTNode.FOR_STATEMENT
			|| nodeType == ASTNode.IF_STATEMENT || nodeType == ASTNode.METHOD_INVOCATION;
}
 
Example 4
Source File: QuickAssistProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean isControlStatementWithBlock(ASTNode node) {
	switch (node.getNodeType()) {
		case ASTNode.IF_STATEMENT:
		case ASTNode.WHILE_STATEMENT:
		case ASTNode.FOR_STATEMENT:
		case ASTNode.ENHANCED_FOR_STATEMENT:
		case ASTNode.DO_STATEMENT:
			return true;
		default:
			return false;
	}
}
 
Example 5
Source File: CompilationUnitBuilder.java    From j2cl with Apache License 2.0 4 votes vote down vote up
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());
  }
}
 
Example 6
Source File: CallInliner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private boolean isControlStatement(ASTNode node) {
	int type= node.getNodeType();
	return type == ASTNode.IF_STATEMENT || type == ASTNode.FOR_STATEMENT || type == ASTNode.ENHANCED_FOR_STATEMENT ||
	        type == ASTNode.WHILE_STATEMENT || type == ASTNode.DO_STATEMENT;
}