Package org.sonar.api.resources
Interface Language
-
- All Known Implementing Classes:
AbstractLanguage
@ScannerSide @ServerSide @SonarLintSide @ComputeEngineSide @ExtensionPoint public interface Language
The extension point to define a new language. A Language is defined by a key and a name (aka label).
When source files are analyzed on SonarLint or on scanner side, they will be optionally assigned to a language. A given source file (seeInputFile
) can only have one language (or no language). Implementors can declare file extensions (usinggetFileSuffixes()
) or filename patterns (usingfilenamePatterns()
that will be used to decide which language should be associated to a file.
Since a source file can only have one language, patterns should match disjoint sets of files.- Since:
- 1.10
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.lang.String[]
filenamePatterns()
Provide a list of patterns following theWildcardPattern
syntax.java.lang.String[]
getFileSuffixes()
Filename extensions, without the dot.java.lang.String
getKey()
For example "java".java.lang.String
getName()
For example "Java"default boolean
publishAllFiles()
Whether all files identified with this language should be sent to SonarQube, even if no data is reported for them
-
-
-
Method Detail
-
getKey
java.lang.String getKey()
For example "java". Should not be more than 20 chars.
-
getName
java.lang.String getName()
For example "Java"
-
getFileSuffixes
java.lang.String[] getFileSuffixes()
Filename extensions, without the dot. For example["jav", "java"]
. Source files having any of those extensions will be associated to this language. This is equivalent to havefilenamePatterns()
returning["**/*.jav", "**/*.java"]
.
The filename extension matching is case-insensitive, so declaring["java"]
will match "src/main/java/Foo.java" and "src/main/java/Foo.JAVA".
If bothgetFileSuffixes()
andfilenamePatterns()
are provided, both will be considered. Implementors should be careful to have each language suffix and patterns matching disjoint set of files, since a file can be assigned to only one language.
-
publishAllFiles
default boolean publishAllFiles()
Whether all files identified with this language should be sent to SonarQube, even if no data is reported for them- Since:
- 9.3
-
filenamePatterns
default java.lang.String[] filenamePatterns()
Provide a list of patterns following theWildcardPattern
syntax. Source files matching any of those patterns will be associated to this language. Pattern are considered relative:["pom.xml"]
is equivalent to["**/pom.xml"]
The filename extension matching is case-insensitive, so declaring["**/*Test.java"]
will match "FooTest.java" and "FooTest.JAVA" but not "FooTEST.java".
If bothgetFileSuffixes()
andfilenamePatterns()
are provided, both will be considered. Implementors should be careful to have each language suffix and patterns matching disjoint set of files, since a file can be assigned to only one language.- Since:
- 9.16
-
-