Skip to content

add surround features #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ LessThan(expected := 0, actual := 0);
GreaterThan(expected := 0, actual := 0);
```

## Surround with

![surround](doc/img/surround.gif)

Available surround with:

- FOR ... END_FOR;
- IF ... THEN ... ELSE
- WHILE ... END_WHILE
- REPEAT .. END_REPEAT

## Snippets Namespace Support

### NamespaceSupport
Expand Down Expand Up @@ -180,6 +191,15 @@ Output example:

Thanks for your interest in contributing. Anybody is free to report bugs, unclear documentation, and other problems regarding this repository in the Issues section or, even better, is free to propose any changes to this repository using Merge Requests.

### Markdownlint-cli

This workspace will be checked by the [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) (there is also documented ho to install the tool) tool in the CI workflow automatically.
To avoid, that the CI workflow fails because of the markdown linter, you can check all markdown files locally by running the markdownlint with:

```sh
markdownlint **/*.md --fix
```

## License and Legal information

Please read the [Legal information](LICENSE.md)
Binary file added doc/img/surround.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions snippets/stSurroundWith.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"surround_if_else": {
"scope": "st",
"prefix": [
"surround with if-else..."
],
"body": [
"IF (${1:condition}) THEN",
"\t${TM_SELECTED_TEXT}",
"END_IF;"
],
"description": "Surround selected text with if-else"
},
"surround_for": {
"scope": "st",
"prefix": [
"surround with for-loop..."
],
"body": [
"FOR Index := ${1:StartValue} TO ${2:EndValue} DO",
"\t${TM_SELECTED_TEXT}",
"END_FOR;"
],
"description": "Surround selected text with for-loop"
},
"surround_while": {
"scope": "st",
"prefix": [
"surround with while..."
],
"body": [
"WHILE (${1:condition})",
"\t${TM_SELECTED_TEXT}",
"END_WHILE;"
],
"description": "Surround selected text with while"
},
"surround_repeat": {
"scope": "st",
"prefix": [
"surround with repeat..."
],
"body": [
"REPEAT",
"\t${TM_SELECTED_TEXT}",
"\tUNTIL (${1:condition})",
"END_REPEAT;"
],
"description": "Surround selected text with repeat"
}
}
17 changes: 17 additions & 0 deletions src/testSurround.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
NAMESPACE Simatic.Ax
CLASS testSurround
VAR PUBLIC
b : BOOL;
END_VAR
VAR PROTECTED

END_VAR

METHOD PUBLIC MyMethod
REPEAT
b := FALSE;
UNTIL (condition)
END_REPEAT;
END_METHOD
END_CLASS
END_NAMESPACE