diff --git a/packages/client/src/highlighter/tokenProvider.ts b/packages/client/src/highlighter/tokenProvider.ts index d5bf1b2..395e25b 100644 --- a/packages/client/src/highlighter/tokenProvider.ts +++ b/packages/client/src/highlighter/tokenProvider.ts @@ -1,4 +1,4 @@ -import { Assignment, Class, Describe, Field, If, Import, KEYWORDS, last, Literal, match, Method, New, Node, Package, Parameter, Program, Reference, Return, Self, Send, Singleton, Super, Test, Throw, Try, Variable, when } from 'wollok-ts' +import { Assignment, Class, Describe, Field, If, Import, KEYWORDS, last, Literal, match, Method, NamedArgument, New, Node, Package, Parameter, Program, Reference, Return, Self, Send, Singleton, Super, Test, Throw, Try, Variable, when } from 'wollok-ts' import { keywords, plotter, tokenTypeObj } from './definitions' import { WollokNodePlotter } from './utils' @@ -147,6 +147,11 @@ function processNode(node: Node, textDocument: string[], context: NodeContext[]) defaultKeywordPlotter(node), ], references: undefined, })), + when(NamedArgument)(node => ({ + result: [ + generatePlotterForNode(node), + ], references: undefined, + })), when(Parameter)(node => { const { line, column, word } = getLine(node, textDocument) const col = column + word.indexOf(node.name) diff --git a/packages/client/src/test/highlighter/class.test.ts b/packages/client/src/test/highlighter/class.test.ts index 0fe70bc..a98c80e 100644 --- a/packages/client/src/test/highlighter/class.test.ts +++ b/packages/client/src/test/highlighter/class.test.ts @@ -91,6 +91,18 @@ suite('a class sample', () => { expect(birthdateDefinitionRange.start).toEqual({ line: 2, column: 15 }) expect(birthdateDefinitionRange.end).toEqual({ line: 2, column: 24 }) + const dayNamedArgumentRange = nextRange() + expect(dayNamedArgumentRange.start).toEqual({ line: 2, column: 36 }) + expect(dayNamedArgumentRange.end).toEqual({ line: 2, column: 39 }) + + const monthNamedArgumentRange = nextRange() + expect(monthNamedArgumentRange.start).toEqual({ line: 2, column: 45 }) + expect(monthNamedArgumentRange.end).toEqual({ line: 2, column: 50 }) + + const yearNamedArgumentRange = nextRange() + expect(yearNamedArgumentRange.start).toEqual({ line: 2, column: 56 }) + expect(yearNamedArgumentRange.end).toEqual({ line: 2, column: 60 }) + const energyInFlyMethodRange1 = nextRange() expect(energyInFlyMethodRange1.start).toEqual({ line: 5, column: 4 }) expect(energyInFlyMethodRange1.end).toEqual({ line: 5, column: 10 }) diff --git a/packages/client/src/test/highlighter/inheritance.test.ts b/packages/client/src/test/highlighter/inheritance.test.ts index d2f3db7..03ce864 100644 --- a/packages/client/src/test/highlighter/inheritance.test.ts +++ b/packages/client/src/test/highlighter/inheritance.test.ts @@ -116,6 +116,18 @@ suite('inheritance sample', () => { const energyVarFromBirdRange = nextRange() expect(energyVarFromBirdRange.start).toEqual({ line: 1, column: 6 }) expect(energyVarFromBirdRange.end).toEqual({ line: 1, column: 12 }) + + const energyAsNamedParameterRange = nextRange() + expect(energyAsNamedParameterRange.start).toEqual({ line: 5, column: 28 }) + expect(energyAsNamedParameterRange.end).toEqual({ line: 5, column: 34 }) + + const energyAsNamedParameter2Range = nextRange() + expect(energyAsNamedParameter2Range.start).toEqual({ line: 7, column: 32 }) + expect(energyAsNamedParameter2Range.end).toEqual({ line: 7, column: 38 }) + + const energyAsNamedParameter3Range = nextRange() + expect(energyAsNamedParameter3Range.start).toEqual({ line: 9, column: 38 }) + expect(energyAsNamedParameter3Range.end).toEqual({ line: 9, column: 44 }) }) test('highlights global variables', () => { diff --git a/packages/client/src/test/highlighter/program.test.ts b/packages/client/src/test/highlighter/program.test.ts index 9548cf5..97449bb 100644 --- a/packages/client/src/test/highlighter/program.test.ts +++ b/packages/client/src/test/highlighter/program.test.ts @@ -95,6 +95,10 @@ suite('a program sample', () => { expect(firstProgramDefinitionRange.start).toEqual({ line: 0, column: 8 }) expect(firstProgramDefinitionRange.end).toEqual({ line: 0, column: 12 }) + const messageNamedArgumentForExceptionRange = nextRange() + expect(messageNamedArgumentForExceptionRange.start).toEqual({ line: 3, column: 40 }) + expect(messageNamedArgumentForExceptionRange.end).toEqual({ line: 3, column: 47 }) + const secondProgramDefinitionRange = nextRange() expect(secondProgramDefinitionRange.start).toEqual({ line: 11, column: 8 }) expect(secondProgramDefinitionRange.end).toEqual({ line: 11, column: 19 })