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

Function DocumentHighlights

internal/compose/documentHighlight.go:290–373  ·  view source on GitHub ↗
(doc document.ComposeDocument, position protocol.Position)

Source from the content-addressed store, hash-verified

288}
289
290func DocumentHighlights(doc document.ComposeDocument, position protocol.Position) (string, dependencyReference) {
291 file := doc.File()
292 if file == nil || len(file.Docs) == 0 {
293 return "", dependencyReference{documentHighlights: nil}
294 }
295
296 line := int(position.Line) + 1
297 character := int(position.Character) + 1
298 if mappingNode, ok := file.Docs[0].Body.(*ast.MappingNode); ok {
299 var networkRefs []*token.Token
300 var volumeRefs []*token.Token
301 var configRefs []*token.Token
302 var secretRefs []*token.Token
303 var modelRefs []*token.Token
304 var networkDeclarations []*token.Token
305 var volumeDeclarations []*token.Token
306 var configDeclarations []*token.Token
307 var secretDeclarations []*token.Token
308 var modelDeclarations []*token.Token
309 for _, node := range mappingNode.Values {
310 name, value := convertTopLevelNode(node)
311 if name == nil || value == nil {
312 continue
313 }
314
315 switch name.Value {
316 case "services":
317 refs := serviceDependencyReferences(value, "depends_on", false)
318 refs = append(refs, extendedServiceReferences(value)...)
319 decls := declarations(value)
320 name, highlights := highlightReferences("services", refs, decls, line, character)
321 if len(highlights.documentHighlights) > 0 {
322 return name, highlights
323 }
324 networkRefs = serviceDependencyReferences(value, "networks", false)
325 configRefs = serviceDependencyReferences(value, "configs", true)
326 secretRefs = serviceDependencyReferences(value, "secrets", true)
327 modelRefs = serviceDependencyReferences(value, "models", false)
328 volumeRefs = volumeReferences(value)
329 case "networks":
330 networkDeclarations = declarations(value)
331 case "volumes":
332 volumeDeclarations = declarations(value)
333 case "configs":
334 configDeclarations = declarations(value)
335 case "secrets":
336 secretDeclarations = declarations(value)
337 case "models":
338 modelDeclarations = declarations(value)
339 }
340 }
341 name, highlights := highlightReferences("networks", networkRefs, networkDeclarations, line, character)
342 if len(highlights.documentHighlights) > 0 {
343 return name, highlights
344 }
345 name, highlights = highlightReferences("volumes", volumeRefs, volumeDeclarations, line, character)
346 if len(highlights.documentHighlights) > 0 {
347 return name, highlights

Callers 2

DocumentHighlightFunction · 0.85
DefinitionFunction · 0.85

Calls 9

convertTopLevelNodeFunction · 0.85
declarationsFunction · 0.85
highlightReferencesFunction · 0.85
volumeReferencesFunction · 0.85
fragmentReferenceFunction · 0.85
FileMethod · 0.65

Tested by

no test coverage detected