MCPcopy
hub / github.com/micro-editor/micro / resolveIncludes

Function resolveIncludes

internal/buffer/buffer.go:776–813  ·  view source on GitHub ↗
(syndef *highlight.Def)

Source from the content-addressed store, hash-verified

774}
775
776func resolveIncludes(syndef *highlight.Def) {
777 includes := highlight.GetIncludes(syndef)
778 if len(includes) == 0 {
779 return
780 }
781
782 var files []*highlight.File
783 for _, f := range config.ListRuntimeFiles(config.RTSyntax) {
784 data, err := f.Data()
785 if err != nil {
786 screen.TermMessage("Error loading syntax file " + f.Name() + ": " + err.Error())
787 continue
788 }
789
790 header, err := highlight.MakeHeaderYaml(data)
791 if err != nil {
792 screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
793 continue
794 }
795
796 for _, i := range includes {
797 if header.FileType == i {
798 file, err := highlight.ParseFile(data)
799 if err != nil {
800 screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
801 continue
802 }
803 files = append(files, file)
804 break
805 }
806 }
807 if len(files) >= len(includes) {
808 break
809 }
810 }
811
812 highlight.ResolveIncludes(syndef, files)
813}
814
815// UpdateRules updates the syntax rules and filetype for this buffer
816// This is called when the colorscheme changes

Callers 1

UpdateRulesMethod · 0.85

Calls 9

GetIncludesFunction · 0.92
ListRuntimeFilesFunction · 0.92
TermMessageFunction · 0.92
MakeHeaderYamlFunction · 0.92
ParseFileFunction · 0.92
ResolveIncludesFunction · 0.92
DataMethod · 0.65
NameMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected