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 */ 020 package org.sonar.api.batch.analyzer; 021 022 import com.google.common.annotations.Beta; 023 import org.sonar.api.batch.analyzer.issue.AnalyzerIssue; 024 import org.sonar.api.batch.analyzer.issue.AnalyzerIssueBuilder; 025 import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure; 026 import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder; 027 import org.sonar.api.batch.fs.FileSystem; 028 import org.sonar.api.batch.fs.InputFile; 029 import org.sonar.api.batch.measure.Metric; 030 import org.sonar.api.batch.rule.ActiveRules; 031 import org.sonar.api.config.Settings; 032 033 import javax.annotation.CheckForNull; 034 035 import java.io.Serializable; 036 037 /** 038 * @since 4.4 039 */ 040 @Beta 041 public interface AnalyzerContext { 042 043 /** 044 * Get settings of the current project. 045 */ 046 Settings settings(); 047 048 /** 049 * Get filesystem of the current project. 050 */ 051 FileSystem fileSystem(); 052 053 /** 054 * Get list of active rules. 055 */ 056 ActiveRules activeRules(); 057 058 // ----------- MEASURES -------------- 059 060 /** 061 * Builder to create a new {@link AnalyzerMeasure}. 062 */ 063 <G extends Serializable> AnalyzerMeasureBuilder<G> measureBuilder(); 064 065 /** 066 * Find a project measure. 067 */ 068 @CheckForNull 069 AnalyzerMeasure getMeasure(String metricKey); 070 071 /** 072 * Find a project measure. 073 */ 074 @CheckForNull 075 <G extends Serializable> AnalyzerMeasure<G> getMeasure(Metric<G> metric); 076 077 /** 078 * Find a file measure. 079 */ 080 @CheckForNull 081 AnalyzerMeasure getMeasure(InputFile file, String metricKey); 082 083 /** 084 * Find a file measure. 085 */ 086 @CheckForNull 087 <G extends Serializable> AnalyzerMeasure<G> getMeasure(InputFile file, Metric<G> metric); 088 089 /** 090 * Add a measure. Use {@link #measureBuilder()} to create the new measure. 091 */ 092 void addMeasure(AnalyzerMeasure<?> measure); 093 094 // ----------- ISSUES -------------- 095 096 /** 097 * Builder to create a new {@link AnalyzerIssue}. 098 */ 099 AnalyzerIssueBuilder issueBuilder(); 100 101 /** 102 * Add an issue. Use {@link #issueBuilder()} to create the new issue. 103 * @return true if the new issue is registered, false if the related rule does not exist or is disabled in the Quality profile. 104 */ 105 boolean addIssue(AnalyzerIssue issue); 106 107 }