-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66228 from Microsoft/octref/customCSSData
css.experimental.customData
- Loading branch information
Showing
7 changed files
with
100 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as path from 'path'; | ||
import { workspace, WorkspaceFolder } from 'vscode'; | ||
|
||
interface ExperimentalConfig { | ||
experimental?: { | ||
customData?: string[] | ||
}; | ||
} | ||
|
||
export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFolder[] | undefined): string[] { | ||
const dataPaths: string[] = []; | ||
|
||
if (!workspaceFolders) { | ||
return dataPaths; | ||
} | ||
|
||
workspaceFolders.forEach(wf => { | ||
const allCssConfig = workspace.getConfiguration(undefined, wf.uri); | ||
const wfCSSConfig = allCssConfig.inspect<ExperimentalConfig>('css'); | ||
if ( | ||
wfCSSConfig && | ||
wfCSSConfig.workspaceFolderValue && | ||
wfCSSConfig.workspaceFolderValue.experimental && | ||
wfCSSConfig.workspaceFolderValue.experimental.customData | ||
) { | ||
|
||
wfCSSConfig.workspaceFolderValue.experimental.customData.forEach(p => [ | ||
dataPaths.push(path.resolve(wf.uri.fsPath, p)) | ||
]); | ||
} | ||
}); | ||
|
||
return dataPaths; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
extensions/css-language-features/server/src/utils/languageFacts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { CSSData } from 'vscode-css-languageservice'; | ||
|
||
export function parseCSSData(source: string): CSSData { | ||
let rawData: any; | ||
|
||
try { | ||
rawData = JSON.parse(source); | ||
} catch (err) { | ||
return {}; | ||
} | ||
|
||
return { | ||
properties: rawData.properties || [], | ||
atDirectives: rawData.atdirectives || [], | ||
pseudoClasses: rawData.pseudoclasses || [], | ||
pseudoElements: rawData.pseudoelements || [] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters