[tree-sitter] Add TODO and hyperlink injections to Java

This commit is contained in:
Andrew Dupont 2024-01-08 16:10:24 -08:00
parent f6e1a22cf7
commit 5e62e205b5

View File

@ -1,3 +1,24 @@
exports.activate = () => {
// TODO: Injections for language-todo and language-hyperlink.
const TODO_PATTERN = /\b(TODO|FIXME|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG|QUESTION|COMBAK|TEMP|DEBUG|OPTIMIZE|WARNING)\b/;
const HYPERLINK_PATTERN = /\bhttps?:/
atom.grammars.addInjectionPoint('source.java', {
type: 'comment',
language: (node) => {
return TODO_PATTERN.test(node.text) ? 'todo' : undefined;
},
content: (node) => node,
languageScope: null
});
for (let type of ['string_literal', 'comment']) {
atom.grammars.addInjectionPoint('source.java', {
type,
language: (node) => {
return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : undefined;
},
content: (node) => node,
languageScope: null
});
}
};