mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 06:55:26 +02:00
fix(server): Improve namin
This commit is contained in:
parent
a2decaeff3
commit
ac97ec77ef
@ -50,13 +50,13 @@ func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileRequired := (v.RequiredType & PathTypeFile) == PathTypeFile
|
fileExpected := (v.RequiredType & PathTypeFile) == PathTypeFile
|
||||||
directoryRequired := (v.RequiredType & PathTypeDirectory) == PathTypeDirectory
|
directoryExpected := (v.RequiredType & PathTypeDirectory) == PathTypeDirectory
|
||||||
|
|
||||||
isValid := true
|
isValid := true
|
||||||
|
|
||||||
// If file is expected
|
// If file is expected
|
||||||
if fileRequired {
|
if fileExpected {
|
||||||
// and exists
|
// and exists
|
||||||
isValid = isValid && utils.IsPathFile(value)
|
isValid = isValid && utils.IsPathFile(value)
|
||||||
// file not expected
|
// file not expected
|
||||||
@ -66,7 +66,7 @@ func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if directory
|
// if directory
|
||||||
if directoryRequired {
|
if directoryExpected {
|
||||||
// and exists
|
// and exists
|
||||||
isValid = isValid && utils.IsPathDirectory(value)
|
isValid = isValid && utils.IsPathDirectory(value)
|
||||||
// directory not expected
|
// directory not expected
|
||||||
@ -79,21 +79,21 @@ func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if fileRequired && directoryRequired {
|
if fileExpected && directoryExpected {
|
||||||
return []*InvalidValue{{
|
return []*InvalidValue{{
|
||||||
Err: errors.New("This must be either a file or a directory"),
|
Err: errors.New("This must be either a file or a directory"),
|
||||||
Start: 0,
|
Start: 0,
|
||||||
End: uint32(len(value)),
|
End: uint32(len(value)),
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
if fileRequired {
|
if fileExpected {
|
||||||
return []*InvalidValue{{
|
return []*InvalidValue{{
|
||||||
Err: errors.New("This must be a file"),
|
Err: errors.New("This must be a file"),
|
||||||
Start: 0,
|
Start: 0,
|
||||||
End: uint32(len(value)),
|
End: uint32(len(value)),
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
if directoryRequired {
|
if directoryExpected {
|
||||||
return []*InvalidValue{{
|
return []*InvalidValue{{
|
||||||
Err: errors.New("This must be a directory"),
|
Err: errors.New("This must be a directory"),
|
||||||
Start: 0,
|
Start: 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user