@stylable/language-service
Advanced tools
Comparing version 5.4.1-rc.1 to 5.5.0
@@ -848,14 +848,20 @@ "use strict"; | ||
const resolvedStates = collectStates(lastNode); | ||
if (Object.keys(resolvedStates).length) { | ||
const resolvedStateNode = lastNode.resolved.find((node) => { | ||
const states = node.symbol[`-st-states`]; | ||
return states && states[stateName] && states[stateName].type === 'enum'; | ||
const resolvedState = resolvedStates[stateName]; | ||
if (resolvedState && | ||
typeof resolvedState !== 'string' && | ||
(resolvedState.type === 'enum' || | ||
(index_internal_1.STCustomState.isTemplateState(resolvedState) && | ||
resolvedState.params[0].type === 'enum'))) { | ||
const resolvedStateNode = lastNode.resolved.find(({ symbol }) => { | ||
const states = symbol['-st-states']; | ||
return (states === null || states === void 0 ? void 0 : states[stateName]) === resolvedState; | ||
}); | ||
if (resolvedStateNode) { | ||
const resolvedState = resolvedStateNode.symbol[`-st-states`][stateName]; | ||
const enumStateParam = index_internal_1.STCustomState.isTemplateState(resolvedState) | ||
? resolvedState.params[0] | ||
: resolvedState; | ||
let existingInput = fullLineText.slice(0, position.character); | ||
existingInput = existingInput.slice(existingInput.lastIndexOf('(') + 1); | ||
if (typeof resolvedState !== 'string' && | ||
(resolvedState === null || resolvedState === void 0 ? void 0 : resolvedState.arguments.every((opt) => typeof opt === 'string'))) { | ||
const options = resolvedState.arguments; | ||
if (enumStateParam === null || enumStateParam === void 0 ? void 0 : enumStateParam.arguments.every((opt) => typeof opt === 'string')) { | ||
const options = enumStateParam.arguments; | ||
let filteredOptions = options.filter((opt) => opt.startsWith(existingInput)); | ||
@@ -862,0 +868,0 @@ filteredOptions = filteredOptions.length ? filteredOptions : options; |
import type { SignatureHelp } from 'vscode-languageserver'; | ||
import { StateParsedValue } from '@stylable/core/dist/index-internal'; | ||
import { StateParsedValue, TemplateStateParsedValue } from '@stylable/core/dist/index-internal'; | ||
import type { ProviderPosition } from '../completion-providers'; | ||
@@ -10,3 +10,3 @@ export declare function resolveStateTypeOrValidator(pos: ProviderPosition, line: string): string | boolean | null; | ||
}): boolean; | ||
export declare function resolveStateParams(stateDef: StateParsedValue): string; | ||
export declare function resolveStateParams(stateDef: StateParsedValue | TemplateStateParsedValue): string; | ||
//# sourceMappingURL=pseudo-class.d.ts.map |
@@ -139,3 +139,6 @@ "use strict"; | ||
const typeArguments = []; | ||
if (stateDef.arguments.length > 0) { | ||
if (index_internal_1.STCustomState.isTemplateState(stateDef)) { | ||
return resolveStateParams(stateDef.params[0]); | ||
} | ||
else if (stateDef.arguments.length > 0) { | ||
stateDef.arguments.forEach((arg) => { | ||
@@ -142,0 +145,0 @@ if (typeof arg === 'object') { |
{ | ||
"name": "@stylable/language-service", | ||
"version": "5.4.1-rc.1", | ||
"version": "5.5.0", | ||
"description": "Stylable Language Services - syntax highlighting, completions, hinting and more for the Stylable CSS preprocessor.", | ||
@@ -14,13 +14,13 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@file-services/types": "^7.0.1", | ||
"@file-services/typescript": "^7.0.1", | ||
"@stylable/code-formatter": "5.4.1-rc.1", | ||
"@stylable/core": "5.4.1-rc.1", | ||
"@file-services/types": "^7.2.0", | ||
"@file-services/typescript": "^7.2.0", | ||
"@stylable/code-formatter": "^5.5.0", | ||
"@stylable/core": "^5.5.0", | ||
"css-selector-tokenizer": "^0.8.0", | ||
"postcss": "^8.4.19", | ||
"postcss": "^8.4.20", | ||
"postcss-value-parser": "^4.2.0", | ||
"vscode-css-languageservice": "^6.2.1", | ||
"vscode-languageserver": "^8.0.2", | ||
"vscode-languageserver-textdocument": "^1.0.7", | ||
"vscode-uri": "^3.0.6" | ||
"vscode-languageserver-textdocument": "^1.0.8", | ||
"vscode-uri": "^3.0.7" | ||
}, | ||
@@ -27,0 +27,0 @@ "author": "Wix.com", |
@@ -1408,18 +1408,23 @@ import path, { dirname } from 'path'; | ||
const resolvedStates: MappedStates = collectStates(lastNode); | ||
if (Object.keys(resolvedStates).length) { | ||
const resolvedStateNode = lastNode.resolved.find((node: any) => { | ||
const states = node.symbol[`-st-states`]; | ||
return states && states[stateName] && states[stateName].type === 'enum'; | ||
const resolvedState = resolvedStates[stateName]; | ||
if ( | ||
resolvedState && | ||
typeof resolvedState !== 'string' && | ||
(resolvedState.type === 'enum' || | ||
(STCustomState.isTemplateState(resolvedState) && | ||
resolvedState.params[0].type === 'enum')) | ||
) { | ||
const resolvedStateNode = lastNode.resolved.find(({ symbol }: any) => { | ||
const states = symbol['-st-states']; | ||
return states?.[stateName] === resolvedState; | ||
}); | ||
if (resolvedStateNode) { | ||
const resolvedState = resolvedStateNode.symbol[`-st-states`]![stateName]; | ||
const enumStateParam = STCustomState.isTemplateState(resolvedState) | ||
? resolvedState.params[0] | ||
: resolvedState; | ||
let existingInput = fullLineText.slice(0, position.character); | ||
existingInput = existingInput.slice(existingInput.lastIndexOf('(') + 1); | ||
if ( | ||
typeof resolvedState !== 'string' && | ||
resolvedState?.arguments.every((opt) => typeof opt === 'string') | ||
) { | ||
const options = resolvedState.arguments as string[]; | ||
if (enumStateParam?.arguments.every((opt) => typeof opt === 'string')) { | ||
const options = enumStateParam.arguments as string[]; | ||
let filteredOptions = options.filter((opt: string) => | ||
@@ -1426,0 +1431,0 @@ opt.startsWith(existingInput) |
@@ -7,3 +7,7 @@ import postcssValueParser from 'postcss-value-parser'; | ||
} from 'vscode-languageserver'; | ||
import { StateParsedValue, STCustomState } from '@stylable/core/dist/index-internal'; | ||
import { | ||
StateParsedValue, | ||
STCustomState, | ||
TemplateStateParsedValue, | ||
} from '@stylable/core/dist/index-internal'; | ||
import type { ProviderPosition } from '../completion-providers'; | ||
@@ -205,5 +209,7 @@ | ||
export function resolveStateParams(stateDef: StateParsedValue) { | ||
export function resolveStateParams(stateDef: StateParsedValue | TemplateStateParsedValue): string { | ||
const typeArguments: string[] = []; | ||
if (stateDef.arguments.length > 0) { | ||
if (STCustomState.isTemplateState(stateDef)) { | ||
return resolveStateParams(stateDef.params[0]); | ||
} else if (stateDef.arguments.length > 0) { | ||
stateDef.arguments.forEach((arg) => { | ||
@@ -210,0 +216,0 @@ if (typeof arg === 'object') { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
549971
8950
0
+ Added@stylable/code-formatter@5.19.0(transitive)
+ Added@stylable/core@5.19.0(transitive)
+ Added@tokey/css-value-parser@0.1.4(transitive)
+ Added@tokey/imports-parser@1.0.0(transitive)
- Removed@stylable/code-formatter@5.4.1-rc.1(transitive)
- Removed@stylable/core@5.4.1-rc.1(transitive)
- Removed@tokey/imports-parser@0.1.2(transitive)
- Removeddeindent@0.1.0(transitive)
Updated@file-services/types@^7.2.0
Updated@stylable/core@^5.5.0
Updatedpostcss@^8.4.20
Updatedvscode-uri@^3.0.7