Examples of InputFile


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

  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

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

  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

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

    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

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

    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

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

    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

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

    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

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

    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

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

  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

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

  @Test
  public void match_relative_path_and_insensitive_file_extension() throws Exception {
    PathPattern pattern = PathPattern.create("**/*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, false)).isTrue();

    file = new File(temp.newFolder(), "src/main/java/org/Other.java");
    inputFile = new DefaultInputFile("ABCDE", "src/main/java/org/Other.java").setFile(file);
    assertThat(pattern.match(inputFile, false)).isFalse();
View Full Code Here

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

  public void match_absolute_path() throws Exception {
    PathPattern pattern = PathPattern.create("file:**/src/main/**Foo.java");
    assertThat(pattern.toString()).isEqualTo("file:**/src/main/**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
Copyright © 2018 www.massapi.com. 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.