Files
owl/tools/owl-vision/scripts/syntax_parts/xpath.mjs
T
Bastien Fafchamps (bafa) 34489a2494 [IMP] owl-vision: syntax scripts, single quotes attributes and slot props highlight and switch below command
This commit adds the following:

- Syntax builder scripts to make syntaxes easier to read and edit
- Syntax highlight in single quote attributes
- Syntax highlight for slot props
- Basic syntax highlight for xpaths
- Added `Switch Below` command

This commit fixes the following:

- Using `Switch Besides` or `Switch Below` does not open a new panel if one was already open
- Fixed missing space in component's snippet indentation
2023-11-02 14:38:31 +01:00

106 lines
3.1 KiB
JavaScript

import { createAttributePatterns, createPattern } from "../syntax_builder_utils.mjs";
const xpathPattern = [createPattern("xpath", {
patterns: [
{
begin: "\\[",
beginCaptures: {
"0": {
name: "punctuation.definition",
}
},
end: "\\]",
endCaptures: {
"0": {
name: "punctuation.definition",
}
},
patterns: [
{
begin: "'",
beginCaptures: {
"0": {
name: "punctuation.definition",
}
},
end: "'",
endCaptures: {
"0": {
name: "punctuation.definition",
}
},
contentName: "string.quoted.single",
},
{
begin: "\\\"",
beginCaptures: {
"0": {
name: "punctuation.definition",
}
},
end: "\\\"",
endCaptures: {
"0": {
name: "punctuation.definition",
}
},
contentName: "string.quoted.double",
},
{
match: "(@)([a-zA-Z0-9_:\\-]+)\\b",
captures: {
"1": {
name: "punctuation.definition",
},
"2": {
name: "entity.other.attribute-name",
}
}
},
{
match: "(\\(|\\))",
name: "meta.brace.round",
},
{
match: "[0-9]+(\\.[0-9]+)?",
name: "constant.numeric.decimal",
},
{
match: "\\b(hasclass)\\b",
captures: {
"1": {
name: "entity.name.function",
},
}
},
]
},
{
match: "/{1,2}",
name: "text",
},
{
match: "(?<!@)([A-Z][a-zA-Z]+)\\b",
captures: {
"1": {
name: "entity.name.type.class",
}
}
},
{
match: "(?<!@)([a-z][a-zA-Z0-9_:.]+|[abiqsuw])\\b",
captures: {
"1": {
name: "entity.name.tag",
}
}
},
]
})];
export const xpathAttributes = createAttributePatterns("xpath-attributes", {
match: "expr",
attributeName: "owl.xml.attribute owl.xml.attribute.xpath",
patterns: xpathPattern,
});