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.sensor; 021 022import com.google.common.annotations.Beta; 023import java.io.Serializable; 024import org.sonar.api.batch.AnalysisMode; 025import org.sonar.api.batch.fs.FileSystem; 026import org.sonar.api.batch.rule.ActiveRules; 027import org.sonar.api.batch.sensor.coverage.NewCoverage; 028import org.sonar.api.batch.sensor.highlighting.NewHighlighting; 029import org.sonar.api.batch.sensor.internal.SensorContextTester; 030import org.sonar.api.batch.sensor.issue.Issue; 031import org.sonar.api.batch.sensor.issue.NewIssue; 032import org.sonar.api.batch.sensor.measure.Measure; 033import org.sonar.api.batch.sensor.measure.NewMeasure; 034import org.sonar.api.config.Settings; 035 036/** 037 * See {@link Sensor#execute(SensorContext)} 038 * In order to write unit tests you can use {@link SensorContextTester} 039 * @since 5.1 040 */ 041@Beta 042public interface SensorContext { 043 044 /** 045 * Get settings of the current module. 046 */ 047 Settings settings(); 048 049 /** 050 * Get filesystem of the current module. 051 */ 052 FileSystem fileSystem(); 053 054 /** 055 * Get list of active rules. 056 */ 057 ActiveRules activeRules(); 058 059 /** 060 * Get analysis mode. 061 */ 062 AnalysisMode analysisMode(); 063 064 // ----------- MEASURES -------------- 065 066 /** 067 * Fluent builder to create a new {@link Measure}. Don't forget to call {@link NewMeasure#save()} once all parameters are provided. 068 */ 069 <G extends Serializable> NewMeasure<G> newMeasure(); 070 071 // ----------- ISSUES -------------- 072 073 /** 074 * Fluent builder to create a new {@link Issue}. Don't forget to call {@link NewIssue#save()} once all parameters are provided. 075 */ 076 NewIssue newIssue(); 077 078 // ------------ HIGHLIGHTING ------------ 079 080 /** 081 * Builder to define highlighting of a file. Don't forget to call {@link NewHighlighting#save()} once all elements are provided. 082 */ 083 NewHighlighting newHighlighting(); 084 085 // ------------ SYMBOL REFERENCES ------------ 086 087 // TODO 088 089 // ------------ TESTS ------------ 090 091 /** 092 * Builder to define coverage in a file. 093 * Don't forget to call {@link NewDuplication#save()}. 094 */ 095 NewCoverage newCoverage(); 096 097}