diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d2bb92a06..56ec93981 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: uses: crystal-lang/install-crystal@v1 - name: Checkout source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dependencies run: shards install diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 78fa15101..4692f3330 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v2 diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml new file mode 100644 index 000000000..99dc0555c --- /dev/null +++ b/.github/workflows/ci-nightly.yml @@ -0,0 +1,55 @@ +name: CI Nightly + +on: + schedule: + - cron: "0 6 * * 1" + workflow_dispatch: + +jobs: + test: + name: Test + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Install Crystal + uses: crystal-lang/install-crystal@v1 + with: + crystal: nightly + + - name: Download source + uses: actions/checkout@v4 + + - name: Install dependencies + run: shards install + + - name: Run specs + run: crystal spec --error-on-warnings --error-trace + + - name: Build the binary + run: shards build --error-on-warnings --error-trace + + - name: Run core specs (Firefox) + working-directory: ./core/tests + run: ../../bin/mint test -b firefox + + - name: Run core specs (Google Chrome) + working-directory: ./core/tests + run: ../../bin/mint test -b chrome + + - name: Check formatting (Mint) + working-directory: ./core + run: ../bin/mint format --check + + - name: Check formatting (Mint tests) + working-directory: ./core/tests + run: ../../bin/mint format --check + + - name: Check formatting (Crystal) + run: crystal tool format --check + + - name: Run ameba + run: bin/ameba diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c5b18c6d..d0cb766df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,6 @@ on: types: [opened, synchronize, reopened] release: types: [published] - schedule: - - cron: "0 6 * * 1" workflow_dispatch: jobs: @@ -18,17 +16,16 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - crystal: [latest, nightly] runs-on: ${{ matrix.os }} steps: - name: Install Crystal uses: crystal-lang/install-crystal@v1 with: - crystal: ${{ matrix.crystal }} + crystal: latest - name: Download source - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dependencies run: shards install diff --git a/.gitignore b/.gitignore index 78d79f265..c284ca24b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /lib/ /bin/ /.shards/ +.vscode \ No newline at end of file diff --git a/core/source/Math.mint b/core/source/Math.mint index 3d0a50f6d..899e2476f 100644 --- a/core/source/Math.mint +++ b/core/source/Math.mint @@ -1,5 +1,29 @@ /* Mathematical functions. */ module Math { + /* Euler's number and the base of natural logarithms; approximately `2.718`. */ + const E = `Math.E` + + /* Natural logarithm of `10`; approximately `2.303`. */ + const LN10 = `Math.LN10` + + /* Natural logarithm of `2`; approximately `0.693`. */ + const LN2 = `Math.LN2` + + /* Base-10 logarithm of `E`; approximately `0.434`. */ + const LOG10E = `Math.LOG10E` + + /* Base-2 logarithm of `E`; approximately `1.443`. */ + const LOG2E = `Math.LOG2E` + + /* Ratio of a circle's circumference to its diameter; approximately `3.14159`. */ + const PI = `Math.PI` + + /* Square root of `0.5`; approximately `0.707`. */ + const SQRT12 = `Math.SQRT1_2` + + /* Square root of `2`; approximately `1.414`. */ + const SQRT2 = `Math.SQRT2` + /* Returns the absolute value of the given number. @@ -10,6 +34,51 @@ module Math { `Math.abs(#{number})` } + /* Returns the inverse cosine of the given angle in radians */ + fun acos (number : Number) : Number { + `Math.acos(#{number})` + } + + /* Returns the inverse hyperbolic cosine of the given angle in radians */ + fun acosh (number : Number) : Number { + `Math.acosh(#{number})` + } + + /* Returns the inverse sine of the given angle in radians */ + fun asin (number : Number) : Number { + `Math.asin(#{number})` + } + + /* Returns the inverse hyperbolic sine of the given angle in radians */ + fun asinh (number : Number) : Number { + `Math.asinh(#{number})` + } + + /* Returns the inverse tangent of the given angle in radians */ + fun atan (number : Number) : Number { + `Math.atan(#{number})` + } + + /* Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y) */ + fun atan2 (y : Number, x : Number) : Number { + `Math.atan2(#{y}, #{x})` + } + + /* Returns the inverse hyperbolic tangent of the given angle in radians */ + fun atanh (number : Number) : Number { + `Math.atanh(#{number})` + } + + /* + Returns the cubic root of the given number + + Math.cbrt(1) == 1 + Math.cbrt(64) == 4 + */ + fun cbrt (number : Number) : Number { + `Math.cbrt(#{number})` + } + /* Returns the smallest integer greater than or equal to the given number. @@ -29,6 +98,41 @@ module Math { Math.min(upper, Math.max(lower, value)) } + /* + Returns the number of leading zero bits in the 32-bit binary representation of a number + + 00000000000000000000000000000100 + Math.clz32(4) == 29 + */ + fun clz32 (number : Number) : Number { + `Math.clz32(#{number})` + } + + /* Returns the cosine of the given angle in radians */ + fun cos (number : Number) : Number { + `Math.cos(#{number})` + } + + /* Returns the hyperbolic cosine of the given angle in radians */ + fun cosh (number : Number) : Number { + `Math.cosh(#{number})` + } + + /* Returns the value of `Math:E` raised to the power x, where x is the given number */ + fun exp (x : Number) : Number { + `Math.exp(#{x})` + } + + /* + Returns the value of `Math:E` to the power x, minus 1 + + Math.exp(2) == 7.38905609893065 + Math.expm1(2) == 6.38905609893065 + */ + fun expm1 (x : Number) : Number { + `Math.expm1(#{x})` + } + /* Returns the largest integer less than or equal to the given number. @@ -48,6 +152,65 @@ module Math { `Number((#{b} - (Math.floor(#{b} / #{a}) * #{a})).toPrecision(8))` } + /* Returns the nearest 32-bit single precision float representation of the given number. */ + fun fround (number : Number) : Number { + `Math.fround(#{number})` + } + + /* + Returns the square root of the sum of squares of its arguments. + + Math.hypot(3, 4) == 5 + */ + fun hypot (a : Number, b : Number) : Number { + `Math.hypot(#{a}, #{b})` + } + + /* + Returns the result using C-like 32-bit multiplication of the two parameters. + + Math.imul(3, 4) == 12 + */ + fun imul (a : Number, b : number) : Number { + `Math.imul(#{a}, #{b})` + } + + /* + Returns natural logarithm (base e) of the given value + + Math.log(1) == 0 + */ + fun log (number : Number) : Number { + `Math.log(#{number})` + } + + /* + Returns natural logarithm (base 10) of the given value + + Math.log10(100) == 10 + */ + fun log10 (number : Number) : Number { + `Math.log10(#{number})` + } + + /* + Returns natural logarithm (base e) of the given value, plus 1 + + Math.log1p(1) == 0 + */ + fun log1p (number : Number) : Number { + `Math.log1p(#{number})` + } + + /* + Returns natural logarithm (base 2) of the given value + + Math.log2(8) == 3 + */ + fun log2 (number : Number) : Number { + `Math.log2(#{number})` + } + /* Returns the highest-valued number from the arguments. @@ -98,6 +261,26 @@ module Math { `Math.round(#{number})` } + /* + Returns the sign of the given number (1 or -1) + + Math.sign(5) == 1 + Math.sign(-5) == -1 + */ + fun sign (number : Number) : Number { + `Math.sign(#{number})` + } + + /* Calculates the sine of the given angle in radians */ + fun sin (value : Number) : Number { + `Math.sin(#{value})` + } + + /* Calculates the hyperbolic sine of the given angle in radians */ + fun sinh (number : Number) : Number { + `Math.sinh(#{number})` + } + /* Returns the square root of the given number @@ -107,6 +290,16 @@ module Math { `Math.sqrt(#{value})` } + /* Calculates the tangent of the given angle in radians */ + fun tan (number : Number) { + `Math.tan(#{number})` + } + + /* Calculates the hyperbolic tangent of the given angle in radians */ + fun tanh (number : Number) : Number { + `Math.tanh(#{number})` + } + /* Returns the integer part of a number by removing any fractional digits. diff --git a/core/source/Object/Decode.mint b/core/source/Object/Decode.mint index 5edc97bf1..85649fcf2 100644 --- a/core/source/Object/Decode.mint +++ b/core/source/Object/Decode.mint @@ -3,7 +3,7 @@ module Object.Decode { /* Decodes the object as an `Array` using the given decoder. - Object.Decode.array(`["A", "B"]`, Object.Decode.string, ) == Result::Ok(["a", "b"]) + Object.Decode.array(`["A", "B"]`, Object.Decode.string) == Result::Ok(["a", "b"]) */ fun array ( input : Object, @@ -25,7 +25,7 @@ module Object.Decode { Decodes a field from an object using the given decoder. Object.Decode.field( - "field", Object.Decode.string, `{field: "Value"}`) == Result::Ok("Value") + `{field: "Value"}`, "field", Object.Decode.string) == Result::Ok("Value") */ fun field ( input : Object, @@ -38,8 +38,8 @@ module Object.Decode { /* Decodes the object as a `Maybe(a)` using the given decoder. - Object.Decode.maybe(Object.Decode.String, `"A"`) == Result::Ok(Maybe::Just("A")) - Object.Decode.maybe(Object.Decode.String, `null`) == Result::Ok(Maybe::Nothing) + Object.Decode.maybe(`"A"`, Object.Decode.String) == Result::Ok(Maybe::Just("A")) + Object.Decode.maybe(`null`, Object.Decode.String) == Result::Ok(Maybe::Nothing) */ fun maybe ( input : Object, @@ -51,7 +51,7 @@ module Object.Decode { /* Decodes the object as a `Number` - Object.Decode.boolean(`0`) == Result::Ok(0) + Object.Decode.number(`0`) == Result::Ok(0) */ fun number (input : Object) : Result(Object.Error, Number) { `Decoder.number(#{input})` @@ -60,7 +60,7 @@ module Object.Decode { /* Decodes the object as a `String` - Object.Decode.boolean(`"A"`) == Result::Ok("A") + Object.Decode.string(`"A"`) == Result::Ok("A") */ fun string (input : Object) : Result(Object.Error, String) { `Decoder.string(#{input})` @@ -69,7 +69,7 @@ module Object.Decode { /* Decodes the object as a `Time` - Object.Decode.boolean(`"new Date()"`) + Object.Decode.time(`"new Date()"`) */ fun time (input : Object) : Result(Object.Error, Time) { `Decoder.time(#{input})` diff --git a/core/tests/tests/Math.mint b/core/tests/tests/Math.mint index 49249dce7..3bd3b6238 100644 --- a/core/tests/tests/Math.mint +++ b/core/tests/tests/Math.mint @@ -100,3 +100,182 @@ suite "Math.random" { n >= 0.0 && n < 1.0 } } + +suite "Math:E" { + test "returns Math.E" { + Math:E == `Math.E` + } +} + +suite "Math:LN2" { + test "returns Math.LN2" { + Math:LN2 == `Math.LN2` + } +} + +suite "Math:LN10" { + test "returns Math.LN10" { + Math:LN10 == `Math.LN10` + } +} + +suite "Math:LOG2E" { + test "returns Math.LOG2E" { + Math:LOG2E == `Math.LOG2E` + } +} + +suite "Math:LOG10E" { + test "returns Math.LOG10E" { + Math:LOG10E == `Math.LOG10E` + } +} + +suite "Math:PI" { + test "returns Math.PI" { + Math:PI == `Math.PI` + } +} + +suite "Math:SQRT12" { + test "returns Math.SQRT12" { + Math:SQRT12 == `Math.SQRT1_2` + } +} + +suite "Math:SQRT2" { + test "returns Math.SQRT2" { + Math:SQRT2 == `Math.SQRT2` + } +} + +suite "Math.acos" { + test "it returns the inverse cosine of an angle in radians" { + Math.acos(1) == `Math.acos(1)` + } +} + +suite "Math.acosh" { + test "it returns the inverse hyperbolic cosine of an angle in radians" { + Math.acosh(1) == `Math.acosh(1)` + } +} + +suite "Math.asin" { + test "it returns the inverse sine of an angle in radians" { + Math.asin(1) == `Math.asin(1)` + } +} + +suite "Math.asinh" { + test "it returns the inverse hyperbolic sine of an angle in radians" { + Math.asinh(1) == `Math.asinh(1)` + } +} + +suite "Math.atan" { + test "it returns the inverse tangent of an angle in radians" { + Math.atan(1) == `Math.atan(1)` + } +} + +suite "Math.atan2" { + test "it returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y)" { + Math.atan2(3, 4) == `Math.atan2(3, 4)` + } +} + +suite "Math.atanh" { + test "it returns the inverse hyperbolic tangent of an angle in radians" { + Math.atanh(1) == `Math.atanh(1)` + } +} + +suite "Math.cbrt" { + test "it returns the cubic root" { + Math.cbrt(8) == `Math.cbrt(8)` + } +} + +suite "Math.clz32" { + test "it returns the sin of an angle in radians" { + Math.clz32(4) == `Math.clz32(4)` + } +} + +suite "Math.cos" { + test "it returns the cosine of an angle in radians" { + Math.cos(1) == `Math.cos(1)` + } +} + +suite "Math.cosh" { + test "it returns the hyperbolic cosine of an angle in radians" { + Math.cosh(1) == `Math.cosh(1)` + } +} + +suite "Math.exp" { + test "it returns e raised to the power of x, where x is the number provided" { + Math.exp(2) == `Math.exp(2)` + } +} + +suite "Math.expm1" { + test "it returns e raised to the power of x - 1, where x is the number provided" { + Math.expm1(2) == `Math.expm1(2)` + } +} + +suite "Math.fround" { + test "returns the nearest 32-bit single precision float representation of a number" { + Math.fround(5.5) == `Math.fround(5.5)` + Math.fround(5.05) == `Math.fround(5.05)` + } +} + +suite "Math.hypot" { + test "returns the square root of the sum of squares of two numbers" { + Math.hypot(3, 4) == 5 + } +} + +suite "Math.imul" { + test "multiples two numbers using C-like 32-bit multiplication" { + Math.imul(-5, 12) == -60 + } +} + +suite "Math.log" { + test "returns the natural log (base e) of a number" { + Math.log(Math:E) == 1 + } +} + +suite "Math.log1p" { + test "returns the natural log (base e) of x + 1, where x is the provided value" { + Math.log1p(Math:E) == `Math.log1p(#{Math:E})` + } +} + +suite "Math.log2" { + test "returns the natural log (base 2) of a number" { + Math.log2(8) == 3 + } +} + +suite "Math.log10" { + test "it returns the natural log (base 10) of a number" { + Math.log10(100) == 2 + } +} + +suite "Math.sign" { + test "it returns the sign (1 or -1) of a number" { + Math.sign(5) == 1 + } + + test "it returns the sign (1 or -1) of a number #2" { + Math.sign(-5) == -1 + } +} diff --git a/spec/language_server/definition/location_link/connect b/spec/language_server/definition/location_link/connect index c03daea65..c32fb04b3 100644 --- a/spec/language_server/definition/location_link/connect +++ b/spec/language_server/definition/location_link/connect @@ -42,39 +42,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 1, - "character": 10 - }, - "end": { - "line": 1, - "character": 15 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 1, + "character": 10 + }, + "end": { + "line": 1, + "character": 15 + } }, - "end": { - "line": 3, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 3, + "character": 1 + } }, - "end": { - "line": 1, - "character": 11 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 11 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/connect_variable_constant b/spec/language_server/definition/location_link/connect_variable_constant index 240e98db2..2c951b0fa 100644 --- a/spec/language_server/definition/location_link/connect_variable_constant +++ b/spec/language_server/definition/location_link/connect_variable_constant @@ -42,39 +42,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 1, - "character": 27 - }, - "end": { - "line": 1, - "character": 35 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 2, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 1, + "character": 27 + }, + "end": { + "line": 1, + "character": 35 + } }, - "end": { - "line": 2, - "character": 23 - } - }, - "targetSelectionRange": { - "start": { - "line": 2, - "character": 8 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 2, + "character": 23 + } }, - "end": { - "line": 2, - "character": 16 + "targetSelectionRange": { + "start": { + "line": 2, + "character": 8 + }, + "end": { + "line": 2, + "character": 16 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/connect_variable_function b/spec/language_server/definition/location_link/connect_variable_function index c3f5c4102..b846d3511 100644 --- a/spec/language_server/definition/location_link/connect_variable_function +++ b/spec/language_server/definition/location_link/connect_variable_function @@ -44,39 +44,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 1, - "character": 27 - }, - "end": { - "line": 1, - "character": 31 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 2, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 1, + "character": 27 + }, + "end": { + "line": 1, + "character": 31 + } }, - "end": { - "line": 4, - "character": 3 - } - }, - "targetSelectionRange": { - "start": { - "line": 2, - "character": 6 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 4, + "character": 3 + } }, - "end": { - "line": 2, - "character": 10 + "targetSelectionRange": { + "start": { + "line": 2, + "character": 6 + }, + "end": { + "line": 2, + "character": 10 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/connect_variable_get b/spec/language_server/definition/location_link/connect_variable_get index d5d90eb2b..f292778ef 100644 --- a/spec/language_server/definition/location_link/connect_variable_get +++ b/spec/language_server/definition/location_link/connect_variable_get @@ -44,39 +44,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 1, - "character": 27 - }, - "end": { - "line": 1, - "character": 31 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 2, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 1, + "character": 27 + }, + "end": { + "line": 1, + "character": 31 + } }, - "end": { - "line": 5, - "character": 0 - } - }, - "targetSelectionRange": { - "start": { - "line": 2, - "character": 6 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 5, + "character": 0 + } }, - "end": { - "line": 2, - "character": 10 + "targetSelectionRange": { + "start": { + "line": 2, + "character": 6 + }, + "end": { + "line": 2, + "character": 10 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/connect_variable_state b/spec/language_server/definition/location_link/connect_variable_state index 25cd3ebb5..7316a195c 100644 --- a/spec/language_server/definition/location_link/connect_variable_state +++ b/spec/language_server/definition/location_link/connect_variable_state @@ -42,39 +42,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 1, - "character": 27 - }, - "end": { - "line": 1, - "character": 35 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 2, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 1, + "character": 27 + }, + "end": { + "line": 1, + "character": 35 + } }, - "end": { - "line": 2, - "character": 24 - } - }, - "targetSelectionRange": { - "start": { - "line": 2, - "character": 8 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 2, + "character": 24 + } }, - "end": { - "line": 2, - "character": 16 + "targetSelectionRange": { + "start": { + "line": 2, + "character": 8 + }, + "end": { + "line": 2, + "character": 16 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/enum_destructuring_name b/spec/language_server/definition/location_link/enum_destructuring_name index f4bc5361f..694b47c1f 100644 --- a/spec/language_server/definition/location_link/enum_destructuring_name +++ b/spec/language_server/definition/location_link/enum_destructuring_name @@ -44,39 +44,41 @@ module Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 6 - }, - "end": { - "line": 3, - "character": 12 - } - }, - "targetUri": "file://#{root_path}/status.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 6 + }, + "end": { + "line": 3, + "character": 12 + } }, - "end": { - "line": 4, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 5 + "targetUri": "file://#{root_path}/status.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 4, + "character": 1 + } }, - "end": { - "line": 1, - "character": 11 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 5 + }, + "end": { + "line": 1, + "character": 11 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/enum_destructuring_option b/spec/language_server/definition/location_link/enum_destructuring_option index 99d3e20b0..2ced2ee10 100644 --- a/spec/language_server/definition/location_link/enum_destructuring_option +++ b/spec/language_server/definition/location_link/enum_destructuring_option @@ -1,3 +1,9 @@ +component Error { + fun render { +
+ } +} +-------------------------------------------------------------file component.mint /* Comment for Status enum. */ enum Status { Error @@ -44,39 +50,41 @@ module Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 14 - }, - "end": { - "line": 3, - "character": 19 - } - }, - "targetUri": "file://#{root_path}/status.mint", - "targetRange": { - "start": { - "line": 2, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 14 + }, + "end": { + "line": 3, + "character": 19 + } }, - "end": { - "line": 3, - "character": 2 - } - }, - "targetSelectionRange": { - "start": { - "line": 2, - "character": 2 + "targetUri": "file://#{root_path}/status.mint", + "targetRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 3, + "character": 2 + } }, - "end": { - "line": 2, - "character": 7 + "targetSelectionRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 2, + "character": 7 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/enum_id_name b/spec/language_server/definition/location_link/enum_id_name index 4cb87f01a..9a34fc737 100644 --- a/spec/language_server/definition/location_link/enum_id_name +++ b/spec/language_server/definition/location_link/enum_id_name @@ -43,39 +43,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 1, - "character": 26 - }, - "end": { - "line": 1, - "character": 32 - } - }, - "targetUri": "file://#{root_path}/status.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 1, + "character": 26 + }, + "end": { + "line": 1, + "character": 32 + } }, - "end": { - "line": 4, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 5 + "targetUri": "file://#{root_path}/status.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 4, + "character": 1 + } }, - "end": { - "line": 1, - "character": 11 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 5 + }, + "end": { + "line": 1, + "character": 11 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/enum_id_option b/spec/language_server/definition/location_link/enum_id_option index 9b90f41b6..4a27d0c48 100644 --- a/spec/language_server/definition/location_link/enum_id_option +++ b/spec/language_server/definition/location_link/enum_id_option @@ -1,3 +1,9 @@ +component Ok { + fun render { +
+ } +} +-------------------------------------------------------------file component.mint enum Status { Error Ok @@ -42,39 +48,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 1, - "character": 34 - }, - "end": { - "line": 1, - "character": 36 - } - }, - "targetUri": "file://#{root_path}/status.mint", - "targetRange": { - "start": { - "line": 2, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 1, + "character": 34 + }, + "end": { + "line": 1, + "character": 36 + } }, - "end": { - "line": 3, - "character": 0 - } - }, - "targetSelectionRange": { - "start": { - "line": 2, - "character": 2 + "targetUri": "file://#{root_path}/status.mint", + "targetRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 3, + "character": 0 + } }, - "end": { - "line": 2, - "character": 4 + "targetSelectionRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 2, + "character": 4 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/html_attribute b/spec/language_server/definition/location_link/html_attribute index 4b680751a..cad9608e4 100644 --- a/spec/language_server/definition/location_link/html_attribute +++ b/spec/language_server/definition/location_link/html_attribute @@ -43,39 +43,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 2, - "character": 12 - }, - "end": { - "line": 2, - "character": 16 - } - }, - "targetUri": "file://#{root_path}/button.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 2, + "character": 12 + }, + "end": { + "line": 2, + "character": 16 + } }, - "end": { - "line": 1, - "character": 34 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 11 + "targetUri": "file://#{root_path}/button.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 34 + } }, - "end": { - "line": 1, - "character": 15 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 11 + }, + "end": { + "line": 1, + "character": 15 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/html_component b/spec/language_server/definition/location_link/html_component index 19448d36e..8796bf68e 100644 --- a/spec/language_server/definition/location_link/html_component +++ b/spec/language_server/definition/location_link/html_component @@ -42,39 +42,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 2, - "character": 5 - }, - "end": { - "line": 2, - "character": 11 - } - }, - "targetUri": "file://#{root_path}/button.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 2, + "character": 5 + }, + "end": { + "line": 2, + "character": 11 + } }, - "end": { - "line": 5, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 10 + "targetUri": "file://#{root_path}/button.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 5, + "character": 1 + } }, - "end": { - "line": 1, - "character": 16 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 10 + }, + "end": { + "line": 1, + "character": 16 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/html_style b/spec/language_server/definition/location_link/html_style index 8dcf970e1..404cf20e1 100644 --- a/spec/language_server/definition/location_link/html_style +++ b/spec/language_server/definition/location_link/html_style @@ -39,39 +39,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 6, - "character": 10 - }, - "end": { - "line": 6, - "character": 14 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 6, + "character": 10 + }, + "end": { + "line": 6, + "character": 14 + } }, - "end": { - "line": 3, - "character": 3 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 3, + "character": 3 + } }, - "end": { - "line": 1, - "character": 12 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 12 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_component_constant b/spec/language_server/definition/location_link/module_access_component_constant index 01d5a2dda..7e0bb4a42 100644 --- a/spec/language_server/definition/location_link/module_access_component_constant +++ b/spec/language_server/definition/location_link/module_access_component_constant @@ -45,39 +45,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/header.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 21 + } }, - "end": { - "line": 1, - "character": 22 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/header.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 22 + } }, - "end": { - "line": 1, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_component_function b/spec/language_server/definition/location_link/module_access_component_function index 0b029b2aa..f2c44ddf3 100644 --- a/spec/language_server/definition/location_link/module_access_component_function +++ b/spec/language_server/definition/location_link/module_access_component_function @@ -43,39 +43,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 22 - } - }, - "targetUri": "file://#{root_path}/header.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 22 + } }, - "end": { - "line": 3, - "character": 3 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/header.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 3, + "character": 3 + } }, - "end": { - "line": 1, - "character": 12 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 12 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_component_gets b/spec/language_server/definition/location_link/module_access_component_gets index 2555b6ee1..3b827025b 100644 --- a/spec/language_server/definition/location_link/module_access_component_gets +++ b/spec/language_server/definition/location_link/module_access_component_gets @@ -47,39 +47,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/header.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 21 + } }, - "end": { - "line": 5, - "character": 2 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/header.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 5, + "character": 2 + } }, - "end": { - "line": 1, - "character": 11 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 11 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_component_name b/spec/language_server/definition/location_link/module_access_component_name index b669f0b49..b1c738c09 100644 --- a/spec/language_server/definition/location_link/module_access_component_name +++ b/spec/language_server/definition/location_link/module_access_component_name @@ -43,39 +43,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 9 - }, - "end": { - "line": 3, - "character": 15 - } - }, - "targetUri": "file://#{root_path}/header.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 9 + }, + "end": { + "line": 3, + "character": 15 + } }, - "end": { - "line": 4, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 0, - "character": 17 + "targetUri": "file://#{root_path}/header.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 4, + "character": 1 + } }, - "end": { - "line": 0, - "character": 23 + "targetSelectionRange": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 23 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_component_state b/spec/language_server/definition/location_link/module_access_component_state index 1208ef692..6ada2760a 100644 --- a/spec/language_server/definition/location_link/module_access_component_state +++ b/spec/language_server/definition/location_link/module_access_component_state @@ -45,39 +45,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/header.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 21 + } }, - "end": { - "line": 1, - "character": 22 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/header.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 22 + } }, - "end": { - "line": 1, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_module_constant b/spec/language_server/definition/location_link/module_access_module_constant index 6896b0322..ac6a20c3e 100644 --- a/spec/language_server/definition/location_link/module_access_module_constant +++ b/spec/language_server/definition/location_link/module_access_module_constant @@ -41,39 +41,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/module.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 21 + } }, - "end": { - "line": 1, - "character": 22 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/module.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 22 + } }, - "end": { - "line": 1, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_module_function b/spec/language_server/definition/location_link/module_access_module_function index 5488f5465..460177780 100644 --- a/spec/language_server/definition/location_link/module_access_module_function +++ b/spec/language_server/definition/location_link/module_access_module_function @@ -43,39 +43,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/module.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 21 + } }, - "end": { - "line": 3, - "character": 3 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/module.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 3, + "character": 3 + } }, - "end": { - "line": 1, - "character": 11 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 11 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_module_name b/spec/language_server/definition/location_link/module_access_module_name index 8b86b1571..876b5cbff 100644 --- a/spec/language_server/definition/location_link/module_access_module_name +++ b/spec/language_server/definition/location_link/module_access_module_name @@ -43,39 +43,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 9 - }, - "end": { - "line": 3, - "character": 15 - } - }, - "targetUri": "file://#{root_path}/module.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 9 + }, + "end": { + "line": 3, + "character": 15 + } }, - "end": { - "line": 4, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 0, - "character": 7 + "targetUri": "file://#{root_path}/module.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 4, + "character": 1 + } }, - "end": { - "line": 0, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_module_name_shared b/spec/language_server/definition/location_link/module_access_module_name_shared index 4288b0f55..b1a772439 100644 --- a/spec/language_server/definition/location_link/module_access_module_name_shared +++ b/spec/language_server/definition/location_link/module_access_module_name_shared @@ -50,39 +50,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 6 - }, - "end": { - "line": 3, - "character": 12 - } - }, - "targetUri": "file://#{root_path}/module.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 6 + }, + "end": { + "line": 3, + "character": 12 + } }, - "end": { - "line": 4, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 0, - "character": 7 + "targetUri": "file://#{root_path}/module.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 4, + "character": 1 + } }, - "end": { - "line": 0, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_store_constant b/spec/language_server/definition/location_link/module_access_store_constant index 4fbb6fb7b..b0be3f73c 100644 --- a/spec/language_server/definition/location_link/module_access_store_constant +++ b/spec/language_server/definition/location_link/module_access_store_constant @@ -41,39 +41,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 21 + } }, - "end": { - "line": 1, - "character": 22 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 22 + } }, - "end": { - "line": 1, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_store_function b/spec/language_server/definition/location_link/module_access_store_function index 169011196..4a75b2732 100644 --- a/spec/language_server/definition/location_link/module_access_store_function +++ b/spec/language_server/definition/location_link/module_access_store_function @@ -43,39 +43,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 21 + } }, - "end": { - "line": 3, - "character": 3 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 3, + "character": 3 + } }, - "end": { - "line": 1, - "character": 11 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 11 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_store_gets b/spec/language_server/definition/location_link/module_access_store_gets index 15b5e99be..a1b18df36 100644 --- a/spec/language_server/definition/location_link/module_access_store_gets +++ b/spec/language_server/definition/location_link/module_access_store_gets @@ -43,39 +43,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 21 + } }, - "end": { - "line": 4, - "character": 0 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 4, + "character": 0 + } }, - "end": { - "line": 1, - "character": 11 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 11 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_store_name b/spec/language_server/definition/location_link/module_access_store_name index 96c9eb66e..78c2f4b68 100644 --- a/spec/language_server/definition/location_link/module_access_store_name +++ b/spec/language_server/definition/location_link/module_access_store_name @@ -43,39 +43,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 9 - }, - "end": { - "line": 3, - "character": 15 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 9 + }, + "end": { + "line": 3, + "character": 15 + } }, - "end": { - "line": 4, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 0, - "character": 6 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 4, + "character": 1 + } }, - "end": { - "line": 0, - "character": 12 + "targetSelectionRange": { + "start": { + "line": 0, + "character": 6 + }, + "end": { + "line": 0, + "character": 12 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/module_access_store_state b/spec/language_server/definition/location_link/module_access_store_state index b473d6795..4d9e4d2eb 100644 --- a/spec/language_server/definition/location_link/module_access_store_state +++ b/spec/language_server/definition/location_link/module_access_store_state @@ -41,39 +41,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 16 - }, - "end": { - "line": 3, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/store.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 16 + }, + "end": { + "line": 3, + "character": 21 + } }, - "end": { - "line": 1, - "character": 22 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/store.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 22 + } }, - "end": { - "line": 1, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/type_enum b/spec/language_server/definition/location_link/type_enum index 2557b4ec8..d7c2d7913 100644 --- a/spec/language_server/definition/location_link/type_enum +++ b/spec/language_server/definition/location_link/type_enum @@ -40,39 +40,41 @@ module Status { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 1, - "character": 16 - }, - "end": { - "line": 1, - "character": 22 - } - }, - "targetUri": "file://#{root_path}/status.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 1, + "character": 16 + }, + "end": { + "line": 1, + "character": 22 + } }, - "end": { - "line": 3, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 0, - "character": 5 + "targetUri": "file://#{root_path}/status.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 3, + "character": 1 + } }, - "end": { - "line": 0, - "character": 11 + "targetSelectionRange": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 11 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/type_record b/spec/language_server/definition/location_link/type_record index 7f5540979..eb590b63f 100644 --- a/spec/language_server/definition/location_link/type_record +++ b/spec/language_server/definition/location_link/type_record @@ -45,39 +45,41 @@ module Article { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 1, - "character": 13 - }, - "end": { - "line": 1, - "character": 20 - } - }, - "targetUri": "file://#{root_path}/article.mint", - "targetRange": { - "start": { - "line": 0, - "character": 0 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 1, + "character": 13 + }, + "end": { + "line": 1, + "character": 20 + } }, - "end": { - "line": 4, - "character": 1 - } - }, - "targetSelectionRange": { - "start": { - "line": 0, - "character": 7 + "targetUri": "file://#{root_path}/article.mint", + "targetRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 4, + "character": 1 + } }, - "end": { - "line": 0, - "character": 14 + "targetSelectionRange": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 14 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_block_statement_target b/spec/language_server/definition/location_link/variable_block_statement_target index 07e7d96b5..6c853c207 100644 --- a/spec/language_server/definition/location_link/variable_block_statement_target +++ b/spec/language_server/definition/location_link/variable_block_statement_target @@ -37,39 +37,41 @@ module Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 5, - "character": 23 - }, - "end": { - "line": 5, - "character": 27 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 2, - "character": 4 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 5, + "character": 23 + }, + "end": { + "line": 5, + "character": 27 + } }, - "end": { - "line": 3, - "character": 12 - } - }, - "targetSelectionRange": { - "start": { - "line": 2, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 3, + "character": 12 + } }, - "end": { - "line": 2, - "character": 12 + "targetSelectionRange": { + "start": { + "line": 2, + "character": 8 + }, + "end": { + "line": 2, + "character": 12 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_casebranch_enumdestructuring b/spec/language_server/definition/location_link/variable_casebranch_enumdestructuring index 4eba5aceb..6c7fd9298 100644 --- a/spec/language_server/definition/location_link/variable_casebranch_enumdestructuring +++ b/spec/language_server/definition/location_link/variable_casebranch_enumdestructuring @@ -43,39 +43,41 @@ module Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 8, - "character": 26 - }, - "end": { - "line": 8, - "character": 30 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 8, - "character": 6 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 8, + "character": 26 + }, + "end": { + "line": 8, + "character": 30 + } }, - "end": { - "line": 8, - "character": 22 - } - }, - "targetSelectionRange": { - "start": { - "line": 8, - "character": 17 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 8, + "character": 6 + }, + "end": { + "line": 8, + "character": 22 + } }, - "end": { - "line": 8, - "character": 21 + "targetSelectionRange": { + "start": { + "line": 8, + "character": 17 + }, + "end": { + "line": 8, + "character": 21 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_component_connect b/spec/language_server/definition/location_link/variable_component_connect index 1b2cef32f..b2c568230 100644 --- a/spec/language_server/definition/location_link/variable_component_connect +++ b/spec/language_server/definition/location_link/variable_component_connect @@ -42,39 +42,41 @@ store Theme { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 5, - "character": 9 - }, - "end": { - "line": 5, - "character": 16 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 16 + } }, - "end": { - "line": 1, - "character": 36 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 27 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 36 + } }, - "end": { - "line": 1, - "character": 34 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 27 + }, + "end": { + "line": 1, + "character": 34 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_component_connect_as b/spec/language_server/definition/location_link/variable_component_connect_as index 6effa0999..9b2b40057 100644 --- a/spec/language_server/definition/location_link/variable_component_connect_as +++ b/spec/language_server/definition/location_link/variable_component_connect_as @@ -42,39 +42,41 @@ store Theme { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 5, - "character": 9 - }, - "end": { - "line": 5, - "character": 21 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 21 + } }, - "end": { - "line": 1, - "character": 52 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 38 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 52 + } }, - "end": { - "line": 1, - "character": 50 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 38 + }, + "end": { + "line": 1, + "character": 50 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_component_constant b/spec/language_server/definition/location_link/variable_component_constant index 03022a727..615269a1e 100644 --- a/spec/language_server/definition/location_link/variable_component_constant +++ b/spec/language_server/definition/location_link/variable_component_constant @@ -39,39 +39,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 5, - "character": 9 - }, - "end": { - "line": 5, - "character": 13 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 13 + } }, - "end": { - "line": 1, - "character": 21 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 21 + } }, - "end": { - "line": 1, - "character": 12 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 12 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_component_function b/spec/language_server/definition/location_link/variable_component_function index 00126bf09..614a2a0f5 100644 --- a/spec/language_server/definition/location_link/variable_component_function +++ b/spec/language_server/definition/location_link/variable_component_function @@ -41,39 +41,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 7, - "character": 9 - }, - "end": { - "line": 7, - "character": 13 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 7, + "character": 9 + }, + "end": { + "line": 7, + "character": 13 + } }, - "end": { - "line": 3, - "character": 3 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 3, + "character": 3 + } }, - "end": { - "line": 1, - "character": 10 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 10 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_component_get b/spec/language_server/definition/location_link/variable_component_get index 1d5fcd4ca..2541d9838 100644 --- a/spec/language_server/definition/location_link/variable_component_get +++ b/spec/language_server/definition/location_link/variable_component_get @@ -41,39 +41,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 7, - "character": 9 - }, - "end": { - "line": 7, - "character": 13 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 7, + "character": 9 + }, + "end": { + "line": 7, + "character": 13 + } }, - "end": { - "line": 5, - "character": 2 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 5, + "character": 2 + } }, - "end": { - "line": 1, - "character": 10 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 10 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_component_property b/spec/language_server/definition/location_link/variable_component_property index ce61b0357..6c500391e 100644 --- a/spec/language_server/definition/location_link/variable_component_property +++ b/spec/language_server/definition/location_link/variable_component_property @@ -39,39 +39,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 5, - "character": 9 - }, - "end": { - "line": 5, - "character": 13 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 13 + } }, - "end": { - "line": 1, - "character": 33 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 11 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 33 + } }, - "end": { - "line": 1, - "character": 15 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 11 + }, + "end": { + "line": 1, + "character": 15 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_component_state b/spec/language_server/definition/location_link/variable_component_state index e8705f482..1b9fe77b9 100644 --- a/spec/language_server/definition/location_link/variable_component_state +++ b/spec/language_server/definition/location_link/variable_component_state @@ -39,39 +39,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 5, - "character": 9 - }, - "end": { - "line": 5, - "character": 13 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 5, + "character": 9 + }, + "end": { + "line": 5, + "character": 13 + } }, - "end": { - "line": 1, - "character": 30 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 30 + } }, - "end": { - "line": 1, - "character": 12 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 12 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_for b/spec/language_server/definition/location_link/variable_for index abd703d41..d2233ebe9 100644 --- a/spec/language_server/definition/location_link/variable_for +++ b/spec/language_server/definition/location_link/variable_for @@ -37,39 +37,41 @@ module Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 3, - "character": 25 - }, - "end": { - "line": 3, - "character": 30 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 2, - "character": 4 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 3, + "character": 25 + }, + "end": { + "line": 3, + "character": 30 + } }, - "end": { - "line": 5, - "character": 2 - } - }, - "targetSelectionRange": { - "start": { - "line": 2, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 5, + "character": 2 + } }, - "end": { - "line": 2, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 2, + "character": 8 + }, + "end": { + "line": 2, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_for_subject b/spec/language_server/definition/location_link/variable_for_subject index 3c41c018e..28cd4e72d 100644 --- a/spec/language_server/definition/location_link/variable_for_subject +++ b/spec/language_server/definition/location_link/variable_for_subject @@ -37,39 +37,41 @@ module Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 2, - "character": 30 - }, - "end": { - "line": 2, - "character": 35 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 17 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 2, + "character": 30 + }, + "end": { + "line": 2, + "character": 35 + } }, - "end": { - "line": 1, - "character": 31 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 17 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 17 + }, + "end": { + "line": 1, + "character": 31 + } }, - "end": { - "line": 1, - "character": 22 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 17 + }, + "end": { + "line": 1, + "character": 22 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_function_argument b/spec/language_server/definition/location_link/variable_function_argument index 78b9f72a3..398691e9f 100644 --- a/spec/language_server/definition/location_link/variable_function_argument +++ b/spec/language_server/definition/location_link/variable_function_argument @@ -35,39 +35,41 @@ module Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 2, - "character": 4 - }, - "end": { - "line": 2, - "character": 10 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 16 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 10 + } }, - "end": { - "line": 1, - "character": 31 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 16 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 16 + }, + "end": { + "line": 1, + "character": 31 + } }, - "end": { - "line": 1, - "character": 22 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 16 + }, + "end": { + "line": 1, + "character": 22 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_module_constant b/spec/language_server/definition/location_link/variable_module_constant index f9adb0c1b..efff8cad5 100644 --- a/spec/language_server/definition/location_link/variable_module_constant +++ b/spec/language_server/definition/location_link/variable_module_constant @@ -37,39 +37,41 @@ module Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 4, - "character": 4 - }, - "end": { - "line": 4, - "character": 9 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 4, + "character": 9 + } }, - "end": { - "line": 1, - "character": 23 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 23 + } }, - "end": { - "line": 1, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_nextcall_component b/spec/language_server/definition/location_link/variable_nextcall_component index 65bb1e6ff..511ce18fc 100644 --- a/spec/language_server/definition/location_link/variable_nextcall_component +++ b/spec/language_server/definition/location_link/variable_nextcall_component @@ -41,39 +41,41 @@ component Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 4, - "character": 11 - }, - "end": { - "line": 4, - "character": 15 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 4, + "character": 11 + }, + "end": { + "line": 4, + "character": 15 + } }, - "end": { - "line": 1, - "character": 26 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 26 + } }, - "end": { - "line": 1, - "character": 12 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 12 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_nextcall_record b/spec/language_server/definition/location_link/variable_nextcall_record index b8a376929..334d0c98a 100644 --- a/spec/language_server/definition/location_link/variable_nextcall_record +++ b/spec/language_server/definition/location_link/variable_nextcall_record @@ -56,39 +56,41 @@ store Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 20, - "character": 12 - }, - "end": { - "line": 20, - "character": 23 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 2, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 20, + "character": 12 + }, + "end": { + "line": 20, + "character": 23 + } }, - "end": { - "line": 2, - "character": 22 - } - }, - "targetSelectionRange": { - "start": { - "line": 2, - "character": 2 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 2, + "character": 22 + } }, - "end": { - "line": 2, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 2, + "character": 2 + }, + "end": { + "line": 2, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_nextcall_store b/spec/language_server/definition/location_link/variable_nextcall_store index 61de09f1c..93845f538 100644 --- a/spec/language_server/definition/location_link/variable_nextcall_store +++ b/spec/language_server/definition/location_link/variable_nextcall_store @@ -37,39 +37,41 @@ store Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 4, - "character": 11 - }, - "end": { - "line": 4, - "character": 15 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 4, + "character": 11 + }, + "end": { + "line": 4, + "character": 15 + } }, - "end": { - "line": 1, - "character": 26 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 26 + } }, - "end": { - "line": 1, - "character": 12 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 12 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_nextcall_value b/spec/language_server/definition/location_link/variable_nextcall_value index bd00bd2e9..4a17bce8b 100644 --- a/spec/language_server/definition/location_link/variable_nextcall_value +++ b/spec/language_server/definition/location_link/variable_nextcall_value @@ -40,39 +40,41 @@ store Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 7, - "character": 17 - }, - "end": { - "line": 7, - "character": 24 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 4, - "character": 4 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 7, + "character": 17 + }, + "end": { + "line": 7, + "character": 24 + } }, - "end": { - "line": 5, - "character": 12 - } - }, - "targetSelectionRange": { - "start": { - "line": 4, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 5, + "character": 12 + } }, - "end": { - "line": 4, - "character": 15 + "targetSelectionRange": { + "start": { + "line": 4, + "character": 8 + }, + "end": { + "line": 4, + "character": 15 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_provider_constant b/spec/language_server/definition/location_link/variable_provider_constant index 4f18c8a0a..d585dd65d 100644 --- a/spec/language_server/definition/location_link/variable_provider_constant +++ b/spec/language_server/definition/location_link/variable_provider_constant @@ -41,39 +41,41 @@ provider Provider : Subscription { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 8, - "character": 4 - }, - "end": { - "line": 8, - "character": 9 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 5, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 8, + "character": 4 + }, + "end": { + "line": 8, + "character": 9 + } }, - "end": { - "line": 5, - "character": 23 - } - }, - "targetSelectionRange": { - "start": { - "line": 5, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 5, + "character": 2 + }, + "end": { + "line": 5, + "character": 23 + } }, - "end": { - "line": 5, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_recordfield_key b/spec/language_server/definition/location_link/variable_recordfield_key index 5846bfacb..055d6ada5 100644 --- a/spec/language_server/definition/location_link/variable_recordfield_key +++ b/spec/language_server/definition/location_link/variable_recordfield_key @@ -45,39 +45,41 @@ module Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 9, - "character": 6 - }, - "end": { - "line": 9, - "character": 8 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 9, + "character": 6 + }, + "end": { + "line": 9, + "character": 8 + } }, - "end": { - "line": 1, - "character": 13 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 2 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 13 + } }, - "end": { - "line": 1, - "character": 4 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 4 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_recordfield_value b/spec/language_server/definition/location_link/variable_recordfield_value index c80653428..a4ea37427 100644 --- a/spec/language_server/definition/location_link/variable_recordfield_value +++ b/spec/language_server/definition/location_link/variable_recordfield_value @@ -45,39 +45,41 @@ module Test { ------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 5, - "character": 13 - }, - "end": { - "line": 5, - "character": 18 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 19 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 5, + "character": 13 + }, + "end": { + "line": 5, + "character": 18 + } }, - "end": { - "line": 1, - "character": 33 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 19 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 19 + }, + "end": { + "line": 1, + "character": 33 + } }, - "end": { - "line": 1, - "character": 24 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 19 + }, + "end": { + "line": 1, + "character": 24 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_store_constant b/spec/language_server/definition/location_link/variable_store_constant index 30d3dd4f7..2d8a6cf55 100644 --- a/spec/language_server/definition/location_link/variable_store_constant +++ b/spec/language_server/definition/location_link/variable_store_constant @@ -37,39 +37,41 @@ store Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 4, - "character": 4 - }, - "end": { - "line": 4, - "character": 9 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 4, + "character": 9 + } }, - "end": { - "line": 1, - "character": 23 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 23 + } }, - "end": { - "line": 1, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_store_function b/spec/language_server/definition/location_link/variable_store_function index fa4c95c04..40366e3c8 100644 --- a/spec/language_server/definition/location_link/variable_store_function +++ b/spec/language_server/definition/location_link/variable_store_function @@ -39,39 +39,41 @@ store Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 6, - "character": 10 - }, - "end": { - "line": 6, - "character": 14 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 6, + "character": 10 + }, + "end": { + "line": 6, + "character": 14 + } }, - "end": { - "line": 3, - "character": 3 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 3, + "character": 3 + } }, - "end": { - "line": 1, - "character": 10 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 10 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_store_get b/spec/language_server/definition/location_link/variable_store_get index 853222a93..070091f95 100644 --- a/spec/language_server/definition/location_link/variable_store_get +++ b/spec/language_server/definition/location_link/variable_store_get @@ -43,39 +43,41 @@ store Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 10, - "character": 15 - }, - "end": { - "line": 10, - "character": 26 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 10, + "character": 15 + }, + "end": { + "line": 10, + "character": 26 + } }, - "end": { - "line": 5, - "character": 2 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 6 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 5, + "character": 2 + } }, - "end": { - "line": 1, - "character": 17 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 6 + }, + "end": { + "line": 1, + "character": 17 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_store_state b/spec/language_server/definition/location_link/variable_store_state index 9c05f619f..2275d1d43 100644 --- a/spec/language_server/definition/location_link/variable_store_state +++ b/spec/language_server/definition/location_link/variable_store_state @@ -41,39 +41,41 @@ store Test { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 8, - "character": 15 - }, - "end": { - "line": 8, - "character": 20 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 8, + "character": 15 + }, + "end": { + "line": 8, + "character": 20 + } }, - "end": { - "line": 1, - "character": 32 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 32 + } }, - "end": { - "line": 1, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/definition/location_link/variable_suite_constant b/spec/language_server/definition/location_link/variable_suite_constant index cdc6aa815..9205a3028 100644 --- a/spec/language_server/definition/location_link/variable_suite_constant +++ b/spec/language_server/definition/location_link/variable_suite_constant @@ -37,39 +37,41 @@ suite "Test" { -------------------------------------------------------------------------request { "jsonrpc": "2.0", - "result": { - "originSelectionRange": { - "start": { - "line": 4, - "character": 4 - }, - "end": { - "line": 4, - "character": 9 - } - }, - "targetUri": "file://#{root_path}/test.mint", - "targetRange": { - "start": { - "line": 1, - "character": 2 + "result": [ + { + "originSelectionRange": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 4, + "character": 9 + } }, - "end": { - "line": 1, - "character": 23 - } - }, - "targetSelectionRange": { - "start": { - "line": 1, - "character": 8 + "targetUri": "file://#{root_path}/test.mint", + "targetRange": { + "start": { + "line": 1, + "character": 2 + }, + "end": { + "line": 1, + "character": 23 + } }, - "end": { - "line": 1, - "character": 13 + "targetSelectionRange": { + "start": { + "line": 1, + "character": 8 + }, + "end": { + "line": 1, + "character": 13 + } } } - }, + ], "id": 1 } ------------------------------------------------------------------------response diff --git a/spec/language_server/semantic_tokens/component b/spec/language_server/semantic_tokens/component new file mode 100644 index 000000000..0357c4a26 --- /dev/null +++ b/spec/language_server/semantic_tokens/component @@ -0,0 +1,106 @@ +component Test { + property nextTitle : String = "World" + + /* + Comment that spans + multiple lines + */ + fun title : String { + nextTitle + } + + fun render { +
+ } +} +------------------------------------------------------------------file test.mint +{ + "id": 0, + "method": "initialize", + "params": { + "capabilities": { + "textDocument": { + "semanticTokens": { + "dynamicRegistration": false, + "tokenTypes": ["property"] + } + } + } + } +} +-------------------------------------------------------------------------request +{ + "jsonrpc": "2.0", + "id": 1, + "params": { + "textDocument": { + "uri": "file://#{root_path}/test.mint" + } + }, + "method": "textDocument/semanticTokens/full" +} +-------------------------------------------------------------------------request +{ + "jsonrpc": "2.0", + "result": { + "data": [ + 0, + 0, + 9, + 4, + 0, + 0, + 10, + 4, + 1, + 0, + 1, + 2, + 8, + 4, + 0, + 0, + 21, + 6, + 1, + 0, + 0, + 9, + 7, + 8, + 0, + 2, + 2, + 48, + 5, + 0, + 4, + 2, + 3, + 4, + 0, + 0, + 12, + 6, + 1, + 0, + 1, + 4, + 9, + 6, + 0, + 3, + 2, + 3, + 4, + 0, + 1, + 5, + 3, + 2, + 0 + ] + }, + "id": 1 +} +------------------------------------------------------------------------response diff --git a/src/ls/README.md b/src/ls/README.md index 8e815f821..317e3cfed 100644 --- a/src/ls/README.md +++ b/src/ls/README.md @@ -15,7 +15,7 @@ The feature set is pretty minimal at this point: | Signature Help | :negative_squared_cross_mark: | | | Goto Declaration | :negative_squared_cross_mark: | | | Goto Type Definition | :negative_squared_cross_mark: | | -| Goto Implementation | :negative_squared_cross_mark: | | +| Goto Implementation | :heavy_check_mark: | Some entities | | Find References | :negative_squared_cross_mark: | | | Document Highlights | :negative_squared_cross_mark: | | | Document Symbols | :negative_squared_cross_mark: | | @@ -28,7 +28,7 @@ The feature set is pretty minimal at this point: | Folding Range | :heavy_check_mark: | Specific entities only | | Selection Range | :negative_squared_cross_mark: | | | Call Hierarchy | :negative_squared_cross_mark: | | -| Semantic Tokens | :negative_squared_cross_mark: | | +| Semantic Tokens | :heavy_check_mark: | Full document only | | Monikers | :negative_squared_cross_mark: | | ### Code Action diff --git a/src/ls/definition.cr b/src/ls/definition.cr index 62422806a..301977b34 100644 --- a/src/ls/definition.cr +++ b/src/ls/definition.cr @@ -4,7 +4,7 @@ module Mint class Definition < LSP::RequestMessage property params : LSP::TextDocumentPositionParams - def execute(server) : Array(LSP::LocationLink | LSP::Location) | LSP::LocationLink | LSP::Location | Nil + def execute(server) : Array(LSP::LocationLink) | Array(LSP::Location) | LSP::Location | Nil uri = URI.parse(params.text_document.uri) @@ -15,13 +15,35 @@ module Mint stack = server.nodes_at_cursor(params) - if node = stack[0]? - definition(node, server, workspace, stack) + return unless node = stack[0]? + + has_link_support = + server + .params + .try(&.capabilities.text_document) + .try(&.definition) + .try(&.link_support) || false + + links = definition(node, workspace, stack) + + case links + when Array(LSP::LocationLink) + # Return a singular `LSP::Location` if possible + return to_lsp_location(links.first) if !has_link_support && links.size == 1 + + return links.map { |link| to_lsp_location(link) } if !has_link_support + + # Prefer nil rather than an empty array + links unless links.empty? + when LSP::LocationLink + return to_lsp_location(links) if !has_link_support + + [links] end end end - def definition(node : Ast::Node, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::Node, workspace : Workspace, stack : Array(Ast::Node)) nil end @@ -44,10 +66,6 @@ module Mint workspace.ast.components.find(&.name.value.== name) end - def has_link_support?(server : Server) - !!(server.params.try &.capabilities.try &.text_document.try &.definition.try &.link_support) - end - def to_lsp_range(location : Ast::Node::Location) : LSP::Range LSP::Range.new( start: LSP::Position.new( @@ -61,26 +79,25 @@ module Mint ) end + def to_lsp_location(location_link : LSP::LocationLink) : LSP::Location + LSP::Location.new( + range: location_link.target_selection_range, + uri: location_link.target_uri, + ) + end + # Returns a `LSP::LocationLink` that links from *source* to the *target* node - # if the language server client has link support, otherwise it returns `LSP::Location`. # - # When returning a `LSP::LocationLink`, *parent* is used to provide the full range - # for the *target* node. For example, for a function, *target* would be the function name, - # and *parent* would be the whole node, including function body and any comments - def location_link(server : Server, source : Ast::Node, target : Ast::Node, parent : Ast::Node) : LSP::LocationLink | LSP::Location - if has_link_support?(server) - LSP::LocationLink.new( - origin_selection_range: to_lsp_range(source.location), - target_uri: "file://#{target.location.filename}", - target_range: to_lsp_range(parent.location), - target_selection_range: to_lsp_range(target.location) - ) - else - LSP::Location.new( - range: to_lsp_range(target.location), - uri: "file://#{target.location.filename}", - ) - end + # The *parent* node is used to provide the full range for the *target* node. + # For example, for a function, *target* would be the function name, and *parent* + # would be the whole node, including function body and any comments + def location_link(source : Ast::Node, target : Ast::Node, parent : Ast::Node) : LSP::LocationLink + LSP::LocationLink.new( + origin_selection_range: to_lsp_range(source.location), + target_uri: "file://#{target.location.filename}", + target_range: to_lsp_range(parent.location), + target_selection_range: to_lsp_range(target.location) + ) end end end diff --git a/src/ls/definition/connect.cr b/src/ls/definition/connect.cr index d8f659d2e..23df69be4 100644 --- a/src/ls/definition/connect.cr +++ b/src/ls/definition/connect.cr @@ -1,13 +1,13 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::Connect, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::Connect, workspace : Workspace, stack : Array(Ast::Node)) return unless cursor_intersects?(node.store) return unless store = workspace.ast.stores.find(&.name.value.==(node.store.value)) - location_link server, node.store, store.name, store + location_link node.store, store.name, store end end end diff --git a/src/ls/definition/connect_variable.cr b/src/ls/definition/connect_variable.cr index 87da6e539..db055da69 100644 --- a/src/ls/definition/connect_variable.cr +++ b/src/ls/definition/connect_variable.cr @@ -1,7 +1,7 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::ConnectVariable, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::ConnectVariable, workspace : Workspace, stack : Array(Ast::Node)) return unless cursor_intersects?(node.variable) return unless connect = stack[1]?.as?(Ast::Connect) @@ -16,7 +16,7 @@ module Mint case target when Ast::Function, Ast::State, Ast::Get, Ast::Constant - location_link server, node.variable, target.name, target + location_link node.variable, target.name, target end end end diff --git a/src/ls/definition/enum_destructuring.cr b/src/ls/definition/enum_destructuring.cr index c1668b3b2..2ec266064 100644 --- a/src/ls/definition/enum_destructuring.cr +++ b/src/ls/definition/enum_destructuring.cr @@ -1,7 +1,7 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::EnumDestructuring, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::EnumDestructuring, workspace : Workspace, stack : Array(Ast::Node)) return unless name = node.name return unless enum_node = workspace.ast.enums.find(&.name.value.==(name.value)) @@ -10,12 +10,12 @@ module Mint case when cursor_intersects?(name) - location_link server, name, enum_node.name, enum_node + location_link name, enum_node.name, enum_node when cursor_intersects?(node.option) return unless option = enum_node.try &.options.find(&.value.value.==(node.option.value)) - location_link server, node.option, option.value, option + location_link node.option, option.value, option end end end diff --git a/src/ls/definition/enum_id.cr b/src/ls/definition/enum_id.cr index 0b4c91b91..7396c2caa 100644 --- a/src/ls/definition/enum_id.cr +++ b/src/ls/definition/enum_id.cr @@ -1,7 +1,7 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::EnumId, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::EnumId, workspace : Workspace, stack : Array(Ast::Node)) name = node.name # When `.name` is nil the node is used as a CONSTANT @@ -15,7 +15,7 @@ module Mint Ast::Provider parent.constants.each do |constant| if node.option.value == constant.name.value - return location_link server, node.option, constant.name, constant + return location_link node.option, constant.name, constant end end end @@ -28,12 +28,12 @@ module Mint case when cursor_intersects?(name) - location_link server, name, enum_node.name, enum_node + location_link name, enum_node.name, enum_node when cursor_intersects?(node.option) return unless option = enum_node.try &.options.find(&.value.value.==(node.option.value)) - location_link server, node.option, option.value, option + location_link node.option, option.value, option end end end diff --git a/src/ls/definition/html_attribute.cr b/src/ls/definition/html_attribute.cr index 8421671ec..7275a1e81 100644 --- a/src/ls/definition/html_attribute.cr +++ b/src/ls/definition/html_attribute.cr @@ -1,7 +1,7 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::HtmlAttribute, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::HtmlAttribute, workspace : Workspace, stack : Array(Ast::Node)) return unless cursor_intersects?(node.name) return unless html_component = stack.find(&.is_a?(Ast::HtmlComponent)).as?(Ast::HtmlComponent) @@ -12,7 +12,7 @@ module Mint return unless component_property = component.properties.find(&.name.value.== node.name.value) - location_link server, node.name, component_property.name, component_property + location_link node.name, component_property.name, component_property end end end diff --git a/src/ls/definition/html_component.cr b/src/ls/definition/html_component.cr index f2e4956f8..63a61d75a 100644 --- a/src/ls/definition/html_component.cr +++ b/src/ls/definition/html_component.cr @@ -1,13 +1,13 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::HtmlComponent, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::HtmlComponent, workspace : Workspace, stack : Array(Ast::Node)) return unless cursor_intersects?(node.component) return unless component = find_component(workspace, node.component.value) - location_link server, node.component, component.name, component + location_link node.component, component.name, component end end end diff --git a/src/ls/definition/html_element.cr b/src/ls/definition/html_element.cr index cf2b1e671..aa43a0c5a 100644 --- a/src/ls/definition/html_element.cr +++ b/src/ls/definition/html_element.cr @@ -1,11 +1,11 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::HtmlElement, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::HtmlElement, workspace : Workspace, stack : Array(Ast::Node)) node.styles.each do |style| next unless cursor_intersects?(style) - return definition(style, server, workspace, stack) + return definition(style, workspace, stack) end end end diff --git a/src/ls/definition/html_style.cr b/src/ls/definition/html_style.cr index c837af679..2e62b9667 100644 --- a/src/ls/definition/html_style.cr +++ b/src/ls/definition/html_style.cr @@ -1,7 +1,7 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::HtmlStyle, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::HtmlStyle, workspace : Workspace, stack : Array(Ast::Node)) return unless cursor_intersects?(node.name) return unless component = stack.find(&.is_a?(Ast::Component)).as?(Ast::Component) @@ -9,7 +9,7 @@ module Mint return unless component_style = component.styles.find(&.name.value.== node.name.value) - location_link server, node.name, component_style.name, component_style + location_link node.name, component_style.name, component_style end end end diff --git a/src/ls/definition/module_access.cr b/src/ls/definition/module_access.cr index 6a67c510d..e4314ccdd 100644 --- a/src/ls/definition/module_access.cr +++ b/src/ls/definition/module_access.cr @@ -1,7 +1,7 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::ModuleAccess, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::ModuleAccess, workspace : Workspace, stack : Array(Ast::Node)) lookup = workspace.type_checker.lookups[node.variable]? if lookup @@ -11,7 +11,7 @@ module Mint Ast::Function, Ast::State, Ast::Get - location_link server, node.variable, lookup.name, lookup + location_link node.variable, lookup.name, lookup end end end diff --git a/src/ls/definition/type.cr b/src/ls/definition/type.cr index dc6d3fa39..321c95d3f 100644 --- a/src/ls/definition/type.cr +++ b/src/ls/definition/type.cr @@ -1,7 +1,7 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::Type, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::Type, workspace : Workspace, stack : Array(Ast::Node)) return unless cursor_intersects?(node.name) enum_node = @@ -10,14 +10,14 @@ module Mint if enum_node return if Core.ast.enums.includes?(enum_node) - location_link server, node.name, enum_node.name, enum_node + location_link node.name, enum_node.name, enum_node else return unless record = workspace.ast.records.find(&.name.value.==(node.name.value)) return if Core.ast.records.includes?(record) - location_link server, node.name, record.name, record + location_link node.name, record.name, record end end end diff --git a/src/ls/definition/type_id.cr b/src/ls/definition/type_id.cr index ad74293d1..2398df353 100644 --- a/src/ls/definition/type_id.cr +++ b/src/ls/definition/type_id.cr @@ -1,7 +1,7 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::TypeId, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::TypeId, workspace : Workspace, stack : Array(Ast::Node)) case stack[1]? when Ast::ModuleAccess links = workspace.ast.modules @@ -9,10 +9,9 @@ module Mint .reject(&.in?(Core.ast.nodes)) .sort_by!(&.input.file) .map do |mod| - location_link server, node, mod.name, mod + location_link node, mod.name, mod end - return links.first if links.size == 1 return links unless links.empty? end @@ -23,14 +22,14 @@ module Mint find_component(workspace, node.value) if found.nil? && (next_node = stack[1]) - return definition(next_node, server, workspace, stack) + return definition(next_node, workspace, stack) end return if Core.ast.nodes.includes?(found) case found when Ast::Store, Ast::Enum, Ast::Component, Ast::RecordDefinition - location_link server, node, found.name, found + location_link node, found.name, found end end end diff --git a/src/ls/definition/variable.cr b/src/ls/definition/variable.cr index 8894f9bb8..d2fe55243 100644 --- a/src/ls/definition/variable.cr +++ b/src/ls/definition/variable.cr @@ -1,20 +1,20 @@ module Mint module LS class Definition < LSP::RequestMessage - def definition(node : Ast::Variable, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def definition(node : Ast::Variable, workspace : Workspace, stack : Array(Ast::Node)) lookup = workspace.type_checker.variables[node]? if lookup - variable_lookup_parent(node, lookup[1], server, workspace) || - variable_connect(node, lookup[2], server) || - variable_lookup(node, lookup[0], server) + variable_lookup_parent(node, lookup[1], workspace) || + variable_connect(node, lookup[2]) || + variable_lookup(node, lookup[0]) else - variable_record_key(node, server, workspace, stack) || - variable_next_key(node, server, workspace, stack) + variable_record_key(node, workspace, stack) || + variable_next_key(node, workspace, stack) end end - def variable_connect(node : Ast::Variable, parents : Array(TypeChecker::Scope::Node), server : Server) + def variable_connect(node : Ast::Variable, parents : Array(TypeChecker::Scope::Node)) # Check to see if this variable is defined as an Ast::ConnectVariable # as the `.variables` cache links directly to the stores state/function etc return unless component = parents.select(Ast::Component).first? @@ -24,13 +24,13 @@ module Mint variable = key.name || key.variable if variable.value == node.value - return location_link server, node, variable, connect + return location_link node, variable, connect end end end end - def variable_lookup_parent(node : Ast::Variable, target : TypeChecker::Scope::Node, server : Server, workspace : Workspace) + def variable_lookup_parent(node : Ast::Variable, target : TypeChecker::Scope::Node, workspace : Workspace) case target when Tuple(String, TypeChecker::Checkable, Ast::Node) case variable = target[2] @@ -44,12 +44,12 @@ module Mint .select(&.input.file.==(variable.input.file)) .find { |other| other.from < variable.from && other.to > variable.to } - location_link server, node, variable, parent + location_link node, variable, parent end end end - def variable_lookup(node : Ast::Variable, target : Ast::Node | TypeChecker::Checkable, server : Server) + def variable_lookup(node : Ast::Variable, target : Ast::Node | TypeChecker::Checkable) case item = target when Ast::Node name = case item @@ -64,11 +64,11 @@ module Mint item end - location_link server, node, name, item + location_link node, name, item end end - def variable_record_key(node : Ast::Variable, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def variable_record_key(node : Ast::Variable, workspace : Workspace, stack : Array(Ast::Node)) case field = stack[1]? when Ast::RecordField return unless record_name = workspace.type_checker.record_field_lookup[field]? @@ -79,11 +79,11 @@ module Mint .find(&.name.value.==(record_name)) .try(&.fields.find(&.key.value.==(node.value))) - location_link server, node, record_definition_field.key, record_definition_field + location_link node, record_definition_field.key, record_definition_field end end - def variable_next_key(node : Ast::Variable, server : Server, workspace : Workspace, stack : Array(Ast::Node)) + def variable_next_key(node : Ast::Variable, workspace : Workspace, stack : Array(Ast::Node)) case next_call = stack[3]? when Ast::NextCall return unless parent = workspace.type_checker.lookups[next_call] @@ -93,7 +93,7 @@ module Mint parent.states.find(&.name.value.==(node.value)) end - location_link server, node, state.name, state + location_link node, state.name, state end end end diff --git a/src/parser.cr b/src/parser.cr index 1b16dff1f..b03f3adea 100644 --- a/src/parser.cr +++ b/src/parser.cr @@ -23,16 +23,29 @@ module Mint def start(&) start_position = position - node_size = ast.nodes.size + + nodes_size = ast.nodes.size + keywords_size = ast.keywords.size + operators_size = ast.operators.size begin node = yield position @position = start_position unless node - ast.nodes.delete_at(node_size...) unless node + + unless node + ast.nodes.delete_at(nodes_size...) + ast.keywords.delete_at(keywords_size...) + ast.operators.delete_at(operators_size...) + end + node rescue error : Error @position = start_position - ast.nodes.delete_at(node_size...) + + ast.nodes.delete_at(nodes_size...) + ast.keywords.delete_at(keywords_size...) + ast.operators.delete_at(operators_size...) + raise error end end diff --git a/src/parsers/enum_destructuring.cr b/src/parsers/enum_destructuring.cr index a22606b90..7d6e8e7e4 100644 --- a/src/parsers/enum_destructuring.cr +++ b/src/parsers/enum_destructuring.cr @@ -6,11 +6,11 @@ module Mint def enum_destructuring start do |start_position| - next unless option = type_id + next unless option = type_id track: false if keyword "::" name = option - option = type_id! EnumDestructuringExpectedOption + option = type_id! EnumDestructuringExpectedOption, track: false end parameters = [] of Ast::Node diff --git a/src/parsers/enum_id.cr b/src/parsers/enum_id.cr index 89ae563b9..aada4b458 100644 --- a/src/parsers/enum_id.cr +++ b/src/parsers/enum_id.cr @@ -30,11 +30,11 @@ module Mint def enum_id start do |start_position| - next unless option = type_id + next unless option = type_id track: false if keyword "::" name = option - option = type_id! EnumIdExpectedOption + option = type_id! EnumIdExpectedOption, track: false end self << Ast::EnumId.new(