feat(ssh_config): Improve match file so that it works with single criterias

This commit is contained in:
Myzel394 2024-09-28 13:38:05 +02:00
parent a4a8e8888f
commit b1a5898f6c
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
27 changed files with 1299 additions and 294 deletions

View File

@ -52,4 +52,3 @@ func checkIsDependent(
return errs
}

View File

@ -50,5 +50,3 @@ User root
t.Fatalf("Expected 1 error, got %v", errors)
}
}

View File

@ -35,4 +35,3 @@ func (d SSHDocument) DoesOptionExist(
) bool {
return d.FindOptionByNameAndBlock(name, block) != nil
}

View File

@ -1,3 +1 @@
package fields

View File

@ -18,4 +18,3 @@ var HostDisallowedOptions = map[string]struct{}{
}
var GlobalDisallowedOptions = map[string]struct{}{}

View File

@ -0,0 +1,123 @@
package handlers
import (
"config-lsp/common"
sshconfig "config-lsp/handlers/ssh_config"
matchparser "config-lsp/handlers/ssh_config/match-parser"
"config-lsp/handlers/sshd_config/fields"
protocol "github.com/tliron/glsp/protocol_3_16"
)
func getMatchCompletions(
d *sshconfig.SSHDocument,
cursor common.CursorPosition,
match *matchparser.Match,
) ([]protocol.CompletionItem, error) {
if match == nil || len(match.Entries) == 0 {
completions := getMatchCriteriaCompletions()
completions = append(completions, getMatchAllKeywordCompletion())
return completions, nil
}
entry := match.GetEntryAtPosition(cursor)
if entry == nil || entry.Criteria.ContainsPosition(cursor) {
return getMatchCriteriaCompletions(), nil
}
return getMatchValueCompletions(entry, cursor), nil
}
func getMatchCriteriaCompletions() []protocol.CompletionItem {
kind := protocol.CompletionItemKindEnum
return []protocol.CompletionItem{
{
Label: string(matchparser.MatchCriteriaTypeCanonical),
Kind: &kind,
},
{
Label: string(matchparser.MatchCriteriaTypeFinal),
Kind: &kind,
},
{
Label: string(matchparser.MatchCriteriaTypeExec),
Kind: &kind,
},
{
Label: string(matchparser.MatchCriteriaTypeLocalNetwork),
Kind: &kind,
},
{
Label: string(matchparser.MatchCriteriaTypeHost),
Kind: &kind,
},
{
Label: string(matchparser.MatchCriteriaTypeOriginalHost),
Kind: &kind,
},
{
Label: string(matchparser.MatchCriteriaTypeTagged),
Kind: &kind,
},
{
Label: string(matchparser.MatchCriteriaTypeUser),
Kind: &kind,
},
{
Label: string(matchparser.MatchCriteriaTypeLocalUser),
Kind: &kind,
},
}
}
func getMatchAllKeywordCompletion() protocol.CompletionItem {
kind := protocol.CompletionItemKindKeyword
return protocol.CompletionItem{
Label: "all",
Kind: &kind,
}
}
func getMatchValueCompletions(
entry *matchparser.MatchEntry,
cursor common.CursorPosition,
) []protocol.CompletionItem {
value := entry.GetValueAtPosition(cursor)
var line string
var relativeCursor uint32
if value != nil {
line = value.Value.Raw
relativeCursor = common.DeprecatedImprovedCursorToIndex(
cursor,
line,
value.Start.Character,
)
} else {
line = ""
relativeCursor = 0
}
switch entry.Criteria.Type {
case matchparser.MatchCriteriaTypeUser:
return fields.MatchUserField.DeprecatedFetchCompletions(line, relativeCursor)
case matchparser.MatchCriteriaTypeGroup:
return fields.MatchGroupField.DeprecatedFetchCompletions(line, relativeCursor)
case matchparser.MatchCriteriaTypeHost:
return fields.MatchHostField.DeprecatedFetchCompletions(line, relativeCursor)
case matchparser.MatchCriteriaTypeAddress:
return fields.MatchAddressField.DeprecatedFetchCompletions(line, relativeCursor)
case matchparser.MatchCriteriaTypeLocalAddress:
return fields.MatchLocalAddressField.DeprecatedFetchCompletions(line, relativeCursor)
case matchparser.MatchCriteriaTypeLocalPort:
return fields.MatchLocalPortField.DeprecatedFetchCompletions(line, relativeCursor)
case matchparser.MatchCriteriaTypeRDomain:
return fields.MatchRDomainField.DeprecatedFetchCompletions(line, relativeCursor)
}
return nil
}

View File

@ -13,4 +13,3 @@ type HostValue struct {
common.LocationRange
Value commonparser.ParsedString
}

View File

@ -2,8 +2,8 @@ package hostparser
import (
"config-lsp/common"
"regexp"
commonparser "config-lsp/common/parser"
"regexp"
)
func NewHost() *Host {

View File

@ -5,7 +5,6 @@ import (
"config-lsp/handlers/ssh_config/ast"
)
type ValidPath string
func (v ValidPath) AsURI() string {
@ -33,4 +32,3 @@ type SSHIndexes struct {
BlockRanges map[uint32]ast.SSHBlock
}

View File

@ -3,8 +3,8 @@ package lsp
import (
"config-lsp/common"
"config-lsp/handlers/ssh_config"
"config-lsp/handlers/ssh_config/ast"
"config-lsp/handlers/ssh_config/analyzer"
"config-lsp/handlers/ssh_config/ast"
"config-lsp/utils"
"github.com/tliron/glsp"

View File

@ -5,17 +5,21 @@ root
;
matchEntry
: criteria separator? values?
: entrySingle | entryWithValue
;
entrySingle
: criteriaSingle
;
entryWithValue
: criteriaWithValue separator? values?
;
separator
: WHITESPACE
;
criteria
: string
;
values
: value? (COMMA value?)*
;
@ -24,6 +28,14 @@ value
: string
;
criteriaSingle
: QUOTE? (ALL | CANONICAL | FINAL) QUOTE?
;
criteriaWithValue
: QUOTE? (EXEC | LOCALNETWORK | HOST | ORIGINALHOST | TAGGED | USER | LOCALUSER) QUOTE?
;
string
: (QUOTED_STRING | STRING)
;
@ -32,6 +44,46 @@ COMMA
: ','
;
ALL
: ('a' | 'A') ('l' | 'L') ('l' | 'L')
;
CANONICAL
: ('c' | 'C') ('a' | 'A') ('n' | 'N') ('o' | 'O') ('n' | 'N') ('i' | 'I') ('c' | 'C') ('a' | 'A') ('l' | 'L')
;
FINAL
: ('f' | 'F') ('i' | 'I') ('n' | 'N') ('a' | 'A') ('l' | 'L')
;
EXEC
: ('e' | 'E') ('x' | 'X') ('e' | 'E') ('c' | 'C')
;
LOCALNETWORK
: ('l' | 'L') ('o' | 'O') ('c' | 'C') ('a' | 'A') ('l' | 'L') ('n' | 'N') ('e' | 'E') ('t' | 'T') ('w' | 'W') ('o' | 'O') ('r' | 'R') ('k' | 'K')
;
HOST
: ('h' | 'H') ('o' | 'O') ('s' | 'S') ('t' | 'T')
;
ORIGINALHOST
: ('o' | 'O') ('r' | 'R') ('i' | 'I') ('g' | 'G') ('i' | 'I') ('n' | 'N') ('a' | 'A') ('l' | 'L') ('h' | 'H') ('o' | 'O') ('s' | 'S') ('t' | 'T')
;
TAGGED
: ('t' | 'T') ('a' | 'A') ('g' | 'G') ('g' | 'G') ('e' | 'E') ('d' | 'D')
;
USER
: ('u' | 'U') ('s' | 'S') ('e' | 'E') ('r' | 'R')
;
LOCALUSER
: ('l' | 'L') ('o' | 'O') ('c' | 'C') ('a' | 'A') ('l' | 'L') ('u' | 'U') ('s' | 'S') ('e' | 'E') ('r' | 'R')
;
STRING
: ~(' ' | '\t' | '\r' | '\n' | '#' | ',')+
;
@ -41,5 +93,9 @@ WHITESPACE
;
QUOTED_STRING
: '"' WHITESPACE? (STRING WHITESPACE)* STRING? ('"')?
: QUOTE WHITESPACE? (STRING WHITESPACE)* STRING? QUOTE?
;
QUOTE
: '"'
;

View File

@ -62,25 +62,13 @@ func (s *matchParserListener) ExitMatchEntry(ctx *parser.MatchEntryContext) {
s.matchContext.currentEntry = nil
}
var availableCriteria = map[string]MatchCriteriaType{
string(MatchCriteriaTypeCanonical): MatchCriteriaTypeCanonical,
string(MatchCriteriaTypeFinal): MatchCriteriaTypeFinal,
string(MatchCriteriaTypeExec): MatchCriteriaTypeExec,
string(MatchCriteriaTypeLocalNetwork): MatchCriteriaTypeLocalNetwork,
string(MatchCriteriaTypeHost): MatchCriteriaTypeHost,
string(MatchCriteriaTypeOriginalHost): MatchCriteriaTypeOriginalHost,
string(MatchCriteriaTypeTagged): MatchCriteriaTypeTagged,
string(MatchCriteriaTypeUser): MatchCriteriaTypeUser,
string(MatchCriteriaTypeLocalUser): MatchCriteriaTypeLocalUser,
}
func (s *matchParserListener) EnterCriteria(ctx *parser.CriteriaContext) {
func (s *matchParserListener) EnterCriteriaSingle(ctx *parser.CriteriaSingleContext) {
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext).ShiftHorizontal(s.matchContext.startCharacter)
location.ChangeBothLines(s.matchContext.line)
value := commonparser.ParseRawString(ctx.GetText(), commonparser.FullFeatures)
criteria, found := availableCriteria[value.Value]
criteria, found := availableCriteria[strings.ToLower(value.Value)]
if !found {
s.Errors = append(s.Errors, common.LSPError{
@ -97,6 +85,42 @@ func (s *matchParserListener) EnterCriteria(ctx *parser.CriteriaContext) {
}
}
func (s *matchParserListener) EnterCriteriaWithValue(ctx *parser.CriteriaWithValueContext) {
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext).ShiftHorizontal(s.matchContext.startCharacter)
location.ChangeBothLines(s.matchContext.line)
value := commonparser.ParseRawString(ctx.GetText(), commonparser.FullFeatures)
criteria, found := availableCriteria[strings.ToLower(value.Value)]
if !found {
s.Errors = append(s.Errors, common.LSPError{
Range: location,
Err: errors.New(fmt.Sprintf("Unknown criteria: %s; It must be one of: %s", ctx.GetText(), strings.Join(utils.KeysOfMap(availableCriteria), ", "))),
})
return
}
s.matchContext.currentEntry.Criteria = MatchCriteria{
LocationRange: location,
Type: criteria,
Value: value,
}
}
var availableCriteria = map[string]MatchCriteriaType{
string(MatchCriteriaTypeAll): MatchCriteriaTypeAll,
string(MatchCriteriaTypeCanonical): MatchCriteriaTypeCanonical,
string(MatchCriteriaTypeFinal): MatchCriteriaTypeFinal,
string(MatchCriteriaTypeExec): MatchCriteriaTypeExec,
string(MatchCriteriaTypeLocalNetwork): MatchCriteriaTypeLocalNetwork,
string(MatchCriteriaTypeHost): MatchCriteriaTypeHost,
string(MatchCriteriaTypeOriginalHost): MatchCriteriaTypeOriginalHost,
string(MatchCriteriaTypeTagged): MatchCriteriaTypeTagged,
string(MatchCriteriaTypeUser): MatchCriteriaTypeUser,
string(MatchCriteriaTypeLocalUser): MatchCriteriaTypeLocalUser,
}
func (s *matchParserListener) EnterSeparator(ctx *parser.SeparatorContext) {
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext).ShiftHorizontal(s.matchContext.startCharacter)
location.ChangeBothLines(s.matchContext.line)

View File

@ -12,6 +12,7 @@ type Match struct {
type MatchCriteriaType string
const (
MatchCriteriaTypeAll MatchCriteriaType = "all"
MatchCriteriaTypeCanonical MatchCriteriaType = "canonical"
MatchCriteriaTypeFinal MatchCriteriaType = "final"
MatchCriteriaTypeExec MatchCriteriaType = "exec"

View File

@ -4,23 +4,48 @@ null
null
null
null
null
null
null
null
null
null
null
null
null
null
'"'
token symbolic names:
null
COMMA
ALL
CANONICAL
FINAL
EXEC
LOCALNETWORK
HOST
ORIGINALHOST
TAGGED
USER
LOCALUSER
STRING
WHITESPACE
QUOTED_STRING
QUOTE
rule names:
root
matchEntry
entrySingle
entryWithValue
separator
criteria
values
value
criteriaSingle
criteriaWithValue
string
atn:
[4, 1, 4, 56, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 1, 0, 3, 0, 16, 8, 0, 1, 0, 1, 0, 3, 0, 20, 8, 0, 5, 0, 22, 8, 0, 10, 0, 12, 0, 25, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 31, 8, 1, 1, 1, 3, 1, 34, 8, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 3, 4, 41, 8, 4, 1, 4, 1, 4, 3, 4, 45, 8, 4, 5, 4, 47, 8, 4, 10, 4, 12, 4, 50, 9, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 0, 0, 7, 0, 2, 4, 6, 8, 10, 12, 0, 1, 2, 0, 2, 2, 4, 4, 56, 0, 15, 1, 0, 0, 0, 2, 28, 1, 0, 0, 0, 4, 35, 1, 0, 0, 0, 6, 37, 1, 0, 0, 0, 8, 40, 1, 0, 0, 0, 10, 51, 1, 0, 0, 0, 12, 53, 1, 0, 0, 0, 14, 16, 3, 2, 1, 0, 15, 14, 1, 0, 0, 0, 15, 16, 1, 0, 0, 0, 16, 23, 1, 0, 0, 0, 17, 19, 5, 3, 0, 0, 18, 20, 3, 2, 1, 0, 19, 18, 1, 0, 0, 0, 19, 20, 1, 0, 0, 0, 20, 22, 1, 0, 0, 0, 21, 17, 1, 0, 0, 0, 22, 25, 1, 0, 0, 0, 23, 21,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5, 0, 45, 44, 1, 0, 0, 0, 45, 46, 1, 0, 0, 0, 46, 7, 1, 0, 0, 0, 47, 48, 5, 13, 0, 0, 48, 9, 1, 0, 0, 0, 49, 51, 3, 12, 6, 0, 50, 49, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 58, 1, 0, 0, 0, 52, 54, 5, 1, 0, 0, 53, 55, 3, 12, 6, 0, 54, 53, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, 55, 57, 1, 0, 0, 0, 56, 52, 1, 0, 0, 0, 57, 60, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 11, 1, 0, 0, 0, 60, 58, 1, 0, 0, 0, 61, 62, 3, 18, 9, 0, 62, 13, 1, 0, 0, 0, 63, 65, 5, 15, 0, 0, 64, 63, 1, 0, 0, 0, 64, 65, 1, 0, 0, 0, 65, 66, 1, 0, 0, 0, 66, 68, 7, 0, 0, 0, 67, 69, 5, 15, 0, 0, 68, 67, 1, 0, 0, 0, 68, 69, 1, 0, 0, 0, 69, 15, 1, 0, 0, 0, 70, 72, 5, 15, 0, 0, 71, 70, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 75, 7, 1, 0, 0, 74, 76, 5, 15, 0, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 17, 1, 0, 0, 0, 77, 78, 7, 2, 0, 0, 78, 19, 1, 0, 0, 0, 13, 21, 25, 29, 36, 42, 45, 50, 54, 58, 64, 68, 71, 75]

View File

@ -1,5 +1,17 @@
COMMA=1
STRING=2
WHITESPACE=3
QUOTED_STRING=4
ALL=2
CANONICAL=3
FINAL=4
EXEC=5
LOCALNETWORK=6
HOST=7
ORIGINALHOST=8
TAGGED=9
USER=10
LOCALUSER=11
STRING=12
WHITESPACE=13
QUOTED_STRING=14
QUOTE=15
','=1
'"'=15

View File

@ -4,19 +4,52 @@ null
null
null
null
null
null
null
null
null
null
null
null
null
null
'"'
token symbolic names:
null
COMMA
ALL
CANONICAL
FINAL
EXEC
LOCALNETWORK
HOST
ORIGINALHOST
TAGGED
USER
LOCALUSER
STRING
WHITESPACE
QUOTED_STRING
QUOTE
rule names:
COMMA
ALL
CANONICAL
FINAL
EXEC
LOCALNETWORK
HOST
ORIGINALHOST
TAGGED
USER
LOCALUSER
STRING
WHITESPACE
QUOTED_STRING
QUOTE
channel names:
DEFAULT_TOKEN_CHANNEL
@ -26,4 +59,4 @@ mode names:
DEFAULT_MODE
atn:
[4, 0, 4, 39, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1, 0, 1, 0, 1, 1, 4, 1, 13, 8, 1, 11, 1, 12, 1, 14, 1, 2, 4, 2, 18, 8, 2, 11, 2, 12, 2, 19, 1, 3, 1, 3, 3, 3, 24, 8, 3, 1, 3, 1, 3, 1, 3, 5, 3, 29, 8, 3, 10, 3, 12, 3, 32, 9, 3, 1, 3, 3, 3, 35, 8, 3, 1, 3, 3, 3, 38, 8, 3, 0, 0, 4, 1, 1, 3, 2, 5, 3, 7, 4, 1, 0, 2, 5, 0, 9, 10, 13, 13, 32, 32, 35, 35, 44, 44, 2, 0, 9, 9, 32, 32, 44, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 1, 9, 1, 0, 0, 0, 3, 12, 1, 0, 0, 0, 5, 17, 1, 0, 0, 0, 7, 21, 1, 0, 0, 0, 9, 10, 5, 44, 0, 0, 10, 2, 1, 0, 0, 0, 11, 13, 8, 0, 0, 0, 12, 11, 1, 0, 0, 0, 13, 14, 1, 0, 0, 0, 14, 12, 1, 0, 0, 0, 14, 15, 1, 0, 0, 0, 15, 4, 1, 0, 0, 0, 16, 18, 7, 1, 0, 0, 17, 16, 1, 0, 0, 0, 18, 19, 1, 0, 0, 0, 19, 17, 1, 0, 0, 0, 19, 20, 1, 0, 0, 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8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 4, 11, 113, 8, 11, 11, 11, 12, 11, 114, 1, 12, 4, 12, 118, 8, 12, 11, 12, 12, 12, 119, 1, 13, 1, 13, 3, 13, 124, 8, 13, 1, 13, 1, 13, 1, 13, 5, 13, 129, 8, 13, 10, 13, 12, 13, 132, 9, 13, 1, 13, 3, 13, 135, 8, 13, 1, 13, 3, 13, 138, 8, 13, 1, 14, 1, 14, 0, 0, 15, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 1, 0, 20, 2, 0, 65, 65, 97, 97, 2, 0, 76, 76, 108, 108, 2, 0, 67, 67, 99, 99, 2, 0, 78, 78, 110, 110, 2, 0, 79, 79, 111, 111, 2, 0, 73, 73, 105, 105, 2, 0, 70, 70, 102, 102, 2, 0, 69, 69, 101, 101, 2, 0, 88, 88, 120, 120, 2, 0, 84, 84, 116, 116, 2, 0, 87, 87, 119, 119, 2, 0, 82, 82, 114, 114, 2, 0, 75, 75, 107, 107, 2, 0, 72, 72, 104, 104, 2, 0, 83, 83, 115, 115, 2, 0, 71, 71, 103, 103, 2, 0, 68, 68, 100, 100, 2, 0, 85, 85, 117, 117, 5, 0, 9, 10, 13, 13, 32, 32, 35, 35, 44, 44, 2, 0, 9, 9, 32, 32, 146, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 1, 31, 1, 0, 0, 0, 3, 33, 1, 0, 0, 0, 5, 37, 1, 0, 0, 0, 7, 47, 1, 0, 0, 0, 9, 53, 1, 0, 0, 0, 11, 58, 1, 0, 0, 0, 13, 71, 1, 0, 0, 0, 15, 76, 1, 0, 0, 0, 17, 89, 1, 0, 0, 0, 19, 96, 1, 0, 0, 0, 21, 101, 1, 0, 0, 0, 23, 112, 1, 0, 0, 0, 25, 117, 1, 0, 0, 0, 27, 121, 1, 0, 0, 0, 29, 139, 1, 0, 0, 0, 31, 32, 5, 44, 0, 0, 32, 2, 1, 0, 0, 0, 33, 34, 7, 0, 0, 0, 34, 35, 7, 1, 0, 0, 35, 36, 7, 1, 0, 0, 36, 4, 1, 0, 0, 0, 37, 38, 7, 2, 0, 0, 38, 39, 7, 0, 0, 0, 39, 40, 7, 3, 0, 0, 40, 41, 7, 4, 0, 0, 41, 42, 7, 3, 0, 0, 42, 43, 7, 5, 0, 0, 43, 44, 7, 2, 0, 0, 44, 45, 7, 0, 0, 0, 45, 46, 7, 1, 0, 0, 46, 6, 1, 0, 0, 0, 47, 48, 7, 6, 0, 0, 48, 49, 7, 5, 0, 0, 49, 50, 7, 3, 0, 0, 50, 51, 7, 0, 0, 0, 51, 52, 7, 1, 0, 0, 52, 8, 1, 0, 0, 0, 53, 54, 7, 7, 0, 0, 54, 55, 7, 8, 0, 0, 55, 56, 7, 7, 0, 0, 56, 57, 7, 2, 0, 0, 57, 10, 1, 0, 0, 0, 58, 59, 7, 1, 0, 0, 59, 60, 7, 4, 0, 0, 60, 61, 7, 2, 0, 0, 61, 62, 7, 0, 0, 0, 62, 63, 7, 1, 0, 0, 63, 64, 7, 3, 0, 0, 64, 65, 7, 7, 0, 0, 65, 66, 7, 9, 0, 0, 66, 67, 7, 10, 0, 0, 67, 68, 7, 4, 0, 0, 68, 69, 7, 11, 0, 0, 69, 70, 7, 12, 0, 0, 70, 12, 1, 0, 0, 0, 71, 72, 7, 13, 0, 0, 72, 73, 7, 4, 0, 0, 73, 74, 7, 14, 0, 0, 74, 75, 7, 9, 0, 0, 75, 14, 1, 0, 0, 0, 76, 77, 7, 4, 0, 0, 77, 78, 7, 11, 0, 0, 78, 79, 7, 5, 0, 0, 79, 80, 7, 15, 0, 0, 80, 81, 7, 5, 0, 0, 81, 82, 7, 3, 0, 0, 82, 83, 7, 0, 0, 0, 83, 84, 7, 1, 0, 0, 84, 85, 7, 13, 0, 0, 85, 86, 7, 4, 0, 0, 86, 87, 7, 14, 0, 0, 87, 88, 7, 9, 0, 0, 88, 16, 1, 0, 0, 0, 89, 90, 7, 9, 0, 0, 90, 91, 7, 0, 0, 0, 91, 92, 7, 15, 0, 0, 92, 93, 7, 15, 0, 0, 93, 94, 7, 7, 0, 0, 94, 95, 7, 16, 0, 0, 95, 18, 1, 0, 0, 0, 96, 97, 7, 17, 0, 0, 97, 98, 7, 14, 0, 0, 98, 99, 7, 7, 0, 0, 99, 100, 7, 11, 0, 0, 100, 20, 1, 0, 0, 0, 101, 102, 7, 1, 0, 0, 102, 103, 7, 4, 0, 0, 103, 104, 7, 2, 0, 0, 104, 105, 7, 0, 0, 0, 105, 106, 7, 1, 0, 0, 106, 107, 7, 17, 0, 0, 107, 108, 7, 14, 0, 0, 108, 109, 7, 7, 0, 0, 109, 110, 7, 11, 0, 0, 110, 22, 1, 0, 0, 0, 111, 113, 8, 18, 0, 0, 112, 111, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 24, 1, 0, 0, 0, 116, 118, 7, 19, 0, 0, 117, 116, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 26, 1, 0, 0, 0, 121, 123, 3, 29, 14, 0, 122, 124, 3, 25, 12, 0, 123, 122, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 130, 1, 0, 0, 0, 125, 126, 3, 23, 11, 0, 126, 127, 3, 25, 12, 0, 127, 129, 1, 0, 0, 0, 128, 125, 1, 0, 0, 0, 129, 132, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, 131, 134, 1, 0, 0, 0, 132, 130, 1, 0, 0, 0, 133, 135, 3, 23, 11, 0, 134, 133, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, 137, 1, 0, 0, 0, 136, 138, 3, 29, 14, 0, 137, 136, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 28, 1, 0, 0, 0, 139, 140, 5, 34, 0, 0, 140, 30, 1, 0, 0, 0, 7, 0, 114, 119, 123, 130, 134, 137, 0]

View File

@ -1,5 +1,17 @@
COMMA=1
STRING=2
WHITESPACE=3
QUOTED_STRING=4
ALL=2
CANONICAL=3
FINAL=4
EXEC=5
LOCALNETWORK=6
HOST=7
ORIGINALHOST=8
TAGGED=9
USER=10
LOCALUSER=11
STRING=12
WHITESPACE=13
QUOTED_STRING=14
QUOTE=15
','=1
'"'=15

View File

@ -33,18 +33,24 @@ func (s *BaseMatchListener) EnterMatchEntry(ctx *MatchEntryContext) {}
// ExitMatchEntry is called when production matchEntry is exited.
func (s *BaseMatchListener) ExitMatchEntry(ctx *MatchEntryContext) {}
// EnterEntrySingle is called when production entrySingle is entered.
func (s *BaseMatchListener) EnterEntrySingle(ctx *EntrySingleContext) {}
// ExitEntrySingle is called when production entrySingle is exited.
func (s *BaseMatchListener) ExitEntrySingle(ctx *EntrySingleContext) {}
// EnterEntryWithValue is called when production entryWithValue is entered.
func (s *BaseMatchListener) EnterEntryWithValue(ctx *EntryWithValueContext) {}
// ExitEntryWithValue is called when production entryWithValue is exited.
func (s *BaseMatchListener) ExitEntryWithValue(ctx *EntryWithValueContext) {}
// EnterSeparator is called when production separator is entered.
func (s *BaseMatchListener) EnterSeparator(ctx *SeparatorContext) {}
// ExitSeparator is called when production separator is exited.
func (s *BaseMatchListener) ExitSeparator(ctx *SeparatorContext) {}
// EnterCriteria is called when production criteria is entered.
func (s *BaseMatchListener) EnterCriteria(ctx *CriteriaContext) {}
// ExitCriteria is called when production criteria is exited.
func (s *BaseMatchListener) ExitCriteria(ctx *CriteriaContext) {}
// EnterValues is called when production values is entered.
func (s *BaseMatchListener) EnterValues(ctx *ValuesContext) {}
@ -57,6 +63,18 @@ func (s *BaseMatchListener) EnterValue(ctx *ValueContext) {}
// ExitValue is called when production value is exited.
func (s *BaseMatchListener) ExitValue(ctx *ValueContext) {}
// EnterCriteriaSingle is called when production criteriaSingle is entered.
func (s *BaseMatchListener) EnterCriteriaSingle(ctx *CriteriaSingleContext) {}
// ExitCriteriaSingle is called when production criteriaSingle is exited.
func (s *BaseMatchListener) ExitCriteriaSingle(ctx *CriteriaSingleContext) {}
// EnterCriteriaWithValue is called when production criteriaWithValue is entered.
func (s *BaseMatchListener) EnterCriteriaWithValue(ctx *CriteriaWithValueContext) {}
// ExitCriteriaWithValue is called when production criteriaWithValue is exited.
func (s *BaseMatchListener) ExitCriteriaWithValue(ctx *CriteriaWithValueContext) {}
// EnterString is called when production string is entered.
func (s *BaseMatchListener) EnterString(ctx *StringContext) {}

View File

@ -43,34 +43,85 @@ func matchlexerLexerInit() {
"DEFAULT_MODE",
}
staticData.LiteralNames = []string{
"", "','",
"", "','", "", "", "", "", "", "", "", "", "", "", "", "", "", "'\"'",
}
staticData.SymbolicNames = []string{
"", "COMMA", "STRING", "WHITESPACE", "QUOTED_STRING",
"", "COMMA", "ALL", "CANONICAL", "FINAL", "EXEC", "LOCALNETWORK", "HOST",
"ORIGINALHOST", "TAGGED", "USER", "LOCALUSER", "STRING", "WHITESPACE",
"QUOTED_STRING", "QUOTE",
}
staticData.RuleNames = []string{
"COMMA", "STRING", "WHITESPACE", "QUOTED_STRING",
"COMMA", "ALL", "CANONICAL", "FINAL", "EXEC", "LOCALNETWORK", "HOST",
"ORIGINALHOST", "TAGGED", "USER", "LOCALUSER", "STRING", "WHITESPACE",
"QUOTED_STRING", "QUOTE",
}
staticData.PredictionContextCache = antlr.NewPredictionContextCache()
staticData.serializedATN = []int32{
4, 0, 4, 39, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1,
0, 1, 0, 1, 1, 4, 1, 13, 8, 1, 11, 1, 12, 1, 14, 1, 2, 4, 2, 18, 8, 2,
11, 2, 12, 2, 19, 1, 3, 1, 3, 3, 3, 24, 8, 3, 1, 3, 1, 3, 1, 3, 5, 3, 29,
8, 3, 10, 3, 12, 3, 32, 9, 3, 1, 3, 3, 3, 35, 8, 3, 1, 3, 3, 3, 38, 8,
3, 0, 0, 4, 1, 1, 3, 2, 5, 3, 7, 4, 1, 0, 2, 5, 0, 9, 10, 13, 13, 32, 32,
35, 35, 44, 44, 2, 0, 9, 9, 32, 32, 44, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0,
0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 1, 9, 1, 0, 0, 0, 3, 12, 1, 0, 0,
0, 5, 17, 1, 0, 0, 0, 7, 21, 1, 0, 0, 0, 9, 10, 5, 44, 0, 0, 10, 2, 1,
0, 0, 0, 11, 13, 8, 0, 0, 0, 12, 11, 1, 0, 0, 0, 13, 14, 1, 0, 0, 0, 14,
12, 1, 0, 0, 0, 14, 15, 1, 0, 0, 0, 15, 4, 1, 0, 0, 0, 16, 18, 7, 1, 0,
0, 17, 16, 1, 0, 0, 0, 18, 19, 1, 0, 0, 0, 19, 17, 1, 0, 0, 0, 19, 20,
1, 0, 0, 0, 20, 6, 1, 0, 0, 0, 21, 23, 5, 34, 0, 0, 22, 24, 3, 5, 2, 0,
23, 22, 1, 0, 0, 0, 23, 24, 1, 0, 0, 0, 24, 30, 1, 0, 0, 0, 25, 26, 3,
3, 1, 0, 26, 27, 3, 5, 2, 0, 27, 29, 1, 0, 0, 0, 28, 25, 1, 0, 0, 0, 29,
32, 1, 0, 0, 0, 30,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1, 13, 1, 13, 5, 13, 129, 8, 13,
10, 13, 12, 13, 132, 9, 13, 1, 13, 3, 13, 135, 8, 13, 1, 13, 3, 13, 138,
8, 13, 1, 14, 1, 14, 0, 0, 15, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13,
7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 1, 0,
20, 2, 0, 65, 65, 97, 97, 2, 0, 76, 76, 108, 108, 2, 0, 67, 67, 99, 99,
2, 0, 78, 78, 110, 110, 2, 0, 79, 79, 111, 111, 2, 0, 73, 73, 105, 105,
2, 0, 70, 70, 102, 102, 2, 0, 69, 69, 101, 101, 2, 0, 88, 88, 120, 120,
2, 0, 84, 84, 116, 116, 2, 0, 87, 87, 119, 119, 2, 0, 82, 82, 114, 114,
2, 0, 75, 75, 107, 107, 2, 0, 72, 72, 104, 104, 2, 0, 83, 83, 115, 115,
2, 0, 71, 71, 103, 103, 2, 0, 68, 68, 100, 100, 2, 0, 85, 85, 117, 117,
5, 0, 9, 10, 13, 13, 32, 32, 35, 35, 44, 44, 2, 0, 9, 9, 32, 32, 146, 0,
1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0,
9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0,
0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0,
0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 1, 31, 1, 0,
0, 0, 3, 33, 1, 0, 0, 0, 5, 37, 1, 0, 0, 0, 7, 47, 1, 0, 0, 0, 9, 53, 1,
0, 0, 0, 11, 58, 1, 0, 0, 0, 13, 71, 1, 0, 0, 0, 15, 76, 1, 0, 0, 0, 17,
89, 1, 0, 0, 0, 19, 96, 1, 0, 0, 0, 21, 101, 1, 0, 0, 0, 23, 112, 1, 0,
0, 0, 25, 117, 1, 0, 0, 0, 27, 121, 1, 0, 0, 0, 29, 139, 1, 0, 0, 0, 31,
32, 5, 44, 0, 0, 32, 2, 1, 0, 0, 0, 33, 34, 7, 0, 0, 0, 34, 35, 7, 1, 0,
0, 35, 36, 7, 1, 0, 0, 36, 4, 1, 0, 0, 0, 37, 38, 7, 2, 0, 0, 38, 39, 7,
0, 0, 0, 39, 40, 7, 3, 0, 0, 40, 41, 7, 4, 0, 0, 41, 42, 7, 3, 0, 0, 42,
43, 7, 5, 0, 0, 43, 44, 7, 2, 0, 0, 44, 45, 7, 0, 0, 0, 45, 46, 7, 1, 0,
0, 46, 6, 1, 0, 0, 0, 47, 48, 7, 6, 0, 0, 48, 49, 7, 5, 0, 0, 49, 50, 7,
3, 0, 0, 50, 51, 7, 0, 0, 0, 51, 52, 7, 1, 0, 0, 52, 8, 1, 0, 0, 0, 53,
54, 7, 7, 0, 0, 54, 55, 7, 8, 0, 0, 55, 56, 7, 7, 0, 0, 56, 57, 7, 2, 0,
0, 57, 10, 1, 0, 0, 0, 58, 59, 7, 1, 0, 0, 59, 60, 7, 4, 0, 0, 60, 61,
7, 2, 0, 0, 61, 62, 7, 0, 0, 0, 62, 63, 7, 1, 0, 0, 63, 64, 7, 3, 0, 0,
64, 65, 7, 7, 0, 0, 65, 66, 7, 9, 0, 0, 66, 67, 7, 10, 0, 0, 67, 68, 7,
4, 0, 0, 68, 69, 7, 11, 0, 0, 69, 70, 7, 12, 0, 0, 70, 12, 1, 0, 0, 0,
71, 72, 7, 13, 0, 0, 72, 73, 7, 4, 0, 0, 73, 74, 7, 14, 0, 0, 74, 75, 7,
9, 0, 0, 75, 14, 1, 0, 0, 0, 76, 77, 7, 4, 0, 0, 77, 78, 7, 11, 0, 0, 78,
79, 7, 5, 0, 0, 79, 80, 7, 15, 0, 0, 80, 81, 7, 5, 0, 0, 81, 82, 7, 3,
0, 0, 82, 83, 7, 0, 0, 0, 83, 84, 7, 1, 0, 0, 84, 85, 7, 13, 0, 0, 85,
86, 7, 4, 0, 0, 86, 87, 7, 14, 0, 0, 87, 88, 7, 9, 0, 0, 88, 16, 1, 0,
0, 0, 89, 90, 7, 9, 0, 0, 90, 91, 7, 0, 0, 0, 91, 92, 7, 15, 0, 0, 92,
93, 7, 15, 0, 0, 93, 94, 7, 7, 0, 0, 94, 95, 7, 16, 0, 0, 95, 18, 1, 0,
0, 0, 96, 97, 7, 17, 0, 0, 97, 98, 7, 14, 0, 0, 98, 99, 7, 7, 0, 0, 99,
100, 7, 11, 0, 0, 100, 20, 1, 0, 0, 0, 101, 102, 7, 1, 0, 0, 102, 103,
7, 4, 0, 0, 103, 104, 7, 2, 0, 0, 104, 105, 7, 0, 0, 0, 105, 106, 7, 1,
0, 0, 106, 107, 7, 17, 0, 0, 107, 108, 7, 14, 0, 0, 108, 109, 7, 7, 0,
0, 109, 110, 7, 11, 0, 0, 110, 22, 1, 0, 0, 0, 111, 113, 8, 18, 0, 0, 112,
111, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 114, 115,
1, 0, 0, 0, 115, 24, 1, 0, 0, 0, 116, 118, 7, 19, 0, 0, 117, 116, 1, 0,
0, 0, 118, 119, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0,
120, 26, 1, 0, 0, 0, 121, 123, 3, 29, 14, 0, 122, 124, 3, 25, 12, 0, 123,
122, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 130, 1, 0, 0, 0, 125, 126,
3, 23, 11, 0, 126, 127, 3, 25, 12, 0, 127, 129, 1, 0, 0, 0, 128, 125, 1,
0, 0, 0, 129, 132, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, 130, 131, 1, 0, 0,
0, 131, 134, 1, 0, 0, 0, 132, 130, 1, 0, 0, 0, 133, 135, 3, 23, 11, 0,
134, 133, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, 137, 1, 0, 0, 0, 136,
138, 3, 29, 14, 0, 137, 136, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 28,
1, 0, 0, 0, 139, 140, 5, 34, 0, 0, 140, 30, 1, 0, 0, 0, 7, 0, 114, 119,
123, 130, 134, 137, 0,
}
deserializer := antlr.NewATNDeserializer(nil)
staticData.atn = deserializer.Deserialize(staticData.serializedATN)
@ -112,7 +163,18 @@ func NewMatchLexer(input antlr.CharStream) *MatchLexer {
// MatchLexer tokens.
const (
MatchLexerCOMMA = 1
MatchLexerSTRING = 2
MatchLexerWHITESPACE = 3
MatchLexerQUOTED_STRING = 4
MatchLexerALL = 2
MatchLexerCANONICAL = 3
MatchLexerFINAL = 4
MatchLexerEXEC = 5
MatchLexerLOCALNETWORK = 6
MatchLexerHOST = 7
MatchLexerORIGINALHOST = 8
MatchLexerTAGGED = 9
MatchLexerUSER = 10
MatchLexerLOCALUSER = 11
MatchLexerSTRING = 12
MatchLexerWHITESPACE = 13
MatchLexerQUOTED_STRING = 14
MatchLexerQUOTE = 15
)

View File

@ -14,18 +14,27 @@ type MatchListener interface {
// EnterMatchEntry is called when entering the matchEntry production.
EnterMatchEntry(c *MatchEntryContext)
// EnterEntrySingle is called when entering the entrySingle production.
EnterEntrySingle(c *EntrySingleContext)
// EnterEntryWithValue is called when entering the entryWithValue production.
EnterEntryWithValue(c *EntryWithValueContext)
// EnterSeparator is called when entering the separator production.
EnterSeparator(c *SeparatorContext)
// EnterCriteria is called when entering the criteria production.
EnterCriteria(c *CriteriaContext)
// EnterValues is called when entering the values production.
EnterValues(c *ValuesContext)
// EnterValue is called when entering the value production.
EnterValue(c *ValueContext)
// EnterCriteriaSingle is called when entering the criteriaSingle production.
EnterCriteriaSingle(c *CriteriaSingleContext)
// EnterCriteriaWithValue is called when entering the criteriaWithValue production.
EnterCriteriaWithValue(c *CriteriaWithValueContext)
// EnterString is called when entering the string production.
EnterString(c *StringContext)
@ -35,18 +44,27 @@ type MatchListener interface {
// ExitMatchEntry is called when exiting the matchEntry production.
ExitMatchEntry(c *MatchEntryContext)
// ExitEntrySingle is called when exiting the entrySingle production.
ExitEntrySingle(c *EntrySingleContext)
// ExitEntryWithValue is called when exiting the entryWithValue production.
ExitEntryWithValue(c *EntryWithValueContext)
// ExitSeparator is called when exiting the separator production.
ExitSeparator(c *SeparatorContext)
// ExitCriteria is called when exiting the criteria production.
ExitCriteria(c *CriteriaContext)
// ExitValues is called when exiting the values production.
ExitValues(c *ValuesContext)
// ExitValue is called when exiting the value production.
ExitValue(c *ValueContext)
// ExitCriteriaSingle is called when exiting the criteriaSingle production.
ExitCriteriaSingle(c *CriteriaSingleContext)
// ExitCriteriaWithValue is called when exiting the criteriaWithValue production.
ExitCriteriaWithValue(c *CriteriaWithValueContext)
// ExitString is called when exiting the string production.
ExitString(c *StringContext)
}

File diff suppressed because it is too large Load Diff

View File

@ -140,4 +140,135 @@ func TestIncompleteBetweenValuesExample(
}
}
func TestSimpleSingleCriteriaExample(
t *testing.T,
) {
input := "all"
match := NewMatch()
errors := match.Parse(input, 0, 0)
if len(errors) > 0 {
t.Fatalf("Expected no errors, but got %v", errors)
}
if !(len(match.Entries) == 1) {
t.Errorf("Expected 1 entries, but got %v", len(match.Entries))
}
if !(match.Entries[0].Criteria.Type == MatchCriteriaTypeAll) {
t.Errorf("Expected criteria to be of type 'all', but got %v", match.Entries[0])
}
if !(match.Entries[0].Values == nil) {
t.Errorf("Expected values to be nil, but got %v", match.Entries[0].Values)
}
}
func TestMixedCriteriaComplexExample(
t *testing.T,
) {
input := "all user root localnetwork 192.168.1.1 final"
match := NewMatch()
errors := match.Parse(input, 0, 0)
if len(errors) > 0 {
t.Fatalf("Expected no errors, but got %v", errors)
}
if !(len(match.Entries) == 4) {
t.Errorf("Expected 4 entries, but got %v", len(match.Entries))
}
if !(match.Entries[0].Criteria.Type == MatchCriteriaTypeAll) {
t.Errorf("Expected criteria to be of type 'all', but got %v", match.Entries[0])
}
if !(match.Entries[1].Criteria.Type == MatchCriteriaTypeUser) {
t.Errorf("Expected criteria to be of type 'user', but got %v", match.Entries[1])
}
if !(match.Entries[2].Criteria.Type == MatchCriteriaTypeLocalNetwork) {
t.Errorf("Expected criteria to be of type 'localnetwork', but got %v", match.Entries[2])
}
if !(match.Entries[3].Criteria.Type == MatchCriteriaTypeFinal) {
t.Errorf("Expected criteria to be of type 'final', but got %v", match.Entries[3])
}
if !(match.Entries[1].Values.Values[0].Value.Value == "root") {
t.Errorf("Expected value to be 'root', but got %v", match.Entries[1].Values.Values[0])
}
if !(match.Entries[2].Values.Values[0].Value.Value == "192.168.1.1") {
t.Errorf("Expected value to be '192.168.1.1', but got %v", match.Entries[2].Values.Values[0])
}
}
func TestIncompleteWithSingleCriteriaExample(
t *testing.T,
) {
input := `all `
match := NewMatch()
errors := match.Parse(input, 0, 0)
if len(errors) > 0 {
t.Fatalf("Expected no errors, but got %v", errors)
}
if !(len(match.Entries) == 1) {
t.Errorf("Expected 1 entries, but got %v", len(match.Entries))
}
if !(match.Entries[0].Criteria.Type == MatchCriteriaTypeAll) {
t.Errorf("Expected Host, but got %v", match.Entries[0])
}
if !(match.Entries[0].Values == nil) {
t.Errorf("Expected nil, but got %v", match.Entries[0].Values)
}
}
func TestIncompleteWithValueCriteriaExample(
t *testing.T,
) {
input := `user `
match := NewMatch()
errors := match.Parse(input, 0, 0)
if len(errors) > 0 {
t.Fatalf("Expected no errors, but got %v", errors)
}
if !(len(match.Entries) == 1) {
t.Errorf("Expected 1 entries, but got %v", len(match.Entries))
}
if !(match.Entries[0].Criteria.Type == MatchCriteriaTypeUser) {
t.Errorf("Expected User, but got %v", match.Entries[0])
}
if match.Entries[0].Values == nil {
t.Errorf("Expected slice, but got %v", match.Entries[0].Values)
}
}
func TestIncompleteExampleWithNotFullyTypedCriteriaExample(
t *testing.T,
) {
input := `us`
match := NewMatch()
errors := match.Parse(input, 0, 0)
if !(len(errors) == 1) {
t.Fatalf("Expected no errors, but got %v", errors)
}
if !(len(match.Entries) == 0) {
t.Errorf("Expected 0 entries, but got %v", len(match.Entries))
}
}

View File

@ -1,8 +1,8 @@
package sshconfig
import (
"config-lsp/handlers/ssh_config/indexes"
"config-lsp/handlers/ssh_config/ast"
"config-lsp/handlers/ssh_config/indexes"
protocol "github.com/tliron/glsp/protocol_3_16"
)
@ -13,4 +13,3 @@ type SSHDocument struct {
}
var DocumentParserMap = map[protocol.DocumentUri]*SSHDocument{}