Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2010-10-21 10:22:06 -0400
committerMarkus Schorn2010-10-21 10:22:06 -0400
commit7129cfccb07c99a68e2ae579e05f463e70a97b39 (patch)
tree27af1a2662b6b727dc27ba7edf3894b7e218d517 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter
parentbefb4d9e04c354d51a34c1408eb773080db65bdf (diff)
downloadorg.eclipse.cdt-7129cfccb07c99a68e2ae579e05f463e70a97b39.tar.gz
org.eclipse.cdt-7129cfccb07c99a68e2ae579e05f463e70a97b39.tar.xz
org.eclipse.cdt-7129cfccb07c99a68e2ae579e05f463e70a97b39.zip
Bug 327223: [C++0x] Range-based for loop.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java21
3 files changed, 23 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java
index 32bb929125..2c994c26db 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -20,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
@@ -61,7 +61,7 @@ public class DeclarationWriter extends NodeWriter{
private static final String USING = "using "; //$NON-NLS-1$
private boolean printSemicolon;
- public DeclarationWriter(Scribe scribe, CPPASTVisitor visitor, NodeCommentMap commentMap) {
+ public DeclarationWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java
index 369fe35e39..700165b1bd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Institute for Software - initial API and implementation
+ * Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@@ -58,6 +58,7 @@ public class NodeWriter {
protected static final String CLASS_SPACE = "class "; //$NON-NLS-1$
protected static final String VAR_ARGS = "..."; //$NON-NLS-1$
protected static final String COLON_COLON = "::"; //$NON-NLS-1$
+ protected static final String COLON_SPACE = ": "; //$NON-NLS-1$
public NodeWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
super();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java
index 36238a1cd5..2e1e6dcafd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -32,10 +32,10 @@ import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSwitchStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
@@ -77,7 +77,7 @@ public class StatementWriter extends NodeWriter{
private boolean decrementIndentationLevelOneMore = false;
private final DeclarationWriter declWriter;
- public StatementWriter(Scribe scribe, CPPASTVisitor visitor, NodeCommentMap commentMap) {
+ public StatementWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
declWriter = new DeclarationWriter(scribe, visitor, commentMap);
}
@@ -140,6 +140,9 @@ public class StatementWriter extends NodeWriter{
} else if (statement instanceof IASTForStatement) {
writeForStatement((IASTForStatement) statement);
newLine = false;
+ } else if (statement instanceof ICPPASTRangeBasedForStatement) {
+ writeForStatement((ICPPASTRangeBasedForStatement) statement);
+ newLine = false;
} else if (statement instanceof IASTDoStatement) {
writeDoStatement((IASTDoStatement) statement);
newLine = true;
@@ -204,6 +207,18 @@ public class StatementWriter extends NodeWriter{
writeBodyStatement(forStatment.getBody(), false);
}
+ private void writeForStatement(ICPPASTRangeBasedForStatement forStatment) {
+ scribe.noNewLines();
+ scribe.print(FOR);
+ writeDeclarationWithoutSemicolon(forStatment.getDeclaration());
+ scribe.print(COLON_SPACE);
+ visitNodeIfNotNull(forStatment.getInitializerClause());
+ scribe.print(')');
+ scribe.newLines();
+ nextCompoundNoNewLine();
+ writeBodyStatement(forStatment.getBody(), false);
+ }
+
private void writeIfStatement(IASTIfStatement ifStatement) {
scribe.print(IF);
scribe.noNewLines();

Back to the top