MCPcopy Create free account
hub / github.com/docker/docker-language-server / dependencyCompletionItems

Function dependencyCompletionItems

internal/compose/completion.go:628–669  ·  view source on GitHub ↗
(file *ast.File, documentPath document.DocumentPath, path []*ast.MappingValueNode, params *protocol.CompletionParams, prefixLength protocol.UInteger)

Source from the content-addressed store, hash-verified

626}
627
628func dependencyCompletionItems(file *ast.File, documentPath document.DocumentPath, path []*ast.MappingValueNode, params *protocol.CompletionParams, prefixLength protocol.UInteger) []protocol.CompletionItem {
629 dependency := map[string]string{
630 "depends_on": "services",
631 "models": "models",
632 "networks": "networks",
633 }
634 for serviceAttribute, dependencyType := range dependency {
635 items := namedDependencyCompletionItems(file, path, serviceAttribute, dependencyType, params, prefixLength)
636 if len(items) > 0 {
637 return items
638 }
639 }
640 if len(path) >= 3 && path[2].Key.GetToken().Value == "extends" && path[0].Key.GetToken().Value == "services" {
641 if (len(path) == 4 && path[3].Key.GetToken().Value == "service") || params.Position.Line == protocol.UInteger(path[2].Key.GetToken().Position.Line)-1 {
642 if !extendingCurrentFile(documentPath, path[2]) {
643 return nil
644 }
645
646 items := []protocol.CompletionItem{}
647 for _, service := range findDependencies(file, "services") {
648 if service != path[1].Key.GetToken().Value {
649 item := protocol.CompletionItem{
650 Label: service,
651 TextEdit: protocol.TextEdit{
652 NewText: service,
653 Range: protocol.Range{
654 Start: protocol.Position{
655 Line: params.Position.Line,
656 Character: params.Position.Character - prefixLength,
657 },
658 End: params.Position,
659 },
660 },
661 }
662 items = append(items, item)
663 }
664 }
665 return items
666 }
667 }
668 return nil
669}
670
671func volumeDependencyCompletionItems(
672 file *ast.File,

Callers 1

CompletionFunction · 0.85

Calls 3

extendingCurrentFileFunction · 0.85
findDependenciesFunction · 0.85

Tested by

no test coverage detected