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.sensor;
021    
022    import org.sonar.api.batch.fs.FileSystem;
023    import org.sonar.api.batch.fs.InputFile;
024    import org.sonar.api.batch.rule.ActiveRules;
025    import org.sonar.api.batch.sensor.dependency.Dependency;
026    import org.sonar.api.batch.sensor.duplication.DuplicationBuilder;
027    import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
028    import org.sonar.api.batch.sensor.duplication.DuplicationTokenBuilder;
029    import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
030    import org.sonar.api.batch.sensor.issue.Issue;
031    import org.sonar.api.batch.sensor.measure.Measure;
032    import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder;
033    import org.sonar.api.batch.sensor.test.Coverage;
034    import org.sonar.api.batch.sensor.test.TestCaseCoverage;
035    import org.sonar.api.batch.sensor.test.TestCaseExecution;
036    import org.sonar.api.config.Settings;
037    
038    import java.io.Serializable;
039    import java.util.List;
040    
041    /**
042     * See {@link Sensor#execute(SensorContext)}
043     * @since 5.0
044     */
045    public 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      // ----------- MEASURES --------------
063    
064      /**
065       * Fluent builder to create a new {@link Measure}. Don't forget to call {@link Measure#save()} once all parameters are provided.
066       */
067      <G extends Serializable> Measure<G> newMeasure();
068    
069      // ----------- ISSUES --------------
070    
071      /**
072       * Fluent builder to create a new {@link Issue}. Don't forget to call {@link Issue#save()} once all parameters are provided.
073       */
074      Issue newIssue();
075    
076      // ------------ HIGHLIGHTING ------------
077    
078      /**
079       * Builder to define highlighting of a file.
080       * @since 4.5
081       */
082      HighlightingBuilder highlightingBuilder(InputFile inputFile);
083    
084      // ------------ SYMBOL REFERENCES ------------
085    
086      /**
087       * Builder to define symbol references in a file.
088       * @since 4.5
089       */
090      SymbolTableBuilder symbolTableBuilder(InputFile inputFile);
091    
092      // ------------ DUPLICATIONS ------------
093    
094      /**
095       * Builder to define tokens in a file. Tokens are used to compute duplication using default SonarQube engine.
096       * @since 4.5
097       */
098      DuplicationTokenBuilder duplicationTokenBuilder(InputFile inputFile);
099    
100      /**
101       * Builder to manually define duplications in a file. When duplication are manually computed then
102       * no need to use {@link #duplicationTokenBuilder(InputFile)}.
103       * @since 4.5
104       */
105      DuplicationBuilder duplicationBuilder(InputFile inputFile);
106    
107      /**
108       * Register all duplications of an {@link InputFile}. Use {@link #duplicationBuilder(InputFile)} to create
109       * list of duplications.
110       * @since 4.5
111       */
112      void saveDuplications(InputFile inputFile, List<DuplicationGroup> duplications);
113    
114      // ------------ TESTS ------------
115    
116      /**
117       * Create a new coverage report.
118       * Don't forget to call {@link Coverage#save()} once all parameters are provided.
119       * @since 5.0
120       */
121      Coverage newCoverage();
122    
123      /**
124       * Create a new test case execution report.
125       * Don't forget to call {@link TestCaseExecution#save()} once all parameters are provided.
126       * @since 5.0
127       */
128      TestCaseExecution newTestCaseExecution();
129    
130      /**
131       * Create a new test case coverage report.
132       * Don't forget to call {@link TestCaseCoverage#save()} once all parameters are provided.
133       * @since 5.0
134       */
135      TestCaseCoverage newTestCaseCoverage();
136    
137      // ------------ DEPENDENCIES ------------
138    
139      /**
140       * Create a new dependency.
141       * Don't forget to call {@link Dependency#save()} once all parameters are provided.
142       * @since 5.0
143       */
144      Dependency newDependency();
145    
146    }