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

Method readAndParse

internal/pkg/document/manager.go:222–238  ·  view source on GitHub ↗
(ctx context.Context, u uri.URI)

Source from the content-addressed store, hash-verified

220}
221
222func (m *Manager) readAndParse(ctx context.Context, u uri.URI) (bool, error) {
223 identifier := protocol.DockerfileLanguage
224 if strings.HasSuffix(string(u), "hcl") {
225 identifier = protocol.DockerBakeLanguage
226 } else if strings.HasSuffix(string(u), "yml") || strings.HasSuffix(string(u), "yaml") {
227 identifier = protocol.DockerComposeLanguage
228 }
229
230 if _, found := m.docs[u]; !found {
231 contents, err := m.readDocFunc(u)
232 if err != nil {
233 return false, err
234 }
235 return m.parse(ctx, u, identifier, 1, contents)
236 }
237 return m.parse(ctx, u, identifier, 1, nil)
238}
239
240func (m *Manager) parse(_ context.Context, uri uri.URI, identifier protocol.LanguageIdentifier, version int32, input []byte) (bool, error) {
241 doc, loaded := m.docs[uri]

Callers 1

tryReadingMethod · 0.95

Calls 1

parseMethod · 0.95

Tested by

no test coverage detected