mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-18 14:13:07 -03:00
Remove name -> LanguageInfo mapping per code review
The GetLanguageInfo method is now implemented in terms of GetLanguageInfoByID. This is possible because you can use GetLanguageID to get the ID for a language.
This commit is contained in:
@ -562,11 +562,12 @@ func GetLanguageGroup(language string) string {
|
||||
|
||||
// GetLanguageInfo returns the LanguageInfo for a given language name, or an error if not found.
|
||||
func GetLanguageInfo(language string) (data.LanguageInfo, error) {
|
||||
if info, ok := data.LanguageInfoByName[language]; ok {
|
||||
return info, nil
|
||||
id, ok := GetLanguageID(language)
|
||||
if !ok {
|
||||
return data.LanguageInfo{}, fmt.Errorf("language %q not found", language)
|
||||
}
|
||||
|
||||
return data.LanguageInfo{}, fmt.Errorf("language %q not found", language)
|
||||
return GetLanguageInfoByID(id)
|
||||
}
|
||||
|
||||
// GetLanguageInfo returns the LanguageInfo for a given language name, or an error if not found.
|
||||
|
13298
data/languageInfo.go
13298
data/languageInfo.go
File diff suppressed because it is too large
Load Diff
@ -20,45 +20,6 @@ type LanguageInfo struct {
|
||||
LanguageID int
|
||||
}
|
||||
|
||||
// LanguageInfoByName allows accessing LanguageInfo by a language's primary name.
|
||||
var LanguageInfoByName = map[string]LanguageInfo{
|
||||
{{range $language, $info := . -}}
|
||||
"{{$language}}": LanguageInfo{
|
||||
Name: "{{$language}}",
|
||||
FSName: "{{$info.FSName}}",
|
||||
Type: TypeForString("{{$info.Type}}"),
|
||||
Color: "{{$info.Color}}",
|
||||
Group: "{{$info.Group}}",
|
||||
Aliases: []string{
|
||||
{{range $alias := $info.Aliases -}}
|
||||
"{{$alias}}",
|
||||
{{end -}}
|
||||
},
|
||||
Extensions: []string{
|
||||
{{range $extension := $info.Extensions -}}
|
||||
"{{$extension}}",
|
||||
{{end -}}
|
||||
},
|
||||
Interpreters: []string{
|
||||
{{range $interpreter := $info.Interpreters -}}
|
||||
"{{$interpreter}}",
|
||||
{{end -}}
|
||||
},
|
||||
Filenames: []string{
|
||||
{{range $filename := $info.Filenames -}}
|
||||
"{{$filename}}",
|
||||
{{end -}}
|
||||
},
|
||||
MimeType: "{{$info.MimeType}}",
|
||||
TMScope: "{{$info.TMScope}}",
|
||||
AceMode: "{{$info.AceMode}}",
|
||||
CodemirrorMode: "{{$info.CodemirrorMode}}",
|
||||
Wrap: {{$info.Wrap}},
|
||||
LanguageID: {{$info.LanguageID}},
|
||||
},
|
||||
{{end -}}
|
||||
}
|
||||
|
||||
// LanguageInfoByID allows accessing LanguageInfo by a language's ID.
|
||||
var LanguageInfoByID = map[int]LanguageInfo{
|
||||
{{range $language, $info := . -}}
|
||||
|
Reference in New Issue
Block a user