From 4b61b2dc09bc85b1c6735f70395360f005cd6bd5 Mon Sep 17 00:00:00 2001 From: mbehzad Date: Thu, 14 Nov 2024 08:32:40 +0100 Subject: [PATCH] Fix #175: add missing enums for the AST node types. To match vscode-css-languageservice@5.1.1 values. this will fix variables in the `MediaQuery` being recognized as `FunctionParameter` and be ignored. --- fixtures/e2e/_variables.scss | 1 + fixtures/e2e/definition/main.scss | 2 ++ .../e2e/suite/definition/definitions.test.ts | 6 ++++++ src/unsafe/types/nodes.ts | 16 ++++++++++++++-- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/fixtures/e2e/_variables.scss b/fixtures/e2e/_variables.scss index 2ecf66b4..ce99fc17 100644 --- a/fixtures/e2e/_variables.scss +++ b/fixtures/e2e/_variables.scss @@ -1 +1,2 @@ $variable: 'value'; +$variable2: min-width 1200px; diff --git a/fixtures/e2e/definition/main.scss b/fixtures/e2e/definition/main.scss index 8516f4da..adc8d693 100644 --- a/fixtures/e2e/definition/main.scss +++ b/fixtures/e2e/definition/main.scss @@ -2,4 +2,6 @@ content: $variable + function(); @include mixin(); + + @media ($variable2) {}; } diff --git a/src/unsafe/test/e2e/suite/definition/definitions.test.ts b/src/unsafe/test/e2e/suite/definition/definitions.test.ts index 1cdec099..82ac410d 100644 --- a/src/unsafe/test/e2e/suite/definition/definitions.test.ts +++ b/src/unsafe/test/e2e/suite/definition/definitions.test.ts @@ -18,6 +18,12 @@ describe('SCSS Definition Test', () => { await testDefinition(docUri, position(2, 13), expectedLocation); }); + it('should find definition for variables in media', async () => { + const expectedDocumentUri = getDocUri('_variables.scss'); + const expectedLocation = sameLineLocation(expectedDocumentUri, 2, 1, 11); + await testDefinition(docUri, position(6, 12), expectedLocation); + }); + it('should find definition for functions', async () => { const expectedDocumentUri = getDocUri('_functions.scss'); const expectedLocation = sameLineLocation(expectedDocumentUri, 1, 1, 9); diff --git a/src/unsafe/types/nodes.ts b/src/unsafe/types/nodes.ts index 8be2ab48..c530bdcc 100644 --- a/src/unsafe/types/nodes.ts +++ b/src/unsafe/types/nodes.ts @@ -49,7 +49,8 @@ export enum NodeType { For, Each, While, - MixinContent, + MixinContentReference, + MixinContentDeclaration, Media, Keyframe, FontFace, @@ -67,7 +68,18 @@ export enum NodeType { AtApplyRule, CustomPropertyDeclaration, CustomPropertySet, - ListEntry + ListEntry, + Supports, + SupportsCondition, + NamespacePrefix, + GridLine, + Plugin, + UnknownAtRule, + Use, + ModuleConfiguration, + Forward, + ForwardVisibility, + Module } export interface INode {