vscode-apollo 2.5.6 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +17 -0
- package/.github/workflows/E2E.yml +3 -2
- package/.github/workflows/build-prs.yml +2 -1
- package/.github/workflows/release.yml +2 -2
- package/.prettierignore +3 -0
- package/.semgrepignore +2 -0
- package/.vscode/settings.json +7 -2
- package/CHANGELOG.md +12 -0
- package/apollo.connectors.mapping.configuration.json +10 -0
- package/package.json +38 -4
- package/sampleWorkspace/connectors-community/.github/ISSUE_TEMPLATE/connector-bug-report.md +36 -0
- package/sampleWorkspace/connectors-community/.github/ISSUE_TEMPLATE/new-connector.md +10 -0
- package/sampleWorkspace/connectors-community/.github/renovate.json5 +3 -0
- package/sampleWorkspace/connectors-community/.vscode/extensions.json +3 -0
- package/sampleWorkspace/connectors-community/.vscode/settings.json +13 -0
- package/sampleWorkspace/connectors-community/.vscode/tasks.json +10 -0
- package/sampleWorkspace/connectors-community/README.md +108 -0
- package/sampleWorkspace/connectors-community/apollo.config.json +5 -0
- package/sampleWorkspace/connectors-community/connectors/.template/Dockerfile +5 -0
- package/sampleWorkspace/connectors-community/connectors/.template/README +46 -0
- package/sampleWorkspace/connectors-community/connectors/.template/connector.graphql +31 -0
- package/sampleWorkspace/connectors-community/connectors/.template/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/.template/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/JSONPlaceholder/README +12 -0
- package/sampleWorkspace/connectors-community/connectors/JSONPlaceholder/albums.graphql +48 -0
- package/sampleWorkspace/connectors-community/connectors/JSONPlaceholder/comments.graphql +54 -0
- package/sampleWorkspace/connectors-community/connectors/JSONPlaceholder/photos.graphql +54 -0
- package/sampleWorkspace/connectors-community/connectors/JSONPlaceholder/posts.graphql +51 -0
- package/sampleWorkspace/connectors-community/connectors/JSONPlaceholder/supergraph.yaml +26 -0
- package/sampleWorkspace/connectors-community/connectors/JSONPlaceholder/todos.graphql +51 -0
- package/sampleWorkspace/connectors-community/connectors/JSONPlaceholder/users.graphql +80 -0
- package/sampleWorkspace/connectors-community/connectors/TM-Forum/README.md +9 -0
- package/sampleWorkspace/connectors-community/connectors/TM-Forum/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/TM-Forum/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/TM-Forum/tmf622-ProductOrdering.graphql +296 -0
- package/sampleWorkspace/connectors-community/connectors/adobe-commerce-cloud/README.md +7 -0
- package/sampleWorkspace/connectors-community/connectors/adobe-commerce-cloud/addresses.graphql +30 -0
- package/sampleWorkspace/connectors-community/connectors/adobe-commerce-cloud/customer.graphql +77 -0
- package/sampleWorkspace/connectors-community/connectors/adobe-commerce-cloud/products.graphql +70 -0
- package/sampleWorkspace/connectors-community/connectors/adobe-commerce-cloud/router.yaml +24 -0
- package/sampleWorkspace/connectors-community/connectors/adobe-commerce-cloud/supergraph.yaml +14 -0
- package/sampleWorkspace/connectors-community/connectors/adobe-commerce-cloud/swagger.json +69226 -0
- package/sampleWorkspace/connectors-community/connectors/anthropic/Dockerfile +5 -0
- package/sampleWorkspace/connectors-community/connectors/anthropic/README +61 -0
- package/sampleWorkspace/connectors-community/connectors/anthropic/messages.graphql +258 -0
- package/sampleWorkspace/connectors-community/connectors/anthropic/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/anthropic/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/apollo-ecomm-simple/README +3 -0
- package/sampleWorkspace/connectors-community/connectors/apollo-ecomm-simple/connector.graphql +38 -0
- package/sampleWorkspace/connectors-community/connectors/apollo-ecomm-simple/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/apollo-ecomm-simple/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/apple/README +36 -0
- package/sampleWorkspace/connectors-community/connectors/apple/app-store-connect.graphql +100 -0
- package/sampleWorkspace/connectors-community/connectors/apple/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/apple/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/aws/README +125 -0
- package/sampleWorkspace/connectors-community/connectors/aws/dynamodb.graphql +130 -0
- package/sampleWorkspace/connectors-community/connectors/aws/json-responses/product-price.json +10 -0
- package/sampleWorkspace/connectors-community/connectors/aws/json-responses/products.json +53 -0
- package/sampleWorkspace/connectors-community/connectors/aws/lambda.graphql +179 -0
- package/sampleWorkspace/connectors-community/connectors/aws/router.yaml +54 -0
- package/sampleWorkspace/connectors-community/connectors/aws/supergraph.yaml +10 -0
- package/sampleWorkspace/connectors-community/connectors/bored/README.md +35 -0
- package/sampleWorkspace/connectors-community/connectors/bored/bored.graphql +87 -0
- package/sampleWorkspace/connectors-community/connectors/bored/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/common-room/README.md +23 -0
- package/sampleWorkspace/connectors-community/connectors/common-room/contacts.graphql +141 -0
- package/sampleWorkspace/connectors-community/connectors/common-room/json-responses/members_email_.json +61 -0
- package/sampleWorkspace/connectors-community/connectors/common-room/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/common-room/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/googlemaps/README.md +58 -0
- package/sampleWorkspace/connectors-community/connectors/googlemaps/distancematrix.graphql +155 -0
- package/sampleWorkspace/connectors-community/connectors/googlemaps/places-legacy.graphql +117 -0
- package/sampleWorkspace/connectors-community/connectors/googlemaps/places.graphql +399 -0
- package/sampleWorkspace/connectors-community/connectors/googlemaps/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/googlemaps/supergraph.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/googlemaps/timezone.graphql +64 -0
- package/sampleWorkspace/connectors-community/connectors/heygen/README +105 -0
- package/sampleWorkspace/connectors-community/connectors/heygen/avatars.graphql +79 -0
- package/sampleWorkspace/connectors-community/connectors/heygen/photo-avatars.graphql +454 -0
- package/sampleWorkspace/connectors-community/connectors/heygen/router.yaml +21 -0
- package/sampleWorkspace/connectors-community/connectors/heygen/supergraph.yaml +10 -0
- package/sampleWorkspace/connectors-community/connectors/jira/README +36 -0
- package/sampleWorkspace/connectors-community/connectors/jira/connector.graphql +197 -0
- package/sampleWorkspace/connectors-community/connectors/jira/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/jira/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/museums/README.md +40 -0
- package/sampleWorkspace/connectors-community/connectors/museums/chicagoArt.graphql +150 -0
- package/sampleWorkspace/connectors-community/connectors/museums/met.graphql +119 -0
- package/sampleWorkspace/connectors-community/connectors/museums/supergraph.yaml +10 -0
- package/sampleWorkspace/connectors-community/connectors/nws/README.md +45 -0
- package/sampleWorkspace/connectors-community/connectors/nws/alerts.graphql +598 -0
- package/sampleWorkspace/connectors-community/connectors/nws/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/odata/README +18 -0
- package/sampleWorkspace/connectors-community/connectors/odata/connector.graphql +171 -0
- package/sampleWorkspace/connectors-community/connectors/odata/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/odata/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/openai/README.md +61 -0
- package/sampleWorkspace/connectors-community/connectors/openai/assistants.graphql +285 -0
- package/sampleWorkspace/connectors-community/connectors/openai/chat-completions.graphql +169 -0
- package/sampleWorkspace/connectors-community/connectors/openai/models.graphql +47 -0
- package/sampleWorkspace/connectors-community/connectors/openai/router.yaml +24 -0
- package/sampleWorkspace/connectors-community/connectors/openai/supergraph.yaml +14 -0
- package/sampleWorkspace/connectors-community/connectors/pokeapi/README +45 -0
- package/sampleWorkspace/connectors-community/connectors/pokeapi/games.graphql +70 -0
- package/sampleWorkspace/connectors-community/connectors/pokeapi/locations.graphql +127 -0
- package/sampleWorkspace/connectors-community/connectors/pokeapi/moves.graphql +107 -0
- package/sampleWorkspace/connectors-community/connectors/pokeapi/pokemon.graphql +539 -0
- package/sampleWorkspace/connectors-community/connectors/pokeapi/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/pokeapi/supergraph.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/strapi/README.md +75 -0
- package/sampleWorkspace/connectors-community/connectors/strapi/router.yaml +19 -0
- package/sampleWorkspace/connectors-community/connectors/strapi/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/strapi/users.graphql +227 -0
- package/sampleWorkspace/connectors-community/connectors/stripe/README.md +83 -0
- package/sampleWorkspace/connectors-community/connectors/stripe/checkout.graphql +112 -0
- package/sampleWorkspace/connectors-community/connectors/stripe/core-resources.graphql +868 -0
- package/sampleWorkspace/connectors-community/connectors/stripe/payment-methods.graphql +526 -0
- package/sampleWorkspace/connectors-community/connectors/stripe/products.graphql +162 -0
- package/sampleWorkspace/connectors-community/connectors/stripe/router.yaml +26 -0
- package/sampleWorkspace/connectors-community/connectors/stripe/supergraph.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/supabase/README.md +80 -0
- package/sampleWorkspace/connectors-community/connectors/supabase/router.yaml +5 -0
- package/sampleWorkspace/connectors-community/connectors/supabase/supabase.graphql +143 -0
- package/sampleWorkspace/connectors-community/connectors/supabase/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/thespacedevs/README +46 -0
- package/sampleWorkspace/connectors-community/connectors/thespacedevs/agencies.graphql +193 -0
- package/sampleWorkspace/connectors-community/connectors/thespacedevs/api-throttle.graphql +33 -0
- package/sampleWorkspace/connectors-community/connectors/thespacedevs/astronauts.graphql +237 -0
- package/sampleWorkspace/connectors-community/connectors/thespacedevs/celestial-bodies.graphql +131 -0
- package/sampleWorkspace/connectors-community/connectors/thespacedevs/docking-events.graphql +3460 -0
- package/sampleWorkspace/connectors-community/connectors/thespacedevs/launches.graphql +1156 -0
- package/sampleWorkspace/connectors-community/connectors/thespacedevs/supergraph.yaml +77 -0
- package/sampleWorkspace/connectors-community/connectors/tint/README +35 -0
- package/sampleWorkspace/connectors-community/connectors/tint/accounts.graphql +69 -0
- package/sampleWorkspace/connectors-community/connectors/tint/router.yaml +21 -0
- package/sampleWorkspace/connectors-community/connectors/tint/social-feeds.graphql +62 -0
- package/sampleWorkspace/connectors-community/connectors/tint/supergraph.yaml +10 -0
- package/sampleWorkspace/connectors-community/connectors/todoist/README.md +48 -0
- package/sampleWorkspace/connectors-community/connectors/todoist/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/todoist/todoist.graphql +381 -0
- package/sampleWorkspace/connectors-community/connectors/trimblemaps/README +99 -0
- package/sampleWorkspace/connectors-community/connectors/trimblemaps/connector.graphql +66 -0
- package/sampleWorkspace/connectors-community/connectors/trimblemaps/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/trimblemaps/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/twilio/README.md +44 -0
- package/sampleWorkspace/connectors-community/connectors/twilio/messages.graphql +107 -0
- package/sampleWorkspace/connectors-community/connectors/twilio/router.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/twilio/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/usgs/earthquakes/README.md +44 -0
- package/sampleWorkspace/connectors-community/connectors/usgs/earthquakes/earthquakes.graphql +235 -0
- package/sampleWorkspace/connectors-community/connectors/usgs/earthquakes/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/usgs/earthquakes-nominatum/README.md +44 -0
- package/sampleWorkspace/connectors-community/connectors/usgs/earthquakes-nominatum/earthquake-simple.graphql +87 -0
- package/sampleWorkspace/connectors-community/connectors/usgs/earthquakes-nominatum/router.yaml +3 -0
- package/sampleWorkspace/connectors-community/connectors/usgs/earthquakes-nominatum/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/usps/README +36 -0
- package/sampleWorkspace/connectors-community/connectors/usps/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/usps/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/connectors/usps/tracking.graphql +118 -0
- package/sampleWorkspace/connectors-community/connectors/zendesk/README +36 -0
- package/sampleWorkspace/connectors-community/connectors/zendesk/connector.graphql +98 -0
- package/sampleWorkspace/connectors-community/connectors/zendesk/router.yaml +18 -0
- package/sampleWorkspace/connectors-community/connectors/zendesk/supergraph.yaml +6 -0
- package/sampleWorkspace/connectors-community/file-new/index.js +520 -0
- package/sampleWorkspace/connectors-community/package-lock.json +119 -0
- package/sampleWorkspace/connectors-community/package.json +20 -0
- package/sampleWorkspace/connectors-community/supergraph.yaml +6 -0
- package/sampleWorkspace/sampleWorkspace.code-workspace +29 -8
- package/src/__tests__/fixtures/textmate/test.apollo.connectors.mapping +213 -0
- package/src/__tests__/fixtures/textmate/test.connect.graphql +104 -0
- package/src/language-server/__tests__/fixtures/documents/functionCall.ts.snap +3 -3
- package/syntaxes/build.ts +266 -0
- package/syntaxes/connectors.mapping.json +532 -0
- package/syntaxes/connectors.mapping.yaml +440 -0
- package/syntaxes/graphql.connectors.json +426 -0
- package/syntaxes/graphql.connectors.yaml +254 -0
- package/syntaxes/graphql.json +8 -1
- package/syntaxes/publish.sh +43 -0
- package/syntaxes/tsconfig.json +6 -0
|
@@ -1,32 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"folders": [
|
|
3
3
|
{
|
|
4
|
-
"path": "localSchema"
|
|
4
|
+
"path": "localSchema"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
|
-
"path": "clientSchema"
|
|
7
|
+
"path": "clientSchema"
|
|
8
8
|
},
|
|
9
9
|
{
|
|
10
|
-
"path": "spotifyGraph"
|
|
10
|
+
"path": "spotifyGraph"
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
|
-
"path": "httpSchema"
|
|
13
|
+
"path": "httpSchema"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
|
-
"path": "localSchemaArray"
|
|
16
|
+
"path": "localSchemaArray"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
"path": "rover"
|
|
19
|
+
"path": "rover"
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
|
-
"path": "configFileTypes"
|
|
22
|
+
"path": "configFileTypes"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"path": "../src/language-server/__tests__/fixtures/documents"
|
|
25
|
+
"path": "../src/language-server/__tests__/fixtures/documents"
|
|
26
26
|
},
|
|
27
|
+
{
|
|
28
|
+
"path": "../src/__tests__/fixtures"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"path": "connectors-community/connectors"
|
|
32
|
+
}
|
|
27
33
|
],
|
|
28
34
|
"settings": {
|
|
29
35
|
"apollographql.devTools.showPanel": "detect",
|
|
30
36
|
"apollographql.devTools.serverPort": 7095,
|
|
37
|
+
"editor.tokenColorCustomizations": {
|
|
38
|
+
"textMateRules": [
|
|
39
|
+
{
|
|
40
|
+
"scope": [ "meta.repository" ],
|
|
41
|
+
"settings": { "fontStyle": "underline" }
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"scope": ["meta.repository.Comment.identifier"],
|
|
45
|
+
"settings": {
|
|
46
|
+
"foreground": "#ffffff17",
|
|
47
|
+
"fontStyle": ""
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
31
52
|
},
|
|
32
53
|
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# SYNTAX TEST "source.apollo.connectors.mapping"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
foo
|
|
5
|
+
#<--- repository.NamedFieldSelection
|
|
6
|
+
foo bar
|
|
7
|
+
#<--- repository.NamedFieldSelection
|
|
8
|
+
# ^ - repository.NamedFieldSelection
|
|
9
|
+
# ^^^ repository.NamedFieldSelection
|
|
10
|
+
alias: field
|
|
11
|
+
#<------------ repository.NamedFieldSelection
|
|
12
|
+
|
|
13
|
+
$( foo )
|
|
14
|
+
#<-------- repository.ExprPath
|
|
15
|
+
$( foo ).bar
|
|
16
|
+
#<------------ repository.ExprPath
|
|
17
|
+
# ^^^^ repository.PathStepDotAccess
|
|
18
|
+
$( foo )->bar
|
|
19
|
+
#<------------- repository.ExprPath
|
|
20
|
+
# ^^^^^ repository.PathStepArrowAccess
|
|
21
|
+
$( foo )->bar("asd")
|
|
22
|
+
#<-------------------- repository.ExprPath
|
|
23
|
+
# ^^^^^^^^^^^^ repository.PathStepArrowMethodArgs
|
|
24
|
+
# ^^^^^ repository.LitString
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
$( foo )->ma("asd") # not builtin function
|
|
28
|
+
# ^^ repository.PathStepArrowMethodArgs.beginCaptures.2
|
|
29
|
+
# ^^ - repository.PathStepArrowMethodArgs.beginCaptures.3
|
|
30
|
+
$( foo )->map("asd") # builtin function
|
|
31
|
+
# ^^^ repository.PathStepArrowMethodArgs.beginCaptures.2
|
|
32
|
+
# ^^^ repository.PathStepArrowMethodArgs.beginCaptures.3
|
|
33
|
+
|
|
34
|
+
$foo
|
|
35
|
+
#<-------- repository.VarPath
|
|
36
|
+
$foo.bar
|
|
37
|
+
#<-------- repository.VarPath
|
|
38
|
+
# ^^^^ repository.PathStepDotAccess
|
|
39
|
+
$foo->bar
|
|
40
|
+
#<--------- repository.VarPath
|
|
41
|
+
# ^^^^^ repository.PathStepArrowAccess
|
|
42
|
+
$foo->bar("asd")
|
|
43
|
+
#<---------------- repository.VarPath
|
|
44
|
+
# ^^^^^^^^^^^^ repository.PathStepArrowMethodArgs
|
|
45
|
+
# ^^^^^ repository.LitString
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
asd.bar
|
|
49
|
+
#<------- repository.KeyPath
|
|
50
|
+
# ^^^^ repository.PathStepDotAccess
|
|
51
|
+
asd->bar
|
|
52
|
+
#<-------- repository.KeyPath
|
|
53
|
+
# ^^^^^ repository.PathStepArrowAccess
|
|
54
|
+
asd->bar("asd")
|
|
55
|
+
#<--------------- repository.KeyPath
|
|
56
|
+
# ^^^^^^^^^^^^ repository.PathStepArrowMethodArgs
|
|
57
|
+
# ^^^^^ repository.LitString
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
"asd".bar
|
|
61
|
+
#<--------- repository.KeyPath
|
|
62
|
+
# ^^^^ repository.PathStepDotAccess
|
|
63
|
+
"asd"->bar
|
|
64
|
+
#<---------- repository.KeyPath
|
|
65
|
+
# ^^^^^ repository.PathStepArrowAccess
|
|
66
|
+
"asd"->bar("asd")
|
|
67
|
+
#<----------------- repository.KeyPath
|
|
68
|
+
# ^^^^^^^^^^^^ repository.PathStepArrowMethodArgs
|
|
69
|
+
# ^^^^^ repository.LitString
|
|
70
|
+
|
|
71
|
+
## AtPath
|
|
72
|
+
@
|
|
73
|
+
#<~ repository.AtPath
|
|
74
|
+
@.bar
|
|
75
|
+
#<----- repository.AtPath
|
|
76
|
+
#^^^^ repository.PathStepDotAccess
|
|
77
|
+
@->bar
|
|
78
|
+
#<------ repository.AtPath
|
|
79
|
+
#^^^^^ repository.PathStepArrowAccess
|
|
80
|
+
@->bar("asd")
|
|
81
|
+
#<------------- repository.AtPath
|
|
82
|
+
#^^^^^^^^^^^^ repository.PathStepArrowMethodArgs
|
|
83
|
+
# ^^^^^ repository.LitString
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@->a("asd")
|
|
87
|
+
# ^^^^^ repository.LitString
|
|
88
|
+
#^^^^ ^ - repository.LitString
|
|
89
|
+
@->a("a'd")
|
|
90
|
+
# ^^^^^ repository.LitString
|
|
91
|
+
#^^^^ ^ - repository.LitString
|
|
92
|
+
@->a("asd\\")
|
|
93
|
+
# ^^^^^^^ repository.LitString
|
|
94
|
+
#^^^^ ^ - repository.LitString
|
|
95
|
+
@->a("asd\"")
|
|
96
|
+
# ^^^^^^^ repository.LitString
|
|
97
|
+
#^^^^ ^ - repository.LitString
|
|
98
|
+
@->a("asd\\\"")
|
|
99
|
+
# ^^^^^^^^^ repository.LitString
|
|
100
|
+
#^^^^ ^ - repository.LitString
|
|
101
|
+
@->a("asd\\\\")
|
|
102
|
+
# ^^^^^^^^^ repository.LitString
|
|
103
|
+
#^^^^ ^ - repository.LitString
|
|
104
|
+
@->a("as\"d
|
|
105
|
+
# ^^^^^^ repository.LitString
|
|
106
|
+
#^^^^ - repository.LitString
|
|
107
|
+
as\\d")
|
|
108
|
+
#<----- repository.LitString
|
|
109
|
+
# ^ - repository.LitString
|
|
110
|
+
@->a('asd')
|
|
111
|
+
# ^^^^^ repository.LitString
|
|
112
|
+
#^^^^ ^ - repository.LitString
|
|
113
|
+
@->a('a"d')
|
|
114
|
+
# ^^^^^ repository.LitString
|
|
115
|
+
#^^^^ ^ - repository.LitString
|
|
116
|
+
@->a('asd\\')
|
|
117
|
+
# ^^^^^^^ repository.LitString
|
|
118
|
+
#^^^^ ^ - repository.LitString
|
|
119
|
+
@->a('asd\'')
|
|
120
|
+
# ^^^^^^^ repository.LitString
|
|
121
|
+
#^^^^ ^ - repository.LitString
|
|
122
|
+
@->a('asd\\\'')
|
|
123
|
+
# ^^^^^^^^^ repository.LitString
|
|
124
|
+
#^^^^ ^ - repository.LitString
|
|
125
|
+
@->a('asd\\\\')
|
|
126
|
+
# ^^^^^^^^^ repository.LitString
|
|
127
|
+
#^^^^ ^ - repository.LitString
|
|
128
|
+
@->a('as\'d
|
|
129
|
+
# ^^^^^^ repository.LitString
|
|
130
|
+
#^^^^ - repository.LitString
|
|
131
|
+
as\\d')
|
|
132
|
+
#<----- repository.LitString
|
|
133
|
+
# ^ - repository.LitString
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@->a(1)
|
|
137
|
+
# ^ repository.LitNumber
|
|
138
|
+
@->a(-1)
|
|
139
|
+
# ^^ repository.LitNumber
|
|
140
|
+
@->a(1.0)
|
|
141
|
+
# ^^^ repository.LitNumber
|
|
142
|
+
@->a(-1.0)
|
|
143
|
+
# ^^^^ repository.LitNumber
|
|
144
|
+
@->a(1.)
|
|
145
|
+
# ^^ repository.LitNumber
|
|
146
|
+
@->a(-1.)
|
|
147
|
+
# ^^^ repository.LitNumber
|
|
148
|
+
@->a(.0)
|
|
149
|
+
# ^^ repository.LitNumber
|
|
150
|
+
@->a(-.0)
|
|
151
|
+
# ^^^ repository.LitNumber
|
|
152
|
+
|
|
153
|
+
@->a(true)
|
|
154
|
+
# ^^^^ repository.LitPrimitive.patterns.2
|
|
155
|
+
@->a(false)
|
|
156
|
+
# ^^^^^ repository.LitPrimitive.patterns.2
|
|
157
|
+
@->a(null)
|
|
158
|
+
# ^^^^ repository.LitPrimitive.patterns.2
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
@->a({ foo: 1, bar: "baz" })
|
|
162
|
+
# ^^^^^^^^^^^^^^^^^^^^^^ repository.LitObject
|
|
163
|
+
# ^^^^^^ ^^^^^^^^^^ repository.LitProperty
|
|
164
|
+
# ^^ ^^ ^^ - repository.LitProperty
|
|
165
|
+
|
|
166
|
+
@->a({
|
|
167
|
+
# ^ repository.LitObject
|
|
168
|
+
a: 1,
|
|
169
|
+
#<--------------------------- repository.LitObject
|
|
170
|
+
# ^ repository.LitNumber
|
|
171
|
+
# ^^^^ repository.LitProperty
|
|
172
|
+
# ^ - repository.LitProperty
|
|
173
|
+
b: "asd",
|
|
174
|
+
#<--------------------------- repository.LitObject
|
|
175
|
+
# ^^^^^ repository.LitString
|
|
176
|
+
# ^^^^^^^^ repository.LitProperty
|
|
177
|
+
# ^ - repository.LitProperty
|
|
178
|
+
c: { foo: 1, bar: "baz" }
|
|
179
|
+
#<--------------------------- repository.LitObject
|
|
180
|
+
})
|
|
181
|
+
#<~ repository.LitObject
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@->a([ 1, "a", { foo: 1 } ])
|
|
185
|
+
# ^^^^^^^^^^^^^^^^^^^^^^ repository.LitArray
|
|
186
|
+
# ^ repository.LitNumber
|
|
187
|
+
# ^^^ repository.LitString
|
|
188
|
+
# ^^^^^^^^^^ repository.LitObject
|
|
189
|
+
# ^^^^^^ repository.LitProperty
|
|
190
|
+
# ^ repository.LitNumber
|
|
191
|
+
|
|
192
|
+
@->a([
|
|
193
|
+
# ^ repository.LitArray
|
|
194
|
+
1,
|
|
195
|
+
#<--------- repository.LitArray
|
|
196
|
+
# ^ repository.LitNumber
|
|
197
|
+
"a",
|
|
198
|
+
#<--------- repository.LitArray
|
|
199
|
+
# ^^^ repository.LitString
|
|
200
|
+
{foo:1}
|
|
201
|
+
#<--------- repository.LitArray
|
|
202
|
+
# ^^^^^^^ repository.LitObject
|
|
203
|
+
# ^^^^^ repository.LitProperty
|
|
204
|
+
# ^ repository.LitNumber
|
|
205
|
+
])
|
|
206
|
+
#<~ repository.LitArray
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@->a("y"->foo)
|
|
210
|
+
# ^^^^^ repository.LitPathTail
|
|
211
|
+
|
|
212
|
+
@->a("y" || "foo" + $asd)
|
|
213
|
+
# ^^ ^ repository.LitOpChainCenter
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# SYNTAX TEST "source.graphql"
|
|
2
|
+
|
|
3
|
+
type Query {
|
|
4
|
+
post(id: ID!): Post
|
|
5
|
+
@connect(
|
|
6
|
+
source: "jsonPlaceholder"
|
|
7
|
+
# ^^^^^^^^^^^^^^^^^^ - repository.JSONSelectionString
|
|
8
|
+
http: {
|
|
9
|
+
GET: "/posts/{ $args.id }"
|
|
10
|
+
# ^^^^^^^^^^^^^^^^^^^^^ repository.JSONSelectionString
|
|
11
|
+
# ^^^^^^^^^^^^ repository.JSONSelectionString.patterns.embedded
|
|
12
|
+
# ^^^^^^^^ ^ - repository.JSONSelectionString.patterns.embedded
|
|
13
|
+
# ^^^^^^^^ repository.VarPath
|
|
14
|
+
# ^^^^^^^^^^ ^^^ - repository.VarPath
|
|
15
|
+
POST: "/posts/{ $args.id }"
|
|
16
|
+
# ^^^^^^^^^^^^^^^^^^^^^ repository.JSONSelectionString
|
|
17
|
+
# ^^^^^^^^^^^^ repository.JSONSelectionString.patterns.embedded
|
|
18
|
+
# ^^^^^^^^ ^ - repository.JSONSelectionString.patterns.embedded
|
|
19
|
+
# ^^^^^^^^ repository.VarPath
|
|
20
|
+
# ^^^^^^^^^^ ^^^ - repository.VarPath
|
|
21
|
+
PATCH: "/posts/{ $args.id }"
|
|
22
|
+
# ^^^^^^^^^^^^^^^^^^^^^ repository.JSONSelectionString
|
|
23
|
+
# ^^^^^^^^^^^^ repository.JSONSelectionString.patterns.embedded
|
|
24
|
+
# ^^^^^^^^ ^ - repository.JSONSelectionString.patterns.embedded
|
|
25
|
+
# ^^^^^^^^ repository.VarPath
|
|
26
|
+
# ^^^^^^^^^^ ^^^ - repository.VarPath
|
|
27
|
+
DELETE: "/posts/{ $args.id }"
|
|
28
|
+
# ^^^^^^^^^^^^^^^^^^^^^ repository.JSONSelectionString
|
|
29
|
+
# ^^^^^^^^^^^^ repository.JSONSelectionString.patterns.embedded
|
|
30
|
+
# ^^^^^^^^ ^ - repository.JSONSelectionString.patterns.embedded
|
|
31
|
+
# ^^^^^^^^ repository.VarPath
|
|
32
|
+
# ^^^^^^^^^^ ^^^ - repository.VarPath
|
|
33
|
+
PUT: "/posts/{ $args.id }"
|
|
34
|
+
# ^^^^^^^^^^^^^^^^^^^^^ repository.JSONSelectionString
|
|
35
|
+
# ^^^^^^^^^^^^ repository.JSONSelectionString.patterns.embedded
|
|
36
|
+
# ^^^^^^^^ ^ - repository.JSONSelectionString.patterns.embedded
|
|
37
|
+
# ^^^^^^^^ repository.VarPath
|
|
38
|
+
# ^^^^^^^^^^ ^^^ - repository.VarPath
|
|
39
|
+
headers: [{ name: "Authorization", value: "Bearer {$config.apiKey}" }]
|
|
40
|
+
# ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ repository.JSONSelectionString
|
|
41
|
+
# ^^^^^^^^^^^^^^^^ repository.JSONSelectionString.patterns.embedded
|
|
42
|
+
# ^^^^^^^^^^^^^^ repository.VarPath
|
|
43
|
+
headers: [
|
|
44
|
+
{ name: "Authorization", value: "Bearer {$config.apiKey}" }
|
|
45
|
+
# ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ repository.JSONSelectionString
|
|
46
|
+
# ^^^^^^^^^^^^^^^^ repository.JSONSelectionString.patterns.embedded
|
|
47
|
+
# ^^^^^^^^^^^^^^ repository.VarPath
|
|
48
|
+
]
|
|
49
|
+
headers: [
|
|
50
|
+
{
|
|
51
|
+
name: "Authorization",
|
|
52
|
+
# ^^^^^^^^^^^^^^^ repository.JSONSelectionString
|
|
53
|
+
value: "Bearer {$config.apiKey}"
|
|
54
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^ repository.JSONSelectionString
|
|
55
|
+
# ^^^^^^^^^^^^^^ repository.JSONSelectionString.patterns.embedded repository.VarPath
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
body: """
|
|
59
|
+
# ^^^^^^^^^^^^^^^ - meta.embedded.block.connectors.mapping.graphql
|
|
60
|
+
# ^^^^^^^^^^^^^^^^^^^^^ meta.embedded.block.connectors.mapping.graphql
|
|
61
|
+
listing: {
|
|
62
|
+
#<------------------------------------ meta.embedded.block.connectors.mapping.graphql
|
|
63
|
+
# ^^^^^^^ repository.NamedSelection.patterns.3.beginCaptures.1
|
|
64
|
+
# ^ repository.SubSelection
|
|
65
|
+
title: $args.input.title
|
|
66
|
+
#<------------------------------------ meta.embedded.block.connectors.mapping.graphql
|
|
67
|
+
#<------------------------------------ repository.SubSelection
|
|
68
|
+
# ^^^^^ repository.NamedSelection.patterns.0.beginCaptures.1
|
|
69
|
+
# ^^^^^^^^^^^^^^^^^ repository.VarPath
|
|
70
|
+
}
|
|
71
|
+
#<------------------------------------ meta.embedded.block.connectors.mapping.graphql
|
|
72
|
+
#<-------- repository.SubSelection
|
|
73
|
+
"""
|
|
74
|
+
#^^^^^^^ meta.embedded.block.connectors.mapping.graphql
|
|
75
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.embedded.block.connectors.mapping.graphql
|
|
76
|
+
body: "foo: bar $.root { a }"
|
|
77
|
+
# ^^^^^^^^^^^^^^^^^^^^^ meta.embedded.line.connectors.mapping.graphql
|
|
78
|
+
#^^^^^^^^^^^^ ^ - meta.embedded.line.connectors.mapping.graphql
|
|
79
|
+
# ^^^^^^^^ ^ repository.NamedFieldSelection
|
|
80
|
+
# ^^^^^^ repository.VarPath
|
|
81
|
+
}
|
|
82
|
+
selection: """
|
|
83
|
+
# ^^^^^^^^^^^^^^^^^^ - meta.embedded.block.connectors.mapping.graphql
|
|
84
|
+
# ^^^^^^^^^^^^^^^^^^ meta.embedded.block.connectors.mapping.graphql
|
|
85
|
+
foo: bar
|
|
86
|
+
#<------------------------------------ meta.embedded.block.connectors.mapping.graphql
|
|
87
|
+
# ^^^^^^^^ repository.NamedFieldSelection
|
|
88
|
+
$.root {
|
|
89
|
+
#<------------------------------------ meta.embedded.block.connectors.mapping.graphql
|
|
90
|
+
# ^^^^^^ repository.VarPath
|
|
91
|
+
a
|
|
92
|
+
#<------------------------------------ meta.embedded.block.connectors.mapping.graphql
|
|
93
|
+
}
|
|
94
|
+
#<------------------------------------ meta.embedded.block.connectors.mapping.graphql
|
|
95
|
+
"""
|
|
96
|
+
#^^^^^ meta.embedded.block.connectors.mapping.graphql
|
|
97
|
+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.embedded.block.connectors.mapping.graphql
|
|
98
|
+
selection: "foo: bar $.root { a }"
|
|
99
|
+
# ^^^^^^^^^^^^^^^^^^^^^ meta.embedded.line.connectors.mapping.graphql
|
|
100
|
+
#^^^^^^^^^^^^^^^^^ ^ - meta.embedded.line.connectors.mapping.graphql
|
|
101
|
+
# ^^^^^^^^ ^ repository.NamedFieldSelection
|
|
102
|
+
# ^^^^^^ repository.VarPath
|
|
103
|
+
)
|
|
104
|
+
}
|
|
@@ -413,11 +413,11 @@
|
|
|
413
413
|
#^^^ source.ts variable.other.readwrite.ts
|
|
414
414
|
>(
|
|
415
415
|
#^ source.ts meta.brace.round.ts
|
|
416
|
-
> `query { test }`
|
|
416
|
+
> `query Q11 { test }`
|
|
417
417
|
#^^ source.ts
|
|
418
418
|
# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts
|
|
419
|
-
#
|
|
420
|
-
#
|
|
419
|
+
# ^^^^^^^^^^^^^^^^^^ source.ts string.template.ts
|
|
420
|
+
# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts
|
|
421
421
|
> )
|
|
422
422
|
#^^ source.ts
|
|
423
423
|
# ^ source.ts meta.brace.round.ts
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs, styleText } from "node:util";
|
|
3
|
+
import {
|
|
4
|
+
watch as nodeWatch,
|
|
5
|
+
readdir,
|
|
6
|
+
readFile,
|
|
7
|
+
writeFile,
|
|
8
|
+
} from "node:fs/promises";
|
|
9
|
+
import yaml from "js-yaml";
|
|
10
|
+
import { format, parse } from "node:path";
|
|
11
|
+
import { optimize } from "oniguruma-parser/optimizer";
|
|
12
|
+
|
|
13
|
+
const dir = import.meta.dirname;
|
|
14
|
+
const {
|
|
15
|
+
values: { watch, debug, snapshot },
|
|
16
|
+
positionals,
|
|
17
|
+
} = parseArgs({
|
|
18
|
+
options: {
|
|
19
|
+
watch: { type: "boolean", default: false },
|
|
20
|
+
debug: {
|
|
21
|
+
type: "boolean",
|
|
22
|
+
default: false,
|
|
23
|
+
description: "pattern names will be concatenated with the pattern path",
|
|
24
|
+
},
|
|
25
|
+
snapshot: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
default: false,
|
|
28
|
+
description: "pattern names will be replaced with the pattern path",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
allowPositionals: true,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const colors = {
|
|
35
|
+
variable: "red",
|
|
36
|
+
availableVariable: "green",
|
|
37
|
+
style: "red",
|
|
38
|
+
availableStyle: "green",
|
|
39
|
+
regex: "magenta",
|
|
40
|
+
reference: "yellow",
|
|
41
|
+
path: "blue",
|
|
42
|
+
filename: ["blue", "underline"],
|
|
43
|
+
} satisfies Record<string, Parameters<typeof styleText>[0]>;
|
|
44
|
+
|
|
45
|
+
const files = new Set<string>();
|
|
46
|
+
|
|
47
|
+
for (const filename of await readdir(dir)) {
|
|
48
|
+
if (positionals.length > 0) {
|
|
49
|
+
if (positionals.includes(parse(filename).base)) {
|
|
50
|
+
files.add(filename);
|
|
51
|
+
}
|
|
52
|
+
} else if (filename.endsWith(".yaml")) {
|
|
53
|
+
files.add(filename);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for (const filename of files) {
|
|
58
|
+
await build(filename);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (watch) {
|
|
62
|
+
(async () => {
|
|
63
|
+
try {
|
|
64
|
+
const watcher = nodeWatch(dir);
|
|
65
|
+
for await (const event of watcher) {
|
|
66
|
+
if (event.eventType === "rename" || event.eventType === "change") {
|
|
67
|
+
const filename = event.filename;
|
|
68
|
+
if (files.has(filename)) {
|
|
69
|
+
await build(filename);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} catch (err) {
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
})();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function build(filename: string) {
|
|
80
|
+
const pathOverrides = new WeakMap<object, string[]>();
|
|
81
|
+
console.log(`Building ${filename}...`);
|
|
82
|
+
const { name, ext } = parse(filename);
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const content = await readFile(format({ dir, name, ext }), "utf8");
|
|
86
|
+
const parsed = yaml.load(content, {
|
|
87
|
+
filename,
|
|
88
|
+
}) as Record<string, any>;
|
|
89
|
+
const { variables = {}, styles = {} } = parsed;
|
|
90
|
+
delete parsed.variables;
|
|
91
|
+
delete parsed.styles;
|
|
92
|
+
const paths = new Map<object, string[]>();
|
|
93
|
+
const knownPatterns = new Map<string, object>();
|
|
94
|
+
const output =
|
|
95
|
+
JSON.stringify(
|
|
96
|
+
parsed,
|
|
97
|
+
function replacer(key, value) {
|
|
98
|
+
const currentPath = (paths.get(this) || []).concat(key);
|
|
99
|
+
if (value && typeof value === "object" && key !== "") {
|
|
100
|
+
paths.set(value, currentPath);
|
|
101
|
+
}
|
|
102
|
+
const isPattern =
|
|
103
|
+
currentPath.length == 2 && currentPath[0] === "repository";
|
|
104
|
+
if (isPattern) {
|
|
105
|
+
knownPatterns.set("#" + key, value);
|
|
106
|
+
}
|
|
107
|
+
if (debug || snapshot) {
|
|
108
|
+
// attach the respository pattern name for debugging
|
|
109
|
+
if (
|
|
110
|
+
typeof value === "object" &&
|
|
111
|
+
value !== null &&
|
|
112
|
+
currentPath[0] === "repository" &&
|
|
113
|
+
// top-level patterns
|
|
114
|
+
(currentPath.length == 2 ||
|
|
115
|
+
// nested inline patterns
|
|
116
|
+
(currentPath.length > 2 &&
|
|
117
|
+
currentPath.at(-2) === "patterns" &&
|
|
118
|
+
typeof value === "object" &&
|
|
119
|
+
!("include" in value)) ||
|
|
120
|
+
// anything with a `debugName` property
|
|
121
|
+
"debugName" in value)
|
|
122
|
+
) {
|
|
123
|
+
let debugPath = currentPath;
|
|
124
|
+
if ("debugName" in value) {
|
|
125
|
+
debugPath = currentPath.slice(0, -1).concat(value.debugName);
|
|
126
|
+
pathOverrides.set(value, debugPath);
|
|
127
|
+
delete value.debugName;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (snapshot) {
|
|
131
|
+
// in snapshot mode we only are interested in the pattern names, not colorization details
|
|
132
|
+
delete value.name;
|
|
133
|
+
}
|
|
134
|
+
value.name =
|
|
135
|
+
(value.name ?? "meta") + "." + pathToString(debugPath, false);
|
|
136
|
+
}
|
|
137
|
+
if (snapshot && currentPath[0] === "repository" && key === "name") {
|
|
138
|
+
return pathToString(
|
|
139
|
+
pathOverrides.get(this) || currentPath.slice(0, -1),
|
|
140
|
+
false,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (typeof value === "string") {
|
|
145
|
+
if (key === "begin" || key === "end" || key === "match") {
|
|
146
|
+
let regexString = value.replace(
|
|
147
|
+
/\{\{([\w#.]+)\}\}/g,
|
|
148
|
+
function replacer(_, reference: string) {
|
|
149
|
+
let replaced: string;
|
|
150
|
+
const patternMatch = /^(#\w+)\.(\w+)/.exec(reference);
|
|
151
|
+
if (patternMatch) {
|
|
152
|
+
const [, pattern, key] = patternMatch;
|
|
153
|
+
const patternObject = knownPatterns.get(pattern);
|
|
154
|
+
if (!patternObject) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`Pattern not found: ${styleText(colors.reference, pattern)}` +
|
|
157
|
+
` accessed from ${pathToString(currentPath)}`,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
replaced = patternObject[key];
|
|
161
|
+
} else {
|
|
162
|
+
if (!(reference in variables)) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
`Variable not found: ${styleText(colors.variable, reference)}` +
|
|
165
|
+
` accessed from ${pathToString(currentPath)}` +
|
|
166
|
+
` with available variables: ${Object.keys(variables)
|
|
167
|
+
.map((v) => styleText(colors.availableVariable, v))
|
|
168
|
+
.join(", ")}`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
replaced = variables[reference];
|
|
172
|
+
}
|
|
173
|
+
return `(?:${verify(
|
|
174
|
+
replaced.replace(/\{\{(\w+)\}\}/g, replacer),
|
|
175
|
+
`reference ${styleText(colors.variable, reference)} accessed from ` +
|
|
176
|
+
pathToString(currentPath),
|
|
177
|
+
)})`;
|
|
178
|
+
},
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
return verify(regexString, pathToString(currentPath));
|
|
182
|
+
} else if (key === "include" && value.startsWith("#")) {
|
|
183
|
+
if (!(value.slice(1) in parsed.repository)) {
|
|
184
|
+
console.warn(
|
|
185
|
+
`Include pattern not found: ${styleText(colors.reference, value)} at path ${pathToString(currentPath)}`,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
} else if (key === "name" || key === "contentName") {
|
|
189
|
+
return value.replace(
|
|
190
|
+
/\{\{\.([\w]+)\}\}/g,
|
|
191
|
+
function replacer(_, reference: string) {
|
|
192
|
+
if (!(reference in styles)) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
`Style not found: ${styleText(colors.style, reference)}` +
|
|
195
|
+
` accessed from ${pathToString(currentPath)}` +
|
|
196
|
+
` with available styles: ${Object.keys(styles)
|
|
197
|
+
.map((v) => styleText(colors.availableStyle, v))
|
|
198
|
+
.join(", ")}`,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
return styles[reference].replace(
|
|
202
|
+
/\{\{\.([\w]+)\}\}/g,
|
|
203
|
+
replacer,
|
|
204
|
+
);
|
|
205
|
+
},
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
} else if (typeof value === "object" && value !== null) {
|
|
209
|
+
if (isPattern) {
|
|
210
|
+
if (typeof value.inherit === "string") {
|
|
211
|
+
const { inherit, ...rest } = value;
|
|
212
|
+
const inheritedPattern = knownPatterns.get(inherit);
|
|
213
|
+
if (!inheritedPattern) {
|
|
214
|
+
throw new Error(
|
|
215
|
+
`Pattern to inherit from not found: ${styleText(
|
|
216
|
+
colors.reference,
|
|
217
|
+
value.inherit,
|
|
218
|
+
)} at path ${pathToString(currentPath)}`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
if (inheritedPattern) {
|
|
222
|
+
value = { ...inheritedPattern, ...rest };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return value;
|
|
228
|
+
},
|
|
229
|
+
2,
|
|
230
|
+
) + "\n";
|
|
231
|
+
|
|
232
|
+
await writeFile(format({ dir, name, ext: ".json" }), output, "utf8");
|
|
233
|
+
} catch (err) {
|
|
234
|
+
console.log(
|
|
235
|
+
`Error building ${styleText(colors.filename, filename)}:\n`,
|
|
236
|
+
err instanceof Error ? err.message : err.toString(),
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function verify(regexString: string, context: string) {
|
|
241
|
+
try {
|
|
242
|
+
return optimize(regexString, {
|
|
243
|
+
rules: {
|
|
244
|
+
// end rules might reference begin rules, so we allow orphan backreferences
|
|
245
|
+
allowOrphanBackrefs: true,
|
|
246
|
+
// Follow `vscode-oniguruma` which enables this Oniguruma option by default (see https://github.com/RedCMD/TmLanguage-Syntax-Highlighter/blob/973552cf6ea41646d0f8b1c1eb2430408e36b25e/src/Providers/CodeActionsProvider.ts#L230)
|
|
247
|
+
captureGroup: true,
|
|
248
|
+
},
|
|
249
|
+
}).pattern;
|
|
250
|
+
} catch (err) {
|
|
251
|
+
throw new Error(
|
|
252
|
+
`Invalid regex: ${styleText(colors.regex, regexString)} in context: ${context}\n${err}`,
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function pathToString(path: string[], colorize = true) {
|
|
257
|
+
const text = path.reduce(
|
|
258
|
+
(acc, part) =>
|
|
259
|
+
acc +
|
|
260
|
+
(colorize && isFinite(+part)
|
|
261
|
+
? "[" + part + "]"
|
|
262
|
+
: (acc ? "." : "") + part),
|
|
263
|
+
"",
|
|
264
|
+
);
|
|
265
|
+
return colorize ? styleText(colors.path, text) : text;
|
|
266
|
+
}
|