From b7e786810ebf4b1df386666fcc2648abd2184174 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sat, 28 Sep 2024 12:07:18 +0200 Subject: [PATCH] refactor: Rename Value -> DeprecatedValue --- common-documentation/mnt-adfs.go | 2 +- common-documentation/mnt-affs.go | 2 +- common-documentation/mnt-btrfs.go | 4 +- common-documentation/mnt-debugfs.go | 2 +- common-documentation/mnt-devpts.go | 2 +- common-documentation/mnt-ext2.go | 2 +- common-documentation/mnt-ext3.go | 2 +- common-documentation/mnt-ext4.go | 2 +- common-documentation/mnt-fat.go | 2 +- common-documentation/mnt-hfs.go | 2 +- common-documentation/mnt-hpfs.go | 2 +- common-documentation/mnt-iso9660.go | 2 +- common-documentation/mnt-jfs.go | 2 +- common-documentation/mnt-ncpfs.go | 2 +- common-documentation/mnt-ntfs.go | 2 +- common-documentation/mnt-overlay.go | 2 +- common-documentation/mnt-reiserfs.go | 2 +- common-documentation/mnt-ubifs.go | 2 +- common-documentation/mnt-udf.go | 2 +- common-documentation/mnt-ufs.go | 2 +- common-documentation/mnt-umsdos.go | 2 +- common-documentation/mnt-usbfs.go | 2 +- common-documentation/mnt-vfat.go | 2 +- doc-values/base-value.go | 8 +- doc-values/errors.go | 2 +- doc-values/extra-values.go | 16 +-- doc-values/utils.go | 4 +- doc-values/value-array.go | 16 +-- doc-values/value-custom.go | 14 +-- doc-values/value-data-amount-value.go | 6 +- doc-values/value-documentation.go | 12 +- doc-values/value-enum.go | 6 +- doc-values/value-gid.go | 6 +- doc-values/value-ip-address.go | 6 +- doc-values/value-key-enum-assignment.go | 24 ++-- doc-values/value-key-value-assignment.go | 36 +++--- doc-values/value-mask-mode.go | 6 +- doc-values/value-number.go | 6 +- doc-values/value-or.go | 20 ++-- doc-values/value-path.go | 6 +- doc-values/value-power-of-two.go | 6 +- doc-values/value-prefix.go | 18 +-- doc-values/value-regex.go | 6 +- doc-values/value-string.go | 6 +- doc-values/value-suffix.go | 18 +-- doc-values/value-time-format.go | 6 +- doc-values/value-uid.go | 6 +- doc-values/value-umask.go | 6 +- handlers/aliases/ast/values.go | 4 +- .../documentation-mount-point.go | 2 +- .../documentation-mountoptions.go | 14 +-- .../fstab/documentation/documentation-pass.go | 2 +- .../fstab/documentation/documentation-spec.go | 4 +- handlers/fstab/handlers/completions.go | 14 +-- handlers/fstab/handlers/hover.go | 4 +- .../fstab/lsp/text-document-completion.go | 2 +- handlers/fstab/parser/parser.go | 14 +-- handlers/hosts/analyzer/values.go | 6 +- handlers/hosts/lsp/text-document-hover.go | 2 +- handlers/ssh_config/analyzer/options.go | 3 +- handlers/ssh_config/fields/fields.go | 112 +++++++++--------- handlers/ssh_config/fields/match.go | 3 + handlers/ssh_config/handlers/completions.go | 4 +- handlers/sshd_config/analyzer/match.go | 5 +- handlers/sshd_config/analyzer/options.go | 2 +- handlers/sshd_config/fields/fields.go | 26 ++-- handlers/sshd_config/fields/match.go | 8 +- handlers/sshd_config/handlers/completions.go | 4 +- .../sshd_config/handlers/completions_match.go | 14 +-- handlers/sshd_config/handlers/hover.go | 2 +- .../wireguard/fields/documentation-fields.go | 2 +- handlers/wireguard/handlers/analyzer.go | 2 +- handlers/wireguard/handlers/completions.go | 4 +- 73 files changed, 287 insertions(+), 286 deletions(-) create mode 100644 handlers/ssh_config/fields/match.go diff --git a/common-documentation/mnt-adfs.go b/common-documentation/mnt-adfs.go index cccb4b2..7ce850e 100644 --- a/common-documentation/mnt-adfs.go +++ b/common-documentation/mnt-adfs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var AdfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var AdfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "uid", "Set the owner of the files in the filesystem (default: uid=0).", diff --git a/common-documentation/mnt-affs.go b/common-documentation/mnt-affs.go index 1a0f6e6..398b879 100644 --- a/common-documentation/mnt-affs.go +++ b/common-documentation/mnt-affs.go @@ -4,7 +4,7 @@ import docvalues "config-lsp/doc-values" var prefixMaxLength = uint32(30) -var AffsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var AffsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "uid", "Set the owner and group of the root of the filesystem (default: uid=gid=0, but with option uid or gid without specified value, the UID and GID of the current process are taken).", diff --git a/common-documentation/mnt-btrfs.go b/common-documentation/mnt-btrfs.go index 664f946..46a7fbf 100644 --- a/common-documentation/mnt-btrfs.go +++ b/common-documentation/mnt-btrfs.go @@ -4,7 +4,7 @@ import docvalues "config-lsp/doc-values" var maxInlineMin = 2048 -var BtrfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var BtrfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "check_int_print_mask", "These debugging options control the behavior of the integrity checking module (the BTRFS_FS_CHECK_INTEGRITY config option required). The main goal is to verify that all blocks from a given transaction period are properly linked.", @@ -71,7 +71,7 @@ var BtrfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ "max_inline", "Specify the maximum amount of space, that can be inlined in a metadata b-tree leaf. The value is specified in bytes, optionally with a K suffix (case insensitive). In practice, this value is limited by the filesystem block size (named sectorsize at mkfs time), and memory page size of the system. In case of sectorsize limit, there's some space unavailable due to leaf headers. For example, a 4Ki", ): docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ diff --git a/common-documentation/mnt-debugfs.go b/common-documentation/mnt-debugfs.go index 8d5ae63..d9f121f 100644 --- a/common-documentation/mnt-debugfs.go +++ b/common-documentation/mnt-debugfs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var DebugfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var DebugfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "uid", "Set the owner of the mountpoint.", diff --git a/common-documentation/mnt-devpts.go b/common-documentation/mnt-devpts.go index e2484b5..27eeaf9 100644 --- a/common-documentation/mnt-devpts.go +++ b/common-documentation/mnt-devpts.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var DevptsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var DevptsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "uid", "This sets the owner or the group of newly created pseudo terminals to the specified values. When nothing is specified, they will be set to the UID and GID of the creating process. For example, if there is a tty group with GID 5, then gid=5 will cause newly created pseudo terminals to belong to the tty group.", diff --git a/common-documentation/mnt-ext2.go b/common-documentation/mnt-ext2.go index 7745c63..fa44c76 100644 --- a/common-documentation/mnt-ext2.go +++ b/common-documentation/mnt-ext2.go @@ -3,7 +3,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var Ext2DocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var Ext2DocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "none", "No checking is done at mount time. This is the default. This is fast. It is wise to invoke e2fsck(8) every now and then, e.g. at boot time. The non-default behavior is unsupported (check=normal and check=strict options have been removed). Note that these mount options don't have to be supported if ext4 kernel driver is used for ext2 and ext3 file systems.", diff --git a/common-documentation/mnt-ext3.go b/common-documentation/mnt-ext3.go index 955f36a..167d64b 100644 --- a/common-documentation/mnt-ext3.go +++ b/common-documentation/mnt-ext3.go @@ -5,7 +5,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var Ext3DocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var Ext3DocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "journal_dev", "When the external journal device's major/minor numbers have changed, these options allow the user to specify the new journal location. The journal device is identified either through its new major/minor numbers encoded in devnum, or via a path to the device.", diff --git a/common-documentation/mnt-ext4.go b/common-documentation/mnt-ext4.go index 6990d55..6f9883a 100644 --- a/common-documentation/mnt-ext4.go +++ b/common-documentation/mnt-ext4.go @@ -5,7 +5,7 @@ import docvalues "config-lsp/doc-values" var zero = 0 var maxJournalIOPrio = 7 -var Ext4DocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var Ext4DocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "inode_readahead_blks", "This tuning parameter controls the maximum number of inode table blocks that ext4's inode table readahead algorithm will pre-read into the buffer cache. The value must be a power of 2. The default value is 32 blocks.", diff --git a/common-documentation/mnt-fat.go b/common-documentation/mnt-fat.go index 4c1e587..432d4ea 100644 --- a/common-documentation/mnt-fat.go +++ b/common-documentation/mnt-fat.go @@ -4,7 +4,7 @@ import ( docvalues "config-lsp/doc-values" ) -var FatDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var FatDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "blocksize", "Set blocksize (default 512). This option is obsolete.", diff --git a/common-documentation/mnt-hfs.go b/common-documentation/mnt-hfs.go index c3d77e5..99f5935 100644 --- a/common-documentation/mnt-hfs.go +++ b/common-documentation/mnt-hfs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var HfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var HfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "creator", "Set the creator/type values as shown by the MacOS finder used for creating new files. Default values: '????'.", diff --git a/common-documentation/mnt-hpfs.go b/common-documentation/mnt-hpfs.go index 0e94cac..9fac6c6 100644 --- a/common-documentation/mnt-hpfs.go +++ b/common-documentation/mnt-hpfs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var HpfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var HpfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "uid", "Set the owner and group of all files. (Default: the UID and GID of the current process.)", diff --git a/common-documentation/mnt-iso9660.go b/common-documentation/mnt-iso9660.go index 4aa71cf..233ec98 100644 --- a/common-documentation/mnt-iso9660.go +++ b/common-documentation/mnt-iso9660.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var Iso9660DocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var Iso9660DocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "check", "With check=relaxed, a filename is first converted to lower case before doing the lookup. This is probably only meaningful together with norock and map=normal. (Default: check=strict.)", diff --git a/common-documentation/mnt-jfs.go b/common-documentation/mnt-jfs.go index 25bf429..f041932 100644 --- a/common-documentation/mnt-jfs.go +++ b/common-documentation/mnt-jfs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var JfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var JfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "iocharset", "Character set to use for converting from Unicode to ASCII. The default is to do no conversion. Use iocharset=utf8 for UTF8 translations. This requires CONFIG_NLS_UTF8 to be set in the kernel .config file.", diff --git a/common-documentation/mnt-ncpfs.go b/common-documentation/mnt-ncpfs.go index 193d06c..4a1d66d 100644 --- a/common-documentation/mnt-ncpfs.go +++ b/common-documentation/mnt-ncpfs.go @@ -2,6 +2,6 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var NcpfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{} +var NcpfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{} var NcpfsDocumentationEnums = []docvalues.EnumString{} diff --git a/common-documentation/mnt-ntfs.go b/common-documentation/mnt-ntfs.go index b1ae89b..ad2ee6a 100644 --- a/common-documentation/mnt-ntfs.go +++ b/common-documentation/mnt-ntfs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var NtfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var NtfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "iocharset", "Character set to use when returning file names. Unlike VFAT, NTFS suppresses names that contain nonconvertible characters. Deprecated.", diff --git a/common-documentation/mnt-overlay.go b/common-documentation/mnt-overlay.go index c20b04b..1e50203 100644 --- a/common-documentation/mnt-overlay.go +++ b/common-documentation/mnt-overlay.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var OverlayDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var OverlayDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "lowerdir", "Any filesystem, does not need to be on a writable filesystem.", diff --git a/common-documentation/mnt-reiserfs.go b/common-documentation/mnt-reiserfs.go index 9f20210..d7ad9c6 100644 --- a/common-documentation/mnt-reiserfs.go +++ b/common-documentation/mnt-reiserfs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var ReiserfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var ReiserfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "hash", "Choose which hash function reiserfs will use to find files within directories.", diff --git a/common-documentation/mnt-ubifs.go b/common-documentation/mnt-ubifs.go index f755663..cfc6672 100644 --- a/common-documentation/mnt-ubifs.go +++ b/common-documentation/mnt-ubifs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var UbifsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var UbifsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "compr", "Select the default compressor which is used when new files are written. It is still possible to read compressed files if mounted with the none option.", diff --git a/common-documentation/mnt-udf.go b/common-documentation/mnt-udf.go index 973f189..fd79db2 100644 --- a/common-documentation/mnt-udf.go +++ b/common-documentation/mnt-udf.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var UdfDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var UdfDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "uid", "Make all files in the filesystem belong to the given user. uid=forget can be specified independently of (or usually in addition to) uid= and results in UDF not storing uids to the media. In fact the recorded uid is the 32-bit overflow uid -1 as defined by the UDF standard. The value is given as either which is a valid user name or the corresponding decimal user id, or the special string 'forget'.", diff --git a/common-documentation/mnt-ufs.go b/common-documentation/mnt-ufs.go index 44545bb..b24b0ad 100644 --- a/common-documentation/mnt-ufs.go +++ b/common-documentation/mnt-ufs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var UfsDocumentationAssignable = map[docvalues.EnumString]docvalues.Value{ +var UfsDocumentationAssignable = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "ufstype", "UFS is a filesystem widely used in different operating systems. The problem are differences among implementations. Features of some implementations are undocumented, so its hard to recognize the type of ufs automatically. That’s why the user must specify the type of ufs by mount option.", diff --git a/common-documentation/mnt-umsdos.go b/common-documentation/mnt-umsdos.go index 2322d95..c533bd4 100644 --- a/common-documentation/mnt-umsdos.go +++ b/common-documentation/mnt-umsdos.go @@ -5,7 +5,7 @@ import ( "config-lsp/utils" ) -var UmsdosDocumentationAssignable = utils.FilterMap(MsdosDocumentationAssignable, func(key docvalues.EnumString, value docvalues.Value) bool { +var UmsdosDocumentationAssignable = utils.FilterMap(MsdosDocumentationAssignable, func(key docvalues.EnumString, value docvalues.DeprecatedValue) bool { // `dotsOK` is explicitly not supported if key.InsertText == "dotsOK" { return false diff --git a/common-documentation/mnt-usbfs.go b/common-documentation/mnt-usbfs.go index a1ab6b4..ddcb4ec 100644 --- a/common-documentation/mnt-usbfs.go +++ b/common-documentation/mnt-usbfs.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var UsbfsDocumentationAssignable = docvalues.MergeKeyEnumAssignmentMaps(FatDocumentationAssignable, map[docvalues.EnumString]docvalues.Value{ +var UsbfsDocumentationAssignable = docvalues.MergeKeyEnumAssignmentMaps(FatDocumentationAssignable, map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "devuid", "Set the owner of the device files in the usbfs filesystem (default: uid=gid=0)", diff --git a/common-documentation/mnt-vfat.go b/common-documentation/mnt-vfat.go index aed5336..6c4563d 100644 --- a/common-documentation/mnt-vfat.go +++ b/common-documentation/mnt-vfat.go @@ -2,7 +2,7 @@ package commondocumentation import docvalues "config-lsp/doc-values" -var VfatDocumentationAssignable = docvalues.MergeKeyEnumAssignmentMaps(FatDocumentationAssignable, map[docvalues.EnumString]docvalues.Value{ +var VfatDocumentationAssignable = docvalues.MergeKeyEnumAssignmentMaps(FatDocumentationAssignable, map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "shortname", "Defines the behavior for creation and display of filenames which fit into 8.3 characters. If a long name for a file exists, it will always be the preferred one for display", diff --git a/doc-values/base-value.go b/doc-values/base-value.go index 2a2d3d6..01cfa7b 100644 --- a/doc-values/base-value.go +++ b/doc-values/base-value.go @@ -5,11 +5,11 @@ import ( protocol "github.com/tliron/glsp/protocol_3_16" ) -type Value interface { +type DeprecatedValue interface { GetTypeDescription() []string - CheckIsValid(value string) []*InvalidValue - FetchCompletions(line string, cursor uint32) []protocol.CompletionItem - FetchHoverInfo(line string, cursor uint32) []string + DeprecatedCheckIsValid(value string) []*InvalidValue + DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem + DeprecatedFetchHoverInfo(line string, cursor uint32) []string } type InvalidValue struct { diff --git a/doc-values/errors.go b/doc-values/errors.go index c9a6d69..8c2bc37 100644 --- a/doc-values/errors.go +++ b/doc-values/errors.go @@ -68,7 +68,7 @@ func (e ValueError) GetPublishDiagnosticsParams() protocol.Diagnostic { } } func (e ValueError) Error() string { - return "Value error" + return "DeprecatedValue error" } type OptionAlreadyExistsError struct { diff --git a/doc-values/extra-values.go b/doc-values/extra-values.go index dcf82d3..8daed43 100644 --- a/doc-values/extra-values.go +++ b/doc-values/extra-values.go @@ -6,11 +6,11 @@ import ( "regexp" ) -// UserValue returns a Value that fetches user names from /etc/passwd +// UserValue returns a DeprecatedValue that fetches user names from /etc/passwd // if `separatorForMultiple` is not empty, it will return an ArrayValue -func UserValue(separatorForMultiple string, enforceValues bool) Value { +func UserValue(separatorForMultiple string, enforceValues bool) DeprecatedValue { return CustomValue{ - FetchValue: func(context CustomValueContext) Value { + FetchValue: func(context CustomValueContext) DeprecatedValue { infos, err := common.FetchPasswdInfo() if err != nil { @@ -37,9 +37,9 @@ func UserValue(separatorForMultiple string, enforceValues bool) Value { } } -func GroupValue(separatorForMultiple string, enforceValues bool) Value { +func GroupValue(separatorForMultiple string, enforceValues bool) DeprecatedValue { return CustomValue{ - FetchValue: func(context CustomValueContext) Value { + FetchValue: func(context CustomValueContext) DeprecatedValue { infos, err := common.FetchGroupInfo() if err != nil { @@ -66,14 +66,14 @@ func GroupValue(separatorForMultiple string, enforceValues bool) Value { } } -func PositiveNumberValue() Value { +func PositiveNumberValue() DeprecatedValue { zero := 0 return NumberValue{ Min: &zero, } } -func MaskValue() Value { +func MaskValue() DeprecatedValue { min := 0 max := 777 return NumberValue{Min: &min, Max: &max} @@ -88,7 +88,7 @@ func SingleEnumValue(value string) EnumValue { } } -func DomainValue() Value { +func DomainValue() DeprecatedValue { return RegexValue{ Regex: *regexp.MustCompile(`^.+?\..+$`), } diff --git a/doc-values/utils.go b/doc-values/utils.go index 8d5a403..2e3c719 100644 --- a/doc-values/utils.go +++ b/doc-values/utils.go @@ -20,9 +20,9 @@ func GenerateBase10Completions(prefix string) []protocol.CompletionItem { ) } -func MergeKeyEnumAssignmentMaps(maps ...map[EnumString]Value) map[EnumString]Value { +func MergeKeyEnumAssignmentMaps(maps ...map[EnumString]DeprecatedValue) map[EnumString]DeprecatedValue { existingEnums := make(map[string]interface{}) - result := make(map[EnumString]Value) + result := make(map[EnumString]DeprecatedValue) slices.Reverse(maps) diff --git a/doc-values/value-array.go b/doc-values/value-array.go index e69d98f..c4cbef4 100644 --- a/doc-values/value-array.go +++ b/doc-values/value-array.go @@ -35,7 +35,7 @@ var ExtractKeyDuplicatesExtractor = func(separator string) func(string) string { var DuplicatesAllowedExtractor func(string) string = nil type ArrayValue struct { - SubValue Value + SubValue DeprecatedValue Separator string // If this function is nil, no duplicate check is done. // (value) => Extracted value @@ -45,7 +45,7 @@ type ArrayValue struct { } func (v ArrayValue) GetTypeDescription() []string { - subValue := v.SubValue.(Value) + subValue := v.SubValue.(DeprecatedValue) return append( []string{fmt.Sprintf("An Array separated by '%s' of:", v.Separator)}, @@ -53,7 +53,7 @@ func (v ArrayValue) GetTypeDescription() []string { ) } -func (v ArrayValue) CheckIsValid(value string) []*InvalidValue { +func (v ArrayValue) DeprecatedCheckIsValid(value string) []*InvalidValue { errors := []*InvalidValue{} values := strings.Split(value, v.Separator) @@ -100,7 +100,7 @@ func (v ArrayValue) CheckIsValid(value string) []*InvalidValue { currentIndex := uint32(0) for _, subValue := range values { - newErrors := v.SubValue.CheckIsValid(subValue) + newErrors := v.SubValue.DeprecatedCheckIsValid(subValue) if len(newErrors) > 0 { ShiftInvalidValues(currentIndex, newErrors) @@ -173,15 +173,15 @@ func (v ArrayValue) getCurrentValue(line string, cursor uint32) (string, uint32) return line[start : end+1], cursor - start } -func (v ArrayValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v ArrayValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { value, cursor := v.getCurrentValue(line, cursor) println("after array", value, cursor) - return v.SubValue.FetchCompletions(value, cursor) + return v.SubValue.DeprecatedFetchCompletions(value, cursor) } -func (v ArrayValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v ArrayValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { value, cursor := v.getCurrentValue(line, cursor) - return v.SubValue.FetchHoverInfo(value, cursor) + return v.SubValue.DeprecatedFetchHoverInfo(value, cursor) } diff --git a/doc-values/value-custom.go b/doc-values/value-custom.go index 22f0e8d..0bb5802 100644 --- a/doc-values/value-custom.go +++ b/doc-values/value-custom.go @@ -17,21 +17,21 @@ func (EmptyValueContext) GetIsContext() bool { var EmptyValueContextInstance = EmptyValueContext{} type CustomValue struct { - FetchValue func(context CustomValueContext) Value + FetchValue func(context CustomValueContext) DeprecatedValue } func (v CustomValue) GetTypeDescription() []string { return v.FetchValue(EmptyValueContextInstance).GetTypeDescription() } -func (v CustomValue) CheckIsValid(value string) []*InvalidValue { - return v.FetchValue(EmptyValueContextInstance).CheckIsValid(value) +func (v CustomValue) DeprecatedCheckIsValid(value string) []*InvalidValue { + return v.FetchValue(EmptyValueContextInstance).DeprecatedCheckIsValid(value) } -func (v CustomValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { - return v.FetchValue(EmptyValueContextInstance).FetchCompletions(line, cursor) +func (v CustomValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { + return v.FetchValue(EmptyValueContextInstance).DeprecatedFetchCompletions(line, cursor) } -func (v CustomValue) FetchHoverInfo(line string, cursor uint32) []string { - return v.FetchValue(EmptyValueContextInstance).FetchHoverInfo(line, cursor) +func (v CustomValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { + return v.FetchValue(EmptyValueContextInstance).DeprecatedFetchHoverInfo(line, cursor) } diff --git a/doc-values/value-data-amount-value.go b/doc-values/value-data-amount-value.go index 0616b54..145315b 100644 --- a/doc-values/value-data-amount-value.go +++ b/doc-values/value-data-amount-value.go @@ -22,7 +22,7 @@ func (v DataAmountValue) GetTypeDescription() []string { return []string{"Data amount"} } -func (v DataAmountValue) CheckIsValid(value string) []*InvalidValue { +func (v DataAmountValue) DeprecatedCheckIsValid(value string) []*InvalidValue { if !dataAmountCheckPattern.MatchString(value) { return []*InvalidValue{ { @@ -55,7 +55,7 @@ func calculateLineToKilobyte(value string, unit string) string { } } -func (v DataAmountValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v DataAmountValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { completions := make([]protocol.CompletionItem, 0) if line != "" && !dataAmountCheckPattern.MatchString(line) { @@ -91,6 +91,6 @@ func (v DataAmountValue) FetchCompletions(line string, cursor uint32) []protocol return completions } -func (v DataAmountValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v DataAmountValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { return []string{} } diff --git a/doc-values/value-documentation.go b/doc-values/value-documentation.go index 7666356..6b085c4 100644 --- a/doc-values/value-documentation.go +++ b/doc-values/value-documentation.go @@ -8,21 +8,21 @@ import ( type DocumentationValue struct { Documentation string - Value Value + Value DeprecatedValue } func (v DocumentationValue) GetTypeDescription() []string { return v.Value.GetTypeDescription() } -func (v DocumentationValue) CheckIsValid(value string) []*InvalidValue { - return v.Value.CheckIsValid(value) +func (v DocumentationValue) DeprecatedCheckIsValid(value string) []*InvalidValue { + return v.Value.DeprecatedCheckIsValid(value) } -func (v DocumentationValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { - return v.Value.FetchCompletions(line, cursor) +func (v DocumentationValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { + return v.Value.DeprecatedFetchCompletions(line, cursor) } -func (v DocumentationValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v DocumentationValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { return strings.Split(v.Documentation, "\n") } diff --git a/doc-values/value-enum.go b/doc-values/value-enum.go index 9457008..875f5f5 100644 --- a/doc-values/value-enum.go +++ b/doc-values/value-enum.go @@ -78,7 +78,7 @@ func (v EnumValue) GetTypeDescription() []string { return lines } -func (v EnumValue) CheckIsValid(value string) []*InvalidValue { +func (v EnumValue) DeprecatedCheckIsValid(value string) []*InvalidValue { if !v.EnforceValues { return nil } @@ -101,7 +101,7 @@ func (v EnumValue) CheckIsValid(value string) []*InvalidValue { }, } } -func (v EnumValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v EnumValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { completions := make([]protocol.CompletionItem, len(v.Values)) for index, value := range v.Values { @@ -118,7 +118,7 @@ func (v EnumValue) FetchCompletions(line string, cursor uint32) []protocol.Compl return completions } -func (v EnumValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v EnumValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { for _, value := range v.Values { if value.InsertText == line { return []string{ diff --git a/doc-values/value-gid.go b/doc-values/value-gid.go index 103592c..cb3d5ed 100644 --- a/doc-values/value-gid.go +++ b/doc-values/value-gid.go @@ -35,7 +35,7 @@ func (v GIDValue) GetTypeDescription() []string { return []string{"Group ID"} } -func (v GIDValue) CheckIsValid(value string) []*InvalidValue { +func (v GIDValue) DeprecatedCheckIsValid(value string) []*InvalidValue { uid, err := strconv.Atoi(value) if err != nil { @@ -90,7 +90,7 @@ var defaultGIDsExplanation = []EnumString{ }, } -func (v GIDValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v GIDValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { infos, err := common.FetchGroupInfo() if err != nil { @@ -128,7 +128,7 @@ func (v GIDValue) FetchCompletions(line string, cursor uint32) []protocol.Comple return completions } -func (v GIDValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v GIDValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { uid, err := strconv.Atoi(line) if err != nil { diff --git a/doc-values/value-ip-address.go b/doc-values/value-ip-address.go index 8c2bca4..0f0daf4 100644 --- a/doc-values/value-ip-address.go +++ b/doc-values/value-ip-address.go @@ -66,7 +66,7 @@ func (v IPAddressValue) GetTypeDescription() []string { return []string{"An IP Address"} } -func (v IPAddressValue) CheckIsValid(value string) []*InvalidValue { +func (v IPAddressValue) DeprecatedCheckIsValid(value string) []*InvalidValue { var ip net.Prefix if v.AllowRange { @@ -151,7 +151,7 @@ func (v IPAddressValue) CheckIsValid(value string) []*InvalidValue { } } -func (v IPAddressValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v IPAddressValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { if v.AllowedIPs != nil && len(*v.AllowedIPs) != 0 { kind := protocol.CompletionItemKindValue @@ -184,7 +184,7 @@ func (v IPAddressValue) FetchCompletions(line string, cursor uint32) []protocol. return []protocol.CompletionItem{} } -func (v IPAddressValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v IPAddressValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { if v.AllowRange { ip, err := net.ParsePrefix(line) diff --git a/doc-values/value-key-enum-assignment.go b/doc-values/value-key-enum-assignment.go index 4953caa..b39127a 100644 --- a/doc-values/value-key-enum-assignment.go +++ b/doc-values/value-key-enum-assignment.go @@ -9,7 +9,7 @@ import ( ) type KeyEnumAssignmentValue struct { - Values map[EnumString]Value + Values map[EnumString]DeprecatedValue Separator string ValueIsOptional bool } @@ -21,7 +21,7 @@ func (v KeyEnumAssignmentValue) GetTypeDescription() []string { if len(valueDescription) == 1 { return []string{ - fmt.Sprintf("Key-Value pair in form of '<%s>%s<%s>'", firstKey.DescriptionText, v.Separator, valueDescription[0]), + fmt.Sprintf("Key-DeprecatedValue pair in form of '<%s>%s<%s>'", firstKey.DescriptionText, v.Separator, valueDescription[0]), } } } @@ -33,11 +33,11 @@ func (v KeyEnumAssignmentValue) GetTypeDescription() []string { } return append([]string{ - "Key-Value pair in form of 'key%svalue'", v.Separator, + "Key-DeprecatedValue pair in form of 'key%svalue'", v.Separator, }, result...) } -func (v KeyEnumAssignmentValue) getValue(findKey string) (*Value, bool) { +func (v KeyEnumAssignmentValue) getValue(findKey string) (*DeprecatedValue, bool) { for key, value := range v.Values { if key.InsertText == findKey { switch value.(type) { @@ -59,7 +59,7 @@ func (v KeyEnumAssignmentValue) getValue(findKey string) (*Value, bool) { return nil, false } -func (v KeyEnumAssignmentValue) CheckIsValid(value string) []*InvalidValue { +func (v KeyEnumAssignmentValue) DeprecatedCheckIsValid(value string) []*InvalidValue { parts := strings.Split(value, v.Separator) if len(parts) == 0 || parts[0] == "" { @@ -96,7 +96,7 @@ func (v KeyEnumAssignmentValue) CheckIsValid(value string) []*InvalidValue { } } - errors := (*checkValue).CheckIsValid(parts[1]) + errors := (*checkValue).DeprecatedCheckIsValid(parts[1]) if len(errors) > 0 { ShiftInvalidValues(uint32(len(parts[0])+len(v.Separator)), errors) @@ -147,7 +147,7 @@ func (v KeyEnumAssignmentValue) getValueAtCursor(line string, cursor uint32) (st relativePosition, found := utils.FindPreviousCharacter(line, v.Separator, int(cursor)) if found { - // Value found + // DeprecatedValue found selected := valueSelected return line[uint32(relativePosition+1):], &selected, cursor - uint32(relativePosition) } @@ -165,7 +165,7 @@ func (v KeyEnumAssignmentValue) getValueAtCursor(line string, cursor uint32) (st return line, &selected, cursor } -func (v KeyEnumAssignmentValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v KeyEnumAssignmentValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { if cursor == 0 { return v.FetchEnumCompletions() } @@ -188,14 +188,14 @@ func (v KeyEnumAssignmentValue) FetchCompletions(line string, cursor uint32) []p return v.FetchEnumCompletions() } - return (*keyValue).FetchCompletions(line, cursor) + return (*keyValue).DeprecatedFetchCompletions(line, cursor) } else { return v.FetchEnumCompletions() } } -func (v KeyEnumAssignmentValue) FetchHoverInfo(line string, cursor uint32) []string { - if len(v.CheckIsValid(line)) != 0 { +func (v KeyEnumAssignmentValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { + if len(v.DeprecatedCheckIsValid(line)) != 0 { return []string{} } @@ -228,7 +228,7 @@ func (v KeyEnumAssignmentValue) FetchHoverInfo(line string, cursor uint32) []str return []string{} } - info := (*checkValue).FetchHoverInfo(value, cursor) + info := (*checkValue).DeprecatedFetchHoverInfo(value, cursor) return append( []string{ diff --git a/doc-values/value-key-value-assignment.go b/doc-values/value-key-value-assignment.go index 77e60b7..5a2efe7 100644 --- a/doc-values/value-key-value-assignment.go +++ b/doc-values/value-key-value-assignment.go @@ -23,9 +23,9 @@ func (KeyValueAssignmentContext) GetIsContext() bool { } type KeyValueAssignmentValue struct { - Key Value + Key DeprecatedValue // If this is a `CustomValue`, it will receive a `KeyValueAssignmentContext` - Value Value + Value DeprecatedValue ValueIsOptional bool Separator string } @@ -36,18 +36,18 @@ func (v KeyValueAssignmentValue) GetTypeDescription() []string { if len(keyDescription) == 1 && len(valueDescription) == 1 { return []string{ - fmt.Sprintf("Key-Value pair in form of '<%s>%s<%s>'", keyDescription[0], v.Separator, valueDescription[0]), + fmt.Sprintf("Key-DeprecatedValue pair in form of '<%s>%s<%s>'", keyDescription[0], v.Separator, valueDescription[0]), } } else { return []string{ - fmt.Sprintf("Key-Value pair in form of 'key%svalue'", v.Separator), + fmt.Sprintf("Key-DeprecatedValue pair in form of 'key%svalue'", v.Separator), fmt.Sprintf("#### Key\n%s", strings.Join(v.Key.GetTypeDescription(), "\n")), - fmt.Sprintf("#### Value:\n%s", strings.Join(v.Value.GetTypeDescription(), "\n")), + fmt.Sprintf("#### DeprecatedValue:\n%s", strings.Join(v.Value.GetTypeDescription(), "\n")), } } } -func (v KeyValueAssignmentValue) getValue(selectedKey string) Value { +func (v KeyValueAssignmentValue) getValue(selectedKey string) DeprecatedValue { switch v.Value.(type) { case CustomValue: { @@ -65,7 +65,7 @@ func (v KeyValueAssignmentValue) getValue(selectedKey string) Value { } } -func (v KeyValueAssignmentValue) CheckIsValid(value string) []*InvalidValue { +func (v KeyValueAssignmentValue) DeprecatedCheckIsValid(value string) []*InvalidValue { parts := strings.Split(value, v.Separator) if len(parts) == 0 || parts[0] == "" { @@ -73,7 +73,7 @@ func (v KeyValueAssignmentValue) CheckIsValid(value string) []*InvalidValue { return nil } - err := v.Key.CheckIsValid(parts[0]) + err := v.Key.DeprecatedCheckIsValid(parts[0]) if err != nil { return err @@ -93,7 +93,7 @@ func (v KeyValueAssignmentValue) CheckIsValid(value string) []*InvalidValue { } } - errors := v.getValue(parts[0]).CheckIsValid(parts[1]) + errors := v.getValue(parts[0]).DeprecatedCheckIsValid(parts[1]) if len(errors) > 0 { ShiftInvalidValues(uint32(len(parts[0])+len(v.Separator)), errors) @@ -103,9 +103,9 @@ func (v KeyValueAssignmentValue) CheckIsValid(value string) []*InvalidValue { return nil } -func (v KeyValueAssignmentValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v KeyValueAssignmentValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { if cursor == 0 || line == "" { - return v.Key.FetchCompletions(line, cursor) + return v.Key.DeprecatedFetchCompletions(line, cursor) } relativePosition, found := utils.FindPreviousCharacter( @@ -119,9 +119,9 @@ func (v KeyValueAssignmentValue) FetchCompletions(line string, cursor uint32) [] line = line[uint32(relativePosition+len(v.Separator)):] cursor -= uint32(relativePosition) - return v.getValue(selectedKey).FetchCompletions(line, cursor) + return v.getValue(selectedKey).DeprecatedFetchCompletions(line, cursor) } else { - return v.Key.FetchCompletions(line, cursor) + return v.Key.DeprecatedFetchCompletions(line, cursor) } } @@ -129,7 +129,7 @@ func (v KeyValueAssignmentValue) getValueAtCursor(line string, cursor uint32) (s relativePosition, found := utils.FindPreviousCharacter(line, v.Separator, int(cursor)) if found { - // Value found + // DeprecatedValue found selected := valueSelected return line[:uint32(relativePosition)], &selected, cursor - uint32(relativePosition) } @@ -147,8 +147,8 @@ func (v KeyValueAssignmentValue) getValueAtCursor(line string, cursor uint32) (s return line, &selected, cursor } -func (v KeyValueAssignmentValue) FetchHoverInfo(line string, cursor uint32) []string { - if len(v.CheckIsValid(line)) != 0 { +func (v KeyValueAssignmentValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { + if len(v.DeprecatedCheckIsValid(line)) != 0 { return []string{} } @@ -160,12 +160,12 @@ func (v KeyValueAssignmentValue) FetchHoverInfo(line string, cursor uint32) []st if *selected == keySelected { // Get key documentation - return v.Key.FetchHoverInfo(value, cursor) + return v.Key.DeprecatedFetchHoverInfo(value, cursor) } else if *selected == valueSelected { // Get for value documentation key := strings.SplitN(line, v.Separator, 2)[0] - return v.getValue(key).FetchHoverInfo(value, cursor) + return v.getValue(key).DeprecatedFetchHoverInfo(value, cursor) } return []string{} diff --git a/doc-values/value-mask-mode.go b/doc-values/value-mask-mode.go index 85de36a..308804d 100644 --- a/doc-values/value-mask-mode.go +++ b/doc-values/value-mask-mode.go @@ -29,7 +29,7 @@ func (v MaskModeValue) GetTypeDescription() []string { var maskModePattern = regexp.MustCompile("^[0-7]{4}$") -func (v MaskModeValue) CheckIsValid(value string) []*InvalidValue { +func (v MaskModeValue) DeprecatedCheckIsValid(value string) []*InvalidValue { if !maskModePattern.MatchString(value) { return []*InvalidValue{{ Err: MaskModeInvalidError{}, @@ -41,7 +41,7 @@ func (v MaskModeValue) CheckIsValid(value string) []*InvalidValue { return []*InvalidValue{} } -func (v MaskModeValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v MaskModeValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { kind := protocol.CompletionItemKindValue perm0644 := "0644" @@ -147,7 +147,7 @@ func getMaskRepresentation(digit uint8) string { return "" } -func (v MaskModeValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v MaskModeValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { if !maskModePattern.MatchString(line) { return []string{} } diff --git a/doc-values/value-number.go b/doc-values/value-number.go index 9133db5..1d03b88 100644 --- a/doc-values/value-number.go +++ b/doc-values/value-number.go @@ -48,7 +48,7 @@ func (v NumberValue) GetTypeDescription() []string { return []string{"A number"} } -func (v NumberValue) CheckIsValid(value string) []*InvalidValue { +func (v NumberValue) DeprecatedCheckIsValid(value string) []*InvalidValue { number, err := strconv.Atoi(value) if err != nil { @@ -73,10 +73,10 @@ func (v NumberValue) CheckIsValid(value string) []*InvalidValue { return nil } -func (v NumberValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v NumberValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { return []protocol.CompletionItem{} } -func (v NumberValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v NumberValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { return []string{} } diff --git a/doc-values/value-or.go b/doc-values/value-or.go index 37bc8d3..9ca9b36 100644 --- a/doc-values/value-or.go +++ b/doc-values/value-or.go @@ -8,14 +8,14 @@ import ( ) type OrValue struct { - Values []Value + Values []DeprecatedValue } func (v OrValue) GetTypeDescription() []string { lines := make([]string, 0) for _, subValueRaw := range v.Values { - subValue := subValueRaw.(Value) + subValue := subValueRaw.(DeprecatedValue) subLines := subValue.GetTypeDescription() for index, line := range subLines { @@ -34,11 +34,11 @@ func (v OrValue) GetTypeDescription() []string { lines..., ) } -func (v OrValue) CheckIsValid(value string) []*InvalidValue { +func (v OrValue) DeprecatedCheckIsValid(value string) []*InvalidValue { errors := make([]*InvalidValue, 0) for _, subValue := range v.Values { - valueErrors := subValue.CheckIsValid(value) + valueErrors := subValue.DeprecatedCheckIsValid(value) if len(valueErrors) == 0 { return nil @@ -49,7 +49,7 @@ func (v OrValue) CheckIsValid(value string) []*InvalidValue { return errors } -func (v OrValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v OrValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { // Check for special cases if len(v.Values) == 2 { switch v.Values[0].(type) { @@ -67,7 +67,7 @@ func (v OrValue) FetchCompletions(line string, cursor uint32) []protocol.Complet ) if found { - return keyEnumValue.FetchCompletions(line, cursor) + return keyEnumValue.DeprecatedFetchCompletions(line, cursor) } } } @@ -76,19 +76,19 @@ func (v OrValue) FetchCompletions(line string, cursor uint32) []protocol.Complet completions := make([]protocol.CompletionItem, 0) for _, subValue := range v.Values { - completions = append(completions, subValue.FetchCompletions(line, cursor)...) + completions = append(completions, subValue.DeprecatedFetchCompletions(line, cursor)...) } return completions } -func (v OrValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v OrValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { for _, subValue := range v.Values { - valueErrors := subValue.CheckIsValid(line) + valueErrors := subValue.DeprecatedCheckIsValid(line) if len(valueErrors) == 0 { // Found - return subValue.FetchHoverInfo(line, cursor) + return subValue.DeprecatedFetchHoverInfo(line, cursor) } } diff --git a/doc-values/value-path.go b/doc-values/value-path.go index 32a689d..fa7d5df 100644 --- a/doc-values/value-path.go +++ b/doc-values/value-path.go @@ -46,7 +46,7 @@ func (v PathValue) GetTypeDescription() []string { return []string{strings.Join(hints, ", ")} } -func (v PathValue) CheckIsValid(value string) []*InvalidValue { +func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue { if !utils.DoesPathExist(value) { return []*InvalidValue{{ Err: PathDoesNotExistError{}, @@ -78,10 +78,10 @@ func (v PathValue) CheckIsValid(value string) []*InvalidValue { } } -func (v PathValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v PathValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { return []protocol.CompletionItem{} } -func (v PathValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v PathValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { return []string{} } diff --git a/doc-values/value-power-of-two.go b/doc-values/value-power-of-two.go index 110e5a5..60eb48a 100644 --- a/doc-values/value-power-of-two.go +++ b/doc-values/value-power-of-two.go @@ -34,7 +34,7 @@ func isPowerOfTwo(number int) bool { return true } -func (v PowerOfTwoValue) CheckIsValid(value string) []*InvalidValue { +func (v PowerOfTwoValue) DeprecatedCheckIsValid(value string) []*InvalidValue { number, err := strconv.Atoi(value) if err != nil { @@ -60,7 +60,7 @@ func (v PowerOfTwoValue) CheckIsValid(value string) []*InvalidValue { var powers = []int{1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536} -func (v PowerOfTwoValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v PowerOfTwoValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { textFormat := protocol.InsertTextFormatPlainText kind := protocol.CompletionItemKindValue @@ -76,6 +76,6 @@ func (v PowerOfTwoValue) FetchCompletions(line string, cursor uint32) []protocol ) } -func (v PowerOfTwoValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v PowerOfTwoValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { return []string{} } diff --git a/doc-values/value-prefix.go b/doc-values/value-prefix.go index d0c1e88..35ef7cd 100644 --- a/doc-values/value-prefix.go +++ b/doc-values/value-prefix.go @@ -14,7 +14,7 @@ type Prefix struct { } type PrefixWithMeaningValue struct { Prefixes []Prefix - SubValue Value + SubValue DeprecatedValue } func (v PrefixWithMeaningValue) GetTypeDescription() []string { @@ -32,17 +32,17 @@ func (v PrefixWithMeaningValue) GetTypeDescription() []string { ) } -func (v PrefixWithMeaningValue) CheckIsValid(value string) []*InvalidValue { +func (v PrefixWithMeaningValue) DeprecatedCheckIsValid(value string) []*InvalidValue { for _, prefix := range v.Prefixes { if strings.HasPrefix(value, prefix.Prefix) { - return v.SubValue.CheckIsValid(value[len(prefix.Prefix):]) + return v.SubValue.DeprecatedCheckIsValid(value[len(prefix.Prefix):]) } } - return v.SubValue.CheckIsValid(value) + return v.SubValue.DeprecatedCheckIsValid(value) } -func (v PrefixWithMeaningValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v PrefixWithMeaningValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { textFormat := protocol.InsertTextFormatPlainText kind := protocol.CompletionItemKindText @@ -67,19 +67,19 @@ func (v PrefixWithMeaningValue) FetchCompletions(line string, cursor uint32) []p }) } - return append(prefixCompletions, v.SubValue.FetchCompletions(line, cursor)...) + return append(prefixCompletions, v.SubValue.DeprecatedFetchCompletions(line, cursor)...) } -func (v PrefixWithMeaningValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v PrefixWithMeaningValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { for _, prefix := range v.Prefixes { if strings.HasPrefix(line, prefix.Prefix) { return append([]string{ fmt.Sprintf("Prefix: _%s_ -> %s", prefix.Prefix, prefix.Meaning), }, - v.SubValue.FetchHoverInfo(line[1:], cursor)..., + v.SubValue.DeprecatedFetchHoverInfo(line[1:], cursor)..., ) } } - return v.SubValue.FetchHoverInfo(line[1:], cursor) + return v.SubValue.DeprecatedFetchHoverInfo(line[1:], cursor) } diff --git a/doc-values/value-regex.go b/doc-values/value-regex.go index 1209953..d72ee47 100644 --- a/doc-values/value-regex.go +++ b/doc-values/value-regex.go @@ -25,7 +25,7 @@ func (v RegexValue) GetTypeDescription() []string { } } -func (v RegexValue) CheckIsValid(value string) []*InvalidValue { +func (v RegexValue) DeprecatedCheckIsValid(value string) []*InvalidValue { if !v.Regex.MatchString(value) { return []*InvalidValue{{ Err: RegexInvalidError{Regex: v.Regex.String()}, @@ -37,11 +37,11 @@ func (v RegexValue) CheckIsValid(value string) []*InvalidValue { return []*InvalidValue{} } -func (v RegexValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v RegexValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { return []protocol.CompletionItem{} } -func (v RegexValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v RegexValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { return []string{ fmt.Sprintf("Pattern: `%s`", v.Regex.String()), } diff --git a/doc-values/value-string.go b/doc-values/value-string.go index ccfbca8..71d359a 100644 --- a/doc-values/value-string.go +++ b/doc-values/value-string.go @@ -24,7 +24,7 @@ func (v StringValue) GetTypeDescription() []string { return []string{"String"} } -func (v StringValue) CheckIsValid(value string) []*InvalidValue { +func (v StringValue) DeprecatedCheckIsValid(value string) []*InvalidValue { if value == "" { return []*InvalidValue{{ Err: EmptyStringError{}, @@ -45,10 +45,10 @@ func (v StringValue) CheckIsValid(value string) []*InvalidValue { return nil } -func (v StringValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v StringValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { return []protocol.CompletionItem{} } -func (v StringValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v StringValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { return []string{} } diff --git a/doc-values/value-suffix.go b/doc-values/value-suffix.go index 4b5feb7..573cdf0 100644 --- a/doc-values/value-suffix.go +++ b/doc-values/value-suffix.go @@ -15,7 +15,7 @@ type Suffix struct { type SuffixWithMeaningValue struct { Suffixes []Suffix - SubValue Value + SubValue DeprecatedValue } func (v SuffixWithMeaningValue) GetTypeDescription() []string { @@ -33,17 +33,17 @@ func (v SuffixWithMeaningValue) GetTypeDescription() []string { ) } -func (v SuffixWithMeaningValue) CheckIsValid(value string) []*InvalidValue { +func (v SuffixWithMeaningValue) DeprecatedCheckIsValid(value string) []*InvalidValue { for _, suffix := range v.Suffixes { if strings.HasSuffix(value, suffix.Suffix) { - return v.SubValue.CheckIsValid(value[:len(value)-len(suffix.Suffix)]) + return v.SubValue.DeprecatedCheckIsValid(value[:len(value)-len(suffix.Suffix)]) } } - return v.SubValue.CheckIsValid(value) + return v.SubValue.DeprecatedCheckIsValid(value) } -func (v SuffixWithMeaningValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v SuffixWithMeaningValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { textFormat := protocol.InsertTextFormatPlainText kind := protocol.CompletionItemKindText @@ -56,19 +56,19 @@ func (v SuffixWithMeaningValue) FetchCompletions(line string, cursor uint32) []p } }) - return append(suffixCompletions, v.SubValue.FetchCompletions(line, cursor)...) + return append(suffixCompletions, v.SubValue.DeprecatedFetchCompletions(line, cursor)...) } -func (v SuffixWithMeaningValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v SuffixWithMeaningValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { for _, suffix := range v.Suffixes { if strings.HasSuffix(line, suffix.Suffix) { return append([]string{ fmt.Sprintf("Suffix: _%s_ -> %s", suffix.Suffix, suffix.Meaning), }, - v.SubValue.FetchHoverInfo(line[:len(line)-len(suffix.Suffix)], cursor)..., + v.SubValue.DeprecatedFetchHoverInfo(line[:len(line)-len(suffix.Suffix)], cursor)..., ) } } - return v.SubValue.FetchHoverInfo(line, cursor) + return v.SubValue.DeprecatedFetchHoverInfo(line, cursor) } diff --git a/doc-values/value-time-format.go b/doc-values/value-time-format.go index b1a3261..4670aa9 100644 --- a/doc-values/value-time-format.go +++ b/doc-values/value-time-format.go @@ -25,7 +25,7 @@ func (v TimeFormatValue) GetTypeDescription() []string { return []string{"Time value"} } -func (v TimeFormatValue) CheckIsValid(value string) []*InvalidValue { +func (v TimeFormatValue) DeprecatedCheckIsValid(value string) []*InvalidValue { if !timeFormatCheckPattern.MatchString(value) { return []*InvalidValue{ { @@ -56,7 +56,7 @@ func calculateInSeconds(value int, unit string) int { } } -func (v TimeFormatValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v TimeFormatValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { completions := make([]protocol.CompletionItem, 0) if line != "" && !timeFormatCompletionsPattern.MatchString(line) { @@ -106,6 +106,6 @@ func (v TimeFormatValue) FetchCompletions(line string, cursor uint32) []protocol return completions } -func (v TimeFormatValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v TimeFormatValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { return []string{} } diff --git a/doc-values/value-uid.go b/doc-values/value-uid.go index bcbf7a4..c6c1fe9 100644 --- a/doc-values/value-uid.go +++ b/doc-values/value-uid.go @@ -35,7 +35,7 @@ func (v UIDValue) GetTypeDescription() []string { return []string{"User ID"} } -func (v UIDValue) CheckIsValid(value string) []*InvalidValue { +func (v UIDValue) DeprecatedCheckIsValid(value string) []*InvalidValue { uid, err := strconv.Atoi(value) if err != nil { @@ -90,7 +90,7 @@ var defaultUIDsExplanation = []EnumString{ }, } -func (v UIDValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v UIDValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { infos, err := common.FetchPasswdInfo() if err != nil { @@ -129,7 +129,7 @@ func (v UIDValue) FetchCompletions(line string, cursor uint32) []protocol.Comple return completions } -func (v UIDValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v UIDValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { uid, err := strconv.Atoi(line) if err != nil { diff --git a/doc-values/value-umask.go b/doc-values/value-umask.go index fc44e2c..f9c3d72 100644 --- a/doc-values/value-umask.go +++ b/doc-values/value-umask.go @@ -28,7 +28,7 @@ func (v UmaskValue) GetTypeDescription() []string { var umaskPattern = regexp.MustCompile("^[0-7]{4}$") -func (v UmaskValue) CheckIsValid(value string) []*InvalidValue { +func (v UmaskValue) DeprecatedCheckIsValid(value string) []*InvalidValue { if !umaskPattern.MatchString(value) { return []*InvalidValue{{ Err: UmaskInvalidError{}, @@ -40,7 +40,7 @@ func (v UmaskValue) CheckIsValid(value string) []*InvalidValue { return []*InvalidValue{} } -func (v UmaskValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { +func (v UmaskValue) DeprecatedFetchCompletions(line string, cursor uint32) []protocol.CompletionItem { kind := protocol.CompletionItemKindValue return []protocol.CompletionItem{ @@ -111,6 +111,6 @@ func (v UmaskValue) FetchCompletions(line string, cursor uint32) []protocol.Comp } } -func (v UmaskValue) FetchHoverInfo(line string, cursor uint32) []string { +func (v UmaskValue) DeprecatedFetchHoverInfo(line string, cursor uint32) []string { return []string{} } diff --git a/handlers/aliases/ast/values.go b/handlers/aliases/ast/values.go index accc7ab..a01c76c 100644 --- a/handlers/aliases/ast/values.go +++ b/handlers/aliases/ast/values.go @@ -71,7 +71,7 @@ type AliasValueInclude struct { func (a AliasValueInclude) CheckIsValid() []common.LSPError { return utils.Map( - fields.PathField.CheckIsValid(string(a.Path.Path)), + fields.PathField.DeprecatedCheckIsValid(string(a.Path.Path)), func(invalidValue *docvalues.InvalidValue) common.LSPError { return docvalues.LSPErrorFromInvalidValue(a.Location.Start.Line, *invalidValue) }, @@ -88,7 +88,7 @@ type AliasValueEmail struct { func (a AliasValueEmail) CheckIsValid() []common.LSPError { return utils.Map( - fields.PathField.CheckIsValid(a.Value), + fields.PathField.DeprecatedCheckIsValid(a.Value), func(invalidValue *docvalues.InvalidValue) common.LSPError { return docvalues.LSPErrorFromInvalidValue(a.Location.Start.Line, *invalidValue) }, diff --git a/handlers/fstab/documentation/documentation-mount-point.go b/handlers/fstab/documentation/documentation-mount-point.go index 958d80d..9de4c6d 100644 --- a/handlers/fstab/documentation/documentation-mount-point.go +++ b/handlers/fstab/documentation/documentation-mount-point.go @@ -6,7 +6,7 @@ import ( ) var MountPointField = docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ Values: []docvalues.EnumString{ { diff --git a/handlers/fstab/documentation/documentation-mountoptions.go b/handlers/fstab/documentation/documentation-mountoptions.go index 019dd22..8c26b5f 100644 --- a/handlers/fstab/documentation/documentation-mountoptions.go +++ b/handlers/fstab/documentation/documentation-mountoptions.go @@ -195,10 +195,10 @@ var defaultOptions = []docvalues.EnumString{ type assignOption struct { Documentation string - Handler func(context docvalues.KeyValueAssignmentContext) docvalues.Value + Handler func(context docvalues.KeyValueAssignmentContext) docvalues.DeprecatedValue } -var defaultAssignOptions = map[docvalues.EnumString]docvalues.Value{ +var defaultAssignOptions = map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumStringWithDoc( "context", "The context= option is useful when mounting filesystems that do not support extended attributes, such as a floppy or hard disk formatted with VFAT, or systems that are not normally running under SELinux, such as an ext3 or ext4 formatted disk from a non-SELinux workstation. You can also use context= on filesystems you do not trust, such as a floppy. It also helps in compatibility with xattr-supporting filesystems on earlier 2.4. kernel versions. Even where xattrs are supported, you can save time not having to label every file by assigning the entire disk one security context. A commonly used option for removable media is context=\"system_u:object_r:removable_t\".", @@ -219,15 +219,15 @@ var defaultAssignOptions = map[docvalues.EnumString]docvalues.Value{ func createMountOptionField( options []docvalues.EnumString, - assignOption map[docvalues.EnumString]docvalues.Value, -) docvalues.Value { + assignOption map[docvalues.EnumString]docvalues.DeprecatedValue, +) docvalues.DeprecatedValue { dynamicOptions := docvalues.MergeKeyEnumAssignmentMaps(defaultAssignOptions, assignOption) return docvalues.ArrayValue{ Separator: ",", DuplicatesExtractor: &mountOptionsExtractor, SubValue: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.KeyEnumAssignmentValue{ Values: dynamicOptions, ValueIsOptional: false, @@ -242,9 +242,9 @@ func createMountOptionField( } } -var DefaultMountOptionsField = createMountOptionField([]docvalues.EnumString{}, map[docvalues.EnumString]docvalues.Value{}) +var DefaultMountOptionsField = createMountOptionField([]docvalues.EnumString{}, map[docvalues.EnumString]docvalues.DeprecatedValue{}) -var MountOptionsMapField = map[string]docvalues.Value{ +var MountOptionsMapField = map[string]docvalues.DeprecatedValue{ "adfs": createMountOptionField( commondocumentation.AdfsDocumentationEnums, commondocumentation.AdfsDocumentationAssignable, diff --git a/handlers/fstab/documentation/documentation-pass.go b/handlers/fstab/documentation/documentation-pass.go index 9be2e39..6163c3b 100644 --- a/handlers/fstab/documentation/documentation-pass.go +++ b/handlers/fstab/documentation/documentation-pass.go @@ -3,7 +3,7 @@ package fstabdocumentation import docvalues "config-lsp/doc-values" var PassField = docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ EnforceValues: false, Values: []docvalues.EnumString{ diff --git a/handlers/fstab/documentation/documentation-spec.go b/handlers/fstab/documentation/documentation-spec.go index 26a0901..f3087f5 100644 --- a/handlers/fstab/documentation/documentation-spec.go +++ b/handlers/fstab/documentation/documentation-spec.go @@ -13,14 +13,14 @@ var LabelField = docvalues.RegexValue{ } var SpecField = docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ // docvalues.PathValue{ // RequiredType: docvalues.PathTypeFile & docvalues.PathTypeExistenceOptional, // }, docvalues.KeyEnumAssignmentValue{ Separator: "=", ValueIsOptional: false, - Values: map[docvalues.EnumString]docvalues.Value{ + Values: map[docvalues.EnumString]docvalues.DeprecatedValue{ docvalues.CreateEnumString("UUID"): UuidField, docvalues.CreateEnumString("PARTUUID"): UuidField, docvalues.CreateEnumString("LABEL"): LabelField, diff --git a/handlers/fstab/handlers/completions.go b/handlers/fstab/handlers/completions.go index 66f07d6..35b79e2 100644 --- a/handlers/fstab/handlers/completions.go +++ b/handlers/fstab/handlers/completions.go @@ -17,28 +17,28 @@ func GetCompletion( case parser.FstabFieldSpec: value, cursor := GetFieldSafely(line.Fields.Spec, cursor) - return fstabdocumentation.SpecField.FetchCompletions( + return fstabdocumentation.SpecField.DeprecatedFetchCompletions( value, cursor, ), nil case parser.FstabFieldMountPoint: value, cursor := GetFieldSafely(line.Fields.MountPoint, cursor) - return fstabdocumentation.MountPointField.FetchCompletions( + return fstabdocumentation.MountPointField.DeprecatedFetchCompletions( value, cursor, ), nil case parser.FstabFieldFileSystemType: value, cursor := GetFieldSafely(line.Fields.FilesystemType, cursor) - return fstabdocumentation.FileSystemTypeField.FetchCompletions( + return fstabdocumentation.FileSystemTypeField.DeprecatedFetchCompletions( value, cursor, ), nil case parser.FstabFieldOptions: fileSystemType := line.Fields.FilesystemType.Value - var optionsField docvalues.Value + var optionsField docvalues.DeprecatedValue if foundField, found := fstabdocumentation.MountOptionsMapField[fileSystemType]; found { optionsField = foundField @@ -48,7 +48,7 @@ func GetCompletion( value, cursor := GetFieldSafely(line.Fields.Options, cursor) - completions := optionsField.FetchCompletions( + completions := optionsField.DeprecatedFetchCompletions( value, cursor, ) @@ -57,14 +57,14 @@ func GetCompletion( case parser.FstabFieldFreq: value, cursor := GetFieldSafely(line.Fields.Freq, cursor) - return fstabdocumentation.FreqField.FetchCompletions( + return fstabdocumentation.FreqField.DeprecatedFetchCompletions( value, cursor, ), nil case parser.FstabFieldPass: value, cursor := GetFieldSafely(line.Fields.Pass, cursor) - return fstabdocumentation.PassField.FetchCompletions( + return fstabdocumentation.PassField.DeprecatedFetchCompletions( value, cursor, ), nil diff --git a/handlers/fstab/handlers/hover.go b/handlers/fstab/handlers/hover.go index d857b6b..33fd213 100644 --- a/handlers/fstab/handlers/hover.go +++ b/handlers/fstab/handlers/hover.go @@ -21,7 +21,7 @@ func GetHoverInfo(entry *parser.FstabEntry, cursor uint32) (*protocol.Hover, err return &FileSystemTypeField, nil case parser.FstabFieldOptions: fileSystemType := line.Fields.FilesystemType.Value - var optionsField docvalues.Value + var optionsField docvalues.DeprecatedValue if foundField, found := fstabdocumentation.MountOptionsMapField[fileSystemType]; found { optionsField = foundField @@ -30,7 +30,7 @@ func GetHoverInfo(entry *parser.FstabEntry, cursor uint32) (*protocol.Hover, err } relativeCursor := cursor - line.Fields.Options.Start - fieldInfo := optionsField.FetchHoverInfo(line.Fields.Options.Value, relativeCursor) + fieldInfo := optionsField.DeprecatedFetchHoverInfo(line.Fields.Options.Value, relativeCursor) hover := protocol.Hover{ Contents: protocol.MarkupContent{ diff --git a/handlers/fstab/lsp/text-document-completion.go b/handlers/fstab/lsp/text-document-completion.go index 4c43e6f..55b585f 100644 --- a/handlers/fstab/lsp/text-document-completion.go +++ b/handlers/fstab/lsp/text-document-completion.go @@ -17,7 +17,7 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa if !found { // Empty line, return spec completions - return fstabdocumentation.SpecField.FetchCompletions( + return fstabdocumentation.SpecField.DeprecatedFetchCompletions( "", params.Position.Character, ), nil diff --git a/handlers/fstab/parser/parser.go b/handlers/fstab/parser/parser.go index 15ee905..a57165a 100644 --- a/handlers/fstab/parser/parser.go +++ b/handlers/fstab/parser/parser.go @@ -88,7 +88,7 @@ func (e *FstabLine) CheckIsValid() []protocol.Diagnostic { diagnostics := make([]protocol.Diagnostic, 0) if e.Fields.Spec != nil { - errors := fstabdocumentation.SpecField.CheckIsValid(e.Fields.Spec.Value) + errors := fstabdocumentation.SpecField.DeprecatedCheckIsValid(e.Fields.Spec.Value) if len(errors) > 0 { diagnostics = append( @@ -99,7 +99,7 @@ func (e *FstabLine) CheckIsValid() []protocol.Diagnostic { } if e.Fields.MountPoint != nil { - errors := fstabdocumentation.MountPointField.CheckIsValid(e.Fields.MountPoint.Value) + errors := fstabdocumentation.MountPointField.DeprecatedCheckIsValid(e.Fields.MountPoint.Value) if len(errors) > 0 { diagnostics = append( @@ -112,7 +112,7 @@ func (e *FstabLine) CheckIsValid() []protocol.Diagnostic { var fileSystemType string = "" if e.Fields.FilesystemType != nil { - errors := fstabdocumentation.FileSystemTypeField.CheckIsValid(e.Fields.FilesystemType.Value) + errors := fstabdocumentation.FileSystemTypeField.DeprecatedCheckIsValid(e.Fields.FilesystemType.Value) if len(errors) > 0 { diagnostics = append( @@ -125,7 +125,7 @@ func (e *FstabLine) CheckIsValid() []protocol.Diagnostic { } if e.Fields.Options != nil && fileSystemType != "" { - var optionsField docvalues.Value + var optionsField docvalues.DeprecatedValue if foundField, found := fstabdocumentation.MountOptionsMapField[fileSystemType]; found { optionsField = foundField @@ -133,7 +133,7 @@ func (e *FstabLine) CheckIsValid() []protocol.Diagnostic { optionsField = fstabdocumentation.DefaultMountOptionsField } - errors := optionsField.CheckIsValid(e.Fields.Options.Value) + errors := optionsField.DeprecatedCheckIsValid(e.Fields.Options.Value) if len(errors) > 0 { diagnostics = append( @@ -144,7 +144,7 @@ func (e *FstabLine) CheckIsValid() []protocol.Diagnostic { } if e.Fields.Freq != nil { - errors := fstabdocumentation.FreqField.CheckIsValid(e.Fields.Freq.Value) + errors := fstabdocumentation.FreqField.DeprecatedCheckIsValid(e.Fields.Freq.Value) if len(errors) > 0 { diagnostics = append( @@ -155,7 +155,7 @@ func (e *FstabLine) CheckIsValid() []protocol.Diagnostic { } if e.Fields.Pass != nil { - errors := fstabdocumentation.PassField.CheckIsValid(e.Fields.Pass.Value) + errors := fstabdocumentation.PassField.DeprecatedCheckIsValid(e.Fields.Pass.Value) if len(errors) > 0 { diagnostics = append( diff --git a/handlers/hosts/analyzer/values.go b/handlers/hosts/analyzer/values.go index d1c4e0a..8dfadcb 100644 --- a/handlers/hosts/analyzer/values.go +++ b/handlers/hosts/analyzer/values.go @@ -53,7 +53,7 @@ func analyzeEntriesAreValid( err = append( err, utils.Map( - fields.IPAddressField.CheckIsValid(entry.IPAddress.Value.String()), + fields.IPAddressField.DeprecatedCheckIsValid(entry.IPAddress.Value.String()), func(val *docvalues.InvalidValue) common.LSPError { return common.LSPError{ Range: entry.IPAddress.Location, @@ -66,7 +66,7 @@ func analyzeEntriesAreValid( err = append( err, utils.Map( - fields.HostnameField.CheckIsValid(entry.Hostname.Value), + fields.HostnameField.DeprecatedCheckIsValid(entry.Hostname.Value), func(val *docvalues.InvalidValue) common.LSPError { return common.LSPError{ Range: entry.Hostname.Location, @@ -80,7 +80,7 @@ func analyzeEntriesAreValid( err = append( err, utils.Map( - fields.HostnameField.CheckIsValid(alias.Value), + fields.HostnameField.DeprecatedCheckIsValid(alias.Value), func(val *docvalues.InvalidValue) common.LSPError { return common.LSPError{ Range: alias.Location, diff --git a/handlers/hosts/lsp/text-document-hover.go b/handlers/hosts/lsp/text-document-hover.go index ca2530b..7fcbe53 100644 --- a/handlers/hosts/lsp/text-document-hover.go +++ b/handlers/hosts/lsp/text-document-hover.go @@ -42,7 +42,7 @@ func TextDocumentHover( case handlers.HoverTargetIPAddress: line := entry.IPAddress.Value.String() relativeCursor := uint32(entry.IPAddress.Location.Start.GetRelativeIndexPosition(index)) - hover := fields.IPAddressField.FetchHoverInfo(line, relativeCursor) + hover := fields.IPAddressField.DeprecatedFetchHoverInfo(line, relativeCursor) return &protocol.Hover{ Contents: hover, diff --git a/handlers/ssh_config/analyzer/options.go b/handlers/ssh_config/analyzer/options.go index 2f00ec3..13ec1f1 100644 --- a/handlers/ssh_config/analyzer/options.go +++ b/handlers/ssh_config/analyzer/options.go @@ -82,7 +82,7 @@ func checkOption( errs = append( errs, utils.Map( - docOption.CheckIsValid(option.OptionValue.Value.Value), + docOption.DeprecatedCheckIsValid(option.OptionValue.Value.Value), func(invalidValue *docvalues.InvalidValue) common.LSPError { err := docvalues.LSPErrorFromInvalidValue(option.Start.Line, *invalidValue) err.ShiftCharacter(option.OptionValue.Start.Character) @@ -137,4 +137,3 @@ func checkHostBlock( return errs } - diff --git a/handlers/ssh_config/fields/fields.go b/handlers/ssh_config/fields/fields.go index acdd952..816782a 100644 --- a/handlers/ssh_config/fields/fields.go +++ b/handlers/ssh_config/fields/fields.go @@ -27,8 +27,8 @@ var Options = map[string]docvalues.DocumentationValue{ }, "AddKeysToAgent": { Documentation: `Specifies whether keys should be automatically added to a running ssh-agent(1). If this option is set to yes and a key is loaded from a file, the key and its passphrase are added to the agent with the default lifetime, as if by ssh-add(1). If this option is set to ask, ssh(1) will require confirmation using the SSH_ASKPASS program before adding a key (see ssh-add(1) for details). If this option is set to confirm, each use of the key must be confirmed, as if the -c option was specified to ssh-add(1). If this option is set to no, no keys are added to the agent. Alternately, this option may be specified as a time interval using the format described in the TIME FORMATS section of sshd_config(5) to specify the key's lifetime in ssh-agent(1), after which it will automatically be removed. The argument must be no (the default), yes, confirm (optionally followed by a time interval), ask or a time interval.`, - Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Value: docvalues.OrValue{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ @@ -59,17 +59,17 @@ var Options = map[string]docvalues.DocumentationValue{ }, "BindAddress": { Documentation: `Use the specified address on the local machine as the source address of the connection. Only useful on systems with more than one address.`, - Value: docvalues.IPAddressValue{ - AllowIPv4: true, - AllowIPv6: true, + Value: docvalues.IPAddressValue{ + AllowIPv4: true, + AllowIPv6: true, AllowRange: false, }, }, "BindInterface": { Documentation: `Use the address of the specified interface on the local machine as the source address of the connection.`, - Value: docvalues.IPAddressValue{ - AllowIPv4: false, - AllowIPv6: false, + Value: docvalues.IPAddressValue{ + AllowIPv4: false, + AllowIPv6: false, AllowRange: false, }, }, @@ -96,9 +96,9 @@ var Options = map[string]docvalues.DocumentationValue{ '*.a.example.com:*.b.example.com,*.c.example.com' will allow hostnames matching '*.a.example.com' to be canonicalized to names in the '*.b.example.com' or '*.c.example.com' domains. A single argument of 'none' causes no CNAMEs to be considered for canonicalization. This is the default behaviour.`, Value: docvalues.ArrayValue{ - Separator: ",", + Separator: ",", DuplicatesExtractor: &docvalues.SimpleDuplicatesExtractor, - SubValue: docvalues.StringValue{}, + SubValue: docvalues.StringValue{}, }, }, "CASignatureAlgorithms": { @@ -167,7 +167,7 @@ Note that in all the above cases, terminating an inactive session does not guara Moreover, terminating an inactive channel or session does not necessarily close the SSH connection, nor does it prevent a client from requesting another channel of the same type. In particular, expiring an inactive forwarding session does not prevent another identical forwarding from being subsequently created. The default is not to expire channels of any type for inactivity.`, - Value: docvalues.ArrayValue{ + Value: docvalues.ArrayValue{ Separator: " ", DuplicatesExtractor: &channelTimeoutExtractor, SubValue: docvalues.KeyValueAssignmentValue{ @@ -192,7 +192,7 @@ The default is not to expire channels of any type for inactivity.`, }, "CheckHostIP": { Documentation: `If set to yes, ssh(1) will additionally check the host IP address in the known_hosts file. This allows it to detect if a host key changed due to DNS spoofing and will add addresses of destination hosts to ~/.ssh/known_hosts in the process, regardless of the setting of StrictHostKeyChecking. If the option is set to no (the default), the check will not be executed.`, - Value: booleanEnumValue, + Value: booleanEnumValue, }, "Ciphers": { Documentation: `Specifies the ciphers allowed and their order of preference. Multiple ciphers must be comma-separated. If the specified list begins with a @@ -236,7 +236,7 @@ aes128-gcm@openssh.com,aes256-gcm@openssh.com }, "Compression": { Documentation: `Specifies whether to use compression. The argument must be yes or no (the default).`, - Value: booleanEnumValue, + Value: booleanEnumValue, }, "ConnectionAttempts": { Documentation: `Specifies the number of tries (one per second) to make before exiting. The argument must be an integer. This may be useful in scripts if the connection sometimes fails. The default is 1.`, @@ -264,12 +264,12 @@ aes128-gcm@openssh.com,aes256-gcm@openssh.com }, "ControlPath": { Documentation: `Specify the path to the control socket used for connection sharing as described in the ControlMaster section above or the string none to disable connection sharing. Arguments to ControlPath may use the tilde syntax to refer to a user's home directory, the tokens described in the TOKENS section and environment variables as described in the ENVIRONMENT VARIABLES section. It is recommended that any ControlPath used for opportunistic connection sharing include at least %h, %p, and %r (or alternatively %C) and be placed in a directory that is not writable by other users. This ensures that shared connections are uniquely identified.`, - Value: docvalues.StringValue{}, + Value: docvalues.StringValue{}, }, "ControlPersist": { Documentation: `When used in conjunction with ControlMaster, specifies that the master connection should remain open in the background (waiting for future client connections) after the initial client connection has been closed. If set to no (the default), then the master connection will not be placed into the background, and will close as soon as the initial client connection is closed. If set to yes or 0, then the master connection will remain in the background indefinitely (until killed or closed via a mechanism such as the 'ssh -O exit'). If set to a time in seconds, or a time in any of the formats documented in sshd_config(5), then the backgrounded master connection will automatically terminate after it has remained idle (with no client connections) for the specified time.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ booleanEnumValue, docvalues.TimeFormatValue{}, docvalues.PositiveNumberValue(), @@ -281,12 +281,12 @@ aes128-gcm@openssh.com,aes256-gcm@openssh.com [bind_address:]port. IPv6 addresses can be specified by enclosing addresses in square brackets. By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of localhost indicates that the listening port be bound for local use only, while an empty address or ‘*’ indicates that the port should be available from all interfaces. Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh(1) will act as a SOCKS server. Multiple forwardings may be specified, and additional forwardings can be given on the command line. Only the superuser can forward privileged ports.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.NumberValue{Min: &ZERO, Max: &MAX_PORT}, docvalues.KeyValueAssignmentValue{ Key: docvalues.IPAddressValue{ - AllowIPv4: true, - AllowIPv6: true, + AllowIPv4: true, + AllowIPv6: true, AllowRange: false, }, Value: docvalues.NumberValue{Min: &ZERO, Max: &MAX_PORT}, @@ -296,7 +296,7 @@ aes128-gcm@openssh.com,aes256-gcm@openssh.com }, "EnableEscapeCommandline": { Documentation: `Enables the command line option in the EscapeChar menu for interactive sessions (default ‘~C’). By default, the command line is disabled.`, - Value: docvalues.StringValue{}, + Value: docvalues.StringValue{}, }, "EnableSSHKeysign": { Documentation: `Setting this option to yes in the global client configuration file /etc/ssh/ssh_config enables the use of the helper program ssh-keysign(8) during HostbasedAuthentication. The argument must be yes or no (the default). This option should be placed in the non-hostspecific section. See ssh-keysign(8) for more information.`, @@ -304,15 +304,15 @@ aes128-gcm@openssh.com,aes256-gcm@openssh.com }, "EscapeChar": { Documentation: `Sets the escape character (default: ‘~’). The escape character can also be set on the command line. The argument should be a single character, ‘^’ followed by a letter, or none to disable the escape character entirely (making the connection transparent for binary data).`, - Value: docvalues.StringValue{}, + Value: docvalues.StringValue{}, }, "ExitOnForwardFailure": { Documentation: `Specifies whether ssh(1) should terminate the connection if it cannot set up all requested dynamic, tunnel, local, and remote port forwardings, (e.g. if either end is unable to bind and listen on a specified port). Note that ExitOnForwardFailure does not apply to connections made over port forwardings and will not, for example, cause ssh(1) to exit if TCP connections to the ultimate forwarding destination fail. The argument must be yes or no (the default).`, - Value: booleanEnumValue, + Value: booleanEnumValue, }, "FingerprintHash": { Documentation: `Specifies the hash algorithm used when displaying key fingerprints. Valid options are: md5 and sha256 (the default).`, - Value: docvalues.EnumValue{ + Value: docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ docvalues.CreateEnumString("md5"), @@ -328,8 +328,8 @@ aes128-gcm@openssh.com,aes256-gcm@openssh.com "ForwardAgent": { Documentation: `Specifies whether the connection to the authentication agent (if any) will be forwarded to the remote machine. The argument may be yes, no (the default), an explicit path to an agent socket or the name of an environment variable (beginning with ‘$’) in which to find the path. Agent forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the agent's Unix-domain socket) can access the local agent through the forwarded connection. An attacker cannot obtain key material from the agent, however they can perform operations on the keys that enable them to authenticate using the identities loaded into the agent.`, - Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Value: docvalues.OrValue{ + Values: []docvalues.DeprecatedValue{ booleanEnumValue, docvalues.StringValue{}, }, @@ -342,7 +342,7 @@ aes128-gcm@openssh.com,aes256-gcm@openssh.com }, "ForwardX11Timeout": { Documentation: `Specify a timeout for untrusted X11 forwarding using the format described in the TIME FORMATS section of sshd_config(5). X11 connections received by ssh(1) after this time will be refused. Setting ForwardX11Timeout to zero will disable the timeout and permit X11 forwarding for the life of the connection. The default is to disable untrusted X11 forwarding after twenty minutes has elapsed.`, - Value: docvalues.TimeFormatValue{}, + Value: docvalues.TimeFormatValue{}, }, "ForwardX11Trusted": { Documentation: `If this option is set to yes, remote X11 clients will have full access to the original X11 display. @@ -352,7 +352,7 @@ aes128-gcm@openssh.com,aes256-gcm@openssh.com }, "GatewayPorts": { Documentation: `Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. The argument must be yes or no (the default).`, - Value: booleanEnumValue, + Value: booleanEnumValue, }, "GlobalKnownHostsFile": { Documentation: `Specifies one or more files to use for the global host key database, separated by whitespace. The default is @@ -376,7 +376,7 @@ aes128-gcm@openssh.com,aes256-gcm@openssh.com }, "HashKnownHosts": { Documentation: `Indicates that ssh(1) should hash host names and addresses when they are added to ~/.ssh/known_hosts. These hashed names may be used normally by ssh(1) and sshd(8), but they do not visually reveal identifying information if the file's contents are disclosed. The default is no. Note that existing names and addresses in known hosts files will not be converted automatically, but may be manually hashed using ssh-keygen(1).`, - Value: booleanEnumValue, + Value: booleanEnumValue, }, "HostbasedAcceptedAlgorithms": { Documentation: `Specifies the signature algorithms that will be used for hostbased authentication as a comma-separated list of patterns. Alternately if the specified list begins with a ‘+’ character, then the specified signature algorithms will be appended to the default set instead of replacing them. If the specified list begins with a ‘-’ character, then the specified signature algorithms (including wildcards) will be removed from the default set instead of replacing them. If the specified list begins with a ‘^’ character, then the specified signature algorithms will be placed at the head of the default set. The default for this option is: @@ -396,16 +396,16 @@ sk-ecdsa-sha2-nistp256@openssh.com, rsa-sha2-512,rsa-sha2-256 The -Q option of ssh(1) may be used to list supported signature algorithms. This was formerly named HostbasedKeyTypes.`, - Value: docvalues.CustomValue{ - FetchValue: func(_ docvalues.CustomValueContext) docvalues.Value { - options, err := ssh.QueryOpenSSHOptions("HostbasedAcceptedAlgorithms") + Value: docvalues.CustomValue{ + FetchValue: func(_ docvalues.CustomValueContext) docvalues.DeprecatedValue { + options, err := ssh.QueryOpenSSHOptions("HostbasedAcceptedAlgorithms") - if err != nil { - // Fallback - options, _ = ssh.QueryOpenSSHOptions("HostbasedAcceptedKeyTypes") - } + if err != nil { + // Fallback + options, _ = ssh.QueryOpenSSHOptions("HostbasedAcceptedKeyTypes") + } - return prefixPlusMinusCaret(options) + return prefixPlusMinusCaret(options) }, }, }, @@ -435,7 +435,7 @@ rsa-sha2-512,rsa-sha2-256 If hostkeys are known for the destination host then this default is modified to prefer their algorithms. The list of available signature algorithms may also be obtained using 'ssh -Q HostKeyAlgorithms'.`, Value: docvalues.CustomValue{ - FetchValue: func(_ docvalues.CustomValueContext) docvalues.Value { + FetchValue: func(_ docvalues.CustomValueContext) docvalues.DeprecatedValue { options, _ := ssh.QueryOpenSSHOptions("HostKeyAlgorithms") return prefixPlusMinusCaret(options) @@ -452,7 +452,7 @@ rsa-sha2-512,rsa-sha2-256 }, "IdentitiesOnly": { Documentation: `Specifies that ssh(1) should only use the configured authentication identity and certificate files (either the default files, or those explicitly configured in the ssh_config files or passed on the ssh(1) command-line), even if ssh-agent(1) or a PKCS11Provider or SecurityKeyProvider offers more identities. The argument to this keyword must be yes or no (the default). This option is intended for situations where ssh-agent offers many different identities.`, - Value: booleanEnumValue, + Value: booleanEnumValue, }, "IdentityAgent": { Documentation: `Specifies the UNIX-domain socket used to communicate with the authentication agent. This option overrides the SSH_AUTH_SOCK environment variable and can be used to select a specific agent. Setting the socket name to none disables the use of an authentication agent. If the string 'SSH_AUTH_SOCK' is specified, the location of the socket will be read from the SSH_AUTH_SOCK environment variable. Otherwise if the specified value begins with a '$' character, then it will be treated as an environment variable containing the location of the socket. @@ -473,7 +473,7 @@ rsa-sha2-512,rsa-sha2-256 // TODO: Add "IgnoreUnknown": { Documentation: `Specifies a pattern-list of unknown options to be ignored if they are encountered in configuration parsing. This may be used to suppress errors if ssh_config contains options that are unrecognised by ssh(1). It is recommended that IgnoreUnknown be listed early in the configuration file as it will not be applied to unknown options that appear before it.`, - Value: docvalues.StringValue{}, + Value: docvalues.StringValue{}, }, "Include": { Documentation: `Include the specified configuration file(s). Multiple pathnames may be specified and each pathname may contain glob(7) wildcards, tokens as described in the TOKENS section, environment variables as described in the ENVIRONMENT VARIABLES section and, for user configurations, shell-like ‘~’ references to user home directories. Wildcards will be expanded and processed in lexical order. Files without absolute paths are assumed to be in ~/.ssh if included in a user configuration file or /etc/ssh if included from the system configuration file. Include directive may appear inside a Match or Host block to perform conditional inclusion.`, @@ -486,7 +486,7 @@ rsa-sha2-512,rsa-sha2-256 "IPQoS": { Documentation: `Specifies the IPv4 type-of-service or DSCP class for connections. Accepted values are af11, af12, af13, af21, af22, af23, af31, af32, af33, af41, af42, af43, cs0, cs1, cs2, cs3, cs4, cs5, cs6, cs7, ef, le, lowdelay, throughput, reliability, a numeric value, or none to use the operating system default. This option may take one or two arguments, separated by whitespace. If one argument is specified, it is used as the packet class unconditionally. If two values are specified, the first is automatically selected for interactive sessions and the second for non-interactive sessions. The default is af21 (Low-Latency Data) for interactive sessions and cs1 (Lower Effort) for non-interactive sessions.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.NumberValue{}, docvalues.EnumValue{ Values: []docvalues.EnumString{ @@ -537,8 +537,8 @@ rsa-sha2-512,rsa-sha2-256 }, "KbdInteractiveDevices": { Documentation: `Specifies the list of methods to use in keyboard-interactive authentication. Multiple method names must be comma-separated. The default is to use the server specified list. The methods available vary depending on what the server supports. For an OpenSSH server, it may be zero or more of: bsdauth, pam, and skey.`, - Value: docvalues.ArrayValue{ - Separator: ",", + Value: docvalues.ArrayValue{ + Separator: ",", DuplicatesExtractor: &docvalues.SimpleDuplicatesExtractor, SubValue: docvalues.EnumValue{ EnforceValues: true, @@ -597,12 +597,12 @@ diffie-hellman-group14-sha256 [bind_address:]port or a Unix domain socket path. The second argument is the destination and may be host:hostport or a Unix domain socket path if the remote host supports it. IPv6 addresses can be specified by enclosing addresses in square brackets. Multiple forwardings may be specified, and additional forwardings can be given on the command line. Only the superuser can forward privileged ports. By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of localhost indicates that the listening port be bound for local use only, while an empty address or ‘*’ indicates that the port should be available from all interfaces. Unix domain socket paths may use the tokens described in the TOKENS section and environment variables as described in the ENVIRONMENT VARIABLES section.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.NumberValue{Min: &ZERO, Max: &MAX_PORT}, docvalues.KeyValueAssignmentValue{ Key: docvalues.IPAddressValue{ - AllowIPv4: true, - AllowIPv6: true, + AllowIPv4: true, + AllowIPv6: true, AllowRange: false, }, }, @@ -611,7 +611,7 @@ diffie-hellman-group14-sha256 }, "LogLevel": { Documentation: `Gives the verbosity level that is used when logging messages from ssh(1). The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of verbose output.`, - Value: docvalues.EnumValue{ + Value: docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ docvalues.CreateEnumString("QUIET"), @@ -677,8 +677,8 @@ hmac-sha2-256,hmac-sha2-512,hmac-sha1 }, "ObscureKeystrokeTiming": { Documentation: `Specifies whether ssh(1) should try to obscure inter-keystroke timings from passive observers of network traffic. If enabled, then for interactive sessions, ssh(1) will send keystrokes at fixed intervals of a few tens of milliseconds and will send fake keystroke packets for some time after typing ceases. The argument to this keyword must be yes, no or an interval specifier of the form interval:milliseconds (e.g. interval:80 for 80 milliseconds). The default is to obscure keystrokes using a 20ms packet interval. Note that smaller intervals will result in higher fake keystroke packet rates.`, - Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Value: docvalues.OrValue{ + Values: []docvalues.DeprecatedValue{ booleanEnumValue, docvalues.RegexValue{ Regex: *regexp.MustCompile(`^interval:[0-9]+$`), @@ -700,7 +700,7 @@ hmac-sha2-256,hmac-sha2-512,hmac-sha1 PermitRemoteOpen host:port PermitRemoteOpen IPv4_addr:port PermitRemoteOpen [IPv6_addr]:port Multiple forwards may be specified by separating them with whitespace. An argument of any can be used to remove all restrictions and permit any forwarding requests. An argument of none can be used to prohibit all forwarding requests. The wildcard ‘*’ can be used for host or port to allow all hosts or ports respectively. Otherwise, no pattern matching or address lookups are performed on supplied names.`, - // TODO: Improve + // TODO: Improve Value: docvalues.StringValue{}, }, "PKCS11Provider": { @@ -768,7 +768,7 @@ rsa-sha2-512,rsa-sha2-256 The list of available signature algorithms may also be obtained using 'ssh -Q PubkeyAcceptedAlgorithms'.`, Value: docvalues.CustomValue{ - FetchValue: func(_ docvalues.CustomValueContext) docvalues.Value { + FetchValue: func(_ docvalues.CustomValueContext) docvalues.DeprecatedValue { options, _ := ssh.QueryOpenSSHOptions("PubkeyAcceptedAlgorithms") return prefixPlusMinusCaret(options) @@ -847,7 +847,7 @@ rsa-sha2-512,rsa-sha2-256 }, "SessionType": { Documentation: `May be used to either request invocation of a subsystem on the remote system, or to prevent the execution of a remote command at all. The latter is useful for just forwarding ports. The argument to this keyword must be none (same as the -N option), subsystem (same as the -s option) or default (shell or command execution).`, - Value: docvalues.StringValue{}, + Value: docvalues.StringValue{}, }, "SetEnv": { Documentation: `Directly specify one or more environment variables and their contents to be sent to the server. Similarly to SendEnv, with the exception of the TERM variable, the server must be prepared to accept the environment variable.`, @@ -855,7 +855,7 @@ rsa-sha2-512,rsa-sha2-256 }, "StdinNull": { Documentation: `Redirects stdin from /dev/null (actually, prevents reading from stdin). Either this or the equivalent -n option must be used when ssh is run in the background. The argument to this keyword must be yes (same as the -n option) or no (the default).`, - Value: booleanEnumValue, + Value: booleanEnumValue, }, "StreamLocalBindMask": { Documentation: `Sets the octal file creation mode mask (umask) used when creating a Unix-domain socket file for local or remote port forwarding. This option is only used for port forwarding to a Unix-domain socket file. @@ -883,7 +883,7 @@ rsa-sha2-512,rsa-sha2-256 }, "SyslogFacility": { Documentation: `Gives the facility code that is used when logging messages from ssh(1). The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The default is USER.`, - Value: docvalues.EnumValue{ + Value: docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ docvalues.CreateEnumString("DAEMON"), @@ -913,7 +913,7 @@ rsa-sha2-512,rsa-sha2-256 }, "Tunnel": { Documentation: `Request tun(4) device forwarding between the client and the server. The argument must be yes, point-to-point (layer 3), ethernet (layer 2), or no (the default). Specifying yes requests the default tunnel mode, which is point-to-point.`, - Value: docvalues.EnumValue{ + Value: docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ docvalues.CreateEnumString("yes"), @@ -954,7 +954,7 @@ rsa-sha2-512,rsa-sha2-256 ~/.ssh/known_hosts2.`, Value: docvalues.ArrayValue{ Separator: " ", - SubValue: docvalues.PathValue{ + SubValue: docvalues.PathValue{ RequiredType: docvalues.PathTypeFile, }, }, @@ -973,11 +973,11 @@ rsa-sha2-512,rsa-sha2-256 }, "VisualHostKey": { Documentation: `If this flag is set to yes, an ASCII art representation of the remote host key fingerprint is printed in addition to the fingerprint string at login and for unknown host keys. If this flag is set to no (the default), no fingerprint strings are printed at login and only the fingerprint string will be printed for unknown host keys.`, - Value: booleanEnumValue, + Value: booleanEnumValue, }, "XAuthLocation": { Documentation: `Specifies the full pathname of the xauth(1) program. The default is /usr/X11R6/bin/xauth.`, - Value: docvalues.PathValue{ + Value: docvalues.PathValue{ RequiredType: docvalues.PathTypeFile, }, }, diff --git a/handlers/ssh_config/fields/match.go b/handlers/ssh_config/fields/match.go new file mode 100644 index 0000000..071562a --- /dev/null +++ b/handlers/ssh_config/fields/match.go @@ -0,0 +1,3 @@ +package fields + + diff --git a/handlers/ssh_config/handlers/completions.go b/handlers/ssh_config/handlers/completions.go index 7694034..bcf9e7e 100644 --- a/handlers/ssh_config/handlers/completions.go +++ b/handlers/ssh_config/handlers/completions.go @@ -81,13 +81,13 @@ func GetOptionCompletions( } if entry.OptionValue == nil { - return option.FetchCompletions("", 0), nil + return option.DeprecatedFetchCompletions("", 0), nil } // Hello wo|rld line := entry.OptionValue.Value.Raw // NEW: docvalues index - return option.FetchCompletions( + return option.DeprecatedFetchCompletions( line, common.DeprecatedImprovedCursorToIndex( cursor, diff --git a/handlers/sshd_config/analyzer/match.go b/handlers/sshd_config/analyzer/match.go index ad316bb..afd3dec 100644 --- a/handlers/sshd_config/analyzer/match.go +++ b/handlers/sshd_config/analyzer/match.go @@ -37,7 +37,7 @@ func analyzeMatchBlocks( }) continue - } + } errs = append(errs, analyzeMatchValuesContainsPositiveValue(entry.Values)...) @@ -127,7 +127,7 @@ func analyzeMatchValueIsValid( } docOption := fields.MatchValueFieldMap[criteria] - invalidValues := docOption.CheckIsValid(value.Value.Raw) + invalidValues := docOption.DeprecatedCheckIsValid(value.Value.Raw) errs = append( errs, @@ -144,4 +144,3 @@ func analyzeMatchValueIsValid( return errs } - diff --git a/handlers/sshd_config/analyzer/options.go b/handlers/sshd_config/analyzer/options.go index 5e40cef..9863b04 100644 --- a/handlers/sshd_config/analyzer/options.go +++ b/handlers/sshd_config/analyzer/options.go @@ -75,7 +75,7 @@ func checkOption( errs = append(errs, checkIsUsingDoubleQuotes(option.OptionValue.Value, option.OptionValue.LocationRange)...) errs = append(errs, checkQuotesAreClosed(option.OptionValue.Value, option.OptionValue.LocationRange)...) - invalidValues := docOption.CheckIsValid(option.OptionValue.Value.Value) + invalidValues := docOption.DeprecatedCheckIsValid(option.OptionValue.Value.Value) errs = append( errs, diff --git a/handlers/sshd_config/fields/fields.go b/handlers/sshd_config/fields/fields.go index dd81bd5..7cc1e85 100644 --- a/handlers/sshd_config/fields/fields.go +++ b/handlers/sshd_config/fields/fields.go @@ -75,7 +75,7 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may Note that each authentication method listed should also be explicitly enabled in the configuration. 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".`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ @@ -315,7 +315,7 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may ssh-ed25519-cert-v01@openssh.com, ecdsa-sha2-nistp256-cert-v01@openssh.com, ecdsa-sha2-nistp384-cert-v01@openssh.com, ecdsa-sha2-nistp521-cert-v01@openssh.com, sk-ssh-ed25519-cert-v01@openssh.com, sk-ecdsa-sha2-nistp256-cert-v01@openssh.com, rsa-sha2-512-cert-v01@openssh.com, rsa-sha2-256-cert-v01@openssh.com, ssh-ed25519, ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521, sk-ssh-ed25519@openssh.com, sk-ecdsa-sha2-nistp256@openssh.com, rsa-sha2-512,rsa-sha2-256 The list of available signature algorithms may also be obtained using "ssh -Q HostbasedAcceptedAlgorithms". This was formerly named HostbasedAcceptedKeyTypes.`, Value: docvalues.CustomValue{ - FetchValue: func(_ docvalues.CustomValueContext) docvalues.Value { + FetchValue: func(_ docvalues.CustomValueContext) docvalues.DeprecatedValue { options, err := ssh.QueryOpenSSHOptions("HostbasedAcceptedAlgorithms") if err != nil { @@ -348,7 +348,7 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may "HostKeyAgent": { Documentation: `Identifies the UNIX-domain socket used to communicate with an agent that has access to the private host keys. If the string "SSH_AUTH_SOCK" is specified, the location of the socket will be read from the SSH_AUTH_SOCK environment variable.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ @@ -364,7 +364,7 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may ssh-ed25519-cert-v01@openssh.com, ecdsa-sha2-nistp256-cert-v01@openssh.com, ecdsa-sha2-nistp384-cert-v01@openssh.com, ecdsa-sha2-nistp521-cert-v01@openssh.com, sk-ssh-ed25519-cert-v01@openssh.com, sk-ecdsa-sha2-nistp256-cert-v01@openssh.com, rsa-sha2-512-cert-v01@openssh.com, rsa-sha2-256-cert-v01@openssh.com, ssh-ed25519, ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521, sk-ssh-ed25519@openssh.com, sk-ecdsa-sha2-nistp256@openssh.com, rsa-sha2-512,rsa-sha2-256 The list of available signature algorithms may also be obtained using "ssh -Q HostKeyAlgorithms".`, Value: docvalues.CustomValue{ - FetchValue: func(_ docvalues.CustomValueContext) docvalues.Value { + FetchValue: func(_ docvalues.CustomValueContext) docvalues.DeprecatedValue { options, _ := ssh.QueryOpenSSHOptions("HostKeyAlgorithms") return prefixPlusMinusCaret(options) @@ -400,7 +400,7 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may "IPQoS": { Documentation: `Specifies the IPv4 type-of-service or DSCP class for the connection. Accepted values are af11, af12, af13, af21, af22, af23, af31, af32, af33, af41, af42, af43, cs0, cs1, cs2, cs3, cs4, cs5, cs6, cs7, ef, le, lowdelay, throughput, reliability, a numeric value, or none to use the operating system default. This option may take one or two arguments, separated by whitespace. If one argument is specified, it is used as the packet class unconditionally. If two values are specified, the first is automatically selected for interactive sessions and the second for non-interactive sessions. The default is af21 (Low-Latency Data) for interactive sessions and cs1 (Lower Effort) for non-interactive sessions.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.NumberValue{}, docvalues.EnumValue{ Values: []docvalues.EnumString{ @@ -613,7 +613,7 @@ Only a subset of keywords may be used on the lines following a Match keyword. Av }, Separator: ":", Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ Values: []docvalues.EnumString{ { @@ -640,7 +640,7 @@ Only a subset of keywords may be used on the lines following a Match keyword. Av SubValue: docvalues.KeyValueAssignmentValue{ ValueIsOptional: true, Key: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ Values: []docvalues.EnumString{ { @@ -660,7 +660,7 @@ Only a subset of keywords may be used on the lines following a Match keyword. Av }, Separator: ":", Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ Values: []docvalues.EnumString{ { @@ -712,7 +712,7 @@ Only a subset of keywords may be used on the lines following a Match keyword. Av "PermitUserEnvironment": { Documentation: `Specifies whether ~/.ssh/environment and environment= options in ~/.ssh/authorized_keys are processed by sshd(8). Valid options are yes, no or a pattern-list specifying which environment variable names to accept (for example "LANG,LC_*"). The default is no. Enabling environment processing may enable users to bypass access restrictions in some configurations using mechanisms such as LD_PRELOAD.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ Values: []docvalues.EnumString{ docvalues.CreateEnumString("yes"), @@ -734,7 +734,7 @@ Only a subset of keywords may be used on the lines following a Match keyword. Av "PerSourceMaxStartups": { Documentation: `Specifies the number of unauthenticated connections allowed from a given source address, or “none” if there is no limit. This limit is applied in addition to MaxStartups, whichever is lower. The default is none.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ @@ -780,7 +780,7 @@ Only a subset of keywords may be used on the lines following a Match keyword. Av ssh-ed25519-cert-v01@openssh.com, ecdsa-sha2-nistp256-cert-v01@openssh.com, ecdsa-sha2-nistp384-cert-v01@openssh.com, ecdsa-sha2-nistp521-cert-v01@openssh.com, sk-ssh-ed25519-cert-v01@openssh.com, sk-ecdsa-sha2-nistp256-cert-v01@openssh.com, rsa-sha2-512-cert-v01@openssh.com, rsa-sha2-256-cert-v01@openssh.com, ssh-ed25519, ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521, sk-ssh-ed25519@openssh.com, sk-ecdsa-sha2-nistp256@openssh.com, rsa-sha2-512,rsa-sha2-256 The list of available signature algorithms may also be obtained using "ssh -Q PubkeyAcceptedAlgorithms".`, Value: docvalues.CustomValue{ - FetchValue: func(_ docvalues.CustomValueContext) docvalues.Value { + FetchValue: func(_ docvalues.CustomValueContext) docvalues.DeprecatedValue { options, _ := ssh.QueryOpenSSHOptions("PubkeyAcceptedAlgorithms") return prefixPlusMinusCaret(options) @@ -828,7 +828,7 @@ Only a subset of keywords may be used on the lines following a Match keyword. Av "RDomain": { Documentation: `Specifies an explicit routing domain that is applied after authentication has completed. The user session, as well as any forwarded or listening IP sockets, will be bound to this rdomain(4). If the routing domain is set to %D, then the domain in which the incoming connection was received will be applied.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ Values: []docvalues.EnumString{ { @@ -933,7 +933,7 @@ Only a subset of keywords may be used on the lines following a Match keyword. Av "VersionAddendum": { Documentation: `Optionally specifies additional text to append to the SSH protocol banner sent by the server upon connection. The default is none.`, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ EnforceValues: true, Values: []docvalues.EnumString{ diff --git a/handlers/sshd_config/fields/match.go b/handlers/sshd_config/fields/match.go index b61943e..0463180 100644 --- a/handlers/sshd_config/fields/match.go +++ b/handlers/sshd_config/fields/match.go @@ -79,10 +79,10 @@ var MatchAddressField = docvalues.IPAddressValue{ AllowRange: true, } -var MatchValueFieldMap = map[matchparser.MatchCriteriaType]docvalues.Value{ - matchparser.MatchCriteriaTypeUser: MatchUserField, - matchparser.MatchCriteriaTypeGroup: MatchGroupField, - matchparser.MatchCriteriaTypeHost: MatchHostField, +var MatchValueFieldMap = map[matchparser.MatchCriteriaType]docvalues.DeprecatedValue{ + matchparser.MatchCriteriaTypeUser: MatchUserField, + matchparser.MatchCriteriaTypeGroup: MatchGroupField, + matchparser.MatchCriteriaTypeHost: MatchHostField, matchparser.MatchCriteriaTypeLocalAddress: MatchLocalAddressField, matchparser.MatchCriteriaTypeLocalPort: MatchLocalPortField, matchparser.MatchCriteriaTypeRDomain: MatchRDomainField, diff --git a/handlers/sshd_config/handlers/completions.go b/handlers/sshd_config/handlers/completions.go index 0082417..3d32060 100644 --- a/handlers/sshd_config/handlers/completions.go +++ b/handlers/sshd_config/handlers/completions.go @@ -86,13 +86,13 @@ func GetOptionCompletions( } if entry.OptionValue == nil { - return option.FetchCompletions("", 0), nil + return option.DeprecatedFetchCompletions("", 0), nil } // Hello wo|rld line := entry.OptionValue.Value.Raw // NEW: docvalues index - return option.FetchCompletions( + return option.DeprecatedFetchCompletions( line, common.DeprecatedImprovedCursorToIndex( cursor, diff --git a/handlers/sshd_config/handlers/completions_match.go b/handlers/sshd_config/handlers/completions_match.go index a5dfa73..79e7d77 100644 --- a/handlers/sshd_config/handlers/completions_match.go +++ b/handlers/sshd_config/handlers/completions_match.go @@ -96,19 +96,19 @@ func getMatchValueCompletions( switch entry.Criteria.Type { case matchparser.MatchCriteriaTypeUser: - return fields.MatchUserField.FetchCompletions(line, relativeCursor) + return fields.MatchUserField.DeprecatedFetchCompletions(line, relativeCursor) case matchparser.MatchCriteriaTypeGroup: - return fields.MatchGroupField.FetchCompletions(line, relativeCursor) + return fields.MatchGroupField.DeprecatedFetchCompletions(line, relativeCursor) case matchparser.MatchCriteriaTypeHost: - return fields.MatchHostField.FetchCompletions(line, relativeCursor) + return fields.MatchHostField.DeprecatedFetchCompletions(line, relativeCursor) case matchparser.MatchCriteriaTypeAddress: - return fields.MatchAddressField.FetchCompletions(line, relativeCursor) + return fields.MatchAddressField.DeprecatedFetchCompletions(line, relativeCursor) case matchparser.MatchCriteriaTypeLocalAddress: - return fields.MatchLocalAddressField.FetchCompletions(line, relativeCursor) + return fields.MatchLocalAddressField.DeprecatedFetchCompletions(line, relativeCursor) case matchparser.MatchCriteriaTypeLocalPort: - return fields.MatchLocalPortField.FetchCompletions(line, relativeCursor) + return fields.MatchLocalPortField.DeprecatedFetchCompletions(line, relativeCursor) case matchparser.MatchCriteriaTypeRDomain: - return fields.MatchRDomainField.FetchCompletions(line, relativeCursor) + return fields.MatchRDomainField.DeprecatedFetchCompletions(line, relativeCursor) } return nil diff --git a/handlers/sshd_config/handlers/hover.go b/handlers/sshd_config/handlers/hover.go index 0a56632..6c947e7 100644 --- a/handlers/sshd_config/handlers/hover.go +++ b/handlers/sshd_config/handlers/hover.go @@ -55,7 +55,7 @@ func GetHoverInfoForOption( if option.OptionValue != nil && option.OptionValue.ContainsPosition(index) { line := option.OptionValue.Value.Raw - contents := docValue.FetchHoverInfo( + contents := docValue.DeprecatedFetchHoverInfo( line, uint32(option.OptionValue.Start.GetRelativeIndexPosition(index)), ) diff --git a/handlers/wireguard/fields/documentation-fields.go b/handlers/wireguard/fields/documentation-fields.go index f7031d7..20204ce 100644 --- a/handlers/wireguard/fields/documentation-fields.go +++ b/handlers/wireguard/fields/documentation-fields.go @@ -109,7 +109,7 @@ https://git.zx2c4.com/WireGuard/about/src/tools/man/wg-quick.8 Table = 1234 `, Value: docvalues.OrValue{ - Values: []docvalues.Value{ + Values: []docvalues.DeprecatedValue{ docvalues.EnumValue{ EnforceValues: false, Values: []docvalues.EnumString{ diff --git a/handlers/wireguard/handlers/analyzer.go b/handlers/wireguard/handlers/analyzer.go index 65355c6..79e2734 100644 --- a/handlers/wireguard/handlers/analyzer.go +++ b/handlers/wireguard/handlers/analyzer.go @@ -232,7 +232,7 @@ func analyzeProperty( } } - errors := option.CheckIsValid(p.Value.Value) + errors := option.DeprecatedCheckIsValid(p.Value.Value) return utils.Map(errors, func(err *docvalues.InvalidValue) protocol.Diagnostic { severity := protocol.DiagnosticSeverityError diff --git a/handlers/wireguard/handlers/completions.go b/handlers/wireguard/handlers/completions.go index a52c3bd..4ebecf6 100644 --- a/handlers/wireguard/handlers/completions.go +++ b/handlers/wireguard/handlers/completions.go @@ -150,11 +150,11 @@ func GetCompletionsForSectionPropertyLine( if property.Value == nil { if character >= property.Separator.Location.End { - return option.FetchCompletions("", 0), nil + return option.DeprecatedFetchCompletions("", 0), nil } } relativeCursor := character - property.Value.Location.Start - return option.FetchCompletions(property.Value.Value, relativeCursor), nil + return option.DeprecatedFetchCompletions(property.Value.Value, relativeCursor), nil }