Improvements in tag highlighting.

This commit is contained in:
William Candillon 2013-01-02 16:35:49 +01:00 committed by nightwing
commit aaee55f115

View file

@ -35,9 +35,7 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var XQueryHighlightRules = function() {
var keywordMapper = this.createKeywordMapper({
keyword: "after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position"
}, "identifier");
var keywords = "after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position".split("|");
var nameStartChar = "[_A-Za-z]";
var nameChar = "[-\\._A-Za-z0-9]";
@ -71,8 +69,8 @@ var XQueryHighlightRules = function() {
next: "comment"
},
{
token: "text", // opening tag
regex: "<\\/?",
token: ["text", "meta.tag"], // opening tag
regex: "(<)(" + qname + ")",
next: "tag"
}, {
token: "constant", // number
@ -82,30 +80,21 @@ var XQueryHighlightRules = function() {
regex: "\\$" + eqname
}, {
token: "string",
regex: '".*?"'
}, {
token: "string",
regex: "'.*?'"
}, {
token: "string",
regex: "'.*?",
regex: "'",
next: "apos-string"
}, {
token: "string",
regex: '".*?',
regex: '"',
next: "quot-string"
}, {
token: "text",
regex: "\\s+"
}, {
token: "support.function",
regex: "\\w[\\w+_\\-:]+(?=\\()"
}, {
token: keywordMapper,
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
token: function(match) { if(keywords.indexOf(match) !== -1) { return "keyword" } else { return "support.function" } },
regex: eqname
}, {
token: "keyword.operator",
regex: "\\*|=|<|>|\\-|\\+"
regex: "\\*|:=|=|<|>|\\-|\\+"
}, {
token: "lparen",
regex: "[[({]"
@ -116,20 +105,32 @@ var XQueryHighlightRules = function() {
tag: [{
token: "text",
regex: ">",
regex: "\\/?>",
next: "start"
}, {
token: ["text", "meta.tag"],
regex: "(<\\/)(" + qname + ")",
next: "start"
}, {
token: "meta.tag",
regex: "[-_a-zA-Z0-9:]+"
regex: qname
}, {
token: "text",
regex: "\\s+"
}, {
token: "string",
regex: '".*?"'
regex: "'",
next: "apos-attr"
}, {
token: "string",
regex: '"',
next: "quot-attr"
}, {
token: "string",
regex: "'.*?'"
}, {
token: "text",
regex: "="
}],
pi: [{
@ -214,6 +215,24 @@ var XQueryHighlightRules = function() {
}, {
token: "string",
regex: ".*"
}],
"apos-attr": [{
token: "string",
regex: ".*?'",
next: "tag"
}, {
token: "string",
regex: ".*"
}],
"quot-attr": [{
token: "string",
regex: '.*?"',
next: "tag"
}, {
token: "string",
regex: ".*"
}]
};
};