Skip to content

Commit 72c6c12

Browse files
Added documentation describing guidelines for writing scope tests
1 parent d53a450 commit 72c6c12

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

packages/cursorless-org-docs/src/docs/contributing/scope-test-format.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ The below example indicates that the content range, removal range, and domain ra
5656

5757
Each range is also visualized:
5858

59+
Single line range
60+
61+
```
62+
>------------<
63+
0| if (true) {}
64+
```
65+
66+
Multi line range
67+
5968
```
6069
>-----------
6170
0| if (true) {
@@ -65,3 +74,30 @@ Each range is also visualized:
6574
```
6675

6776
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 `><`.
77+
78+
## Style guidelines
79+
80+
For ease of readability we want all scope test to follow the recommended style guidelines.
81+
82+
### Naming convention and values
83+
84+
- 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.
85+
- For arguments and parameters we usually use: `aaa`, `bbb`, `ccc` and so on.
86+
- For data type we usually use `int` or `number`.
87+
- For value we usually use `0`, `1`, `2` and so on.
88+
89+
### Keep it compact
90+
91+
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.
92+
93+
```
94+
>---<
95+
0| class Foo {}
96+
```
97+
98+
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:
99+
100+
```
101+
>-<
102+
0| class Foo { }
103+
```

0 commit comments

Comments
 (0)