-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpython.go
40 lines (31 loc) · 860 Bytes
/
python.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package lang
import (
"github.com/safedep/code/core"
sitter "github.com/smacker/go-tree-sitter"
"github.com/smacker/go-tree-sitter/python"
)
const pythonLanguageName = "python"
type pythonLanguage struct{}
var _ core.Language = (*pythonLanguage)(nil)
func NewPythonLanguage() (*pythonLanguage, error) {
return &pythonLanguage{}, nil
}
func (l *pythonLanguage) Name() string {
return pythonLanguageName
}
func (l *pythonLanguage) Meta() core.LanguageMeta {
return core.LanguageMeta{
Name: pythonLanguageName,
Code: core.LanguageCodePython,
ObjectOriented: true,
SourceFileExtensions: []string{".py"},
}
}
func (l *pythonLanguage) Language() *sitter.Language {
return python.GetLanguage()
}
func (l *pythonLanguage) Resolvers() core.LanguageResolvers {
return &pythonResolvers{
language: l,
}
}