diff --git a/newtests/lsp/findReferences/__fixtures__/match.js b/newtests/lsp/findReferences/__fixtures__/match.js new file mode 100644 index 00000000000..4d8336f567c --- /dev/null +++ b/newtests/lsp/findReferences/__fixtures__/match.js @@ -0,0 +1,12 @@ +// @flow + +declare const x: mixed; + +const e = match (x) { + [const a]: a, + {foo: const a}: a, + {const a}: a, + 1 as const a: a, + 2 as a: a, + const a: a, +}; diff --git a/newtests/lsp/findReferences/__snapshots__/match-as-const.json b/newtests/lsp/findReferences/__snapshots__/match-as-const.json new file mode 100644 index 00000000000..477ce6024ae --- /dev/null +++ b/newtests/lsp/findReferences/__snapshots__/match-as-const.json @@ -0,0 +1,31 @@ +{ + "method": "textDocument/references", + "result": [ + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 8, + "character": 13 + }, + "end": { + "line": 8, + "character": 14 + } + } + }, + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 8, + "character": 16 + }, + "end": { + "line": 8, + "character": 17 + } + } + } + ] +} diff --git a/newtests/lsp/findReferences/__snapshots__/match-as.json b/newtests/lsp/findReferences/__snapshots__/match-as.json new file mode 100644 index 00000000000..d5bcdd92819 --- /dev/null +++ b/newtests/lsp/findReferences/__snapshots__/match-as.json @@ -0,0 +1,31 @@ +{ + "method": "textDocument/references", + "result": [ + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 9, + "character": 7 + }, + "end": { + "line": 9, + "character": 8 + } + } + }, + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 9, + "character": 10 + }, + "end": { + "line": 9, + "character": 11 + } + } + } + ] +} diff --git a/newtests/lsp/findReferences/__snapshots__/match-binding-top.json b/newtests/lsp/findReferences/__snapshots__/match-binding-top.json new file mode 100644 index 00000000000..e0adb4446ac --- /dev/null +++ b/newtests/lsp/findReferences/__snapshots__/match-binding-top.json @@ -0,0 +1,31 @@ +{ + "method": "textDocument/references", + "result": [ + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 10, + "character": 8 + }, + "end": { + "line": 10, + "character": 9 + } + } + }, + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 10, + "character": 11 + }, + "end": { + "line": 10, + "character": 12 + } + } + } + ] +} diff --git a/newtests/lsp/findReferences/__snapshots__/match-obj-long.json b/newtests/lsp/findReferences/__snapshots__/match-obj-long.json new file mode 100644 index 00000000000..493b1b62d5a --- /dev/null +++ b/newtests/lsp/findReferences/__snapshots__/match-obj-long.json @@ -0,0 +1,31 @@ +{ + "method": "textDocument/references", + "result": [ + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 6, + "character": 14 + }, + "end": { + "line": 6, + "character": 15 + } + } + }, + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 6, + "character": 18 + }, + "end": { + "line": 6, + "character": 19 + } + } + } + ] +} diff --git a/newtests/lsp/findReferences/__snapshots__/match-obj-shorthand.json b/newtests/lsp/findReferences/__snapshots__/match-obj-shorthand.json new file mode 100644 index 00000000000..948ed4c21ac --- /dev/null +++ b/newtests/lsp/findReferences/__snapshots__/match-obj-shorthand.json @@ -0,0 +1,31 @@ +{ + "method": "textDocument/references", + "result": [ + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 7, + "character": 9 + }, + "end": { + "line": 7, + "character": 10 + } + } + }, + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 7, + "character": 13 + }, + "end": { + "line": 7, + "character": 14 + } + } + } + ] +} diff --git a/newtests/lsp/findReferences/__snapshots__/match-tuple.json b/newtests/lsp/findReferences/__snapshots__/match-tuple.json new file mode 100644 index 00000000000..abc37650bdb --- /dev/null +++ b/newtests/lsp/findReferences/__snapshots__/match-tuple.json @@ -0,0 +1,31 @@ +{ + "method": "textDocument/references", + "result": [ + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 10 + } + } + }, + { + "uri": "/__fixtures__/match.js", + "range": { + "start": { + "line": 5, + "character": 13 + }, + "end": { + "line": 5, + "character": 14 + } + } + } + ] +} diff --git a/newtests/lsp/findReferences/_flowconfig_match b/newtests/lsp/findReferences/_flowconfig_match new file mode 100644 index 00000000000..f0847b0a552 --- /dev/null +++ b/newtests/lsp/findReferences/_flowconfig_match @@ -0,0 +1,2 @@ +[options] +experimental.pattern_matching_expressions=true diff --git a/newtests/lsp/findReferences/test.js b/newtests/lsp/findReferences/test.js index e7f55235f55..abcc2067169 100644 --- a/newtests/lsp/findReferences/test.js +++ b/newtests/lsp/findReferences/test.js @@ -71,6 +71,11 @@ module.exports = (suite( lspStartAndConnect(), snapshot('locals.js', 29, 16, 'jsx_props.json'), ]), + test('JSX Props', [ + addFiles(...fixtures), + lspStartAndConnect(), + snapshot('locals.js', 29, 16, 'jsx_props.json'), + ]), test('Private Names', [ addFiles(...fixtures), lspStartAndConnect(), @@ -79,6 +84,16 @@ module.exports = (suite( snapshot('private-name.js', 20, 17, 'private-name-3.json'), snapshot('private-name.js', 23, 12, 'private-name-4.json'), ]), + test('Match', [ + addFiles(...fixtures), + lspStartAndConnect(), + snapshot('match.js', 5, 10, 'match-tuple.json'), + snapshot('match.js', 6, 15, 'match-obj-long.json'), + snapshot('match.js', 7, 10, 'match-obj-shorthand.json'), + snapshot('match.js', 8, 14, 'match-as-const.json'), + snapshot('match.js', 9, 8, 'match-as.json'), + snapshot('match.js', 10, 9, 'match-binding-top.json'), + ]).flowConfig('_flowconfig_match'), ]; }, ): SuiteType);