SyntaxHighlighterVisitor extends SubscriptionVisitor { private void highlight(SyntaxToken token, TypeOfText type) { highlighting.highlight(token.line(), token.column(), token.endLine(), token.endColumn(), type); } SyntaxHighlighterVisitor(SensorContext sensorContext); @Override List<Tree.Kind> nodesToVisit(); @Override void visitFile(Tree tree); @Override void leaveFile(Tree scriptTree); @Override void visitNode(Tree tree);  }
@Test public void empty_input() throws Exception { setUp(Charsets.ISO_8859_1); highlight(""); assertThat(sensorContext.highlightingTypeAt("moduleKey:" + file.getName(), 1, 0)).isEmpty(); }
@Test public void key() throws Exception { setUp(Charsets.ISO_8859_1); highlight("abc: abc...abc\n def=def...def"); assertHighlighting(1, 0, 3, KEYWORD); assertHighlighting(2, 1, 3, KEYWORD); }
@Test public void value() throws Exception { setUp(Charsets.ISO_8859_1); highlight("abc: abc...abc\n def=def...def"); assertHighlighting(1, 5, 9, STRING); assertHighlighting(2, 5, 9, STRING); }
@Test public void comment_hash() throws Exception { setUp(Charsets.ISO_8859_1); highlight("# blabla"); assertHighlighting(1, 0, 8, COMMENT); }
@Test public void comment_hash2() throws Exception { setUp(Charsets.ISO_8859_1); highlight("#blabla"); assertHighlighting(1, 0, 7, COMMENT); }
@Test public void comment_hash3() throws Exception { setUp(Charsets.ISO_8859_1); highlight("abc: abc...abc\n # blabla"); assertHighlighting(2, 1, 8, COMMENT); }
@Test public void comment_exclamation_mark() throws Exception { setUp(Charsets.ISO_8859_1); highlight("! blabla"); assertHighlighting(1, 0, 8, COMMENT); }
@Test public void comment_exclamation_mark2() throws Exception { setUp(Charsets.ISO_8859_1); highlight("!blabla"); assertHighlighting(1, 0, 7, COMMENT); }
@Test public void comment_exclamation_mark3() throws Exception { setUp(Charsets.ISO_8859_1); highlight("abc: abc...abc\n ! blabla"); assertHighlighting(2, 1, 8, COMMENT); }
@Test public void byte_order_mark() throws Exception { setUp(Charsets.UTF_8); highlight("\ufeffabc: abc...abc"); assertHighlighting(1, 0, 3, KEYWORD); }
@Test public void empty_input() throws Exception { highlight(""); assertThat(sensorContext.highlightingTypeAt("moduleKey:" + file.getName(), 1, 0)).isEmpty(); }
@Test public void truee() throws Exception { highlight("true"); assertHighlighting(1, 0, 4, CONSTANT); }
@Test public void falsee() throws Exception { highlight("false"); assertHighlighting(1, 0, 5, CONSTANT); }
@Test public void nulle() throws Exception { highlight("null"); assertHighlighting(1, 0, 4, CONSTANT); }
@Test public void number() throws Exception { highlight("1.3e-1"); assertHighlighting(1, 0, 6, CONSTANT); }
@Test public void string() throws Exception { highlight("\"blabla\""); assertHighlighting(1, 0, 8, STRING); }
@Test public void key() throws Exception { highlight("{\"blabla\": 2}"); assertHighlighting(1, 1, 8, KEYWORD); assertHighlighting(1, 11, 1, CONSTANT); }
@Test public void byte_order_mark() throws Exception { highlight("\ufefftrue"); assertHighlighting(1, 0, 4, CONSTANT); }
@Test public void tag() throws Exception { highlight("@my-tag\nFeature: my feature..."); assertHighlighting(1, 0, 7, ANNOTATION); }
@Test public void name() throws Exception { highlight("@my-tag\nFeature: my feature..."); assertHighlighting(2, 9, 13, STRING); }
@Test public void feature_prefix() throws Exception { highlight("Feature: my feature..."); assertHighlighting(1, 0, 7, KEYWORD); }
@Test public void background_prefix() throws Exception { highlight("Feature: my feature...\nBackground:"); assertHighlighting(2, 0, 10, KEYWORD); }
@Test public void scenario_prefix() throws Exception { highlight("Feature: my feature...\nScenario: my scenario..."); assertHighlighting(2, 0, 8, KEYWORD); }
@Test public void scenario_outline_prefix() throws Exception { highlight("Feature: my feature...\nScenario Outline: my scenario...\nExamples:"); assertHighlighting(2, 0, 16, KEYWORD); }
@Test public void examples_prefix() throws Exception { highlight("Feature: my feature...\nScenario Outline: my scenario...\nExamples:"); assertHighlighting(3, 0, 8, KEYWORD); }
@Test public void step_prefix() throws Exception { highlight("Feature: my feature...\nScenario: my scenario...\nGiven blabla...\nWhen blabla...\nThen blabla...\n* blabla..."); assertHighlighting(3, 0, 5, KEYWORD); assertHighlighting(4, 0, 4, KEYWORD); assertHighlighting(5, 0, 4, KEYWORD); assertHighlighting(6, 0, 1, KEYWORD); }
@Test public void comment1() throws Exception { highlight("# blabla\nFeature: my feature..."); assertHighlighting(1, 0, 8, COMMENT); }
@Test public void comment2() throws Exception { highlight("#blabla\nFeature: my feature..."); assertHighlighting(1, 0, 7, COMMENT); }
@Test public void language_declaration1() throws Exception { highlight("# language: ru"); assertHighlighting(1, 0, 14, ANNOTATION); }
@Test public void language_declaration2() throws Exception { highlight("#language: ru"); assertHighlighting(1, 0, 13, ANNOTATION); }
@Test public void byte_order_mark() throws Exception { highlight("\ufeffFeature: my feature..."); assertHighlighting(1, 0, 7, KEYWORD); }