1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
diff --git a/src/lsp/providers/diagnostics/diagnosticsProvider.ts b/src/lsp/providers/diagnostics/diagnosticsProvider.ts
index 1c98a391dfe30bdfd994e1c474d0c5251b6fdc42..91ca0e3eedd6db523fbaf2a96198b659330771ab 100644
--- a/src/lsp/providers/diagnostics/diagnosticsProvider.ts
+++ b/src/lsp/providers/diagnostics/diagnosticsProvider.ts
@@ -197,8 +197,11 @@ return null
}
let message = `The screen '${match.groups.screen}' does not exist in your theme config.`
+ let suggestions: string[] = []
let suggestion = closest(match.groups.screen, screens)
+
if (suggestion) {
+ suggestions.push(suggestion)
message += ` Did you mean '${suggestion}'?`
}
@@ -219,6 +222,7 @@ severity === 'error'
? DiagnosticSeverity.Error
: DiagnosticSeverity.Warning,
message,
+ suggestions,
})
})
})
@@ -261,8 +265,11 @@ continue
}
let message = `The variant '${variant}' does not exist.`
+ let suggestions: string[] = []
let suggestion = closest(variant, state.variants)
+
if (suggestion) {
+ suggestions.push(suggestion)
message += ` Did you mean '${suggestion}'?`
}
@@ -283,6 +290,7 @@ severity === 'error'
? DiagnosticSeverity.Error
: DiagnosticSeverity.Warning,
message,
+ suggestions,
})
}
})
@@ -337,6 +345,7 @@ return `${acc}.${cur}`
}, '')
let message: string
+ let suggestions: string[] = []
if (isValid(value)) {
// The value resolves successfully, but we need to check that there
@@ -374,24 +383,24 @@ keys[keys.length - 1],
Object.keys(parentValue).filter((key) => isValid(parentValue[key]))
)
if (closestValidKey) {
- message += ` Did you mean '${stitch([
- ...keys.slice(0, keys.length - 1),
- closestValidKey,
- ])}'?`
+ suggestions.push(
+ stitch([...keys.slice(0, keys.length - 1), closestValidKey])
+ )
+ message += ` Did you mean '${suggestions[0]}'?`
}
}
} else {
message = `'${match.groups.key}' was found but does not resolve to a string.`
if (isObject(value)) {
- let firstValidKey = Object.keys(value).find((key) =>
+ let validKeys = Object.keys(value).filter((key) =>
isValid(value[key])
)
- if (firstValidKey) {
- message += ` Did you mean something like '${stitch([
- ...keys,
- firstValidKey,
- ])}'?`
+ if (validKeys.length) {
+ suggestions.push(
+ ...validKeys.map((validKey) => stitch([...keys, validKey]))
+ )
+ message += ` Did you mean something like '${suggestions[0]}'?`
}
}
}
@@ -421,6 +430,7 @@ severity === 'error'
? DiagnosticSeverity.Error
: DiagnosticSeverity.Warning,
message,
+ suggestions,
})
})
})
@@ -464,11 +474,15 @@ return null
}
let message = `'${match.groups.value}' is not a valid group.`
+ let suggestions: string[] = []
+
if (match.groups.value === 'preflight') {
+ suggestions.push('base')
message += ` Did you mean 'base'?`
} else {
let suggestion = closest(match.groups.value, valid)
if (suggestion) {
+ suggestions.push(suggestion)
message += ` Did you mean '${suggestion}'?`
}
}
@@ -490,6 +504,7 @@ severity === 'error'
? DiagnosticSeverity.Error
: DiagnosticSeverity.Warning,
message,
+ suggestions,
})
})
})
|