001/* 002 * SonarQube, open source software quality management tool. 003 * Copyright (C) 2008-2014 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * SonarQube is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * SonarQube is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020package org.sonar.api.batch.scm; 021 022import org.sonar.api.batch.BatchSide; 023import org.sonar.api.batch.InstantiationStrategy; 024import org.sonar.api.batch.fs.FileSystem; 025import org.sonar.api.batch.fs.InputFile; 026 027import java.util.List; 028 029/** 030 * This class should be implemented by SCM providers. 031 * @since 5.0 032 */ 033@InstantiationStrategy(InstantiationStrategy.PER_BATCH) 034@BatchSide 035public abstract class BlameCommand { 036 037 /** 038 * Compute blame of the provided files. 039 * Computation can be done in parallel if this is more efficient. 040 * If there is an error that prevent to blame a file then an exception should be raised. If 041 * one file is new or contains local modifications then an exception should be raised. 042 */ 043 public abstract void blame(BlameInput input, BlameOutput output); 044 045 /** 046 * Callback for the provider to report results of blame per file. 047 */ 048 public interface BlameInput { 049 050 /** 051 * Filesystem of the current (sub )project. 052 */ 053 FileSystem fileSystem(); 054 055 /** 056 * List of files that should be blamed. 057 */ 058 Iterable<InputFile> filesToBlame(); 059 060 } 061 062 /** 063 * Callback for the provider to report results of blame per file. 064 */ 065 public interface BlameOutput { 066 067 /** 068 * Add result of the blame command for a single file. Number of lines should 069 * be consistent with {@link InputFile#lines()}. This method is thread safe. 070 * @param lines One entry per line in the file. 071 */ 072 void blameResult(InputFile file, List<BlameLine> lines); 073 074 } 075 076}