private static void parseReferences(NewSymbol s, Iterator<String> split, @Nullable Integer defaultLen) { while (split.hasNext()) { addReference(s, split.next(), defaultLen); } }
private void processMeasure(InputComponent component, SensorContext context, File measureFile, int lineNumber, String line) { try { String metricKey = StringUtils.substringBefore(line, ":"); String value = line.substring(metricKey.length() + 1); saveMeasure(context, component, metricKey, value); } catch (Exception e) { LOG.error("Error processing line " + lineNumber + " of file " + measureFile.getAbsolutePath(), e); throw new IllegalStateException("Error processing line " + lineNumber + " of file " + measureFile.getAbsolutePath(), e); } }
@Test public void testExecution() throws IOException { File significantCode = new File(baseDir, "src/foo.xoo.significantCode"); FileUtils.write(significantCode, "1,1,4\n2,2,5"); context.fileSystem().add(inputFile); sensor.execute(context); assertThat(context.significantCodeTextRange("foo:src/foo.xoo", 1)).isEqualTo(range(1, 1, 4)); assertThat(context.significantCodeTextRange("foo:src/foo.xoo", 2)).isEqualTo(range(2, 2, 5)); }
@Override public void execute(SensorContext context) { for (InputFile file : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguages(Xoo.KEY))) { processFileHighlighting(file, context); } } }
@Override public void execute(SensorContext context) { for (InputFile file : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguages(Xoo.KEY))) { processFileSymbol(file, context); } } }
@Override public void execute(SensorContext context) { for (InputFile file : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguages(Xoo.KEY))) { processFileMeasures(file, context); } } }
@Override public void execute(SensorContext context) { for (InputFile file : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguages(Xoo.KEY))) { processSignificantCodeFile(file, context); } }
@Test public void testExecution() throws IOException { String content = "public class Foo {\n\n}"; createSourceFile(content); sensor.execute(context); assertThat(context.cpdTokens("foo:src/foo.xoo")).extracting("value", "startLine", "startUnit", "endUnit") .containsExactly( tuple("publicclassFoo{", 1, 1, 4), tuple("}", 3, 5, 5)); }
@Override public void execute(SensorContext context) { FilePredicates p = context.fileSystem().predicates(); for (InputFile file : context.fileSystem().inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(Type.MAIN)))) { tokenize(file, context); } } }
@Test public void testDescriptor() { sensor.describe(new DefaultSensorDescriptor()); }
@Test public void testDescriptor() { sensor.describe(new DefaultSensorDescriptor()); }
@Test public void testDescriptor() { sensor.describe(new DefaultSensorDescriptor()); }
@Test public void testDescriptor() { sensor.describe(new DefaultSensorDescriptor()); }
@Test public void testDescriptor() { sensor.describe(new DefaultSensorDescriptor()); }
@Before public void prepare() throws IOException { baseDir = temp.newFolder(); metricFinder = mock(MetricFinder.class); sensor = new MeasureSensor(metricFinder); context = SensorContextTester.create(baseDir); }
@Before public void prepare() throws IOException { baseDir = temp.newFolder(); sensor = new CpdTokenizerSensor(); context = SensorContextTester.create(baseDir); }
@Before public void prepare() throws IOException { baseDir = temp.newFolder(); sensor = new SyntaxHighlightingSensor(); context = SensorContextTester.create(baseDir); }
@Test public void testNoExceptionIfNoFileWithOffsets() { context.fileSystem().add(inputFile); sensor.execute(context); }
@Before public void prepare() throws IOException { baseDir = temp.newFolder(); sensor = new SignificantCodeSensor(); context = SensorContextTester.create(baseDir); inputFile = new TestInputFileBuilder("foo", baseDir, new File(baseDir, "src/foo.xoo")) .setLanguage("xoo") .setContents("some lines\nof code\nyet another line") .build(); }
@Test public void testNoExecutionIfNoMeasureFile() { InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").build(); context.fileSystem().add(inputFile); sensor.execute(context); }