Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-03-13 05:49:37 -0400
committerMarkus Schorn2008-03-13 05:49:37 -0400
commit2ee490ecf38060997a582bd9ec0d87f3b2afe6be (patch)
tree625618c0541d7af4ad6448054b6300d59de5b48d
parentda521c277ce97865a927d4efa64aa06541fffb07 (diff)
downloadorg.eclipse.cdt-2ee490ecf38060997a582bd9ec0d87f3b2afe6be.tar.gz
org.eclipse.cdt-2ee490ecf38060997a582bd9ec0d87f3b2afe6be.tar.xz
org.eclipse.cdt-2ee490ecf38060997a582bd9ec0d87f3b2afe6be.zip
Improved comment assignment for the NodeCommenter, by Guido Zgraggen, bug 222529.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java79
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts73
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts23
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource2.awts10
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/rewrite/CommentHandlingTestSource.rts228
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/ASTCommenterVisitor.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommentMap.java28
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java19
9 files changed, 318 insertions, 148 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java
index 3ccb632a8b..ee1912a8ef 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java
@@ -142,7 +142,7 @@ public class RewriteTester extends TestSuite{
}
return test;
} catch (ClassNotFoundException e) {
- throw new Exception("Unknown TestClass. Make sure the test's sourcefile specifies a valid test class.");
+ throw new Exception("Unknown TestClass: " + e.getMessage() + ". Make sure the test's sourcefile specifies a valid test class.");
} catch (SecurityException e) {
throw new Exception("Security Exception during Test creation", e);
} catch (NoSuchMethodException e) {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java
index 2d4f334dce..436cc3e7d9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java
@@ -39,17 +39,29 @@ public class NodeCommentMapTest extends TestCase {
public void testNoComment(){
ASTNode node = new CPPASTName();
- assertEquals(0, map.getCommentsForNode(node).size());
+ assertEquals(0, map.getLeadingCommentsForNode(node).size());
+ assertEquals(0, map.getTrailingCommentsForNode(node).size());
+ assertEquals(0, map.getFreestandingCommentsForNode(node).size());
}
public void testOneComment(){
ASTNode node = new CPPASTName();
- IASTComment comm = new Comment();
+ IASTComment comm1 = new Comment();
+ IASTComment comm2 = new Comment();
+ IASTComment comm3 = new Comment();
- map.addCommentToNode(node, comm);
- assertEquals(1, map.getCommentsForNode(node).size());
- assertEquals(comm, map.getCommentsForNode(node).get(0));
+ map.addLeadingCommentToNode(node, comm1);
+ map.addTrailingCommentToNode(node, comm2);
+ map.addFreestandingCommentToNode(node, comm3);
+
+ assertEquals(1, map.getLeadingCommentsForNode(node).size());
+ assertEquals(1, map.getTrailingCommentsForNode(node).size());
+ assertEquals(1, map.getFreestandingCommentsForNode(node).size());
+
+ assertEquals(comm1, map.getLeadingCommentsForNode(node).get(0));
+ assertEquals(comm2, map.getTrailingCommentsForNode(node).get(0));
+ assertEquals(comm3, map.getFreestandingCommentsForNode(node).get(0));
}
public void testTwoComment(){
@@ -57,12 +69,23 @@ public class NodeCommentMapTest extends TestCase {
IASTComment com1 = new Comment();
IASTComment com2 = new Comment();
- map.addCommentToNode(node, com1);
- map.addCommentToNode(node, com2);
+ map.addLeadingCommentToNode(node, com1);
+ map.addLeadingCommentToNode(node, com2);
+ map.addTrailingCommentToNode(node, com1);
+ map.addTrailingCommentToNode(node, com2);
+ map.addFreestandingCommentToNode(node, com1);
+ map.addFreestandingCommentToNode(node, com2);
- assertEquals(2, map.getCommentsForNode(node).size());
- assertEquals(com1, map.getCommentsForNode(node).get(0));
- assertEquals(com2, map.getCommentsForNode(node).get(1));
+ assertEquals(2, map.getLeadingCommentsForNode(node).size());
+ assertEquals(2, map.getTrailingCommentsForNode(node).size());
+ assertEquals(2, map.getFreestandingCommentsForNode(node).size());
+
+ assertEquals(com1, map.getLeadingCommentsForNode(node).get(0));
+ assertEquals(com2, map.getLeadingCommentsForNode(node).get(1));
+ assertEquals(com1, map.getTrailingCommentsForNode(node).get(0));
+ assertEquals(com2, map.getTrailingCommentsForNode(node).get(1));
+ assertEquals(com1, map.getFreestandingCommentsForNode(node).get(0));
+ assertEquals(com2, map.getFreestandingCommentsForNode(node).get(1));
}
@@ -72,17 +95,37 @@ public class NodeCommentMapTest extends TestCase {
IASTComment com1 = new Comment();
IASTComment com2 = new Comment();
IASTComment com3 = new Comment();
+
+ map.addLeadingCommentToNode(node1, com1);
+ map.addLeadingCommentToNode(node2, com2);
+ map.addLeadingCommentToNode(node1, com3);
+
+ map.addTrailingCommentToNode(node1, com1);
+ map.addTrailingCommentToNode(node2, com2);
+ map.addTrailingCommentToNode(node1, com3);
+
+ map.addFreestandingCommentToNode(node1, com1);
+ map.addFreestandingCommentToNode(node2, com2);
+ map.addFreestandingCommentToNode(node1, com3);
+
+ assertEquals(2, map.getLeadingCommentsForNode(node1).size());
+ assertEquals(1, map.getLeadingCommentsForNode(node2).size());
+ assertEquals(2, map.getTrailingCommentsForNode(node1).size());
+ assertEquals(1, map.getTrailingCommentsForNode(node2).size());
+ assertEquals(2, map.getFreestandingCommentsForNode(node1).size());
+ assertEquals(1, map.getFreestandingCommentsForNode(node2).size());
+ assertEquals(com1, map.getLeadingCommentsForNode(node1).get(0));
+ assertEquals(com2, map.getLeadingCommentsForNode(node2).get(0));
+ assertEquals(com3, map.getLeadingCommentsForNode(node1).get(1));
- map.addCommentToNode(node1, com1);
- map.addCommentToNode(node2, com2);
- map.addCommentToNode(node1, com3);
+ assertEquals(com1, map.getTrailingCommentsForNode(node1).get(0));
+ assertEquals(com2, map.getTrailingCommentsForNode(node2).get(0));
+ assertEquals(com3, map.getTrailingCommentsForNode(node1).get(1));
- assertEquals(2, map.getCommentsForNode(node1).size());
- assertEquals(1, map.getCommentsForNode(node2).size());
- assertEquals(com1, map.getCommentsForNode(node1).get(0));
- assertEquals(com2, map.getCommentsForNode(node2).get(0));
- assertEquals(com3, map.getCommentsForNode(node1).get(1));
+ assertEquals(com1, map.getFreestandingCommentsForNode(node1).get(0));
+ assertEquals(com2, map.getFreestandingCommentsForNode(node2).get(0));
+ assertEquals(com3, map.getFreestandingCommentsForNode(node1).get(1));
}
diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts
index e814662df5..dea92c8ef2 100644
--- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts
+++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts
@@ -35,6 +35,44 @@ int i = 2, y = 3; //TEST 2
//TEST 3
int b = 0; //TEST 4
+//!Commented SimpleDeclarationTest 2
+//%CPP
+/*TEST 1*/
+int i = 2, y = 3; /*TEST 2*/
+/*TEST 3*/
+int b = 0; /*TEST 4*/
+
+//!Commented ExplicitTemplateInstantion 1
+//%CPP
+//TEST 1
+template class vector<int>; //TEST 2
+
+//!Commented ExplicitTemplateInstantion 2
+//%CPP
+/*TEST 1*/
+template class vector<int>; /*TEST 2*/
+
+//!Commented GPPExplicitTemplateInstantion 1
+//%CPP GNU
+//TEST 1
+static template class vector<int>; //TEST 2
+//TEST 3
+inline template class vector<int>; //TEST 4
+//TEST 5
+inline template class vector<int>; //TEST 6
+
+//!Commented LinkageSpecification 1
+//%CPP
+//TEST 1
+extern "C" typedef void FUNC(); //TEST 2
+
+
+//!Commented LinkageSpecification 2
+//%CPP
+/*TEST 1*/
+extern "C" typedef void FUNC(); /*TEST 2*/
+
+
//!Commented NamespaceAlias 1
//%CPP
//TEST 1
@@ -45,6 +83,41 @@ namespace kurz = ziemlichlangernamespace; //TEST 2
/*TEST 1*/
namespace kurz = ziemlichlangernamespace; /*TEST 2*/
+//!Commented NamespaceDefinition 1
+//%CPP
+//TEST 1
+namespace ziemlichlangernamespace
+{
+ //TEST 2
+} //TEST 3
+
+//!Commented NamespaceDefinition 2
+//%CPP
+/*TEST 1*/
+namespace ziemlichlangernamespace
+{
+ /*TEST 2*/
+} /*TEST 3*/
+
+//!Commented NamespaceDefinition 3
+//%CPP
+namespace ziemlichlangernamespace
+{
+ //TEST
+}
+
+//!Commented NamespaceDefinition 4
+//%CPP
+namespace ziemlichlangernamespace
+{
+ //TEST
+}
+void doIt()
+{
+ int i = 0;
+}
+
+
//!Commented TemplateDeclaration 1
//%CPP
//TEST 1
diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts
index f436b1da35..564bcd0506 100644
--- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts
+++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts
@@ -250,26 +250,3 @@ void foo()
}
-//!Commented ICPPASTFunctionTryBlockDeclarator 14
-//%CPP
-void foo()
-{
- int f(int);
- class C
- {
- int i;
- double d;
- public:
- C(int, double);
- };
- C::C(int ii, double id)
- try
- :i(f(ii)), d(id)
- {
- }
- catch(...){
- }
-
-}
-
-
diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource2.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource2.awts
index f74b82c2e8..42b22752dd 100644
--- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource2.awts
+++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource2.awts
@@ -20,6 +20,16 @@ template<typename T> int tempFunct(T p)
}
+//!Commented TemplateFunction3
+//%CPP
+template<typename T> int tempFunct(T p)
+{
+ ++p;
+ p + 4;
+ return 0;
+} //Kommentar
+
+
//!Commented ExpressionList1
//%CPP
void foo()
diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/CommentHandlingTestSource.rts b/core/org.eclipse.cdt.core.tests/resources/rewrite/CommentHandlingTestSource.rts
index ddb079255d..834c12d3ec 100644
--- a/core/org.eclipse.cdt.core.tests/resources/rewrite/CommentHandlingTestSource.rts
+++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/CommentHandlingTestSource.rts
@@ -1,78 +1,3 @@
-//!CommentRecognition209 - von ASTWriter GPPExplicitTemplateInstantitation
-//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
-//@Klasse1.h
-//TEST 1
-static template class vector<int>; //TEST 2
-//TEST 3
-inline template class vector<int>; //TEST 4
-//TEST 5
-inline template class vector<int>; //TEST 6
-
-//=
-=>leading
-static template class vector<int>; = //TEST 1
-inline template class vector<int>; = //TEST 3
-inline template class vector<int>; = //TEST 5
-
-=>trailing
-static template class vector<int>; = //TEST 2
-inline template class vector<int>; = //TEST 4
-inline template class vector<int>; = //TEST 6
-
-=>freestanding
-
-//!CommentRecognition210 - von ASTWriter LinkageSpecification
-//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
-//@Klasse1.h
-//TEST 1
-extern "C" typedef void FUNC(); //TEST 2
-
-//=
-=>leading
-extern "C" typedef void FUNC(); = //TEST 1
-
-=>trailing
-extern "C" typedef void FUNC(); = //TEST 2
-
-=>freestanding
-
-//!CommentRecognition212 - von ASTWriter TemplateFunction
-//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
-//@Klasse1.h
-template<typename T> int tempFunct(T p)
-{
- ++p;
- p + 4;
- return 0;
-} //Kommentar
-
-//=
-=>leading
-
-=>trailing
-template<typename T> int tempFunct(T p)
-{
- ++p;
- p + 4;
- return 0;
-} = //Kommentar
-
-=>freestanding
-
-//!CommentRecognition213 - von ASTWriter DeclarationWithTraillingDoubleComments
-//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
-//@Klasse1.h
-int foo = bar; //Comment
- //Zweiteilig
-//=
-=>leading
-
-=>trailing
-int foo = bar; = //Comment
-
-=>freestanding
-int foo = bar; = //Zweiteilig
-
//!CommentHandlingTest 1 - von CERP
//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
//@test.h
@@ -2772,10 +2697,161 @@ template class vector<int>; //TEST 2
template class vector<int>; = //TEST 1
=>trailing
-template class vector<int>; = //TEST 2
+class vector<int>; = //TEST 2
+
+=>freestanding
+
+//!CommentRecognition209 - von ASTWriter GPPExplicitTemplateInstantitation
+//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
+//@Klasse1.h
+//TEST 1
+static template class vector<int>; //TEST 2
+//TEST 3
+inline template class vector<int>; //TEST 4
+//TEST 5
+inline template class vector<int>; //TEST 6
+
+//=
+=>leading
+static template class vector<int>; = //TEST 1
+inline template class vector<int>; = //TEST 3
+inline template class vector<int>; = //TEST 5
+
+=>trailing
+class vector<int>; = //TEST 2
+class vector<int>; = //TEST 4
+class vector<int>; = //TEST 6
=>freestanding
+//!CommentRecognition210 - von ASTWriter LinkageSpecification
+//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
+//@Klasse1.h
+//TEST 1
+extern "C" typedef void FUNC(); //TEST 2
+
+//=
+=>leading
+extern "C" typedef void FUNC(); = //TEST 1
+
+=>trailing
+typedef void FUNC(); = //TEST 2
+
+=>freestanding
+
+//!CommentRecognition212 - von ASTWriter TemplateFunction
+//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
+//@Klasse1.h
+template<typename T> int tempFunct(T p)
+{
+ ++p;
+ p + 4;
+ return 0;
+} //Kommentar
+
+//=
+=>leading
+
+=>trailing
+{
+ ++p;
+ p + 4;
+ return 0;
+} = //Kommentar
+
+=>freestanding
+
+//!CommentRecognition213 - von ASTWriter DeclarationWithTraillingDoubleComments
+//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
+//@Klasse1.h
+int foo = bar; //Comment
+ //Zweiteilig
+//=
+=>leading
+
+=>trailing
+int foo = bar; = //Comment
+
+=>freestanding
+int foo = bar; = //Zweiteilig
+
+//!CommentRecognition214 - von ASTWriter NamesapceDefinition
+//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
+//@Klasse1.h
+//TEST 1
+namespace ziemlichlangernamespace
+{
+ //TEST 2
+} //TEST 3
+
+//=
+=>leading
+namespace ziemlichlangernamespace
+{
+ //TEST 2
+} = //TEST 1
+
+=>trailing
+namespace ziemlichlangernamespace
+{
+ //TEST 2
+} = //TEST 3
+
+=>freestanding
+namespace ziemlichlangernamespace
+{
+ //TEST 2
+} = //TEST 2
+
+
+//!CommentRecognition215 - von ASTWriter NamesapceDefinition
+//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
+//@Klasse1.h
+namespace ziemlichlangernamespace
+{
+ //TEST
+}
+
+void doIt(){
+ int i = 0;
+}
+
+//=
+=>leading
+
+=>trailing
+
+=>freestanding
+namespace ziemlichlangernamespace
+{
+ //TEST
+} = //TEST
+
+//!CommentRecognition216 - von ASTWriter NamesapceDefinition
+//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
+//@Klasse1.h
+namespace ziemlichlangernamespace
+{
+ int i = 0;
+ //TEST
+}
+
+void doIt(){
+ int i = 0;
+}
+
+//=
+=>leading
+
+=>trailing
+
+=>freestanding
+namespace ziemlichlangernamespace
+{
+ int i = 0;
+ //TEST
+} = //TEST
+
//!ImplementationFileCommentRecognition1 - von CERP
//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
//@Klasse1.h
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 6856c23494..d72bf39136 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
@@ -139,6 +139,10 @@ public class ASTCommenterVisitor extends CPPASTVisitor {
return PROCESS_CONTINUE;
}
@Override
+ public int leave(ICPPASTNamespaceDefinition namespaceDefinition) {
+ return nodeCommenter.appendFreestandingComments((ASTNode)namespaceDefinition);
+ }
+ @Override
public int leave(IASTInitializer initializer) {
nodeCommenter.appendComments((ASTNode)initializer);
return PROCESS_CONTINUE;
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 08fc854912..42aa07ee72 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
@@ -22,34 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
*
*/
public class NodeCommentMap {
-
- protected final HashMap<IASTNode, ArrayList<IASTComment>> map = new HashMap<IASTNode, ArrayList<IASTComment>>();
-
- public void addCommentToNode(IASTNode node, IASTComment comment){
- ArrayList<IASTComment> comments = map.get(node);
- if(comments == null){
- comments = new ArrayList<IASTComment>();
- }
- comments.add(comment);
- map.put(node, comments);
- }
-
- public ArrayList<IASTComment> getCommentsForNode(IASTNode node){
- if(map.get(node) == null) {
- return new ArrayList<IASTComment>();
- }
- return map.get(node);
- }
-
- //needed for testing
- public HashMap<IASTNode, ArrayList<IASTComment>> getMap() {
- return map;
- }
-
-
- //===
- //Erst nur einmal zu test zwecken
- // Wenn wircklich gebraucht refactorn
protected final HashMap<IASTNode, ArrayList<IASTComment>> leadingMap = new HashMap<IASTNode, ArrayList<IASTComment>>();
protected final HashMap<IASTNode, ArrayList<IASTComment>> trailingMap = new HashMap<IASTNode, ArrayList<IASTComment>>();
protected final HashMap<IASTNode, ArrayList<IASTComment>> freestandingMap = new HashMap<IASTNode, ArrayList<IASTComment>>();
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 09677a232b..2fbd7d1763 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
@@ -24,12 +24,16 @@ 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;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarationStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTForStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIfStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLabelStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLinkageSpecification;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSwitchStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTWhileStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.internal.core.dom.rewrite.util.OffsetHelper;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -164,12 +168,12 @@ public class NodeCommenter {
return true;
}else if(parent instanceof IASTTranslationUnit) {
return true;
- }else if(parent instanceof ICPPASTBaseSpecifier) {
- parent = (ASTNode) parent.getParent();
}else if(parent instanceof ICPPASTTemplateDeclaration) {
return true;
}else if(parent instanceof CPPASTIfStatement) {
return true;
+ }else if(parent instanceof ICPPASTBaseSpecifier) {
+ parent = (ASTNode) parent.getParent();
}
return !(OffsetHelper.getNodeOffset(com) >= OffsetHelper.getNodeEndPoint(parent));
}
@@ -193,6 +197,14 @@ public class NodeCommenter {
return true;
}else if(node instanceof CPPASTWhileStatement) {
return true;
+ }else if(node instanceof CPPASTTemplateDeclaration) {
+ return true;
+ }else if(node instanceof CPPASTLinkageSpecification) {
+ return true;
+ }else if(node instanceof GPPASTExplicitTemplateInstantiation) {
+ return true;
+ }else if(node instanceof CPPASTExplicitTemplateInstantiation) {
+ return true;
}
return false;
}
@@ -234,6 +246,9 @@ public class NodeCommenter {
public void appendRemainingComments(IASTDeclaration declaration) {
while(commHandler.hasMore()) {
IASTComment comment = commHandler.getFirst();
+ if(appendComment((ASTNode)declaration, comment)) {
+ continue;
+ }
addFreestandingCommentToMap((ASTNode) declaration, comment);
}
}

Back to the top