OpenEdgeDBColorizer implements Sensor { @Override public void execute(SensorContext context) { if (context.runtime().getProduct() == SonarProduct.SONARLINT) return; for (InputFile file : context.fileSystem().inputFiles( context.fileSystem().predicates().hasLanguage(Constants.DB_LANGUAGE_KEY))) { LOG.debug("DF syntax highlight on {}", file); try { highlightFile(context, file); } catch (RuntimeException | IOException caught) { LOG.error("Unable to lex file " + file, caught); } } }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context);  }
@Test public void testSp2k() throws Exception { SensorContextTester context = TestProjectSensorContext.createContext(); OpenEdgeDBColorizer sensor = new OpenEdgeDBColorizer(); sensor.execute(context); Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + DF1, 19, 10)); Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + DF1, 19, 10).size(), 1); Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + DF1, 19, 10).get(0), TypeOfText.KEYWORD); Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + DF1, 19, 20)); Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + DF1, 19, 20).size(), 1); Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + DF1, 19, 20).get(0), TypeOfText.STRING); Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + DF1, 20, 12)); Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + DF1, 20, 12).size(), 1); Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + DF1, 20, 12).get(0), TypeOfText.CONSTANT); Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + DF1, 79, 10)); Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + DF1, 79, 10).size(), 1); Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + DF1, 79, 10).get(0), TypeOfText.ANNOTATION); }