0
# Language Module
1
2
The language module provides core PMD integration for Scala support, registering the language with PMD's framework and providing version-specific configuration.
3
4
## Core Language Integration
5
6
### ScalaLanguageModule
7
8
Main language module registration class that integrates Scala with PMD's multilanguage architecture.
9
10
```java { .api }
11
public class ScalaLanguageModule extends SimpleLanguageModuleBase {
12
public ScalaLanguageModule();
13
public static ScalaLanguageModule getInstance();
14
public CpdLexer createCpdLexer(LanguagePropertyBundle bundle);
15
}
16
```
17
18
**Usage Example**:
19
20
```java
21
// Get the singleton Scala language module instance
22
ScalaLanguageModule module = ScalaLanguageModule.getInstance();
23
24
// Create a CPD lexer for copy-paste detection
25
LanguagePropertyBundle bundle = // ... configure language properties
26
CpdLexer lexer = module.createCpdLexer(bundle);
27
```
28
29
### ScalaLanguageHandler
30
31
Language version handler that provides parser instances for different Scala versions.
32
33
```java { .api }
34
public class ScalaLanguageHandler extends AbstractPmdLanguageVersionHandler {
35
public ScalaParser getParser();
36
}
37
```
38
39
**Usage Example**:
40
41
```java
42
ScalaLanguageHandler handler = new ScalaLanguageHandler();
43
ScalaParser parser = handler.getParser();
44
```
45
46
## Supported Versions
47
48
The module supports the following Scala versions through dialect configuration:
49
50
- **Scala 2.10**: Historical support
51
- **Scala 2.11**: Historical support
52
- **Scala 2.12**: Primary target version for this module
53
- **Scala 2.13**: Default version used when no specific version is specified
54
55
## Integration Points
56
57
### PMD Framework Integration
58
59
The language module integrates with PMD through:
60
61
1. **Language Registry**: Registers "scala" as a supported language
62
2. **File Extensions**: Associates ".scala" files with the Scala language module
63
3. **Version Management**: Provides version-specific parsing capabilities
64
4. **CPD Integration**: Creates lexers for copy-paste detection
65
66
### Configuration
67
68
Language configuration is handled through:
69
70
```java { .api }
71
// Language metadata configuration
72
LanguageMetadata.withId("scala")
73
.name("Scala")
74
.extensions("scala")
75
.addVersion("2.10")
76
.addVersion("2.11")
77
.addVersion("2.12")
78
.addDefaultVersion("2.13")
79
```
80
81
The module automatically configures:
82
- Language identifier: "scala"
83
- Display name: "Scala"
84
- File extensions: ".scala"
85
- Supported versions with 2.13 as default