HighlighterVisitor extends SubscriptionVisitor { private void highlight(SyntaxToken token, TypeOfText type) { highlighting.highlight(token.line(), token.column(), token.endLine(), token.endColumn(), type); } HighlighterVisitor(SensorContext sensorContext); @Override Set<Kind> nodesToVisit(); @Override void visitFile(Tree scriptTree); @Override void leaveFile(Tree scriptTree); @Override void visitNode(Tree tree);  }
@Test public void empty_input() throws Exception { highlight(""); assertThat(sensorContext.highlightingTypeAt("moduleKey:" + inputFile.relativePath(), 1, 0)).isEmpty(); }
@Test public void multiline_comment() throws Exception { highlight(" "); assertHighlighting(1, 0, 2, COMMENT); assertHighlighting(2, 0, 7, COMMENT); assertHighlighting(3, 0, 2, COMMENT); }
@Test public void single_line_comment() throws Exception { highlight(" --Comment "); assertHighlighting(2, 10, COMMENT); }
@Test public void javadoc_comment() throws Exception { highlight(" "); assertHighlighting(2, 12, TypeOfText.STRUCTURED_COMMENT); }
@Test public void numbers() throws Exception { highlight("CREATE FUNCTION a() SET x = 1;"); assertHighlighting(28, 1, TypeOfText.CONSTANT); }
@Test public void string() throws Exception { highlight("CREATE FUNCTION a() SET x = 'a';"); assertHighlighting(28, 3, STRING); }
@Test public void keyword() throws Exception { highlight("CREATE FUNCTION a() SET x = 0;"); assertHighlighting(20, 3, KEYWORD); }
@Test public void byte_order_mark() throws Exception { highlight("\uFEFFDECLARE a CHAR; --"); assertHighlighting(0, 7, KEYWORD); }