Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2012-02-03 21:32:59 -0500
committerSergey Prigogin2012-02-03 21:32:59 -0500
commitfa13b42c51a646487bb29aa5b353914606223cc3 (patch)
treeaf687db0747ae828e42fd1a67bc705c66fcf34f2 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite
parent0d4d66ec6e22720d9e567944293b8f05ca008be0 (diff)
downloadorg.eclipse.cdt-fa13b42c51a646487bb29aa5b353914606223cc3.tar.gz
org.eclipse.cdt-fa13b42c51a646487bb29aa5b353914606223cc3.tar.xz
org.eclipse.cdt-fa13b42c51a646487bb29aa5b353914606223cc3.zip
New UI and other improvements for Extract Function refactoring .
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java7
3 files changed, 13 insertions, 10 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java
index ee4c9d8625..4718e1e11a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java
@@ -105,13 +105,13 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
returnedDeclSpec = declSpec;
} else if (type instanceof ICPPTemplateInstance) {
returnedDeclSpec = getDeclSpecForTemplate((ICPPTemplateInstance) type);
-
} else if (type instanceof IBinding) { /* ITypedef, ICompositeType... */
// BTW - we need to distinguish (and fail explicitly) on literal composites like:
// struct { } aSingleInstance;
returnedDeclSpec = getDeclSpecForBinding((IBinding) type);
}
+ // TODO(sprigogin): Be honest and return null instead of void.
// Fallback...
if (returnedDeclSpec == null) {
IASTSimpleDeclSpecifier specifier = factory.newSimpleDeclSpecifier();
@@ -129,7 +129,7 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
// Addition of pointer operators has to be in reverse order, so it's deferred until the end
Map<IASTDeclarator, LinkedList<IASTPointerOperator>> pointerOperatorMap = new HashMap<IASTDeclarator, LinkedList<IASTPointerOperator>>();
- IASTName newName = (name != null) ? factory.newName(name) : factory.newName();
+ IASTName newName = name != null ? factory.newName(name) : factory.newName();
// If the type is an array of something, create a declaration of a pointer to something instead
// (to allow assignment, etc)
@@ -311,8 +311,8 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
ICPPNodeFactory cppFactory = (ICPPNodeFactory) factory;
ICPPASTTemplateId tempId = cppFactory.newTemplateId(templateName.copy());
for (ICPPTemplateArgument arg : type.getTemplateArguments()) {
- IASTDeclSpecifier argDeclSpec = createDeclSpecFromType(arg.isTypeValue() ? arg
- .getTypeValue() : arg.getTypeOfNonTypeValue());
+ IASTDeclSpecifier argDeclSpec = createDeclSpecFromType(arg.isTypeValue() ?
+ arg.getTypeValue() : arg.getTypeOfNonTypeValue());
IASTTypeId typeId = cppFactory.newTypeId(argDeclSpec, null);
tempId.addTemplateArgument(typeId);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java
index 83dd18fdf4..f9992e2c68 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java
@@ -39,7 +39,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
* @author Emanuel Graf
*/
public class ASTWriter {
- private ASTModificationStore modificationStore = new ASTModificationStore();
+ private final ASTModificationStore modificationStore = new ASTModificationStore();
/**
* Creates a <code>ASTWriter</code>.
@@ -63,7 +63,7 @@ public class ASTWriter {
* Generates the source code representing this node including comments.
*
* @param rootNode Node to write.
- * @param commentMap Node Comment Map <code>ASTCommenter</code>
+ * @param commentMap comments for the translation unit
* @return A <code>String</code> representing the source code for the node.
* @throws ProblemRuntimeException if the node or one of it's children is
* an <code>IASTProblemNode</code>.
@@ -79,10 +79,6 @@ public class ASTWriter {
return writer.toString();
}
- public void setModificationStore(ASTModificationStore modificationStore) {
- this.modificationStore = modificationStore;
- }
-
/**
* Returns <code>true</code> if the node should be separated by a blank line from the node
* before it.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java
index cd1e5c363d..ef08a0ba86 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java
@@ -80,6 +80,13 @@ public class ASTWriterVisitor extends ASTVisitor {
shouldVisitTypeIds = true;
}
+ /**
+ * Creates a writer with an empty comment map.
+ */
+ public ASTWriterVisitor() {
+ this(new NodeCommentMap());
+ }
+
public ASTWriterVisitor(NodeCommentMap commentMap) {
super();
init(commentMap);

Back to the top