当前位置: 首页>>代码示例>>Java>>正文


Java DefaultFileSystem.setEncoding方法代码示例

本文整理汇总了Java中org.sonar.api.batch.fs.internal.DefaultFileSystem.setEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultFileSystem.setEncoding方法的具体用法?Java DefaultFileSystem.setEncoding怎么用?Java DefaultFileSystem.setEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sonar.api.batch.fs.internal.DefaultFileSystem的用法示例。


在下文中一共展示了DefaultFileSystem.setEncoding方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
  fileSystem.setEncoding(Charsets.UTF_8);
  file = tempFolder.newFile();
  inputFile = new DefaultInputFile("moduleKey", file.getName())
    .setLanguage("less")
    .setType(InputFile.Type.MAIN);
  fileSystem.add(inputFile);

  sensorContext = SensorContextTester.create(tempFolder.getRoot());
  sensorContext.setFileSystem(fileSystem);

  visitorContext = mock(TreeVisitorContext.class);
  highlighterVisitor = new LessSyntaxHighlighterVisitor(sensorContext);
  when(visitorContext.getFile()).thenReturn(file);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:18,代码来源:LessSyntaxHighlighterVisitorTest.java

示例2: setUp

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
  fileSystem.setEncoding(Charsets.UTF_8);
  file = tempFolder.newFile();
  inputFile = new DefaultInputFile("moduleKey", file.getName())
    .setLanguage("scss")
    .setType(InputFile.Type.MAIN);
  fileSystem.add(inputFile);

  sensorContext = SensorContextTester.create(tempFolder.getRoot());
  sensorContext.setFileSystem(fileSystem);

  visitorContext = mock(TreeVisitorContext.class);
  highlighterVisitor = new ScssSyntaxHighlighterVisitor(sensorContext);
  when(visitorContext.getFile()).thenReturn(file);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:18,代码来源:ScssSyntaxHighlighterVisitorTest.java

示例3: setUp

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
  fileSystem.setEncoding(Charsets.UTF_8);
  file = tempFolder.newFile();
  inputFile = new DefaultInputFile("moduleKey", file.getName())
    .setLanguage("css")
    .setType(InputFile.Type.MAIN);
  fileSystem.add(inputFile);

  sensorContext = SensorContextTester.create(tempFolder.getRoot());
  sensorContext.setFileSystem(fileSystem);

  visitorContext = mock(TreeVisitorContext.class);
  highlighterVisitor = new CssSyntaxHighlighterVisitor(sensorContext);
  when(visitorContext.getFile()).thenReturn(file);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:18,代码来源:CssSyntaxHighlighterVisitorTest.java

示例4: setUp

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
  fileSystem.setEncoding(Charsets.UTF_8);
  file = tempFolder.newFile();
  inputFile = new DefaultInputFile("moduleKey", file.getName())
    .setLanguage("css")
    .setType(InputFile.Type.MAIN);
  fileSystem.add(inputFile);

  sensorContext = SensorContextTester.create(tempFolder.getRoot());
  sensorContext.setFileSystem(fileSystem);

  visitorContext = mock(TreeVisitorContext.class);
  cpdVisitor = new CpdVisitor(sensorContext);
  when(visitorContext.getFile()).thenReturn(file);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:18,代码来源:CpdVisitorTest.java

示例5: setUp

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
  fileSystem.setEncoding(Charsets.UTF_8);
  file = tempFolder.newFile();
  inputFile = new DefaultInputFile("moduleKey", file.getName())
    .setLanguage("gherkin")
    .setType(InputFile.Type.MAIN);
  fileSystem.add(inputFile);

  sensorContext = SensorContextTester.create(tempFolder.getRoot());
  sensorContext.setFileSystem(fileSystem);
  visitorContext = mock(TreeVisitorContext.class);
  highlighterVisitor = new SyntaxHighlighterVisitor(sensorContext);
  when(visitorContext.getFile()).thenReturn(file);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:SyntaxHighlighterVisitorTest.java

示例6: setUp

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
private void setUp(Charset charset) throws IOException {
  this.charset = charset;
  DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
  fileSystem.setEncoding(charset);
  file = tempFolder.newFile();
  inputFile = new DefaultInputFile("moduleKey", file.getName())
    .setLanguage("jproperties")
    .setType(InputFile.Type.MAIN);
  fileSystem.add(inputFile);

  sensorContext = SensorContextTester.create(tempFolder.getRoot());
  sensorContext.setFileSystem(fileSystem);
  visitorContext = mock(TreeVisitorContext.class);
  highlighterVisitor = new SyntaxHighlighterVisitor(sensorContext);
  when(visitorContext.getFile()).thenReturn(file);
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:17,代码来源:SyntaxHighlighterVisitorTest.java

示例7: setUp

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
  fileSystem.setEncoding(Charsets.UTF_8);
  file = tempFolder.newFile();
  inputFile = new DefaultInputFile("moduleKey", file.getName())
    .setLanguage("json")
    .setType(InputFile.Type.MAIN);
  fileSystem.add(inputFile);

  sensorContext = SensorContextTester.create(tempFolder.getRoot());
  sensorContext.setFileSystem(fileSystem);
  visitorContext = mock(TreeVisitorContext.class);
  highlighterVisitor = new SyntaxHighlighterVisitor(sensorContext);
  when(visitorContext.getFile()).thenReturn(file);
}
 
开发者ID:racodond,项目名称:sonar-json-plugin,代码行数:17,代码来源:SyntaxHighlighterVisitorTest.java

示例8: createFileSystem

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
protected DefaultFileSystem createFileSystem() {
   File workDir;
try {
	workDir = temporaryFolder.newFolder("temp");
} catch (IOException e) {
	throw new RuntimeException(e);
}

   DefaultFileSystem fs = new DefaultFileSystem();
   fs.setEncoding(Charset.defaultCharset());
   fs.setWorkDir(workDir);

   return fs;
 }
 
开发者ID:gjd6640,项目名称:sonar-text-plugin,代码行数:15,代码来源:AbstractCheckTester.java

示例9: createFileSystem

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
protected DefaultFileSystem createFileSystem() {
  File workDir = temporaryFolder.newFolder("temp");

  DefaultFileSystem fs = new DefaultFileSystem(workDir);
  fs.setEncoding(Charset.defaultCharset());
  fs.setWorkDir(workDir);

  return fs;
}
 
开发者ID:SonarSource,项目名称:sonar-xml,代码行数:10,代码来源:AbstractCheckTester.java

示例10: getFirstHighlightingData

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
private HighlightingData getFirstHighlightingData(String filename) throws IOException {
  File file = new File("src/test/resources/highlighting/" + filename);
  DefaultInputFile inputFile = new DefaultInputFile("modulekey", filename)
    .setModuleBaseDir(file.getParentFile().toPath())
    .setType(InputFile.Type.MAIN)
    .setLanguage(Xml.KEY)
    .setCharset(StandardCharsets.UTF_8);
  DefaultFileSystem localFS = new DefaultFileSystem(new File(file.getParent()));
  localFS.setEncoding(StandardCharsets.UTF_8);
  localFS.add(inputFile).setWorkDir(tmpFolder.newFolder());

  XmlFile xmlFile = new XmlFile(wrap(inputFile), localFS);
  return new XMLHighlighting(xmlFile).getHighlightingData().get(0);
}
 
开发者ID:SonarSource,项目名称:sonar-xml,代码行数:15,代码来源:XmlHighlightingTest.java

示例11: should_parse_file_with_its_own_encoding

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void should_parse_file_with_its_own_encoding() throws IOException, XMLStreamException {
  Charset fileSystemCharset = StandardCharsets.UTF_8;
  Charset fileCharset = StandardCharsets.UTF_16;

  Path moduleBaseDir = tmpFolder.newFolder().toPath();
  SensorContextTester context = SensorContextTester.create(moduleBaseDir);

  DefaultFileSystem fileSystem = new DefaultFileSystem(moduleBaseDir);
  fileSystem.setEncoding(fileSystemCharset);
  context.setFileSystem(fileSystem);

  String filename = "utf16.xml";
  try (BufferedWriter writer = Files.newBufferedWriter(moduleBaseDir.resolve(filename), fileCharset)) {
    writer.write("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?>\n");
    writer.write("<tag></tag>");
  }

  String modulekey = "modulekey";
  DefaultInputFile defaultInputFile = new DefaultInputFile(modulekey, filename)
    .setModuleBaseDir(moduleBaseDir)
    .setType(InputFile.Type.MAIN)
    .setLanguage(Xml.KEY)
    .setCharset(fileCharset);
  defaultInputFile.initMetadata(new FileMetadata().readMetadata(defaultInputFile.file(), fileCharset));
  fileSystem.add(defaultInputFile);

  XmlFile xmlFile = new XmlFile(wrap(defaultInputFile), fileSystem);
  List<HighlightingData> highlightingData = new XMLHighlighting(xmlFile).getHighlightingData();
  assertThat(highlightingData).hasSize(11);
}
 
开发者ID:SonarSource,项目名称:sonar-xml,代码行数:32,代码来源:XmlHighlightingTest.java

示例12: should_analyze_file_with_its_own_encoding

import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void should_analyze_file_with_its_own_encoding() throws IOException {
  Charset fileSystemCharset = StandardCharsets.UTF_8;
  Charset fileCharset = StandardCharsets.UTF_16;

  Path moduleBaseDir = temporaryFolder.newFolder().toPath();
  SensorContextTester context = SensorContextTester.create(moduleBaseDir);

  DefaultFileSystem fileSystem = new DefaultFileSystem(moduleBaseDir);
  fileSystem.setEncoding(fileSystemCharset);
  context.setFileSystem(fileSystem);
  String filename = "utf16.xml";
  try (BufferedWriter writer = Files.newBufferedWriter(moduleBaseDir.resolve(filename), fileCharset)) {
    writer.write("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?>\n");
    writer.write("<tag></tag>");
  }

  String modulekey = "modulekey";
  DefaultInputFile defaultInputFile = new DefaultInputFile(modulekey, filename)
    .setModuleBaseDir(moduleBaseDir)
    .setType(InputFile.Type.MAIN)
    .setLanguage(Xml.KEY)
    .setCharset(fileCharset);
  defaultInputFile.initMetadata(new FileMetadata().readMetadata(defaultInputFile.file(), fileCharset));
  fileSystem.add(defaultInputFile);

  ActiveRules activeRules = new ActiveRulesBuilder()
    .create(ruleKey)
    .activate()
    .build();
  CheckFactory checkFactory = new CheckFactory(activeRules);

  FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);
  when(fileLinesContextFactory.createFor(any(InputFile.class))).thenReturn(mock(FileLinesContext.class));
  sensor = new XmlSensor(fileSystem, checkFactory, fileLinesContextFactory);
  sensor.analyse(context);

  String componentKey = modulekey + ":" + filename;
  assertThat(context.measure(componentKey, CoreMetrics.NCLOC).value()).isEqualTo(2);
}
 
开发者ID:SonarSource,项目名称:sonar-xml,代码行数:41,代码来源:XmlSensorTest.java


注:本文中的org.sonar.api.batch.fs.internal.DefaultFileSystem.setEncoding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。