MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / matchCodeLanguage

Function matchCodeLanguage

executor/compile.go:17–45  ·  view source on GitHub ↗

匹配编程语言

(keyword string, fileName string)

Source from the content-addressed store, hash-verified

15
16// 匹配编程语言
17func matchCodeLanguage(keyword string, fileName string) (provider.CodeCompileProviderInterface, error) {
18_match:
19 switch keyword {
20 case "c", "gcc", "gnu-c":
21 return provider.NewGnucCompileProvider(), nil
22 case "cpp", "gcc-cpp", "gcpp", "g++":
23 return provider.NewGnucppCompileProvider(), nil
24 case "java":
25 return provider.NewJavaCompileProvider(), nil
26 case "py2", "python2":
27 return provider.NewPy2CompileProvider(), nil
28 case "py", "py3", "python3":
29 return provider.NewPy3CompileProvider(), nil
30 case "php":
31 return provider.NewPHPCompileProvider(), nil
32 case "go", "golang":
33 return provider.NewGolangCompileProvider(), nil
34 case "node", "nodejs":
35 return provider.NewNodeJSCompileProvider(), nil
36 case "rb", "ruby":
37 return provider.NewRubyCompileProvider(), nil
38 case "rs", "rust":
39 return provider.NewRustCompileProvider(), nil
40 case "auto", "":
41 keyword = strings.Replace(path.Ext(fileName), ".", "", -1)
42 goto _match
43 }
44 return nil, errors.Errorf("unsupported language")
45}
46
47// GetCompiler get a compiler provider from session.CodeLangName
48// 如果不设置codeStr,默认会读取配置文件里的code_file字段并打开对应文件

Callers 1

GetCompilerMethod · 0.85

Calls 11

NewGnucCompileProviderFunction · 0.92
NewGnucppCompileProviderFunction · 0.92
NewJavaCompileProviderFunction · 0.92
NewPy2CompileProviderFunction · 0.92
NewPy3CompileProviderFunction · 0.92
NewPHPCompileProviderFunction · 0.92
NewGolangCompileProviderFunction · 0.92
NewNodeJSCompileProviderFunction · 0.92
NewRubyCompileProviderFunction · 0.92
NewRustCompileProviderFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected