Skip to content

Commit

Permalink
Changing boolean to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Dec 31, 2024
1 parent 24e740c commit f29cde5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 deletions.
35 changes: 17 additions & 18 deletions packages/client/src/highlighter/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const tokenTypeObj = {
'If': 'property',
'Import': 'namespace',
'Keyword': 'keyword',
'Literal_bool': 'keyword',
'Literal_bool': 'enum',
'Literal_number': 'number',
'Literal_string': 'string',
'Literal': 'property',
Expand Down Expand Up @@ -84,31 +84,30 @@ export const keywords = {
// Standard token types:
// ID Description
export const tokenTypes = [
'namespace', // For identifiers that declare or reference a namespace, module, or package.
'class', // For identifiers that declare or reference a class type.
'object', //No es parte de los tipos por default
'comment', // For tokens that represent a comment.
'decorator', // For identifiers that declare or reference decorators and annotations.
'enum', // For identifiers that declare or reference an enumeration type.
'interface', // For identifiers that declare or reference an interface type.
'struct', // For identifiers that declare or reference a struct type.
'typeParameter', // For identifiers that declare or reference a type parameter.
'type', // For identifiers that declare or reference a type that is not covered above.
'parameter', // For identifiers that declare or reference a function or method parameters.
'variable', // For identifiers that declare or reference a local or global variable.
'property', // For identifiers that declare or reference a member property, member field, or member variable.
'enumMember', // For identifiers that declare or reference an enumeration property, constant, or member.
'decorator', // For identifiers that declare or reference decorators and annotations.
'event', // For identifiers that declare an event property.
'function', // For identifiers that declare a function.
'method', // For identifiers that declare a member function or method.
'macro', // For identifiers that declare a macro.
'label', // For identifiers that declare a label.
'comment', // For tokens that represent a comment.
'string', // For tokens that represent a string literal.
'interface', // For identifiers that declare or reference an interface type.
'keyword', // For tokens that represent a language keyword.
'label', // For identifiers that declare a label.
'macro', // For identifiers that declare a macro.
'method', // For identifiers that declare a member function or method.
'namespace', // For identifiers that declare or reference a namespace, module, or package.
'number', // For tokens that represent a number literal.
'regexp', // For tokens that represent a regular expression literal.
'object', //No es parte de los tipos por default
'operator', // For tokens that represent an operator.
'comment',
'parameter', // For identifiers that declare or reference a function or method parameters.
'property', // For identifiers that declare or reference a member property, member field, or member variable.
'regexp', // For tokens that represent a regular expression literal.
'string', // For tokens that represent a string literal.
'struct', // For identifiers that declare or reference a struct type.
'type', // For identifiers that declare or reference a type that is not covered above.
'typeParameter', // For identifiers that declare or reference a type parameter.
'variable', // For identifiers that declare or reference a local or global variable.
]

export function plotter(start: { ln, col, len }, kind: string): WollokNodePlotter {
Expand Down
19 changes: 6 additions & 13 deletions packages/client/src/test/highlighter/literals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ suite('literals sample', () => {
expect(var3Range.start).toEqual({ line: 4, column: 2 })
expect(var3Range.end).toEqual({ line: 4, column: 5 })

const booleanRange = nextRange()
expect(booleanRange.start).toEqual({ line: 4, column: 14 })
expect(booleanRange.end).toEqual({ line: 4, column: 18 })

const const2Range = nextRange()
expect(const2Range.start).toEqual({ line: 5, column: 2 })
expect(const2Range.end).toEqual({ line: 5, column: 7 })
Expand Down Expand Up @@ -124,18 +120,15 @@ suite('literals sample', () => {
expect(nameValueRange.end).toEqual({ line: 3, column: 23 })
})

test('highlights parameter', () => {
const variableTokens = processedByTokenType(processed, 'parameter')

const nextRange = () => variableTokens.next().value.range
test('highlights boolean', () => {
const operatorTokens = processedByTokenType(processed, 'enum')

const parameterInClosureDefinitionRange = nextRange()
expect(parameterInClosureDefinitionRange.start).toEqual({ line: 6, column: 18 })
expect(parameterInClosureDefinitionRange.end).toEqual({ line: 6, column: 23 })
const nextRange = () => operatorTokens.next().value.range

const parameterInClosureUseRange = nextRange()
expect(parameterInClosureUseRange.start).toEqual({ line: 6, column: 27 })
expect(parameterInClosureUseRange.end).toEqual({ line: 6, column: 32 })
const booleanRange = nextRange()
expect(booleanRange.start).toEqual({ line: 4, column: 14 })
expect(booleanRange.end).toEqual({ line: 4, column: 18 })
})

test('highlights parameter', () => {
Expand Down

0 comments on commit f29cde5

Please sign in to comment.