Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsprigogin2011-08-05 23:00:20 -0400
committersprigogin2011-08-06 22:55:00 -0400
commit26acd7fa6a26e287507fb2b7cd9d1f52a57804e8 (patch)
tree795855454e9649214b737ddd6635f68442ef9730 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite
parent1293690a4ccd15609b73b0cecff0535af6fb2fd6 (diff)
downloadorg.eclipse.cdt-26acd7fa6a26e287507fb2b7cd9d1f52a57804e8.tar.gz
org.eclipse.cdt-26acd7fa6a26e287507fb2b7cd9d1f52a57804e8.tar.xz
org.eclipse.cdt-26acd7fa6a26e287507fb2b7cd9d1f52a57804e8.zip
Cosmetics.
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/ASTModificationMap.java28
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java5
2 files changed, 17 insertions, 16 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTModificationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTModificationMap.java
index 6085c977fa..ea35926d43 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTModificationMap.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTModificationMap.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite;
@@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
/**
- * Represents a list of modifications to an ast-node. If there are nested modifications
+ * Represents a list of modifications to an AST node. If there are nested modifications
* to nodes introduced by insertions or replacements, these modifications are collected
* in separate modification maps. I.e. a modification map represents one level of
* modifications.
@@ -28,51 +28,51 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKin
* @since 5.0
*/
public class ASTModificationMap {
-
- private HashMap<IASTNode,List<ASTModification>> fModifications= new HashMap<IASTNode,List<ASTModification>>();
+ private HashMap<IASTNode, List<ASTModification>> fModifications= new HashMap<IASTNode, List<ASTModification>>();
/**
* Adds a modification to this modification map.
*/
public void addModification(ASTModification mod) {
- final IASTNode targetNode = mod.getKind()==ASTModification.ModificationKind.INSERT_BEFORE ? mod.getTargetNode().getParent() :mod.getTargetNode();
+ final IASTNode targetNode = mod.getKind() == ASTModification.ModificationKind.INSERT_BEFORE ?
+ mod.getTargetNode().getParent() : mod.getTargetNode();
List<ASTModification> mods= fModifications.get(targetNode);
if (mods == null || mods.isEmpty()) {
mods= new ArrayList<ASTModification>();
mods.add(mod);
fModifications.put(targetNode, mods);
- }
- else {
+ } else {
switch (mod.getKind()) {
case REPLACE:
- if (mods.get(mods.size()-1).getKind() != ModificationKind.INSERT_BEFORE ) {
+ if (mods.get(mods.size() - 1).getKind() != ModificationKind.INSERT_BEFORE) {
throw new IllegalArgumentException("Attempt to replace a node that has been modified"); //$NON-NLS-1$
}
mods.add(mod);
break;
case APPEND_CHILD:
- if (mods.get(mods.size()-1).getKind() == ModificationKind.REPLACE) {
+ if (mods.get(mods.size() - 1).getKind() == ModificationKind.REPLACE) {
throw new IllegalArgumentException("Attempt to modify a node that has been replaced"); //$NON-NLS-1$
}
mods.add(mod);
break;
case INSERT_BEFORE:
int i;
- for (i=mods.size()-1; i>=0; i--) {
+ for (i= mods.size(); --i >= 0;) {
if (mods.get(i).getKind() == ModificationKind.INSERT_BEFORE) {
break;
}
}
- mods.add(i+1, mod);
+ mods.add(i + 1, mod);
break;
}
}
}
/**
- * Returns the list of modifications for a given node. The list can contain different modifications.
- * It is guaranteed that INSERT_BEFORE modifications appear first. Furthermore, if there is a
- * REPLACE modification the list will not contain any other REPLACE or APPEND_CHILD modifications.
+ * Returns the list of modifications for a given node. The list can contain different
+ * modifications. It is guaranteed that INSERT_BEFORE modifications appear first. Furthermore,
+ * if there is a REPLACE modification the list will not contain any other REPLACE or
+ * APPEND_CHILD modifications.
* @return the modification list, which may be empty.
*/
public List<ASTModification> getModificationsForNode(IASTNode node) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
index 700ccad2ee..05ac568168 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
@@ -195,8 +195,9 @@ public class ChangeGenerator extends ASTVisitor {
createChange(synthNode, synthSource);
- int newOffset = synthNode.getFileLocation().getNodeOffset() + synthNode.getFileLocation().getNodeLength();
- sourceOffsets.put(synthNode.getFileLocation().getFileName(), Integer.valueOf(newOffset));
+ IASTFileLocation fileLocation = synthNode.getFileLocation();
+ int newOffset = fileLocation.getNodeOffset() + fileLocation.getNodeLength();
+ sourceOffsets.put(fileLocation.getFileName(), Integer.valueOf(newOffset));
}
private void synthTreatment(IASTTranslationUnit synthTU) {

Back to the top