1
0
mirror of https://github.com/golang/go synced 2024-11-19 03:24:40 -07:00
go/internal/lsp/protocol/printers.go
Ian Cottrell dbad8e90c9 internal/lsp: convert to the new location library
This rationalises all the position handling and conversion code out.
Fixes golang/go#29149

Change-Id: I2814f3e8ba769924bc70f35df9e5bf4d97d064de
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166884
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-13 19:34:21 +00:00

54 lines
1.4 KiB
Go

// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains formatting functions for types that
// are commonly printed in debugging information.
// They are separated from their types and gathered here as
// they are hand written and not generated from the spec.
// They should not be relied on for programmatic use (their
// results should never be parsed for instance) but are meant
// for temporary debugging and error messages.
package protocol
import (
"fmt"
)
func (s DiagnosticSeverity) Format(f fmt.State, c rune) {
switch s {
case SeverityError:
fmt.Fprint(f, "Error")
case SeverityWarning:
fmt.Fprint(f, "Warning")
case SeverityInformation:
fmt.Fprint(f, "Information")
case SeverityHint:
fmt.Fprint(f, "Hint")
}
}
func (k CompletionItemKind) Format(f fmt.State, c rune) {
switch k {
case StructCompletion:
fmt.Fprintf(f, "struct")
case FunctionCompletion:
fmt.Fprintf(f, "func")
case VariableCompletion:
fmt.Fprintf(f, "var")
case TypeParameterCompletion:
fmt.Fprintf(f, "type")
case FieldCompletion:
fmt.Fprintf(f, "field")
case InterfaceCompletion:
fmt.Fprintf(f, "interface")
case ConstantCompletion:
fmt.Fprintf(f, "const")
case MethodCompletion:
fmt.Fprintf(f, "method")
case ModuleCompletion:
fmt.Fprintf(f, "package")
}
}