Skip to content

Commit

Permalink
Merge branch 'master' of github.com:flix/vscode-flix
Browse files Browse the repository at this point in the history
  • Loading branch information
magnus-madsen committed Aug 20, 2024
2 parents acce07d + 41342e6 commit b3c21b8
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 83 deletions.
12 changes: 0 additions & 12 deletions syntaxes/flix.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,6 @@
"name": "keyword.expression.import.flix",
"match": "\\b(import)\\b"
},
{
"name": "keyword.expression.javanew.flix",
"match": "\\b(java_new)\\b"
},
{
"name": "keyword.expression.javagetfield.flix",
"match": "\\b(java_get_field)\\b"
},
{
"name": "keyword.expression.javasetfield.flix",
"match": "\\b(java_set_field)\\b"
},
{
"name": "keyword.expression.let.flix",
"match": "\\b(let\\*|let)\\b"
Expand Down
38 changes: 20 additions & 18 deletions test/src/findReferences.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ suite('Find references', () => {
})

test('Should find references to Dividable trait', async () => {
await testFindReferences(dividableDocUri, new vscode.Position(5, 6), [
new vscode.Location(dividableDocUri, new vscode.Range(5, 6, 5, 15)),
new vscode.Location(dividableDocUri, new vscode.Range(10, 9, 10, 18)),
await testFindReferences(dividableDocUri, new vscode.Position(1, 6), [
new vscode.Location(dividableDocUri, new vscode.Range(1, 6, 1, 15)),
new vscode.Location(dividableDocUri, new vscode.Range(5, 9, 5, 18)),
])
})

Expand All @@ -79,21 +79,21 @@ suite('Find references', () => {
test('Should find references to Equatable.equals signature', async () => {
await testFindReferences(equatableDocUri, new vscode.Position(2, 12), [
new vscode.Location(equatableDocUri, new vscode.Range(2, 12, 2, 18)),
new vscode.Location(equatableDocUri, new vscode.Range(9, 51, 9, 57)),
new vscode.Location(equatableDocUri, new vscode.Range(22, 14, 22, 20)),
new vscode.Location(equatableDocUri, new vscode.Range(29, 14, 29, 20)),
new vscode.Location(equatableDocUri, new vscode.Range(36, 18, 36, 24)),
new vscode.Location(equatableDocUri, new vscode.Range(43, 18, 43, 24)),
new vscode.Location(equatableDocUri, new vscode.Range(9, 41, 9, 57)),
new vscode.Location(equatableDocUri, new vscode.Range(22, 4, 22, 20)),
new vscode.Location(equatableDocUri, new vscode.Range(29, 4, 29, 20)),
new vscode.Location(equatableDocUri, new vscode.Range(36, 8, 36, 24)),
new vscode.Location(equatableDocUri, new vscode.Range(43, 8, 43, 24)),
])
})
test('Should find references to Equatable.equals signature-use', async () => {
await testFindReferences(equatableDocUri, new vscode.Position(29, 14), [
new vscode.Location(equatableDocUri, new vscode.Range(2, 12, 2, 18)),
new vscode.Location(equatableDocUri, new vscode.Range(9, 51, 9, 57)),
new vscode.Location(equatableDocUri, new vscode.Range(22, 14, 22, 20)),
new vscode.Location(equatableDocUri, new vscode.Range(29, 14, 29, 20)),
new vscode.Location(equatableDocUri, new vscode.Range(36, 18, 36, 24)),
new vscode.Location(equatableDocUri, new vscode.Range(43, 18, 43, 24)),
new vscode.Location(equatableDocUri, new vscode.Range(9, 41, 9, 57)),
new vscode.Location(equatableDocUri, new vscode.Range(22, 4, 22, 20)),
new vscode.Location(equatableDocUri, new vscode.Range(29, 4, 29, 20)),
new vscode.Location(equatableDocUri, new vscode.Range(36, 8, 36, 24)),
new vscode.Location(equatableDocUri, new vscode.Range(43, 8, 43, 24)),
])
})

Expand All @@ -111,28 +111,30 @@ suite('Find references', () => {
])
})

test('Should find references to Dividable.Aef associated effect', async () => {
/////// See https://github.com/flix/flix/issues/8326 ///////
test.skip('Should find references to Dividable.Aef associated effect', async () => {
await testFindReferences(dividableDocUri, new vscode.Position(6, 9), [
new vscode.Location(dividableDocUri, new vscode.Range(6, 9, 6, 12)),
new vscode.Location(dividableDocUri, new vscode.Range(7, 33, 7, 46)),
new vscode.Location(dividableDocUri, new vscode.Range(11, 9, 11, 12)),
])
})

test('Should find references to DivByZero effect', async () => {
test.skip('Should find references to DivByZero effect', async () => {
await testFindReferences(dividableDocUri, new vscode.Position(1, 4), [
new vscode.Location(dividableDocUri, new vscode.Range(1, 4, 1, 13)),
new vscode.Location(dividableDocUri, new vscode.Range(11, 15, 11, 24)),
new vscode.Location(dividableDocUri, new vscode.Range(12, 45, 12, 54)),
])
})

test('Should find references to DivByZero.throw operation', async () => {
test.skip('Should find references to DivByZero.throw operation', async () => {
await testFindReferences(dividableDocUri, new vscode.Position(2, 12), [
new vscode.Location(dividableDocUri, new vscode.Range(2, 12, 2, 17)),
new vscode.Location(dividableDocUri, new vscode.Range(13, 23, 13, 38)),
])
})
////////////////////////////////////////////////////////////

test('Should find references to function parameter', async () => {
await testFindReferences(equatableDocUri, new vscode.Position(6, 19), [
Expand Down Expand Up @@ -179,8 +181,8 @@ suite('Find references', () => {
new vscode.Location(recordsDocUri, new vscode.Range(2, 48, 2, 49)),
new vscode.Location(recordsDocUri, new vscode.Range(3, 6, 3, 7)),
new vscode.Location(recordsDocUri, new vscode.Range(13, 14, 13, 15)),
new vscode.Location(recordsDocUri, new vscode.Range(15, 7, 15, 8)),
new vscode.Location(recordsDocUri, new vscode.Range(15, 14, 15, 15)),
new vscode.Location(recordsDocUri, new vscode.Range(15, 8, 15, 9)),
new vscode.Location(recordsDocUri, new vscode.Range(15, 15, 15, 16)),
])
})
})
48 changes: 23 additions & 25 deletions test/src/highlight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as assert from 'assert'
import * as vscode from 'vscode'
import { getTestDocUri, init, stringify } from './util'
import { getTestDocUri, init } from './util'

suite('Highlight uses', () => {
const mainDocUri = getTestDocUri('src/Main.flix')
Expand Down Expand Up @@ -49,33 +49,27 @@ suite('Highlight uses', () => {

const actualRanges = r.map(h => h.range)

// TODO: Require that they match exactly (https://github.com/flix/flix/issues/7742)
for (const expectedRange of expectedRanges) {
assert.ok(
actualRanges.some(r => r.isEqual(expectedRange)),
`Expected range ${stringify(expectedRange)} not found in ${stringify(actualRanges)}`,
)
}
assert.deepStrictEqual(new Set(actualRanges), new Set(expectedRanges))
}

test('Should find highlights of Shape.Circle case', async () => {
await testHighlight(mainDocUri, new vscode.Position(3, 9), [
new vscode.Range(3, 9, 3, 22),
new vscode.Range(12, 52, 12, 58),
new vscode.Range(12, 46, 12, 58),
new vscode.Range(17, 17, 17, 29),
])
})
test('Should find highlights of Shape.Circle case-use', async () => {
await testHighlight(mainDocUri, new vscode.Position(12, 52), [
new vscode.Range(3, 9, 3, 22),
new vscode.Range(12, 52, 12, 58),
new vscode.Range(12, 46, 12, 58),
new vscode.Range(17, 17, 17, 29),
])
})
test('Should find highlights of Shape.Circle case-use from pattern match', async () => {
await testHighlight(mainDocUri, new vscode.Position(17, 23), [
new vscode.Range(3, 9, 3, 22),
new vscode.Range(12, 52, 12, 58),
new vscode.Range(12, 46, 12, 58),
new vscode.Range(17, 17, 17, 29),
])
})
Expand All @@ -96,19 +90,21 @@ suite('Highlight uses', () => {
test('Should find highlights of Equatable.equals signature', async () => {
await testHighlight(equatableDocUri, new vscode.Position(2, 12), [
new vscode.Range(2, 12, 2, 18),
new vscode.Range(9, 51, 9, 57),
new vscode.Range(22, 14, 22, 20),
new vscode.Range(29, 14, 29, 20),
new vscode.Range(36, 18, 36, 24),
new vscode.Range(9, 41, 9, 57),
new vscode.Range(22, 4, 22, 20),
new vscode.Range(29, 4, 29, 20),
new vscode.Range(36, 8, 36, 24),
new vscode.Range(43, 8, 43, 24),
])
})
test('Should find highlights of Equatable.equals signature-use', async () => {
await testHighlight(equatableDocUri, new vscode.Position(29, 20), [
new vscode.Range(2, 12, 2, 18),
new vscode.Range(9, 51, 9, 57),
new vscode.Range(22, 14, 22, 20),
new vscode.Range(29, 14, 29, 20),
new vscode.Range(36, 18, 36, 24),
new vscode.Range(9, 41, 9, 57),
new vscode.Range(22, 4, 22, 20),
new vscode.Range(29, 4, 29, 20),
new vscode.Range(36, 8, 36, 24),
new vscode.Range(43, 8, 43, 24),
])
})

Expand All @@ -119,34 +115,36 @@ suite('Highlight uses', () => {
])
})

test('Should find highlights of Aef associated effect', async () => {
/////// See https://github.com/flix/flix/issues/8326 ///////
test.skip('Should find highlights of Aef associated effect', async () => {
await testHighlight(dividableDocUri, new vscode.Position(6, 9), [
new vscode.Range(6, 9, 6, 12),
new vscode.Range(7, 33, 7, 46),
new vscode.Range(11, 9, 11, 12),
])
})

test('Should find highlights of DivByZero effect', async () => {
test.skip('Should find highlights of DivByZero effect', async () => {
await testHighlight(dividableDocUri, new vscode.Position(1, 4), [
new vscode.Range(1, 4, 1, 13),
new vscode.Range(11, 15, 11, 24),
new vscode.Range(12, 45, 12, 54),
])
})

test('Should find highlights of DivByZero.throw operation', async () => {
test.skip('Should find highlights of DivByZero.throw operation', async () => {
await testHighlight(dividableDocUri, new vscode.Position(2, 12), [
new vscode.Range(2, 12, 2, 17),
new vscode.Range(13, 23, 13, 38),
])
})
test('Should find highlights of DivByZero.throw operation-use', async () => {
test.skip('Should find highlights of DivByZero.throw operation-use', async () => {
await testHighlight(dividableDocUri, new vscode.Position(13, 23), [
new vscode.Range(2, 12, 2, 17),
new vscode.Range(13, 23, 13, 38),
])
})
////////////////////////////////////////////////////////////

test('Should find highlights of function parameter', async () => {
await testHighlight(equatableDocUri, new vscode.Position(6, 19), [
Expand Down Expand Up @@ -193,8 +191,8 @@ suite('Highlight uses', () => {
new vscode.Range(2, 48, 2, 49),
new vscode.Range(3, 6, 3, 7),
new vscode.Range(13, 14, 13, 15),
new vscode.Range(15, 7, 15, 8),
new vscode.Range(15, 14, 15, 15),
new vscode.Range(15, 8, 15, 9),
new vscode.Range(15, 15, 15, 16),
])
})
})
4 changes: 2 additions & 2 deletions test/src/implementation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ suite('Find implementations', () => {
}

test('Should find Dividable trait implementation', async () => {
await testImplementations(dividableDocUri, new vscode.Position(5, 6), [
new vscode.Location(dividableDocUri, new vscode.Range(10, 9, 10, 18)),
await testImplementations(dividableDocUri, new vscode.Position(1, 6), [
new vscode.Location(dividableDocUri, new vscode.Range(5, 9, 5, 18)),
])
})
})
12 changes: 7 additions & 5 deletions test/src/rename.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,26 @@ suite('Rename', () => {
assert.deepStrictEqual(new Set(actualRangesString), new Set(expectedRangesString))
}

test('Should rename Shape.Circle case', async () => {
/////// See https://github.com/flix/flix/issues/8355 ///////
test.skip('Should rename Shape.Circle case', async () => {
await testRename(mainDocUri, new vscode.Position(3, 9), [
[mainDocUri, [new vscode.Range(3, 9, 3, 15), new vscode.Range(12, 52, 12, 58), new vscode.Range(17, 17, 17, 29)]],
[areaDocUri, [new vscode.Range(5, 13, 5, 25)]],
])
})
test('Should rename Shape.Circle case-use', async () => {
test.skip('Should rename Shape.Circle case-use', async () => {
await testRename(mainDocUri, new vscode.Position(12, 52), [
[mainDocUri, [new vscode.Range(3, 9, 3, 15), new vscode.Range(12, 52, 12, 58), new vscode.Range(17, 17, 17, 29)]],
[areaDocUri, [new vscode.Range(5, 13, 5, 25)]],
])
})
test('Should rename Shape.Circle case-use from pattern match', async () => {
test.skip('Should rename Shape.Circle case-use from pattern match', async () => {
await testRename(mainDocUri, new vscode.Position(17, 23), [
[mainDocUri, [new vscode.Range(3, 9, 3, 15), new vscode.Range(12, 52, 12, 58), new vscode.Range(17, 17, 17, 29)]],
[areaDocUri, [new vscode.Range(5, 13, 5, 25)]],
])
})
////////////////////////////////////////////////////////////

test('Should rename area function', async () => {
await testRename(areaDocUri, new vscode.Position(3, 4), [
Expand Down Expand Up @@ -153,8 +155,8 @@ suite('Rename', () => {
new vscode.Range(2, 48, 2, 49),
new vscode.Range(3, 6, 3, 7),
new vscode.Range(13, 14, 13, 15),
new vscode.Range(15, 7, 15, 8),
new vscode.Range(15, 14, 15, 15),
new vscode.Range(15, 8, 15, 9),
new vscode.Range(15, 15, 15, 16),
],
],
])
Expand Down
12 changes: 3 additions & 9 deletions test/testWorkspaces/findReferences/src/Dividable.flix
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// Blank line
eff DivByZero {
pub def throw(): Void
}

trait Dividable[t] {
type Aef: Eff
pub def div(x: t, y: t): t \ Dividable.Aef[t]
pub def div(x: t, y: t): t
}

instance Dividable[Int32] {
type Aef = DivByZero
pub def div(x: Int32, y: Int32): Int32 \ DivByZero =
if (y == 0) do DivByZero.throw() else x / y
pub def div(x: Int32, y: Int32): Int32 =
x / y
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// TODO: Use this file instead as soon as https://github.com/flix/flix/issues/8326 is fixed.

// Blank line
eff DivByZero {
pub def throw(): Void
Expand Down
2 changes: 1 addition & 1 deletion test/testWorkspaces/findReferences/src/Records.flix
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def setY(r: {y = Int32 | a}, v: Int32): {y = Int32 | a} =
def testRecords(): Bool =
let r1 = {x = 1, y = 2};
let r2 = setX(r1, 3);
r1.x + r2.x == 4
(r1#x + r2#x) == 4

17 changes: 17 additions & 0 deletions test/testWorkspaces/highlight/src/Dividable.flix.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// TODO: Use this file instead as soon as https://github.com/flix/flix/issues/8326 is fixed.

// Blank line
eff DivByZero {
pub def throw(): Void
}

trait Dividable[t] {
type Aef: Eff
pub def div(x: t, y: t): t \ Dividable.Aef[t]
}

instance Dividable[Int32] {
type Aef = DivByZero
pub def div(x: Int32, y: Int32): Int32 \ DivByZero =
if (y == 0) do DivByZero.throw() else x / y
}
2 changes: 1 addition & 1 deletion test/testWorkspaces/highlight/src/Records.flix
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def setY(r: {y = Int32 | a}, v: Int32): {y = Int32 | a} =
def testRecords(): Bool =
let r1 = {x = 1, y = 2};
let r2 = setX(r1, 3);
r1.x + r2.x == 4
(r1#x + r2#x) == 4
12 changes: 3 additions & 9 deletions test/testWorkspaces/implementation/src/Dividable.flix
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// Blank line
eff DivByZero {
pub def throw(): Void
}

trait Dividable[t] {
type Aef: Eff
pub def div(x: t, y: t): t \ Dividable.Aef[t]
pub def div(x: t, y: t): t
}

instance Dividable[Int32] {
type Aef = DivByZero
pub def div(x: Int32, y: Int32): Int32 \ DivByZero =
if (y == 0) do DivByZero.throw() else x / y
pub def div(x: Int32, y: Int32): Int32 =
x / y
}
17 changes: 17 additions & 0 deletions test/testWorkspaces/implementation/src/Dividable.flix.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// TODO: Use this file instead as soon as https://github.com/flix/flix/issues/8326 is fixed.

// Blank line
eff DivByZero {
pub def throw(): Void
}

trait Dividable[t] {
type Aef: Eff
pub def div(x: t, y: t): t \ Dividable.Aef[t]
}

instance Dividable[Int32] {
type Aef = DivByZero
pub def div(x: Int32, y: Int32): Int32 \ DivByZero =
if (y == 0) do DivByZero.throw() else x / y
}
2 changes: 1 addition & 1 deletion test/testWorkspaces/rename/src/Records.flix
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def setY(r: {y = Int32 | a}, v: Int32): {y = Int32 | a} =
def testRecords(): Bool =
let r1 = {x = 1, y = 2};
let r2 = setX(r1, 3);
r1.x + r2.x == 4
(r1#x + r2#x) == 4

0 comments on commit b3c21b8

Please sign in to comment.