chore: Apply gofmt

This commit is contained in:
Myzel394 2024-07-28 18:05:24 +02:00
parent 403cc9a336
commit 1d55158fc8
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
12 changed files with 579 additions and 580 deletions

View File

@ -14,6 +14,7 @@ type Value interface {
type EnumValue struct {
Values []string
}
func (v EnumValue) getTypeDescription() []string {
lines := make([]string, len(v.Values)+1)
lines[0] = "Enum of:"
@ -26,6 +27,7 @@ func (v EnumValue) getTypeDescription() []string {
}
type PositiveNumberValue struct{}
func (v PositiveNumberValue) getTypeDescription() []string {
return []string{"Positive number"}
}
@ -35,18 +37,20 @@ type ArrayValue struct {
Separator string
AllowDuplicates bool
}
func (v ArrayValue) getTypeDescription() []string {
subValue := v.SubValue.(Value)
return append(
[]string{"An Array separated by " + v.Separator + " of:"},
subValue.getTypeDescription()...
subValue.getTypeDescription()...,
)
}
type OrValue struct {
Values []Value
}
func (v OrValue) getTypeDescription() []string {
lines := make([]string, 0)
@ -67,11 +71,12 @@ func (v OrValue) getTypeDescription() []string {
return append(
[]string{"One of:"},
lines...
lines...,
)
}
type StringValue struct{}
func (v StringValue) getTypeDescription() []string {
return []string{"String"}
}
@ -79,6 +84,7 @@ func (v StringValue) getTypeDescription() []string {
type CustomValue struct {
FetchValue func() Value
}
func (v CustomValue) getTypeDescription() []string {
return []string{"Custom"}
}
@ -91,6 +97,7 @@ type PrefixWithMeaningValue struct {
Prefixes []Prefix
SubValue Value
}
func (v PrefixWithMeaningValue) getTypeDescription() []string {
subDescription := v.SubValue.getTypeDescription()
@ -106,7 +113,6 @@ func (v PrefixWithMeaningValue) getTypeDescription() []string {
)
}
type Option struct {
Documentation string
Value Value
@ -124,4 +130,3 @@ func GetDocumentation(o *Option) protocol.MarkupContent {
func NewOption(documentation string, value Value) Option {
return Option{documentation, value}
}

View File

@ -11,6 +11,7 @@ type OptionAlreadyExistsError struct {
Option string
FoundOnLine uint32
}
func (e OptionAlreadyExistsError) Error() string {
return fmt.Sprintf("Option %s already exists", e.Option)
}
@ -18,6 +19,7 @@ func (e OptionAlreadyExistsError) Error() string {
type OptionUnknownError struct {
Option string
}
func (e OptionUnknownError) Error() string {
return fmt.Sprintf("Option '%s' does not exist", e.Option)
}
@ -25,11 +27,13 @@ func (e OptionUnknownError) Error() string {
type MalformedLineError struct {
Line string
}
func (e MalformedLineError) Error() string {
return fmt.Sprintf("Malformed line: %s", e.Line)
}
type LineNotFoundError struct{}
func (e LineNotFoundError) Error() string {
return "Line not found"
}
@ -38,7 +42,7 @@ type ValueNotInEnumError struct {
availableValues []string
providedValue string
}
func (e ValueNotInEnumError) Error() string {
return fmt.Sprint("'%s' is not valid. Select one from: %s", e.providedValue, strings.Join(e.availableValues, ","))
}

View File

@ -50,7 +50,6 @@ func fetchPasswdInfo() ([]passwdInfo, error) {
return infos, nil
}
// UserValue returns a Value that fetches user names from /etc/passwd
// if `separatorForMultiple` is not empty, it will return an ArrayValue
func UserValue(separatorForMultiple string) Value {
@ -80,4 +79,3 @@ func UserValue(separatorForMultiple string) Value {
},
}
}

View File

@ -144,4 +144,3 @@ func (p *SimpleConfigParser) FindByLineNumber(lineNumber int) (string, SimpleCon
return "", SimpleConfigLine{Value: "", Position: SimpleConfigPosition{Line: 0}}, LineNotFoundError{}
}

View File

@ -28,4 +28,3 @@ func Map[T any, O any](values []T, f func(T) O) []O {
return result
}

View File

@ -24,7 +24,8 @@ func SendDiagnosticsFromParserErrors(context *glsp.Context, uri protocol.Documen
for _, parserError := range parserErrors {
switch parserError.(type) {
case common.OptionAlreadyExistsError: {
case common.OptionAlreadyExistsError:
{
err := parserError.(common.OptionAlreadyExistsError)
existingOption, _ := Parser.GetOption(err.Option)
@ -53,4 +54,3 @@ func SendDiagnosticsFromParserErrors(context *glsp.Context, uri protocol.Documen
},
)
}

View File

@ -89,7 +89,7 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
The available authentication methods are: "gssapi-with-mic", "hostbased", "keyboard-interactive", "none" (used for access to password-less accounts when PermitEmptyPasswords is enabled), "password" and "publickey".`,
common.OrValue{
Values: []common.Value{
common.EnumValue{ Values: []string{"any"}, },
common.EnumValue{Values: []string{"any"}},
common.ArrayValue{
AllowDuplicates: true,
SubValue: common.EnumValue{

View File

@ -8,7 +8,7 @@ import (
func createOpenSSHConfigParser() common.SimpleConfigParser {
pattern, err := regexp.Compile(`^(?:#|\s*$)`)
if (err != nil) {
if err != nil {
panic(err)
}
@ -23,4 +23,3 @@ func createOpenSSHConfigParser() common.SimpleConfigParser {
}
var Parser = createOpenSSHConfigParser()

View File

@ -100,4 +100,3 @@ func getOptionCompletions(optionName string) []protocol.CompletionItem {
return completions
}

View File

@ -18,6 +18,5 @@ func TextDocumentDidChange(context *glsp.Context, params *protocol.DidChangeText
ClearDiagnostics(context, params.TextDocument.URI)
}
return nil
}

View File

@ -22,5 +22,3 @@ func TextDocumentDidOpen(context *glsp.Context, params *protocol.DidOpenTextDocu
return nil
}

View File

@ -65,4 +65,3 @@ func setTrace(context *glsp.Context, params *protocol.SetTraceParams) error {
protocol.SetTraceValue(params.Value)
return nil
}