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:
parent
eb2f600fc2
commit
36be849242
3 changed files with 14 additions and 3 deletions
|
@ -210,7 +210,7 @@ public class CommentTests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// //comment
|
// //comment
|
||||||
public void _testCommentLocation_bug186337() throws Exception{
|
public void testCommentLocation_bug186337() throws Exception{
|
||||||
StringBuffer code= getContents(1)[0];
|
StringBuffer code= getContents(1)[0];
|
||||||
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true, true);
|
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true, true);
|
||||||
IASTComment[] comments = tu.getComments();
|
IASTComment[] comments = tu.getComments();
|
||||||
|
@ -218,5 +218,12 @@ public class CommentTests extends AST2BaseTest {
|
||||||
assertEquals(1, comments.length);
|
assertEquals(1, comments.length);
|
||||||
assertNotNull(comments[0].getFileLocation());
|
assertNotNull(comments[0].getFileLocation());
|
||||||
assertNotNull(comments[0].getNodeLocations());
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3027,7 +3027,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
protected IASTComment createComment(IToken commentToken)
|
protected IASTComment createComment(IToken commentToken)
|
||||||
throws EndOfFileException {
|
throws EndOfFileException {
|
||||||
return new ASTComment(commentToken);
|
ASTComment comment = new ASTComment(commentToken);
|
||||||
|
comment.setParent(translationUnit);
|
||||||
|
return comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5596,6 +5596,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
protected IASTComment createComment(IToken commentToken)
|
protected IASTComment createComment(IToken commentToken)
|
||||||
throws EndOfFileException {
|
throws EndOfFileException {
|
||||||
return new ASTComment(commentToken);
|
ASTComment comment = new ASTComment(commentToken);
|
||||||
|
comment.setParent(translationUnit);
|
||||||
|
return comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue