Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java1
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java41
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenterVisitor.java79
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java86
4 files changed, 102 insertions, 105 deletions
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 e80ac65408..afea96e775 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
@@ -42,7 +42,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
* @author Emanuel Graf IFS
*/
public class ASTWriterVisitor extends ASTVisitor {
-
protected Scribe scribe = new Scribe();
protected NodeCommentMap commentMap;
protected ExpressionWriter expWriter;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java
index 11cb9a659e..e8e2c76f80 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java
@@ -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.commenthandler;
@@ -32,7 +32,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
@@ -56,8 +55,7 @@ import org.eclipse.core.runtime.Path;
*/
public class ASTCommenter {
- private static final class PPRangeChecker extends CPPASTVisitor {
-
+ private static final class PPRangeChecker extends ASTVisitor {
int ppOffset;
int commentOffset;
boolean isPrePPComment = true;
@@ -72,12 +70,12 @@ public class ASTCommenter {
int offset = ((ASTNode)node).getOffset();
int status = ASTVisitor.PROCESS_CONTINUE;
- if(offset > commentOffset && offset < ppOffset) {
+ if (offset > commentOffset && offset < ppOffset) {
isPrePPComment = false;
status = ASTVisitor.PROCESS_ABORT;
- }else if ((offset + ((ASTNode)node).getLength() < commentOffset)) {
+ } else if ((offset + ((ASTNode)node).getLength() < commentOffset)) {
status = ASTVisitor.PROCESS_SKIP;
- }else if(offset > ppOffset) {
+ } else if (offset > ppOffset) {
status = ASTVisitor.PROCESS_ABORT;
}
@@ -165,7 +163,6 @@ public class ASTCommenter {
}
}
-
/**
* Creates a NodeCommentMap for the given TranslationUnit. This is the only way
* to get a NodeCommentMap which contains all the comments mapped against nodes.
@@ -174,11 +171,11 @@ public class ASTCommenter {
* @return NodeCommentMap
*/
public static NodeCommentMap getCommentedNodeMap(IASTTranslationUnit transUnit){
- if(transUnit== null) {
+ if (transUnit== null) {
return new NodeCommentMap();
}
ArrayList<IASTComment> comments = removeNotNeededComments(transUnit);
- if(comments == null || comments.size() == 0) {
+ if (comments == null || comments.size() == 0) {
return new NodeCommentMap();
}
return addCommentsToCommentMap(transUnit, comments);
@@ -219,7 +216,7 @@ public class ASTCommenter {
String fileName = statement.getFileLocation().getFileName();
treeOfPreProcessorLines.put(OffsetHelper.getStartingLineNumber(statement), fileName);
ArrayList<Integer> offsetList = ppOffsetForFiles.get(fileName);
- if(offsetList == null) {
+ if (offsetList == null) {
offsetList = new ArrayList<Integer>();
ppOffsetForFiles.put(fileName, offsetList);
}
@@ -236,7 +233,7 @@ public class ASTCommenter {
)) {
continue;
}
- if(commentIsAtTheBeginningBeforePreprocessorStatements(comment, ppOffsetForFiles.get(fileName), tu)) {
+ if (commentIsAtTheBeginningBeforePreprocessorStatements(comment, ppOffsetForFiles.get(fileName), tu)) {
continue;
}
commentsInCode.add(comment);
@@ -244,33 +241,32 @@ public class ASTCommenter {
return commentsInCode;
}
- private static boolean commentIsAtTheBeginningBeforePreprocessorStatements(
- IASTComment comment,
+ private static boolean commentIsAtTheBeginningBeforePreprocessorStatements(IASTComment comment,
ArrayList<Integer> listOfPreProcessorOffset, IASTTranslationUnit tu) {
- if(listOfPreProcessorOffset == null) {
+ if (listOfPreProcessorOffset == null) {
return false;
}
- if(comment.getTranslationUnit()==null || comment.getTranslationUnit().getDeclarations().length < 1) {
+ if (comment.getTranslationUnit()==null || comment.getTranslationUnit().getDeclarations().length < 1) {
return true;
}
IASTDeclaration decl = comment.getTranslationUnit().getDeclarations()[0];
String commentFileName = comment.getFileLocation().getFileName();
boolean sameFile = decl.getFileLocation().getFileName().equals(commentFileName);
int commentNodeOffset = ((ASTNode)comment).getOffset();
- if(sameFile) {
- if(decl.getFileLocation().getNodeOffset() < commentNodeOffset) {
+ if (sameFile) {
+ if (decl.getFileLocation().getNodeOffset() < commentNodeOffset) {
return false;
}
}
Collections.sort(listOfPreProcessorOffset);
int nextPPOfset = -1;
for (Integer integer : listOfPreProcessorOffset) {
- if(integer > commentNodeOffset) {
+ if (integer > commentNodeOffset) {
nextPPOfset = integer;
PPRangeChecker visti = new PPRangeChecker(true, nextPPOfset, commentNodeOffset);
tu.accept(visti);
- if(visti.isPrePPComment) {
+ if (visti.isPrePPComment) {
return true;
}
}
@@ -283,11 +279,10 @@ public class ASTCommenter {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
IPath nodePath = new Path(node.getContainingFilename());
for (IProject project : projects) {
- if(project.getLocation().isPrefixOf(nodePath)) return true;
+ if (project.getLocation().isPrefixOf(nodePath)) return true;
}
return false;
}
-
private static NodeCommentMap addCommentsToCommentMap(IASTTranslationUnit rootNode, ArrayList<IASTComment> comments){
NodeCommentMap commentMap = new NodeCommentMap();
@@ -295,9 +290,7 @@ public class ASTCommenter {
IASTDeclaration[] declarations = rootNode.getDeclarations();
for (int i = 0; i < declarations.length; i++) {
-
if (isInWorkspace(declarations[i])) {
-
ASTCommenterVisitor commenter = new ASTCommenterVisitor(commHandler, commentMap);
declarations[i].accept(commenter);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenterVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenterVisitor.java
index 503dc28ebd..6d7b1e2677 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenterVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenterVisitor.java
@@ -7,10 +7,11 @@
* 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.commenthandler;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@@ -25,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
@@ -38,8 +38,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier
*
* @author Guido Zgraggen IFS
*/
-public class ASTCommenterVisitor extends CPPASTVisitor {
-
+public class ASTCommenterVisitor extends ASTVisitor {
protected CommentHandler commHandler;
protected NodeCommentMap commentMap;
@@ -69,136 +68,146 @@ public class ASTCommenterVisitor extends CPPASTVisitor {
nodeCommenter = new NodeCommenter(this, commHandler, commentMap);
}
-
public void addRemainingComments(IASTDeclaration declaration) {
nodeCommenter.appendRemainingComments(declaration);
}
-
-
@Override
public int visit(IASTName name) {
- return nodeCommenter.appendComments((ASTNode)name);
+ return nodeCommenter.appendComments((ASTNode) name);
}
@Override
public int visit(IASTDeclSpecifier declSpec) {
- return nodeCommenter.appendComments((ASTNode)declSpec);
+ return nodeCommenter.appendComments((ASTNode) declSpec);
}
@Override
public int visit(IASTExpression expression) {
- return nodeCommenter.appendComments((ASTNode)expression);
+ return nodeCommenter.appendComments((ASTNode) expression);
}
@Override
public int visit(IASTStatement statement) {
- return nodeCommenter.appendComments((ASTNode)statement);
+ return nodeCommenter.appendComments((ASTNode) statement);
}
@Override
public int visit(IASTDeclaration declaration) {
- return nodeCommenter.appendComments((ASTNode)declaration);
+ return nodeCommenter.appendComments((ASTNode) declaration);
}
@Override
public int visit(IASTDeclarator declarator) {
- return nodeCommenter.appendComments((ASTNode)declarator);
+ return nodeCommenter.appendComments((ASTNode) declarator);
}
@Override
public int visit(IASTInitializer initializer) {
- return nodeCommenter.appendComments((ASTNode)initializer);
+ return nodeCommenter.appendComments((ASTNode) initializer);
}
@Override
public int visit(IASTParameterDeclaration parameterDeclaration) {
- return nodeCommenter.appendComments((ASTNode)parameterDeclaration);
+ return nodeCommenter.appendComments((ASTNode) parameterDeclaration);
}
@Override
public int visit(ICPPASTNamespaceDefinition namespace) {
- return nodeCommenter.appendComments((ASTNode)namespace);
+ return nodeCommenter.appendComments((ASTNode) namespace);
}
@Override
public int visit(ICPPASTTemplateParameter parameter) {
- return nodeCommenter.appendComments((ASTNode)parameter);
+ return nodeCommenter.appendComments((ASTNode) parameter);
}
@Override
public int leave(IASTTranslationUnit tu) {
- nodeCommenter.appendComments((ASTNode)tu);
+ nodeCommenter.appendComments((ASTNode) tu);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTName name) {
- nodeCommenter.appendComments((ASTNode)name);
+ nodeCommenter.appendComments((ASTNode) name);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTDeclaration declaration) {
- nodeCommenter.appendComments((ASTNode)declaration);
+ nodeCommenter.appendComments((ASTNode) declaration);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(ICPPASTNamespaceDefinition namespaceDefinition) {
- return nodeCommenter.appendFreestandingComments((ASTNode)namespaceDefinition);
+ return nodeCommenter.appendFreestandingComments((ASTNode) namespaceDefinition);
}
+
@Override
public int leave(IASTInitializer initializer) {
- nodeCommenter.appendComments((ASTNode)initializer);
+ nodeCommenter.appendComments((ASTNode) initializer);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTParameterDeclaration parameterDeclaration) {
- nodeCommenter.appendComments((ASTNode)parameterDeclaration);
+ nodeCommenter.appendComments((ASTNode) parameterDeclaration);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTDeclarator declarator) {
- nodeCommenter.appendComments((ASTNode)declarator);
+ nodeCommenter.appendComments((ASTNode) declarator);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTDeclSpecifier declSpec) {
if(declSpec instanceof CPPASTCompositeTypeSpecifier) {
- return nodeCommenter.appendFreestandingComments((ASTNode)declSpec);
+ return nodeCommenter.appendFreestandingComments((ASTNode) declSpec);
}
- nodeCommenter.appendComments((ASTNode)declSpec);
+ nodeCommenter.appendComments((ASTNode) declSpec);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTExpression expression) {
- nodeCommenter.appendComments((ASTNode)expression);
+ nodeCommenter.appendComments((ASTNode) expression);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTStatement statement) {
if(statement instanceof IASTCompoundStatement) {
- return nodeCommenter.appendFreestandingComments((ASTNode)statement);
+ return nodeCommenter.appendFreestandingComments((ASTNode) statement);
}
- nodeCommenter.appendComments((ASTNode)statement);
+ nodeCommenter.appendComments((ASTNode) statement);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTTypeId typeId) {
- nodeCommenter.appendComments((ASTNode)typeId);
+ nodeCommenter.appendComments((ASTNode) typeId);
return PROCESS_CONTINUE;
}
+
@Override
public int leave(IASTEnumerator enumerator) {
- nodeCommenter.appendComments((ASTNode)enumerator);
+ nodeCommenter.appendComments((ASTNode) enumerator);
return PROCESS_CONTINUE;
- }
+ }
+
@Override
public int leave(IASTProblem problem){
- nodeCommenter.appendComments((ASTNode)problem);
+ nodeCommenter.appendComments((ASTNode) problem);
return PROCESS_CONTINUE;
- }
+ }
+
@Override
public int leave( IASTComment comment){
- nodeCommenter.appendComments((ASTNode)comment);
+ nodeCommenter.appendComments((ASTNode) comment);
return PROCESS_CONTINUE;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java
index b13f427eda..5ae49e8f7d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java
@@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
@@ -63,13 +62,12 @@ import org.eclipse.core.runtime.Path;
* @author Guido Zgraggen IFS
*/
public class NodeCommenter {
-
- protected CPPASTVisitor visitor;
+ protected ASTVisitor visitor;
protected CommentHandler commHandler;
protected NodeCommentMap commentMap;
protected Vector<IASTNode> children;
- public NodeCommenter(CPPASTVisitor visitor, CommentHandler commHandler, NodeCommentMap commentMap) {
+ public NodeCommenter(ASTVisitor visitor, CommentHandler commHandler, NodeCommentMap commentMap) {
this.visitor = visitor;
this.commHandler = commHandler;
this.commentMap = commentMap;
@@ -77,13 +75,13 @@ public class NodeCommenter {
}
protected void writeNodeList(IASTNode[] nodes) {
- for(int i = 0; i < nodes.length; ++i) {
+ for (int i = 0; i < nodes.length; ++i) {
nodes[i].accept(visitor);
}
}
protected void visitNodeIfNotNull(IASTNode node){
- if(node != null){
+ if (node != null){
node.accept(visitor);
}
}
@@ -91,19 +89,18 @@ public class NodeCommenter {
protected boolean appendComment(ASTNode node, IASTComment comment) {
ASTNode com = (ASTNode) comment;
- if(node.getFileLocation() == null) {
- //MacroExpansions have no Filelocation
+ if (node.getFileLocation() == null) {
+ //MacroExpansions have no FileLocation
return false;
}
int nodeLineNumber = OffsetHelper.getEndingLineNumber(node);
int commentLineNumber= OffsetHelper.getStartingLineNumber(comment);
- if(OffsetHelper.getNodeEndPoint(com) <= OffsetHelper.getNodeOffset(node)) {
+ if (OffsetHelper.getNodeEndPoint(com) <= OffsetHelper.getNodeOffset(node)) {
addLeadingCommentToMap(node, comment);
return true;
- }
- else if(isTrailing(node, com, nodeLineNumber, commentLineNumber)) {
+ } else if (isTrailing(node, com, nodeLineNumber, commentLineNumber)) {
addTrailingCommentToMap(node, comment);
return true;
}
@@ -113,11 +110,11 @@ public class NodeCommenter {
protected boolean appendFreestandingComment(ASTNode node, IASTComment comment) {
ASTNode com = (ASTNode) comment;
- if(node.getFileLocation() == null) {
+ if (node.getFileLocation() == null) {
//MacroExpansions have no Filelocation
return false;
}
- if(OffsetHelper.getNodeEndPoint(com) <= OffsetHelper.getNodeEndPoint(node)) {
+ if (OffsetHelper.getNodeEndPoint(com) <= OffsetHelper.getNodeEndPoint(node)) {
addFreestandingCommentToMap(node, comment);
return true;
}
@@ -140,12 +137,11 @@ public class NodeCommenter {
}
private boolean isTrailing(ASTNode node, ASTNode com, int nodeLineNumber, int commentLineNumber) {
- if(nodeLineNumber == commentLineNumber
+ if (nodeLineNumber == commentLineNumber
&& OffsetHelper.getNodeOffset(com) >= OffsetHelper.getNodeEndPoint(node)
&& canNotBeAddedToParent(node,com)
&& !mustBeAddToSubnodes(node)) {
-
- if(OffsetHelper.getNodeOffset(com) < OffsetHelper.getNodeEndPoint(node) + 2) {
+ if (OffsetHelper.getNodeOffset(com) < OffsetHelper.getNodeEndPoint(node) + 2) {
return true;
}
IPath path = new Path(node.getContainingFilename());
@@ -159,15 +155,15 @@ public class NodeCommenter {
byte[] b = new byte[length];
long count = is.skip(OffsetHelper.getEndOffsetWithoutComments(node));
- if(count < OffsetHelper.getEndOffsetWithoutComments(node)) {
+ if (count < OffsetHelper.getEndOffsetWithoutComments(node)) {
return false;
}
- if(is.read(b, 0, length) == -1) {
+ if (is.read(b, 0, length) == -1) {
return false;
}
- for(byte bb : b) {
- if(!Character.isWhitespace(bb)) {
+ for (byte bb : b) {
+ if (!Character.isWhitespace(bb)) {
is.close();
return false;
}
@@ -185,15 +181,15 @@ public class NodeCommenter {
private boolean canNotBeAddedToParent(ASTNode node, ASTNode com) {
ASTNode parent = (ASTNode) node.getParent();
- if(hasNodeSameEndingAsSubnode(parent)) {
+ if (hasNodeSameEndingAsSubnode(parent)) {
return true;
- }else if(parent instanceof IASTTranslationUnit) {
+ } else if (parent instanceof IASTTranslationUnit) {
return true;
- }else if(parent instanceof ICPPASTTemplateDeclaration) {
+ } else if (parent instanceof ICPPASTTemplateDeclaration) {
return true;
- }else if(parent instanceof CPPASTIfStatement) {
+ } else if (parent instanceof CPPASTIfStatement) {
return true;
- }else if(parent instanceof ICPPASTBaseSpecifier) {
+ } else if (parent instanceof ICPPASTBaseSpecifier) {
parent = (ASTNode) parent.getParent();
}
return !(OffsetHelper.getNodeOffset(com) >= OffsetHelper.getNodeEndPoint(parent));
@@ -204,39 +200,39 @@ public class NodeCommenter {
}
private boolean hasNodeSameEndingAsSubnode(ASTNode node) {
- if(node instanceof CPPASTFunctionDefinition) {
+ if (node instanceof CPPASTFunctionDefinition) {
return true;
- }else if(node instanceof CPPASTDeclarationStatement) {
+ } else if (node instanceof CPPASTDeclarationStatement) {
return true;
- }else if(node instanceof CPPASTForStatement) {
+ } else if (node instanceof CPPASTForStatement) {
return true;
- }else if(node instanceof CPPASTLabelStatement) {
+ } else if (node instanceof CPPASTLabelStatement) {
return true;
- }else if(node instanceof CPPASTIfStatement) {
+ } else if (node instanceof CPPASTIfStatement) {
return true;
- }else if(node instanceof CPPASTSwitchStatement) {
+ } else if (node instanceof CPPASTSwitchStatement) {
return true;
- }else if(node instanceof CPPASTWhileStatement) {
+ } else if (node instanceof CPPASTWhileStatement) {
return true;
- }else if(node instanceof CPPASTTemplateDeclaration) {
+ } else if (node instanceof CPPASTTemplateDeclaration) {
return true;
- }else if(node instanceof CPPASTLinkageSpecification) {
+ } else if (node instanceof CPPASTLinkageSpecification) {
return true;
- }else if(node instanceof CPPASTExplicitTemplateInstantiation) {
+ } else if (node instanceof CPPASTExplicitTemplateInstantiation) {
return true;
}
return false;
}
protected int appendComments(ASTNode node) {
- while(commHandler.hasMore()) {
+ while (commHandler.hasMore()) {
IASTComment comment = commHandler.getFirst();
- if(isNotSameFile(node, comment)) {
+ if (isNotSameFile(node, comment)) {
return ASTVisitor.PROCESS_SKIP;
}
- if(!appendComment(node, comment)) {
+ if (!appendComment(node, comment)) {
return ASTVisitor.PROCESS_CONTINUE;
}
}
@@ -244,18 +240,18 @@ public class NodeCommenter {
}
protected int appendFreestandingComments(ASTNode node) {
- while(commHandler.hasMore()) {
+ while (commHandler.hasMore()) {
IASTComment comment = commHandler.getFirst();
- if(isNotSameFile(node, comment)) {
+ if (isNotSameFile(node, comment)) {
return ASTVisitor.PROCESS_SKIP;
}
- if(appendComment(node, comment)) {
+ if (appendComment(node, comment)) {
return ASTVisitor.PROCESS_CONTINUE;
}
- if(!appendFreestandingComment(node, comment)) {
+ if (!appendFreestandingComment(node, comment)) {
return ASTVisitor.PROCESS_CONTINUE;
}
}
@@ -263,9 +259,9 @@ public class NodeCommenter {
}
public void appendRemainingComments(IASTDeclaration declaration) {
- while(commHandler.hasMore()) {
+ while (commHandler.hasMore()) {
IASTComment comment = commHandler.getFirst();
- if(appendComment((ASTNode)declaration, comment)) {
+ if (appendComment((ASTNode)declaration, comment)) {
continue;
}
addFreestandingCommentToMap((ASTNode) declaration, comment);
@@ -273,7 +269,7 @@ public class NodeCommenter {
}
private boolean isNotSameFile(IASTNode node, IASTComment comment) {
- if(node.getFileLocation()==null) {
+ if (node.getFileLocation() == null) {
return true;
}
return !node.getFileLocation().getFileName().equals(comment.getFileLocation().getFileName());

Back to the top