Skip to content

Commit a10ac77

Browse files
committed
Improve Language EP documentation
1 parent 769b275 commit a10ac77

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

plugin-api/src/main/java/org/sonar/api/resources/Language.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@
2626
import org.sonarsource.api.sonarlint.SonarLintSide;
2727

2828
/**
29-
* The extension point to define a new language
29+
* The extension point to define a new language. A Language is defined by a key and a name (aka label).
30+
* <br/><br/>
31+
* When source files are analyzed on SonarLint or on scanner side, they will be optionally assigned to a language. A given source file
32+
* (see {@link org.sonar.api.batch.fs.InputFile}) can only have one language (or no language).
33+
* Implementors can declare file extensions (using {@link #getFileSuffixes()})
34+
* or filename patterns (using {@link #filenamePatterns()} that will be used to decide which language should be associated to a file.
35+
* <br/>
36+
* Since a source file can only have one language, patterns should match disjoint sets of files.
3037
*
3138
* @since 1.10
3239
*/
@@ -53,7 +60,8 @@ public interface Language {
5360
* returning <code>["&#42;&#42;/&#42;.jav", "&#42;&#42;/&#42;.java"]</code>.<br/>
5461
* The filename extension matching is case-insensitive, so declaring <code>["java"]</code> will match "src/main/java/Foo.java" and
5562
* "src/main/java/Foo.JAVA".<br/>
56-
* If both {@link #getFileSuffixes()} and {@link #filenamePatterns()} are provided, both will be considered.
63+
* If both {@link #getFileSuffixes()} and {@link #filenamePatterns()} are provided, both will be considered. Implementors should be careful
64+
* to have each language suffix and patterns matching disjoint set of files, since a file can be assigned to only one language.
5765
*/
5866
String[] getFileSuffixes();
5967

@@ -71,7 +79,8 @@ default boolean publishAllFiles() {
7179
* Pattern are considered relative: <code>["pom.xml"]</code> is equivalent to <code>["&#42;&#42;/pom.xml"]</code> <br/>
7280
* The filename extension matching is case-insensitive, so declaring <code>["&#42;&#42;/&#42;Test.java"]</code> will match "FooTest.java" and
7381
* "FooTest.JAVA" but <strong>not</strong> "FooTEST.java".<br/>
74-
* If both {@link #getFileSuffixes()} and {@link #filenamePatterns()} are provided, both will be considered.
82+
* If both {@link #getFileSuffixes()} and {@link #filenamePatterns()} are provided, both will be considered. Implementors should be careful
83+
* to have each language suffix and patterns matching disjoint set of files, since a file can be assigned to only one language.
7584
* @since 9.16
7685
*/
7786
default String[] filenamePatterns() {

0 commit comments

Comments
 (0)