1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 186337 by Emanuel Graf, locations for comments in AST.

This commit is contained in:
Markus Schorn 2007-05-15 14:31:08 +00:00
parent eb2f600fc2
commit 36be849242
3 changed files with 14 additions and 3 deletions

View file

@ -210,7 +210,7 @@ public class CommentTests extends AST2BaseTest {
}
// //comment
public void _testCommentLocation_bug186337() throws Exception{
public void testCommentLocation_bug186337() throws Exception{
StringBuffer code= getContents(1)[0];
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true, true);
IASTComment[] comments = tu.getComments();
@ -218,5 +218,12 @@ public class CommentTests extends AST2BaseTest {
assertEquals(1, comments.length);
assertNotNull(comments[0].getFileLocation());
assertNotNull(comments[0].getNodeLocations());
tu = parse(code.toString(), ParserLanguage.C, false, true, true);
comments = tu.getComments();
assertEquals(1, comments.length);
assertNotNull(comments[0].getFileLocation());
assertNotNull(comments[0].getNodeLocations());
}
}

View file

@ -3027,7 +3027,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
protected IASTComment createComment(IToken commentToken)
throws EndOfFileException {
return new ASTComment(commentToken);
ASTComment comment = new ASTComment(commentToken);
comment.setParent(translationUnit);
return comment;
}
}

View file

@ -5596,6 +5596,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected IASTComment createComment(IToken commentToken)
throws EndOfFileException {
return new ASTComment(commentToken);
ASTComment comment = new ASTComment(commentToken);
comment.setParent(translationUnit);
return comment;
}
}