⚡️ Handle override and overrideAll better
Some checks failed
Build extension / build (push) Failing after 30s
Linter / lint (push) Has been cancelled
Some checks failed
Build extension / build (push) Failing after 30s
Linter / lint (push) Has been cancelled
This commit is contained in:
parent
25f4b44e57
commit
f3666b8d5c
2 changed files with 34 additions and 18 deletions
|
@ -89,15 +89,17 @@ export const iconDefinitionProvider =
|
|||
* - As a color name, like red
|
||||
*
|
||||
* JSON paths:
|
||||
* - (layers.{index}.)lineRendering.{index}.color
|
||||
* - (layers.{index}.)lineRendering.{index}.color.render
|
||||
* - (layers.{index}.)lineRendering.{index}.color.mappings.{index}.then
|
||||
* - (layers.{index}.)lineRendering.{index}.fillColor
|
||||
* - (layers.{index}.)lineRendering.{index}.fillColor.render
|
||||
* - (layers.{index}.)lineRendering.{index}.fillColor.mappings.{index}.then
|
||||
* - (layers.{index}.)pointRendering.{index}.marker.{index}.color
|
||||
* - (layers.{index}.)pointRendering.{index}.marker.{index}.color.render
|
||||
* - (layers.{index}.)pointRendering.{index}.marker.{index}.color.mappings.{index}.then
|
||||
* - (layers.{index}(.override).)lineRendering.{index}.color
|
||||
* - (layers.{index}(.override).)lineRendering.{index}.color.render
|
||||
* - (layers.{index}(.override).)lineRendering.{index}.color.mappings.{index}.then
|
||||
* - (layers.{index}(.override).)lineRendering.{index}.fillColor
|
||||
* - (layers.{index}(.override).)lineRendering.{index}.fillColor.render
|
||||
* - (layers.{index}(.override).)lineRendering.{index}.fillColor.mappings.{index}.then
|
||||
* - (layers.{index}(.override).)pointRendering.{index}.marker.{index}.color
|
||||
* - (layers.{index}(.override).)pointRendering.{index}.marker.{index}.color.render
|
||||
* - (layers.{index}(.override).)pointRendering.{index}.marker.{index}.color.mappings.{index}.then
|
||||
*
|
||||
* In all cases (layers.{index}.) can also be replaced by overrideAll
|
||||
*
|
||||
*/
|
||||
export const colorProvider = vscode.languages.registerColorProvider(
|
||||
|
@ -164,9 +166,9 @@ export const colorProvider = vscode.languages.registerColorProvider(
|
|||
findPaths(jsonParsed);
|
||||
|
||||
const regexes = [
|
||||
/^(layers.\d+.)?lineRendering.\d+.color((.render)|(.mappings.\d+.then))?$/,
|
||||
/^(layers.\d+.)?lineRendering.\d+.fillColor((.render)|(.mappings.\d+.then))?$/,
|
||||
/^(layers.\d+.)?pointRendering.\d+.marker.\d+.color((.render)|(.mappings.\d+.then))?$/,
|
||||
/^((layers\.\d+\.(override\.([+=])?)?)|(overrideAll\.))?lineRendering\.\d+\.color((\.render)|(\.mappings\.\d+\.then))?$/,
|
||||
/^((layers\.\d+\.(override\.([+=])?)?)|(overrideAll\.))?lineRendering.\d+.fillColor((.render)|(.mappings.\d+.then))?$/,
|
||||
/^((layers\.\d+\.(override\.([+=])?)?)|(overrideAll\.))?pointRendering.\d+.marker.\d+.color((.render)|(.mappings.\d+.then))?$/,
|
||||
];
|
||||
|
||||
regexes.forEach((regex) => {
|
||||
|
|
|
@ -20,7 +20,9 @@ import { JSONPath } from "jsonc-parser";
|
|||
* This provider will provide a list of existing tagRenderings for autocompletion
|
||||
*
|
||||
* JSON path:
|
||||
* - (layers.{index}.)tagRenderings.{index}(.builtin)
|
||||
* - (layers.{index}.(override).)tagRenderings.{index}(.builtin)
|
||||
* - overrideAll.tagRenderings.{index}(.builtin)
|
||||
* Also +/= characters around tagRenderings are supported
|
||||
*/
|
||||
export const tagRenderingCompletionProvider =
|
||||
vscode.languages.registerCompletionItemProvider(
|
||||
|
@ -43,7 +45,9 @@ export const tagRenderingCompletionProvider =
|
|||
const text = document.getText();
|
||||
const jsonPath = getCursorPath(text, position);
|
||||
|
||||
const regex = /^(layers.\d+.)?tagRenderings\.\d+(.builtin)?$/;
|
||||
// This technically also matches layers.1.tagRenderings+, and similar, but that's fine
|
||||
const regex =
|
||||
/^((layers\.\d+\.(override\.([+=])?)?)|(overrideAll\.))?tagRenderings(\+)?\.\d+(.builtin)?$/;
|
||||
if (regex.exec(jsonPath)) {
|
||||
const tagRenderings = await getTagRenderings();
|
||||
console.log(`Got ${tagRenderings.length} tagRenderings`);
|
||||
|
@ -63,7 +67,9 @@ export const tagRenderingCompletionProvider =
|
|||
* This provider will provide a definition for tagRenderings, allowing users to jump to the tagRendering definition
|
||||
*
|
||||
* JSON path:
|
||||
* - (layers.{index}.)tagRenderings.{index}(.builtin)
|
||||
* - (layers.{index}.(override).)tagRenderings.{index}(.builtin)
|
||||
* - overrideAll.tagRenderings.{index}(.builtin)
|
||||
* Also +/= characters around tagRenderings are supported
|
||||
*/
|
||||
export const tagRenderingDefinitionProvider =
|
||||
vscode.languages.registerDefinitionProvider(
|
||||
|
@ -82,7 +88,9 @@ export const tagRenderingDefinitionProvider =
|
|||
const jsonPath = getCursorPath(text, position);
|
||||
const rawJsonPath = getRawCursorPath(text, position);
|
||||
|
||||
const regex = /^(layers.\d.)?tagRenderings.\d*(.builtin)?$/;
|
||||
// This technically also matches layers.1.tagRenderings+, and similar, but that's fine
|
||||
const regex =
|
||||
/^((layers\.\d+\.(override\.([+=])?)?)|(overrideAll\.))?tagRenderings(\+)?\.\d+(.builtin)?$/;
|
||||
|
||||
if (regex.exec(jsonPath)) {
|
||||
const tagRendering = getValueFromPath(text, rawJsonPath);
|
||||
|
@ -171,6 +179,8 @@ export const tagRenderingDefinitionProvider =
|
|||
*
|
||||
* JSON path:
|
||||
* - (layers.{index}.)filter.{index}
|
||||
* - overrideAll.filter.{index}
|
||||
* Also +/= characters around filter are supported
|
||||
*/
|
||||
export const filterCompletionProvider =
|
||||
vscode.languages.registerCompletionItemProvider(
|
||||
|
@ -195,7 +205,8 @@ export const filterCompletionProvider =
|
|||
|
||||
console.log(jsonPath);
|
||||
|
||||
const regex = /^(layers.\d+.)?filter\.\d+$/;
|
||||
const regex =
|
||||
/^((layers\.\d+\.(override\.([+=])?)?)|(overrideAll\.))?filter(\+)?\.\d+$/;
|
||||
if (regex.exec(jsonPath)) {
|
||||
const filters = await getFilters();
|
||||
console.log(`Got ${filters.length} filters`);
|
||||
|
@ -216,6 +227,8 @@ export const filterCompletionProvider =
|
|||
*
|
||||
* JSON path:
|
||||
* - (layers.{index}.)filter.{index}
|
||||
* - overrideAll.filter.{index}
|
||||
* Also +/= characters around filter are supported
|
||||
*/
|
||||
export const filterDefinitionProvider =
|
||||
vscode.languages.registerDefinitionProvider(
|
||||
|
@ -234,7 +247,8 @@ export const filterDefinitionProvider =
|
|||
const jsonPath = getCursorPath(text, position);
|
||||
const rawJsonPath = getRawCursorPath(text, position);
|
||||
|
||||
const regex = /^(layers.\d.)?filter.\d*$/;
|
||||
const regex =
|
||||
/^((layers\.\d+\.(override\.([+=])?)?)|(overrideAll\.))?filter(\+)?\.\d+$/;
|
||||
|
||||
if (regex.exec(jsonPath)) {
|
||||
const filter = getValueFromPath(text, rawJsonPath);
|
||||
|
|
Loading…
Reference in a new issue