addRegularComment method
void
addRegularComment(
- void listener(
- Token comment
Implementation
void addRegularComment(void Function(Token comment) listener) {
addCompilationUnit((node) {
bool isRegularComment(Token commentToken) {
final token = commentToken.toString();
return !token.startsWith('///') && token.startsWith('//');
}
Token? token = node.root.beginToken;
while (token != null) {
Token? commentToken = token.precedingComments;
while (commentToken != null) {
if (isRegularComment(commentToken)) {
listener(commentToken);
}
commentToken = commentToken.next;
}
if (token == token.next) {
break;
}
token = token.next;
}
});
}