diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-10-30 20:14:50 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2021-10-31 19:26:14 +0100 |
commit | cbf442d8fd9f72c567ebf9f036a219a9ff100487 (patch) | |
tree | a128345d9a9863bef7f3670da585bcb62d13cb34 /language-web/src/main/js/xtext/xtextServiceResults.ts | |
parent | feat(web): show error count on generate button (diff) | |
download | refinery-cbf442d8fd9f72c567ebf9f036a219a9ff100487.tar.gz refinery-cbf442d8fd9f72c567ebf9f036a219a9ff100487.tar.zst refinery-cbf442d8fd9f72c567ebf9f036a219a9ff100487.zip |
feat(web): semantic highlighting
Diffstat (limited to 'language-web/src/main/js/xtext/xtextServiceResults.ts')
-rw-r--r-- | language-web/src/main/js/xtext/xtextServiceResults.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/language-web/src/main/js/xtext/xtextServiceResults.ts b/language-web/src/main/js/xtext/xtextServiceResults.ts index 6c3d9daf..e32d49c3 100644 --- a/language-web/src/main/js/xtext/xtextServiceResults.ts +++ b/language-web/src/main/js/xtext/xtextServiceResults.ts | |||
@@ -198,3 +198,29 @@ export function isContentAssistResult(result: unknown): result is IContentAssist | |||
198 | return isDocumentStateResult(result) | 198 | return isDocumentStateResult(result) |
199 | && isArrayOfType(contentAssistResult.entries, isContentAssistEntry); | 199 | && isArrayOfType(contentAssistResult.entries, isContentAssistEntry); |
200 | } | 200 | } |
201 | |||
202 | export interface IHighlightingRegion { | ||
203 | offset: number; | ||
204 | |||
205 | length: number; | ||
206 | |||
207 | styleClasses: string[]; | ||
208 | } | ||
209 | |||
210 | export function isHighlightingRegion(value: unknown): value is IHighlightingRegion { | ||
211 | const region = value as IHighlightingRegion; | ||
212 | return typeof region === 'object' | ||
213 | && typeof region.offset === 'number' | ||
214 | && typeof region.length === 'number' | ||
215 | && isArrayOfType(region.styleClasses, (s): s is string => typeof s === 'string'); | ||
216 | } | ||
217 | |||
218 | export interface IHighlightingResult { | ||
219 | regions: IHighlightingRegion[]; | ||
220 | } | ||
221 | |||
222 | export function isHighlightingResult(result: unknown): result is IHighlightingResult { | ||
223 | const highlightingResult = result as IHighlightingResult; | ||
224 | return typeof highlightingResult === 'object' | ||
225 | && isArrayOfType(highlightingResult.regions, isHighlightingRegion); | ||
226 | } | ||