optics-framework-lsp 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- optics_framework_lsp-1.0.0/LICENSE +201 -0
- optics_framework_lsp-1.0.0/PKG-INFO +347 -0
- optics_framework_lsp-1.0.0/README.md +324 -0
- optics_framework_lsp-1.0.0/pyproject.toml +53 -0
- optics_framework_lsp-1.0.0/pyproject.toml.orig +46 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/__init__.py +2 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/cli.py +83 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/completion.py +467 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/keyword_catalog.py +47 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/keywords.py +353 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/lint.py +94 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/parser/__init__.py +0 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/parser/ast.py +76 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/parser/csv_parser.py +183 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/py.typed +0 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/rename.py +170 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/server.py +353 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/symbols.py +99 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/tokens.py +129 -0
- optics_framework_lsp-1.0.0/src/optics_framework_lsp/validation.py +387 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: optics-framework-lsp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Language server and linter for optics-framework csv test suites
|
|
5
|
+
Keywords: lsp,language-server,optics-framework,linter,test-automation,csv
|
|
6
|
+
Author: Bishwa Bhusan Saha
|
|
7
|
+
Author-email: Bishwa Bhusan Saha <77796630+kun-codes@users.noreply.github.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
14
|
+
Classifier: Topic :: Software Development :: Testing
|
|
15
|
+
Classifier: Topic :: Text Editors :: Integrated Development Environments (IDE)
|
|
16
|
+
Requires-Dist: pygls>=2.1.1
|
|
17
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
18
|
+
Requires-Python: >=3.14
|
|
19
|
+
Project-URL: Homepage, https://github.com/mozarkai/optics-framework-lsp
|
|
20
|
+
Project-URL: Repository, https://github.com/mozarkai/optics-framework-lsp
|
|
21
|
+
Project-URL: Issues, https://github.com/mozarkai/optics-framework-lsp/issues
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
<h1 align="center">optics-framework-lsp</h1>
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
A language server and linter for
|
|
28
|
+
<a href="https://mozarkai.github.io/optics-framework/">optics-framework</a> test suites.
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<a href="https://github.com/mozarkai/optics-framework-lsp/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="License"></a>
|
|
33
|
+
<img src="https://img.shields.io/badge/python-3.14%2B-blue" alt="Python 3.14+">
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
An optics suite is CSV files referring to each other by name, and nothing checks that those
|
|
39
|
+
names line up. This does, across the whole project, over LSP while you type or as one command.
|
|
40
|
+
Its rules come from optics-framework's own readers, so it agrees with the runtime.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
uv tool install optics-framework-lsp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or from a checkout, for development:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
uv sync
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
# The linter
|
|
57
|
+
|
|
58
|
+
`optics-lsp lint` reports every problem in a suite in one shot. Point it at a project:
|
|
59
|
+
|
|
60
|
+
```console
|
|
61
|
+
$ optics-lsp lint ~/projects/my_project
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Line numbers are 1-based, matching your editor's status bar. A whole project takes about
|
|
65
|
+
60 ms including process start, because nothing on this path imports any LSP machinery.
|
|
66
|
+
|
|
67
|
+
**The exit code is 0 whenever validation ran**, findings or not. Non-zero means the input could
|
|
68
|
+
not be read at all. Which severities should block a pipeline is your policy, so read `status`
|
|
69
|
+
if you want that decision made for you.
|
|
70
|
+
|
|
71
|
+
<details>
|
|
72
|
+
<summary><b>JSON, for another program</b></summary>
|
|
73
|
+
|
|
74
|
+
Add `--json` for the machine-readable form. A caller holding uploaded files in memory, with
|
|
75
|
+
nothing on disk, can pipe them in instead and skip the filesystem entirely:
|
|
76
|
+
|
|
77
|
+
```console
|
|
78
|
+
$ echo '{"files": [{"name": "modules.csv", "content": "module_name,module_step\nM,Sleep\n"}]}' \
|
|
79
|
+
| optics-lsp lint
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Reading on stdin always answers JSON:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"status": "FAIL",
|
|
87
|
+
"analyzed": { "modules.csv": "modules" },
|
|
88
|
+
"skipped": [],
|
|
89
|
+
"diagnostics": [
|
|
90
|
+
{
|
|
91
|
+
"uri": "modules.csv",
|
|
92
|
+
"severity": "error",
|
|
93
|
+
"code": "keyword-arity",
|
|
94
|
+
"message": "'Sleep' takes 1-1 params, got 0",
|
|
95
|
+
"row": 2,
|
|
96
|
+
"range": { "startLine": 1, "startColumn": 0, "endLine": 2, "endColumn": 0 },
|
|
97
|
+
"source": "optics"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`row` is 1-based for a person, `range` is 0-based for an editor. Diagnostics arrive sorted by
|
|
104
|
+
file then row, so a caller need not re-sort.
|
|
105
|
+
|
|
106
|
+
Shelling out from Node: pass the arguments as an array with the payload on stdin rather than
|
|
107
|
+
interpolating either into a shell string, and raise `maxBuffer` past its 1 MB default.
|
|
108
|
+
|
|
109
|
+
</details>
|
|
110
|
+
|
|
111
|
+
<details>
|
|
112
|
+
<summary><b><code>analyzed</code> and <code>skipped</code>: which files were even looked at</b></summary>
|
|
113
|
+
|
|
114
|
+
File kind comes from the header row, not the filename. `analyzed` says what each file became
|
|
115
|
+
(`test_cases`, `modules`, `elements`, `error_definitions`); `skipped` lists the CSVs whose
|
|
116
|
+
header matched none of those.
|
|
117
|
+
|
|
118
|
+
optics ignores those files too, so a skipped file is usually a dataset and fine. But a
|
|
119
|
+
`test_cases` file with a typo in its header lands there as well, and would otherwise be
|
|
120
|
+
indistinguishable from a clean one.
|
|
121
|
+
|
|
122
|
+
</details>
|
|
123
|
+
|
|
124
|
+
## What it reports
|
|
125
|
+
|
|
126
|
+
Two severities, and the line between them is one question: **does optics fail, or does it run
|
|
127
|
+
and do something you probably didn't mean?**
|
|
128
|
+
|
|
129
|
+
Errors are a name that resolves to nothing, or a call the keyword rejects:
|
|
130
|
+
|
|
131
|
+
| code | meaning |
|
|
132
|
+
| --- | --- |
|
|
133
|
+
| `module-not-found` | a test step names a module no file defines |
|
|
134
|
+
| `keyword-not-found` | a module step is neither a keyword nor another module |
|
|
135
|
+
| `keyword-arity` | a keyword got too few or too many params |
|
|
136
|
+
| `element-not-found` | a `${ref}` has no element and nothing binds it |
|
|
137
|
+
|
|
138
|
+
Warnings mean it loads, but a row you wrote isn't doing what it looks like:
|
|
139
|
+
|
|
140
|
+
| code | meaning |
|
|
141
|
+
| --- | --- |
|
|
142
|
+
| `duplicate-module`, `duplicate-test-case` | the later definition wins, wherever the files sit |
|
|
143
|
+
| `duplicate-element` | a file repeats an entire element row |
|
|
144
|
+
| `duplicate-error-code`, `duplicate-match-string` | error definitions merge across files, so these clash |
|
|
145
|
+
| `error-definition-incomplete` | a row missing a column, so it never matches |
|
|
146
|
+
| `csv-too-few-columns` | the reader skips the row |
|
|
147
|
+
| `csv-too-many-columns` | the extra cells are dropped |
|
|
148
|
+
| `csv-whitespace-line` | a row of nothing but separators |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
# The language server
|
|
153
|
+
|
|
154
|
+
Run with no arguments and it speaks LSP over stdio. Unknown flags are ignored rather than
|
|
155
|
+
rejected, so a client that insists on passing `--stdio` needs no special handling.
|
|
156
|
+
|
|
157
|
+
One workspace folder is one project. Cross-file rules mean a single edit can change
|
|
158
|
+
diagnostics anywhere in the suite, so the whole folder is revalidated on every change, and the
|
|
159
|
+
server asks the client to watch `**/*.csv` so a git checkout is picked up too. Open buffers
|
|
160
|
+
override what is on disk. Dot folders are never descended into, because a project's `.venv` holds
|
|
161
|
+
optics-framework's own sample CSVs and images, which would invent element and module names the
|
|
162
|
+
project does not have.
|
|
163
|
+
|
|
164
|
+
## Features
|
|
165
|
+
|
|
166
|
+
<details open>
|
|
167
|
+
<summary><b>Diagnostics</b></summary>
|
|
168
|
+
|
|
169
|
+
Everything from the linter section above, live, across the whole project. Because resolution
|
|
170
|
+
is a project-wide question, defining an element in one file clears the `element-not-found` in
|
|
171
|
+
another without touching it.
|
|
172
|
+
|
|
173
|
+
</details>
|
|
174
|
+
|
|
175
|
+
<details>
|
|
176
|
+
<summary><b>Completion</b></summary>
|
|
177
|
+
|
|
178
|
+
Aware of which column you are in, because in a CSV the column *is* the context.
|
|
179
|
+
|
|
180
|
+
| where the cursor is | what is offered |
|
|
181
|
+
| --- | --- |
|
|
182
|
+
| an empty file | the four header rows, since the header decides the file's kind |
|
|
183
|
+
| `module_step` | every keyword **and** every module in the project, since a step can be either |
|
|
184
|
+
| a param cell | what that particular keyword accepts at that position |
|
|
185
|
+
| `test_step`, `module_name` | modules that already exist, since both columns continue a block |
|
|
186
|
+
| `element_name` | names used somewhere but never defined |
|
|
187
|
+
| any `element_id*` | template image filenames found anywhere in the project |
|
|
188
|
+
| `test_case` | existing test cases, plus the lifecycle names (`Suite Setup`, …) not yet used |
|
|
189
|
+
|
|
190
|
+
Param completion is specific rather than generic. `Read Data`'s second param offers the
|
|
191
|
+
project's data files; `Invoke API`'s first offers `collection.api` identifiers parsed out of
|
|
192
|
+
the project's YAML; `Run Loop` and `Execute Module` offer modules, written bare. Params with a
|
|
193
|
+
documented set of values offer exactly those. `direction` gives `up`, `down`, `left`, `right`;
|
|
194
|
+
`rule` gives `any`, `all`; `element_state` gives `visible`, `invisible`, `enabled`, `disabled`.
|
|
195
|
+
`Condition` alternates condition and target, so it offers modules in the target slots and
|
|
196
|
+
modules-or-variables in the others, with `!` inversion preserved.
|
|
197
|
+
|
|
198
|
+
Accepting a param the header does not yet cover **widens the header in the same edit**, because
|
|
199
|
+
`csv.DictReader` drops cells the header does not name and the param would otherwise silently
|
|
200
|
+
vanish.
|
|
201
|
+
|
|
202
|
+
</details>
|
|
203
|
+
|
|
204
|
+
<details>
|
|
205
|
+
<summary><b>Hover</b></summary>
|
|
206
|
+
|
|
207
|
+
A keyword's real signature and the framework's own docstring, which is where the accepted
|
|
208
|
+
values are actually written:
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
Press Element(element, repeat='1', offset_x='0', offset_y='0', index='0',
|
|
212
|
+
aoi_x='0', aoi_y='0', aoi_width='100', aoi_height='100', event_name=None)
|
|
213
|
+
|
|
214
|
+
Press a specified element.
|
|
215
|
+
|
|
216
|
+
:param element: The element to be pressed (text, xpath or image).
|
|
217
|
+
:param repeat: Number of times to repeat the press.
|
|
218
|
+
:param index: Index of the element if multiple matches are found.
|
|
219
|
+
:param aoi_width: Width percentage of Area of Interest (0-100). Default: 100.
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Defaults are rendered as `name='value'`, so what an omitted cell falls back to is visible
|
|
223
|
+
without reading the source.
|
|
224
|
+
|
|
225
|
+
</details>
|
|
226
|
+
|
|
227
|
+
<details>
|
|
228
|
+
<summary><b>Signature help</b></summary>
|
|
229
|
+
|
|
230
|
+
The keyword's params with the column you are in marked active, retriggering on every comma,
|
|
231
|
+
which is how you tell param 4 from param 5 in a row of commas.
|
|
232
|
+
|
|
233
|
+
</details>
|
|
234
|
+
|
|
235
|
+
<details>
|
|
236
|
+
<summary><b>Goto definition</b></summary>
|
|
237
|
+
|
|
238
|
+
From a step to the module it runs, or from a `${ref}` to the elements it reads. Every `${name}`
|
|
239
|
+
in the cell is offered, not just one: a fallback element is several rows, and so is
|
|
240
|
+
`${a} == ${b}`.
|
|
241
|
+
|
|
242
|
+
Two details it gets right. A `module_step` naming something that is *also* a keyword resolves
|
|
243
|
+
to the keyword, so a same-named module is not offered, mirroring what the runner does. And
|
|
244
|
+
`Condition`'s `!Name` inversion is stripped the same way the runner strips it.
|
|
245
|
+
|
|
246
|
+
</details>
|
|
247
|
+
|
|
248
|
+
<details>
|
|
249
|
+
<summary><b>Find references</b></summary>
|
|
250
|
+
|
|
251
|
+
Every place a name is used across the project, optionally including where it is bound. Works
|
|
252
|
+
on test cases, modules, elements and error codes, the things the project owns. A keyword
|
|
253
|
+
belongs to the framework, and an image, data file or API identifier names something outside
|
|
254
|
+
the CSVs, so neither comes back from here.
|
|
255
|
+
|
|
256
|
+
</details>
|
|
257
|
+
|
|
258
|
+
<details>
|
|
259
|
+
<summary><b>Rename</b></summary>
|
|
260
|
+
|
|
261
|
+
Renames across every file that writes the name, with prepare-rename so the client can reject
|
|
262
|
+
an invalid position before you start typing. This is the feature that most needs to be
|
|
263
|
+
project-wide: the runner keys everything by name, so a rename that misses one cell quietly
|
|
264
|
+
changes what runs instead of failing loudly.
|
|
265
|
+
|
|
266
|
+
</details>
|
|
267
|
+
|
|
268
|
+
<details>
|
|
269
|
+
<summary><b>Document symbols</b></summary>
|
|
270
|
+
|
|
271
|
+
One file's outline: what it defines, and the rows making each one up:
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
Open App [Function] 2 steps
|
|
275
|
+
Launch App [Method]
|
|
276
|
+
Sleep [Method] 2
|
|
277
|
+
Login [Function] 1 step
|
|
278
|
+
Press Element [Method] ${btn}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
</details>
|
|
282
|
+
|
|
283
|
+
<details>
|
|
284
|
+
<summary><b>Semantic tokens</b></summary>
|
|
285
|
+
|
|
286
|
+
Highlighting a CSV grammar cannot express, because the meaning of a cell depends on the column
|
|
287
|
+
above it and on the rest of the project:
|
|
288
|
+
|
|
289
|
+
| token | what it marks |
|
|
290
|
+
| --- | --- |
|
|
291
|
+
| `keyword` | the header row, the names that decide what the file is |
|
|
292
|
+
| `class` | a test case |
|
|
293
|
+
| `function` | a module, wherever it is named |
|
|
294
|
+
| `method` | a step that resolves to a framework keyword |
|
|
295
|
+
| `variable` | `${name}`, and an `element_name` that defines one |
|
|
296
|
+
| `string` | a locator, a data file, an API identifier |
|
|
297
|
+
| `enumMember` | an error code, and a param with a documented set of values |
|
|
298
|
+
| `operator` | the `!` that inverts a `Condition` |
|
|
299
|
+
|
|
300
|
+
A framework keyword also carries the `defaultLibrary` modifier, so themes colour it apart from
|
|
301
|
+
a module of the same shape, which they would otherwise draw identically.
|
|
302
|
+
|
|
303
|
+
</details>
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## The keyword catalog
|
|
308
|
+
|
|
309
|
+
`src/optics_framework_lsp/keywords.py` is generated and holds **49 keywords from
|
|
310
|
+
optics-framework 1.9.3**: each one's params, which are required, the defaults, and the
|
|
311
|
+
framework's own docstring, which is where hover text and the param values come from.
|
|
312
|
+
|
|
313
|
+
It is compiled in rather than read from your environment. Importing `optics_framework.api.*`
|
|
314
|
+
pulls numpy, cv2, pandas and skimage through `common.optics_builder`, needing a 342 MB install
|
|
315
|
+
and failing outright if any one of those is broken, leaving a project with no keyword
|
|
316
|
+
diagnostics at all and no explanation why.
|
|
317
|
+
|
|
318
|
+
To refresh it for a new optics release:
|
|
319
|
+
|
|
320
|
+
```sh
|
|
321
|
+
python scripts/update_catalog.py ~/src/optics-framework
|
|
322
|
+
python scripts/update_catalog.py --check # exits 1 if the committed table is stale
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Signatures are read with `ast`, never imported, which is what lets the script run against a
|
|
326
|
+
bare checkout or a `--no-deps` install and makes it usable for diffing two releases. It refuses
|
|
327
|
+
to run if one of the four API classes gains a base class, since that would mean keywords it
|
|
328
|
+
cannot see. A test runs `--check`, so a stale table fails the suite.
|
|
329
|
+
|
|
330
|
+
## Development
|
|
331
|
+
|
|
332
|
+
```sh
|
|
333
|
+
uv run pytest tests/ -q
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
One test needs optics-framework itself and skips without it; point `OPTICS_PROBE_VENV` at a
|
|
337
|
+
virtualenv that has it to run that one.
|
|
338
|
+
|
|
339
|
+
The engine is deliberately protocol-free. `validate()` returns plain `Finding` objects and each
|
|
340
|
+
transport converts at its own boundary: `server.py` to `lsprotocol` diagnostics, `lint.py` to
|
|
341
|
+
JSON. `import lsprotocol.types` alone costs ~290 ms, which a long-lived server pays once and a
|
|
342
|
+
per-call command would pay every time. `tests/test_lint.py` asserts the lint path imports
|
|
343
|
+
neither pygls nor lsprotocol, so it stays that way.
|
|
344
|
+
|
|
345
|
+
## License
|
|
346
|
+
|
|
347
|
+
Apache 2.0.
|