You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/cursorless-org-docs/src/docs/contributing/scope-test-format.md
+59-12Lines changed: 59 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,22 +4,16 @@ We have a custom format we use to test that our scopes are correct. The format i
4
4
5
5
## Example
6
6
7
-
Example of `.scope` file for the javascript if statement scope.
7
+
Example of `.scope` file for the javascript statement scope.
8
8
9
9
```
10
-
if (true) {
11
-
12
-
}
10
+
const value = 0;
13
11
---
14
-
15
12
[Content] =
16
13
[Removal] =
17
-
[Domain] = 0:0-2:1
18
-
>-----------
19
-
0| if (true) {
20
-
1|
21
-
2| }
22
-
-<
14
+
[Domain] = 0:0-0:16
15
+
>----------------<
16
+
0| const value = 0;
23
17
24
18
[Insertion delimiter] = "\n"
25
19
```
@@ -46,16 +40,34 @@ A description of the different ranges and how they are used is available in our
46
40
47
41
### Scope ranges
48
42
49
-
The below example indicates that the content range, removal range, and domain range was the same. Line 0, column 0, to line 2, column 1. These ranges could also be different and in that case each show up as a separate range.
43
+
The below example indicates that the content range, removal range, and domain range was the same. Line 0, column 0, to line 0, column 16.
50
44
51
45
```
52
46
[Content] =
53
47
[Removal] =
54
48
[Domain] = 0:0-2:1
55
49
```
56
50
51
+
These ranges could also be different and in that case each show up as a separate range.
52
+
53
+
```
54
+
[Removal] =
55
+
[Content] = 0:0-0:6
56
+
57
+
[Domain] = 0:0-2:1
58
+
```
59
+
57
60
Each range is also visualized:
58
61
62
+
Single line range
63
+
64
+
```
65
+
>------------<
66
+
0| if (true) {}
67
+
```
68
+
69
+
Multi line range
70
+
59
71
```
60
72
>-----------
61
73
0| if (true) {
@@ -65,3 +77,38 @@ Each range is also visualized:
65
77
```
66
78
67
79
On the left hand side we first have the line numbers, a pipe separator, and finally the source code. The range is visualized by starting after `>` and ending before `<`. Note that `>` and `<` is excluded from the range. That means a range of length one is `>-<` and an empty range is `><`.
80
+
81
+
## Style guidelines
82
+
83
+
For ease of readability we want all scope test to follow the recommended style guidelines.
84
+
85
+
### Naming convention and values
86
+
87
+
- For classes, functions and variables we use the classic: `foo`, `bar`, `baz`, `bongo`. Language specific formatting still applies. eg `Foo` for a class in Java, `IFoo` for an interface in C# etc.
88
+
- For arguments and parameters we usually use: `aaa`, `bbb`, `ccc` and so on.
89
+
- For data type we usually use `int` or `number`.
90
+
- For value we usually use `0`, `1`, `2` and so on.
91
+
92
+
Examples:
93
+
94
+
```
95
+
class Foo {}
96
+
int foo = 0;
97
+
foo(aaa, bbb);
98
+
```
99
+
100
+
### Keep it compact
101
+
102
+
Don't add more lines than the example actually needs. For example if the test is about the class name, the facet `name.class`: there is no point having a lot of code in the class body or having its span multiple lines.
103
+
104
+
```
105
+
>---<
106
+
0| class Foo {}
107
+
```
108
+
109
+
Sometimes we actually need a body but that doesn't mean that we need it to be multiple lines. The facet `interior.class` can look like this:
0 commit comments