@Test public void should_parse_file_with_its_own_encoding() throws Exception { Charset fileSystemCharset = UTF_8; Charset fileCharset = StandardCharsets.UTF_16; Path moduleBaseDir = tmpFolder.newFolder().toPath(); context = SensorContextTester.create(moduleBaseDir); fileSystem = new DefaultFileSystem(moduleBaseDir); fileSystem.setEncoding(fileSystemCharset); context.setFileSystem(fileSystem); String filename = "utf16.xml"; Path file = moduleBaseDir.resolve(filename); try (BufferedWriter writer = Files.newBufferedWriter(file, fileCharset)) { writer.write("<?xml version=\"1.0\" encoding=\"" + fileCharset.name().toLowerCase() + "\" standalone=\"yes\"?>\n"); writer.write("<tag></tag>"); } DefaultInputFile defaultInputFile = TestInputFileBuilder.create("moduleKey", filename) .setModuleBaseDir(moduleBaseDir) .initMetadata(Files.lines(file, fileCharset).collect(Collectors.joining("\n"))) .setType(InputFile.Type.MAIN) .setLanguage(Xml.KEY) .setCharset(fileCharset) .build(); fileSystem.add(defaultInputFile); highlight(defaultInputFile); assertHighlighting(0, 5, TypeOfText.KEYWORD); assertHighlighting(6, 13, TypeOfText.CONSTANT); assertHighlighting(14, 19, TypeOfText.STRING); }
public static void highlight(SensorContext context, XmlFile xmlFile) { new XmlHighlighting(xmlFile).highlight(context); }
XmlHighlighting { public static void highlight(SensorContext context, XmlFile xmlFile) { new XmlHighlighting(xmlFile).highlight(context); } }
XmlHighlighting { public static void highlight(SensorContext context, XmlFile xmlFile) { new XmlHighlighting(xmlFile).highlight(context); } private  XmlHighlighting(XmlFile xmlFile); }
XmlHighlighting { public static void highlight(SensorContext context, XmlFile xmlFile) { new XmlHighlighting(xmlFile).highlight(context); } private  XmlHighlighting(XmlFile xmlFile); static void highlight(SensorContext context, XmlFile xmlFile); }
XmlHighlighting { public static void highlight(SensorContext context, XmlFile xmlFile) { new XmlHighlighting(xmlFile).highlight(context); } private  XmlHighlighting(XmlFile xmlFile); static void highlight(SensorContext context, XmlFile xmlFile);  }