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 org.sonar.api.batch.AnalysisMode;
024import org.sonar.api.batch.CpdMapping;
025import org.sonar.api.batch.fs.FileSystem;
026import org.sonar.api.batch.rule.ActiveRules;
027import org.sonar.api.batch.sensor.dependency.NewDependency;
028import org.sonar.api.batch.sensor.duplication.NewDuplication;
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;
036
037import java.io.Serializable;
038
039/**
040 * See {@link Sensor#execute(SensorContext)}
041 * In order to write unit tests you can use {@link SensorContextTester}
042 * @since 5.1
043 */
044@Beta
045public interface SensorContext {
046
047  /**
048   * Get settings of the current project.
049   */
050  Settings settings();
051
052  /**
053   * Get filesystem of the current project.
054   */
055  FileSystem fileSystem();
056
057  /**
058   * Get list of active rules.
059   */
060  ActiveRules activeRules();
061
062  /**
063   * Get analysis mode.
064   */
065  AnalysisMode analysisMode();
066
067  // ----------- MEASURES --------------
068
069  /**
070   * Fluent builder to create a new {@link Measure}. Don't forget to call {@link NewMeasure#save()} once all parameters are provided.
071   */
072  <G extends Serializable> NewMeasure<G> newMeasure();
073
074  // ----------- ISSUES --------------
075
076  /**
077   * Fluent builder to create a new {@link Issue}. Don't forget to call {@link NewIssue#save()} once all parameters are provided.
078   */
079  NewIssue newIssue();
080
081  // ------------ HIGHLIGHTING ------------
082
083  /**
084   * Builder to define highlighting of a file. Don't forget to call {@link NewHighlighting#save()} once all elements are provided.
085   */
086  NewHighlighting newHighlighting();
087
088  // ------------ SYMBOL REFERENCES ------------
089
090  // TODO
091
092  // ------------ DUPLICATIONS ------------
093
094  /**
095   * Builder to manually register duplication in a file. This can be used in addition to {@link CpdMapping} extension point.
096   * Don't forget to call {@link NewDuplication#save()}.
097   */
098  NewDuplication newDuplication();
099
100  // ------------ TESTS ------------
101
102  // TODO
103
104  // ------------ DEPENDENCIES ------------
105
106  /**
107   * Create a new dependency.
108   * Don't forget to call {@link NewDependency#save()} once all parameters are provided.
109   */
110  NewDependency newDependency();
111
112}