Commit d1e5f3f
committed
feat: diagnostics modifiers
Implement functionality to configure diagnostic error messages during source code analysis. Lines in the code with the `# robotcode:` marker are now interpreted as modifiers. The full structure of a modifier is `# robotcode: <action>[code(,code)*]*`.
**Allowed actions:**
- `ignore`: Ignore specified diagnostic codes.
- `hint`: Treat specified diagnostic codes as hints.
- `warn`: Treat specified diagnostic codes as warnings.
- `error`: Treat specified diagnostic codes as errors.
- `reset`: Reset the diagnostic codes to their default state.
**This implementation allows for the following:**
- Custom actions to be performed on specified diagnostic codes.
- Enhanced control over which diagnostic messages are shown, ignored, or modified.
- Flexibility in managing diagnostic outputs for better code quality and debugging experience.
**Usage details:**
- A diagnostic modifier can be placed at the end of a line. It modifies only the errors occurring in that line.
- A modifier can be placed at the very beginning of a line. It applies from that line to the end of the file.
- If a modifier is within a block (e.g., Testcase, Keyword, IF, FOR) and is indented, it applies only to the current block.
**Example usage:**
- `# robotcode: ignore[variable-not-found, keyword-not-found]` - Ignores the errors for variable not found and keyword not found.
- `# robotcode: hint[MultipleKeywords]` - Treats the MultipleKeywords error as a hint.
- `# robotcode: warn[variable-not-found]` - Treats the variable-not-found error as a warning.
- `# robotcode: error[keyword-not-found]` - Treats the keyword-not-found error as an error.
- `# robotcode: reset[MultipleKeywords]` - Resets the MultipleKeywords error to its default state.
- `# robotcode: ignore` - Ignores all diagnostic messages .
- `# robotcode: reset` - Resets all diagnostic messages to their default.
**Example scenarios:**
*Modifier at the end of a line:*
```robot
*** Keywords ***
Keyword Name
Log ${arg1} # robotcode: ignore[variable-not-found]
```
This modifier will ignore the `variable-not-found` error for the `Log` keyword in this line only.
*Modifier at the beginning of a line:*
```robot
# robotcode: ignore[keyword-not-found]
*** Test Cases ***
Example Test
Log Hello
Some Undefined Keyword
```
This modifier will ignore `keyword-not-found` errors from the point it is declared to the end of the file.
*Modifier within a block:*
```robot
*** Keywords ***
Example Keyword
# robotcode: warn[variable-not-found]
Log ${arg1}
Another Keyword
```
This modifier will treat `variable-not-found` errors as warnings within the `Example Keyword` block.
*Modifier using reset:*
```robot
# robotcode: error[variable-not-found]
*** Test Cases ***
Example Test
Log ${undefined_variable}
# robotcode: reset[variable-not-found]
Log ${undefined_variable}
```
In this example, the `variable-not-found` error is treated as an error until it is reset in the `Another Test` block, where it will return to its default state.
*Modifier to ignore all diagnostic messages:*
```robot
# robotcode: ignore
*** Test Cases ***
Example Test
Log ${undefined_variable}
Some Undefined Keyword
```
This modifier will ignore all diagnostic messages from the point it is declared to the end of the file.
*Modifier to reset all diagnostic messages:*
```robot
# robotcode: ignore
*** Test Cases ***
Example Test
Log ${undefined_variable}
# robotcode: reset
Another Test
Some Undefined Keyword
```
In this example, all diagnostic messages are ignored until the `reset` modifier, which returns all messages to their default state from that point onward.1 parent 1d01f43 commit d1e5f3f
File tree
30 files changed
+817
-324
lines changed- .vscode
- packages
- analyze/src/robotcode/analyze
- core/src/robotcode/core/utils
- jsonrpc2/src/robotcode/jsonrpc2
- language_server/src/robotcode/language_server/robotframework/parts
- robot/src/robotcode/robot
- diagnostics
- utils
- tests
- robotcode
- language_server/robotframework/parts/data/data
- robot/diagnostics
- vscode-client
- test
30 files changed
+817
-324
lines changedThis file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
53 | 51 | | |
54 | | - | |
| 52 | + | |
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
0 commit comments