From 7f930ec6b82542081bc3874120fcc0ac5641828a Mon Sep 17 00:00:00 2001 From: Fernando Dodino Date: Sat, 28 Dec 2024 09:06:00 -0300 Subject: [PATCH] Add comments to utils --- packages/client/src/highlighter.ts | 2 +- packages/client/src/test/highlighter/utils.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/client/src/highlighter.ts b/packages/client/src/highlighter.ts index f10e926..ac629d9 100644 --- a/packages/client/src/highlighter.ts +++ b/packages/client/src/highlighter.ts @@ -9,7 +9,7 @@ const convertToVSCPosition = (position: WollokPosition) => new vscode.Position(position.line, position.column) const convertToVSCTokens = (wollokNodesPlotter: WollokNodePlotter[]) => - excludeNullish(wollokNodesPlotter) + wollokNodesPlotter .filter(wollokNodePlotter => { const { range } = wollokNodePlotter return !!range && range.start && range.end diff --git a/packages/client/src/test/highlighter/utils.ts b/packages/client/src/test/highlighter/utils.ts index 7181945..d486582 100644 --- a/packages/client/src/test/highlighter/utils.ts +++ b/packages/client/src/test/highlighter/utils.ts @@ -1,14 +1,14 @@ import { excludeNullish, parse } from 'wollok-ts' import { readFileSync } from 'fs' -import { processCode } from '../../highlighter/tokenProvider' +import { processCode, processComments } from '../../highlighter/tokenProvider' import { WollokNodePlotter } from '../../highlighter/utils' export const readFileForTokenProvider = (filePath: string): WollokNodePlotter[] => { const parsedFile = parse.File(filePath) const docText = readFileSync(filePath, { encoding: 'utf-8' }) - const tp = parsedFile.tryParse(docText) + const parsedPackage = parsedFile.tryParse(docText) const splittedLines = docText.split('\n') - return excludeNullish(processCode(tp.members[0], splittedLines)) + return excludeNullish(processCode(parsedPackage.members[0], splittedLines)).concat(processComments(splittedLines)) } export const processedByTokenType = (processed: WollokNodePlotter[], tokenType: string): IterableIterator => processed.filter(token => token.tokenType === tokenType).values()