001/* 002 * SonarQube 003 * Copyright (C) 2009-2016 SonarSource SA 004 * mailto:contact AT sonarsource DOT com 005 * 006 * This program 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 * This program 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.fs.FileSystem; 025import org.sonar.api.batch.fs.InputModule; 026import org.sonar.api.batch.rule.ActiveRules; 027import org.sonar.api.batch.sensor.coverage.NewCoverage; 028import org.sonar.api.batch.sensor.cpd.NewCpdTokens; 029import org.sonar.api.batch.sensor.highlighting.NewHighlighting; 030import org.sonar.api.batch.sensor.internal.SensorContextTester; 031import org.sonar.api.batch.sensor.issue.Issue; 032import org.sonar.api.batch.sensor.issue.NewIssue; 033import org.sonar.api.batch.sensor.measure.Measure; 034import org.sonar.api.batch.sensor.measure.NewMeasure; 035import org.sonar.api.config.Settings; 036import org.sonar.api.utils.Version; 037 038/** 039 * See {@link Sensor#execute(SensorContext)} 040 * In order to write unit tests you can use {@link SensorContextTester} 041 * @since 5.1 042 */ 043@Beta 044public interface SensorContext { 045 046 /** 047 * Get settings of the current module. 048 */ 049 Settings settings(); 050 051 /** 052 * Get filesystem of the current module. 053 */ 054 FileSystem fileSystem(); 055 056 /** 057 * Get list of active rules. 058 */ 059 ActiveRules activeRules(); 060 061 /** 062 * @since 5.5 063 */ 064 InputModule module(); 065 066 /** 067 * @since 5.5 068 */ 069 Version getSonarQubeVersion(); 070 071 // ----------- MEASURES -------------- 072 073 /** 074 * Fluent builder to create a new {@link Measure}. Don't forget to call {@link NewMeasure#save()} once all parameters are provided. 075 */ 076 <G extends Serializable> NewMeasure<G> newMeasure(); 077 078 // ----------- ISSUES -------------- 079 080 /** 081 * Fluent builder to create a new {@link Issue}. Don't forget to call {@link NewIssue#save()} once all parameters are provided. 082 */ 083 NewIssue newIssue(); 084 085 // ------------ HIGHLIGHTING ------------ 086 087 /** 088 * Builder to define highlighting of a file. Don't forget to call {@link NewHighlighting#save()} once all elements are provided. 089 */ 090 NewHighlighting newHighlighting(); 091 092 // ------------ SYMBOL REFERENCES ------------ 093 094 // TODO 095 096 // ------------ TESTS ------------ 097 098 /** 099 * Builder to define coverage in a file. 100 * Don't forget to call {@link NewCoverage#save()}. 101 */ 102 NewCoverage newCoverage(); 103 104 // ------------ CPD ------------ 105 106 /** 107 * Builder to define CPD tokens in a file. 108 * Don't forget to call {@link NewCpdTokens#save()}. 109 * @since 5.5 110 */ 111 NewCpdTokens newCpdTokens(); 112 113}