|
| 1 | +Test that hovering over jkind annotations shows their full expansion. |
| 2 | + |
| 3 | + $ file="test.ml" |
| 4 | + |
| 5 | + $ print_merlin_result () { |
| 6 | + > result="$1" |
| 7 | + > line=$(echo "$result" | jq '.start.line') |
| 8 | + > start=$(echo "$result" | jq '.start.col') |
| 9 | + > end=$(echo "$result" | jq '.end.col') |
| 10 | + > |
| 11 | + > start_for_cut=$((start + 1)) |
| 12 | + > end_for_cut=$((end + 1)) |
| 13 | + > value=$(sed -n "${line}p" "$file" | cut -c "${start_for_cut}-${end_for_cut}") |
| 14 | + > type=$(echo "$result" | jq '.type' -r) |
| 15 | + > echo "\"$value\" : \"$type\"" |
| 16 | + > } |
| 17 | + |
| 18 | + $ hover () { |
| 19 | + > line="$1" |
| 20 | + > col="$2" |
| 21 | + > enclosings="$3" |
| 22 | + > |
| 23 | + > # Print the location we are hovering |
| 24 | + > sed -n "${line}p" "$file" |
| 25 | + > printf '%*s^\n' "$col" '' |
| 26 | + > |
| 27 | + > # Then print the output from Merlin |
| 28 | + > $MERLIN single type-enclosing -position "$line:$col" -filename "$file" < "$file" \ |
| 29 | + > | jq -c ".value[:$enclosings][]" \ |
| 30 | + > | while read -r result; do |
| 31 | + > print_merlin_result "$result" |
| 32 | + > done |
| 33 | + > } |
| 34 | + |
| 35 | + $ cat > "$file" << EOF |
| 36 | + > type t1 : immutable_data |
| 37 | + > type t2 : value mod portable |
| 38 | + > type ('a : immediate) t3 : value |
| 39 | + > type 'a t4 : immutable_data mod global with 'a |
| 40 | + > EOF |
| 41 | +
|
| 42 | + $ hover 1 14 1 |
| 43 | + type t1 : immutable_data |
| 44 | + ^ |
| 45 | + "immutable_data" : "value mod forkable unyielding many stateless immutable non_float" |
| 46 | +
|
| 47 | + $ hover 2 11 2 |
| 48 | + type t2 : value mod portable |
| 49 | + ^ |
| 50 | + "value " : "value" |
| 51 | + "value mod portable" : "value mod portable" |
| 52 | +
|
| 53 | + $ hover 3 16 1 |
| 54 | + type ('a : immediate) t3 : value |
| 55 | + ^ |
| 56 | + "immediate)" : "value mod global many stateless immutable external_ non_float" |
| 57 | + |
| 58 | + $ hover 3 28 2 |
| 59 | + type ('a : immediate) t3 : value |
| 60 | + ^ |
| 61 | + "value" : "value" |
| 62 | + "type ('a : immediate) t3 : value" : "type ('a : immediate) t3" |
| 63 | +
|
| 64 | +# CR-someday: It'd be nice to print the with-bounds when we enclose the whole jkind |
| 65 | + $ hover 4 20 3 |
| 66 | + type 'a t4 : immutable_data mod global with 'a |
| 67 | + ^ |
| 68 | + "immutable_data " : "value mod forkable unyielding many stateless immutable non_float" |
| 69 | + "immutable_data mod global " : "value mod global many stateless immutable non_float" |
| 70 | + "type 'a t4 : immutable_data mod global with 'a" : "type 'a t4 : immutable_data mod global unforkable yielding with 'a" |
0 commit comments