Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2018-11-20 11:20:42 -0500
committerJonah Graham2018-11-22 16:47:02 -0500
commit170e654b4796bad1453ae85a427b97317d67a69a (patch)
tree6ca9b8a8fedd5fd25f97eb79c408312e256ff981 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler
parent35996a5c5ca5c254959ba48241eaada6dbf8628d (diff)
downloadorg.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.gz
org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.xz
org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.zip
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then Source -> Clean Up... -> choosing: - Format source code - Remove trailing white spaces on all lines and completing the wizard Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenter.java49
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenterVisitor.java39
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/CommentHandler.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommentMap.java40
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java71
5 files changed, 108 insertions, 109 deletions
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 2235e192a1..a8f061a2c0 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
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
@@ -43,16 +43,16 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
/**
- * This is the starting point of the entire comment handling process. The creation of the
+ * This is the starting point of the entire comment handling process. The creation of the
* {@link NodeCommentMap} is based on the {@link IASTTranslationUnit}. From this translation unit
* the comments are extracted and skipped if they belong not to the same workspace.
* An {@link ASTCommenterVisitor} is initialized with this collection of comments. And the visit
- * process can start.
- *
+ * process can start.
+ *
* @see NodeCommenter
* @see NodeCommentMap
- *
- * @author Guido Zgraggen IFS
+ *
+ * @author Guido Zgraggen IFS
*/
public class ASTCommenter {
@@ -71,11 +71,11 @@ public class ASTCommenter {
IASTFileLocation nodeLocation = node.getFileLocation();
if (nodeLocation == null)
return PROCESS_SKIP;
-
+
int nodeEndOffset = nodeLocation.getNodeOffset() + nodeLocation.getNodeLength();
- boolean nodeInBetweenCommentAndPpStmt =
- nodeEndOffset > commentLocation.getNodeOffset() && nodeEndOffset < ppStmtOffset;
+ boolean nodeInBetweenCommentAndPpStmt = nodeEndOffset > commentLocation.getNodeOffset()
+ && nodeEndOffset < ppStmtOffset;
if (isCommentOnSameLine(node) || nodeInBetweenCommentAndPpStmt) {
isPrePpStmtComment = false;
return PROCESS_ABORT;
@@ -84,20 +84,21 @@ public class ASTCommenter {
} else if (nodeLocation.getNodeOffset() > ppStmtOffset) {
return PROCESS_ABORT;
}
-
+
return PROCESS_CONTINUE;
}
private boolean isCommentOnSameLine(IASTNode node) {
IASTFileLocation fileLocation = node.getFileLocation();
- return fileLocation != null && commentLocation.getStartingLineNumber() == fileLocation.getEndingLineNumber();
+ return fileLocation != null
+ && commentLocation.getStartingLineNumber() == fileLocation.getEndingLineNumber();
}
@Override
public int visit(ICPPASTBaseSpecifier baseSpecifier) {
return checkOffsets(baseSpecifier);
}
-
+
@Override
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
return checkOffsets(namespaceDefinition);
@@ -177,7 +178,7 @@ public class ASTCommenter {
/**
* Creates a NodeCommentMap for the given AST. This is the only way to get a NodeCommentMap
* which contains all the comments mapped against nodes.
- *
+ *
* @param ast the AST
* @return NodeCommentMap
*/
@@ -193,7 +194,7 @@ public class ASTCommenter {
/**
* Adds all comments given in {@code ast} to the {@code commentMap}. Calling this twice has
* no effect.
- *
+ *
* @param ast
* the AST which contains the comments to add
* @param commentMap
@@ -235,13 +236,13 @@ public class ASTCommenter {
public static boolean isInWorkspace(IASTNode node) {
return node.isPartOfTranslationUnitFile();
}
-
+
/**
* Puts leading and trailing comments to {@code commentMap} and removes them from
- * the {@code comments} list.
+ * the {@code comments} list.
*/
- private static void assignPreprocessorComments(NodeCommentMap commentMap,
- List<IASTComment> comments, IASTTranslationUnit tu) {
+ private static void assignPreprocessorComments(NodeCommentMap commentMap, List<IASTComment> comments,
+ IASTTranslationUnit tu) {
IASTPreprocessorStatement[] preprocessorStatementsArray = tu.getAllPreprocessorStatements();
if (preprocessorStatementsArray == null) {
return;
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 e4f757f2bc..f1fd54dbe0 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
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
@@ -35,18 +35,18 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier
/**
* A visitor for the comments. Calls the NodeCommenter to assign the comments.
- *
- * @see org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommenter
- *
- * @author Guido Zgraggen IFS
+ *
+ * @see org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommenter
+ *
+ * @author Guido Zgraggen IFS
*/
public class ASTCommenterVisitor extends ASTVisitor {
protected CommentHandler commentHandler;
protected NodeCommentMap commentMap;
-
+
private NodeCommenter nodeCommenter;
private IASTDeclaration lastDecl;
-
+
{
shouldVisitBaseSpecifiers = true;
shouldVisitDeclarations = true;
@@ -62,7 +62,7 @@ public class ASTCommenterVisitor extends ASTVisitor {
shouldVisitTypeIds = true;
shouldVisitTranslationUnit = true;
}
-
+
public ASTCommenterVisitor(CommentHandler commentHandler, NodeCommentMap commentMap) {
this.commentHandler = commentHandler;
this.commentMap = commentMap;
@@ -72,7 +72,7 @@ public class ASTCommenterVisitor extends ASTVisitor {
private void init() {
nodeCommenter = new NodeCommenter(this, commentHandler, commentMap);
}
-
+
@Override
public int visit(IASTName name) {
return nodeCommenter.appendComments((ASTNode) name);
@@ -108,7 +108,7 @@ public class ASTCommenterVisitor extends ASTVisitor {
@Override
public int visit(IASTDeclarator declarator) {
- return nodeCommenter.appendComments((ASTNode) declarator);
+ return nodeCommenter.appendComments((ASTNode) declarator);
}
@Override
@@ -120,7 +120,7 @@ public class ASTCommenterVisitor extends ASTVisitor {
public int visit(IASTParameterDeclaration parameterDeclaration) {
return nodeCommenter.appendComments((ASTNode) parameterDeclaration);
}
-
+
@Override
public int visit(ICPPASTNamespaceDefinition namespace) {
return nodeCommenter.appendComments((ASTNode) namespace);
@@ -140,7 +140,6 @@ public class ASTCommenterVisitor extends ASTVisitor {
return PROCESS_CONTINUE;
}
-
@Override
public int leave(IASTName name) {
nodeCommenter.appendComments((ASTNode) name);
@@ -179,7 +178,7 @@ public class ASTCommenterVisitor extends ASTVisitor {
@Override
public int leave(IASTDeclSpecifier declSpec) {
- if(declSpec instanceof CPPASTCompositeTypeSpecifier) {
+ if (declSpec instanceof CPPASTCompositeTypeSpecifier) {
return nodeCommenter.appendFreestandingComments((ASTNode) declSpec);
}
nodeCommenter.appendComments((ASTNode) declSpec);
@@ -194,7 +193,7 @@ public class ASTCommenterVisitor extends ASTVisitor {
@Override
public int leave(IASTStatement statement) {
- if(statement instanceof IASTCompoundStatement) {
+ if (statement instanceof IASTCompoundStatement) {
return nodeCommenter.appendFreestandingComments((ASTNode) statement);
}
nodeCommenter.appendComments((ASTNode) statement);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/CommentHandler.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/CommentHandler.java
index ce69c1562d..e09d8080e0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/CommentHandler.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/CommentHandler.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
@@ -22,12 +22,12 @@ import org.eclipse.cdt.core.dom.ast.IASTComment;
* The CommentHandler is initialized with all the comment which should be processed.
* During the process of comment assignment this comment collection is work through one
* after another until no more comments are left.
- *
+ *
* @author Guido Zgraggen IFS
*/
public class CommentHandler {
private final List<IASTComment> comments;
-
+
public CommentHandler(List<IASTComment> comments) {
super();
this.comments = comments;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommentMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommentMap.java
index 5a2333b900..f8f0d14d34 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommentMap.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommentMap.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2014 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
@@ -27,10 +27,10 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.rewrite.util.ASTNodes;
/**
- * The NodeCommentMap is the map where all the comments are assigned to a node. For better
- * performance the comments are stored in three different maps which have the same name as
+ * The NodeCommentMap is the map where all the comments are assigned to a node. For better
+ * performance the comments are stored in three different maps which have the same name as
* the relative position of the comment.
- *
+ *
* @author Guido Zgraggen IFS
*/
public class NodeCommentMap {
@@ -38,7 +38,7 @@ public class NodeCommentMap {
protected final Map<IASTNode, List<IASTComment>> trailingMap = new HashMap<IASTNode, List<IASTComment>>();
protected final Map<IASTNode, List<IASTComment>> freestandingMap = new HashMap<IASTNode, List<IASTComment>>();
protected final List<IASTTranslationUnit> coveredUnits = new ArrayList<IASTTranslationUnit>();
-
+
/**
* Add a comment to the map with the trailing comments.
* @param node The node is the key.
@@ -52,9 +52,9 @@ public class NodeCommentMap {
comments.add(comment);
trailingMap.put(node, comments);
}
-
+
/**
- * Returns a List for the given node. This List contains all the comments
+ * Returns a List for the given node. This List contains all the comments
* which are assigned to this specific node. If no comments are available an empty
* List is returned.
* @param node The key to fetch the associated comments.
@@ -64,7 +64,7 @@ public class NodeCommentMap {
List<IASTComment> list = trailingMap.get(node);
return list != null ? list : new ArrayList<IASTComment>();
}
-
+
/**
* Add a comment to the map with the leading comments.
* @param node The node is the key.
@@ -78,9 +78,9 @@ public class NodeCommentMap {
comments.add(comment);
leadingMap.put(node, comments);
}
-
+
/**
- * Returns a List for the given node. This List contains all the comments
+ * Returns a List for the given node. This List contains all the comments
* which are assigned to this specific node. If no comments are available an empty
* List is returned.
* @param node The key to fetch the associated comments.
@@ -90,7 +90,7 @@ public class NodeCommentMap {
List<IASTComment> list = leadingMap.get(node);
return list != null ? list : new ArrayList<IASTComment>();
}
-
+
/**
* Add a comment to the map with the freestanding comments.
* @param node The node is the key.
@@ -104,9 +104,9 @@ public class NodeCommentMap {
comments.add(comment);
freestandingMap.put(node, comments);
}
-
+
/**
- * Returns a List for the given node. This List contains all the comments
+ * Returns a List for the given node. This List contains all the comments
* which are assigned to this specific node. If no comments are available an empty
* List is returned.
* @param node The key to fetch the associated comments.
@@ -142,7 +142,7 @@ public class NodeCommentMap {
}
/**
- * Returns an List for the given node. This List contains all the comments
+ * Returns an List for the given node. This List contains all the comments
* which are assigned to this specific node. If no comments are available an empty
* List is returned.
* @param node The key to fetch the associated comments.
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 687456f8ea..378f98c5cc 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
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
@@ -42,25 +42,25 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTWhileStatement;
* The NodeCommenter contains all the logic that is needed for the ASTCommentVisitor to assign
* the comments to the suitable node. Together with the ASTCommenterVisitor it fills all
* the comments with the correspondent node into the NodeCommentMap.
- *
+ *
* Following, a little explanation of the assignment logic. It is only a loose illustration
* a detailed description would include a combined explanation of ASTCommenterVisitor and
* NodeCommenter.<br>
* To understand the logic we define the three types of comments:<br>
* leading comments - Comments before a statement, declaration, or definition.<br>
* trailing comments - Comments right after the AST node on the same line.<br>
- * freestanding comments - Comments before a closing brace such as they occur in
+ * freestanding comments - Comments before a closing brace such as they occur in
* namespace-, class- and method-definitions or at the end of a file.<br>
- *
+ *
* The first comment is fetched and the position of it is compared to the position of the actual
* node. If the position of the comment is smaller than the comment is added to the node as leading.
* If it is behind the node but on the same line it is added as trailing. If one of these
* possibilities match the next comment is fetched for the same check. If it doesn't match the same
* procedure is done for all the child nodes. After checking the sub nodes the actual node is
- * checked again if the comment is trailing. Then there is also the possibility that this comment is
+ * checked again if the comment is trailing. Then there is also the possibility that this comment is
* freestanding. This is the case when the comment is not added to any child node but the position
- * is smaller than the end position of the node.
- *
+ * is smaller than the end position of the node.
+ *
* @author Guido Zgraggen IFS
*/
public class NodeCommenter {
@@ -81,9 +81,9 @@ public class NodeCommenter {
nodes[i].accept(visitor);
}
}
-
- protected void visitNodeIfNotNull(IASTNode node){
- if (node != null){
+
+ protected void visitNodeIfNotNull(IASTNode node) {
+ if (node != null) {
node.accept(visitor);
}
}
@@ -95,10 +95,10 @@ public class NodeCommenter {
// MacroExpansions have no FileLocation
return false;
}
-
+
int nodeLineNumber = getEndingLineNumber(node);
- int commentLineNumber= getStartingLineNumber(comment);
-
+ int commentLineNumber = getStartingLineNumber(comment);
+
if (getNodeEndPoint(com) <= getNodeOffset(node)) {
addLeadingCommentToMap(node, comment);
return true;
@@ -108,7 +108,7 @@ public class NodeCommenter {
}
return false;
}
-
+
protected boolean appendFreestandingComment(ASTNode node, IASTComment comment) {
ASTNode com = (ASTNode) comment;
@@ -139,10 +139,8 @@ public class NodeCommenter {
}
private boolean isTrailing(ASTNode node, ASTNode com, int nodeLineNumber, int commentLineNumber) {
- if (nodeLineNumber != commentLineNumber ||
- getNodeOffset(com) < getNodeEndPoint(node) ||
- !canNotBeAddedToParent(node, com) ||
- mustBeAddedToSubnodes(node)) {
+ if (nodeLineNumber != commentLineNumber || getNodeOffset(com) < getNodeEndPoint(node)
+ || !canNotBeAddedToParent(node, com) || mustBeAddedToSubnodes(node)) {
return false;
}
if (getNodeOffset(com) < getNodeEndPoint(node) + 2) {
@@ -156,9 +154,10 @@ public class NodeCommenter {
}
return true;
}
+
private boolean canNotBeAddedToParent(ASTNode node, ASTNode com) {
ASTNode parent = (ASTNode) node.getParent();
-
+
if (hasNodeSameEndingAsSubnode(parent)) {
return true;
} else if (parent instanceof IASTTranslationUnit) {
@@ -176,7 +175,7 @@ public class NodeCommenter {
private boolean mustBeAddedToSubnodes(ASTNode node) {
return hasNodeSameEndingAsSubnode(node);
}
-
+
private boolean hasNodeSameEndingAsSubnode(ASTNode node) {
if (node instanceof CPPASTFunctionDefinition) {
return true;
@@ -201,41 +200,41 @@ public class NodeCommenter {
}
return false;
}
-
+
protected int appendComments(ASTNode node) {
while (commentHandler.hasMore()) {
IASTComment comment = commentHandler.getFirst();
-
+
if (isNotSameFile(node, comment)) {
return ASTVisitor.PROCESS_SKIP;
}
-
+
if (!appendComment(node, comment)) {
return ASTVisitor.PROCESS_CONTINUE;
}
}
return ASTVisitor.PROCESS_ABORT;
}
-
+
protected int appendFreestandingComments(ASTNode node) {
while (commentHandler.hasMore()) {
IASTComment comment = commentHandler.getFirst();
-
+
if (isNotSameFile(node, comment)) {
return ASTVisitor.PROCESS_SKIP;
}
-
+
if (appendComment(node, comment)) {
return ASTVisitor.PROCESS_CONTINUE;
}
-
+
if (!appendFreestandingComment(node, comment)) {
return ASTVisitor.PROCESS_CONTINUE;
}
}
return ASTVisitor.PROCESS_ABORT;
}
-
+
public void appendRemainingComments(IASTDeclaration declaration) {
while (commentHandler.hasMore()) {
IASTComment comment = commentHandler.getFirst();
@@ -245,7 +244,7 @@ public class NodeCommenter {
addFreestandingCommentToMap((ASTNode) declaration, comment);
}
}
-
+
private boolean isNotSameFile(IASTNode node, IASTComment comment) {
if (node.getFileLocation() == null) {
return true;
@@ -257,7 +256,7 @@ public class NodeCommenter {
IASTFileLocation fileLocation = node.getFileLocation();
return fileLocation.getNodeOffset() + fileLocation.getNodeLength();
}
-
+
private static int getNodeOffset(ASTNode node) {
return node.getOffset();
}

Back to the top