Skip to content

Commit 277ad5c

Browse files
committed
feat: update grammar for sfhttp to support better color coding including of XML or JSON POST bodies
1 parent 6b0fcd4 commit 277ad5c

File tree

3 files changed

+62
-29
lines changed

3 files changed

+62
-29
lines changed

packages/vscode-extension/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,8 @@
12941294
"extensions": [
12951295
".sfhttp",
12961296
".http"
1297-
]
1297+
],
1298+
"configuration": "./syntax/sfhttp-language.json"
12981299
},
12991300
{
13001301
"id": "xml",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"comments": {
3+
"lineComment": "#"
4+
},
5+
"brackets": [
6+
["{", "}"],
7+
["[", "]"],
8+
["<", ">"]
9+
],
10+
"autoClosingPairs": [
11+
{ "open": "{", "close": "}" },
12+
{ "open": "[", "close": "]" },
13+
{ "open": "(", "close": ")" },
14+
{ "open": "\"", "close": "\"" },
15+
{ "open": "'", "close": "'" }
16+
],
17+
"surroundingPairs": [
18+
{ "open": "{", "close": "}" },
19+
{ "open": "[", "close": "]" },
20+
{ "open": "(", "close": ")" },
21+
{ "open": "\"", "close": "\"" },
22+
{ "open": "'", "close": "'" }
23+
]
24+
}
Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,44 @@
11
{
2-
"name": "Salesforce http API",
32
"scopeName": "source.sfhttp",
4-
"patterns": [{ "include": "#method-and-headers" }],
5-
"repository": {
6-
"method-and-headers": {
7-
"patterns": [{ "include": "#method-and-url" }, { "include": "#header" }],
8-
"end": "\\r?\\n\\r?\\n"
9-
},
10-
"method-and-url": {
3+
"name": "Salesforce HTTP API",
4+
"patterns": [
5+
{
6+
"name": "meta.request-line.sfhttp",
7+
"match": "^(GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD)\\s+([^\\s]+)",
118
"captures": {
12-
"1": { "name": "http.sf.method" },
13-
"2": { "name": "http.sf.url" }
14-
},
15-
"match": "(?i)^(GET|POST|PUT|DELETE|PATCH) (.*)$\\n?",
16-
"name": "meta.http.sf.method-url"
9+
"1": { "name": "keyword.control.http.method.sfhttp" },
10+
"2": { "name": "string.unquoted.url.path.sfhttp" }
11+
}
1712
},
18-
"header": {
13+
{
14+
"name": "meta.header.sfhttp",
15+
"match": "^([A-Za-z-]+):(\\s*)(.+)$",
1916
"captures": {
20-
"1": { "name": "http.sf.header.name" },
21-
"2": { "name": "http.sf.header.value" }
22-
},
23-
"match": "(?i)^([a-z]+)[ ]*:[ ]*([a-z]+)$\\n?",
24-
"name": "meta.http.sf.header"
17+
"1": { "name": "keyword.other.http.header.name.sfhttp" },
18+
"3": { "name": "string.unquoted.header.value.sfhttp" }
19+
}
2520
},
26-
"comment": {
27-
"captures": {
28-
"1": {
29-
"name": "http.sf.method.comment"
30-
}
31-
},
32-
"match": "(//).*$\\n?",
33-
"name": "comment.line.double-slash"
21+
{ "include": "#json-block" },
22+
{ "include": "#xml-block" },
23+
{ "include": "#graphql-block" }
24+
],
25+
"repository": {
26+
"json-block": {
27+
"begin": "^(?=\\s*[\\{\\[])",
28+
"end": "^(?=\\s*$)",
29+
"patterns": [{ "include": "source.json" }]
30+
},
31+
"xml-block": {
32+
"begin": "^(?=\\s*<\\?*[^\\s>]+)",
33+
"end": "^(?=\\s*$)",
34+
"patterns": [{ "include": "text.xml" }]
35+
},
36+
"graphql-block": {
37+
"begin": "^(?=\\s*\\{\\s*(query|mutation|subscription)?\\s*\\{?)",
38+
"end": "^(?=\\s*$)",
39+
"patterns": [{ "include": "source.graphql" }]
3440
}
35-
}
41+
},
42+
"fileTypes": ["sfhttp"],
43+
"uuid": "3f1cda14-9d21-4b13-aaa4-2b9f57dbf6c0"
3644
}

0 commit comments

Comments
 (0)