Package org.sonar.api.batch.fs

Examples of org.sonar.api.batch.fs.InputFile


    assertThat(m.getMetric()).isEqualTo(CoreMetrics.NCLOC);
  }

  @Test
  public void shouldAddIssueOnFile() {
    InputFile file = new DefaultInputFile("foo", "src/Foo.php");

    ArgumentCaptor<Issue> argumentCaptor = ArgumentCaptor.forClass(Issue.class);

    Issuable issuable = mock(Issuable.class);
    when(resourcePerspectives.as(Issuable.class, File.create("src/Foo.php"))).thenReturn(issuable);
View Full Code Here


  @Test
  public void no_filters() throws Exception {
    DeprecatedFileFilters filters = new DeprecatedFileFilters();

    InputFile inputFile = new DeprecatedDefaultInputFile("foo", "src/main/java/Foo.java").setFile(temp.newFile());
    assertThat(filters.accept(inputFile)).isTrue();
  }
View Full Code Here

  public void at_least_one_filter() throws Exception {
    DeprecatedFileFilters filters = new DeprecatedFileFilters(new FileSystemFilter[] {filter});

    File basedir = temp.newFolder();
    File file = temp.newFile();
    InputFile inputFile = new DeprecatedDefaultInputFile("foo", "src/main/java/Foo.java")
      .setSourceDirAbsolutePath(new File(basedir, "src/main/java").getAbsolutePath())
      .setPathRelativeToSourceDir("Foo.java")
      .setFile(file)
      .setType(InputFile.Type.MAIN);
    when(filter.accept(eq(file), any(DeprecatedFileFilters.DeprecatedContext.class))).thenReturn(false);
View Full Code Here

  private void processLine(File coverPerTest, int lineNumber, SensorContext context, String line, InputFile file) {
    try {
      Iterator<String> split = Splitter.on(":").split(line).iterator();
      String otherFileRelativePath = split.next();
      FileSystem fs = context.fileSystem();
      InputFile otherFile = fs.inputFile(fs.predicates().hasRelativePath(otherFileRelativePath));
      if (otherFile == null) {
        throw new IllegalStateException("Unable to find file " + otherFileRelativePath);
      }
      int weight = Integer.parseInt(split.next());
      context.newDependency()
View Full Code Here

    try {
      Iterator<String> split = Splitter.on(":").split(line).iterator();
      String testCaseName = split.next();
      String mainFileRelativePath = split.next();
      FileSystem fs = context.fileSystem();
      InputFile mainFile = fs.inputFile(fs.predicates().hasRelativePath(mainFileRelativePath));
      if (mainFile == null) {
        throw new IllegalStateException("Unable to find file " + mainFileRelativePath);
      }
      List<Integer> coveredLines = new ArrayList<Integer>();
      Iterator<String> lines = Splitter.on(",").split(split.next()).iterator();
View Full Code Here

    Iterable<InputFile> files = inputFiles(predicate);
    Iterator<InputFile> iterator = files.iterator();
    if (!iterator.hasNext()) {
      return null;
    }
    InputFile first = iterator.next();
    if (!iterator.hasNext()) {
      return first;
    }

    StringBuilder sb = new StringBuilder();
View Full Code Here

    json.name("components").beginArray();
    // Dump modules
    writeJsonModuleComponents(json, rootModule);
    for (InputPath inputPath : fileCache.all()) {
      if (inputPath instanceof InputFile) {
        InputFile inputFile = (InputFile) inputPath;
        String key = ((DefaultInputFile) inputFile).key();
        json
          .beginObject()
          .prop("key", key)
          .prop("path", inputFile.relativePath())
          .prop("moduleKey", StringUtils.substringBeforeLast(key, ":"))
          .prop("status", inputFile.status().name())
          .endObject();
      } else {
        InputDir inputDir = (InputDir) inputPath;
        String key = ((DefaultInputDir) inputDir).key();
        json
View Full Code Here

    Callable<Void> task = new Callable<Void>() {

      @Override
      public Void call() throws Exception {
        InputFile completedFile = inputFileBuilder.complete(inputFile, type);
        if (completedFile != null && accept(completedFile)) {
          status.markAsIndexed(inputFile);
          File parentDir = inputFile.file().getParentFile();
          String relativePath = new PathResolver().relativePath(fs.baseDir(), parentDir);
          if (relativePath != null) {
View Full Code Here

    Map<String, ResourceModel> disabledResourceByKey = loadDisabledResources(moduleId, hql);
    List<ResourceModel> resources = loadEnabledResources(moduleId, hql);
    for (ResourceModel resourceModel : resources) {
      String oldEffectiveKey = resourceModel.getKey();
      boolean isTest = Qualifiers.UNIT_TEST_FILE.equals(resourceModel.getQualifier());
      InputFile matchedFile = findInputFile(deprecatedFileKeyMapper, deprecatedTestKeyMapper, oldEffectiveKey, isTest);
      if (matchedFile != null) {
        String newEffectiveKey = ((DeprecatedDefaultInputFile) matchedFile).key();
        // Now compute migration of the parent dir
        String oldKey = StringUtils.substringAfterLast(oldEffectiveKey, ":");
        Resource sonarFile;
View Full Code Here

  public void match_relative_path() throws Exception {
    PathPattern pattern = PathPattern.create("**/*Foo.java");
    assertThat(pattern.toString()).isEqualTo("**/*Foo.java");

    File file = new File(temp.newFolder(), "src/main/java/org/MyFoo.java");
    InputFile inputFile = new DefaultInputFile("ABCDE", "src/main/java/org/MyFoo.java").setFile(file);
    assertThat(pattern.match(inputFile)).isTrue();

    // case sensitive by default
    file = new File(temp.newFolder(), "src/main/java/org/MyFoo.JAVA");
    inputFile = new DefaultInputFile("ABCDE", "src/main/java/org/MyFoo.JAVA").setFile(file);
View Full Code Here

TOP

Related Classes of org.sonar.api.batch.fs.InputFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.