Skip to content

Commit fcc5b64

Browse files
committed
test: Add tests. Fix CI
1 parent 2cdb058 commit fcc5b64

26 files changed

Lines changed: 3183 additions & 39 deletions

.claude/settings.local.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
"Bash(git stash:*)",
1818
"Bash(/usr/libexec/java_home:*)",
1919
"Bash(JAVA_HOME=/Users/glebmikhailov/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home ./gradlew compileKotlin:*)",
20-
"Bash(JAVA_HOME=/Users/glebmikhailov/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home ./gradlew buildPlugin:*)"
20+
"Bash(JAVA_HOME=/Users/glebmikhailov/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home ./gradlew buildPlugin:*)",
21+
"Bash(JAVA_HOME=/Users/glebmikhailov/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home ./gradlew compileTestKotlin:*)",
22+
"Bash(JAVA_HOME=/Users/glebmikhailov/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home ./gradlew test:*)",
23+
"Bash(JAVA_HOME=/Users/glebmikhailov/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home ./gradlew clean test:*)",
24+
"Bash(JAVA_HOME=/Users/glebmikhailov/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home ./gradlew:*)"
2125
]
2226
}
2327
}

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
- name: Build
3030
run: ./gradlew buildPlugin
3131

32+
- name: Run Tests
33+
run: ./gradlew test
34+
3235
- name: Run Detekt
3336
run: ./gradlew detekt
3437

PUBLISHING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,15 @@ jobs:
135135
run: |
136136
sed -i "s/version = \".*\"/version = \"${{ steps.version.outputs.VERSION }}\"/" build.gradle.kts
137137
138+
- name: Generate Lexer and Parser
139+
run: ./gradlew generateLexer generateParser
140+
138141
- name: Build plugin
139142
run: ./gradlew buildPlugin
140143

144+
- name: Run Tests
145+
run: ./gradlew test
146+
141147
- name: Verify plugin
142148
run: ./gradlew verifyPlugin
143149

@@ -182,14 +188,26 @@ jobs:
182188
- name: Setup Gradle
183189
uses: gradle/actions/setup-gradle@v3
184190
191+
- name: Generate Lexer and Parser
192+
run: ./gradlew generateLexer generateParser
193+
185194
- name: Build
186195
run: ./gradlew buildPlugin
187196
197+
- name: Run Tests
198+
run: ./gradlew test
199+
188200
- name: Run Detekt
189201
run: ./gradlew detekt
190202
191203
- name: Verify Plugin
192204
run: ./gradlew verifyPlugin
205+
206+
- name: Upload build artifact
207+
uses: actions/upload-artifact@v4
208+
with:
209+
name: plugin-zip
210+
path: build/distributions/*.zip
193211
```
194212

195213
---
@@ -232,9 +250,15 @@ gh release create v1.0.0 --title "v1.0.0" --notes "Release notes here"
232250
## Полезные команды
233251

234252
```bash
253+
# Генерация лексера и парсера
254+
./gradlew generateLexer generateParser
255+
235256
# Сборка плагина
236257
./gradlew buildPlugin
237258
259+
# Запуск тестов
260+
./gradlew test
261+
238262
# Проверка плагина
239263
./gradlew verifyPlugin
240264

README.md

Lines changed: 126 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Rhai Language Support for JetBrains IDEs
22

3+
[![Build Status](https://github.com/your-username/rhai-highlight-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/your-username/rhai-highlight-plugin/actions)
34
[![JetBrains Plugin](https://img.shields.io/badge/JetBrains-Plugin-orange)](https://plugins.jetbrains.com/)
45
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
56

@@ -10,41 +11,87 @@ Full-featured language support for the [Rhai](https://rhai.rs/) scripting langua
1011
### Syntax Highlighting
1112
- Full syntax highlighting for Rhai scripts
1213
- Customizable colors via **Settings > Editor > Color Scheme > Rhai**
14+
- Semantic highlighting for functions, variables, parameters, and more
1315
- Support for all Rhai constructs: functions, variables, strings, numbers, operators, etc.
1416

1517
### Code Intelligence
16-
- **Code completion** for keywords, built-in functions, and user-defined symbols
18+
- **Code completion** for:
19+
- Keywords with smart insertion (automatic spaces after modifiers)
20+
- 40+ built-in functions with documentation
21+
- Array methods (push, pop, map, filter, reduce, etc.)
22+
- String methods (trim, split, to_upper, etc.)
23+
- User-defined functions and variables
24+
- Cross-file symbols with automatic import generation
25+
- Registered functions from Rust (via registry system)
1726
- **Go to definition** (Ctrl+Click or Ctrl+B)
1827
- **Find usages** (Alt+F7)
1928
- **Parameter info** for function calls
20-
- **Documentation on hover**
29+
- **Documentation on hover** for built-in and user-defined symbols
30+
31+
### Refactoring
32+
- **Rename refactoring** (Shift+F6) for:
33+
- Variables and constants
34+
- Functions
35+
- Function parameters
36+
- Closure parameters
37+
- For loop variables
38+
- Smart scope detection (local vs global)
39+
- Automatic update of all usages
2140

2241
### Code Navigation
2342
- **Structure view** with filtering (Alt+7)
43+
- Functions (public/private/test indicators)
44+
- Constants
45+
- Variables
46+
- Modules
2447
- **Breadcrumb navigation**
2548
- **Go to Symbol** (Ctrl+Alt+Shift+N)
49+
- **Line markers** for function definitions and usages
2650

2751
### Code Editing
28-
- **Code folding** for functions, blocks, and comments
52+
- **Code folding** for functions, blocks, comments, and imports
2953
- **Brace matching** and auto-closing
3054
- **Smart Enter** completion
3155
- **Comment/uncomment** (Ctrl+/)
32-
- **Surround with** templates (Ctrl+Alt+T)
56+
- **Surround with** templates (Ctrl+Alt+T):
57+
- if, if-else, while, for, loop
58+
- try-catch, block
59+
- Parentheses
3360
- **Live templates** for common patterns
3461

62+
### Code Formatting
63+
- **Reformat code** (Ctrl+Alt+L)
64+
- Configurable spacing rules for:
65+
- Assignment, logical, equality, relational operators
66+
- Additive and multiplicative operators
67+
- Range and arrow operators
68+
- Commas, colons, semicolons
69+
- Braces, parentheses, brackets
70+
- Closure pipes
71+
- Automatic indentation for blocks
72+
- Alignment of multiline parameters and arguments
73+
3574
### Code Quality
3675
- **Inspections:**
3776
- Unused variable detection
3877
- Unresolved reference detection
3978
- Duplicate function definition detection
40-
- **Quick fixes** for common issues
79+
- **Quick fixes (Alt+Enter):**
80+
- **Create function** - creates a new function stub for unresolved function calls
81+
- **Create variable** - creates a variable declaration for unresolved references
82+
- **Auto-import symbols** from other files
83+
- **Import and prefix** with module name (e.g., `module::symbol`)
84+
- **Rename to `_name`** - marks unused variable as intentionally unused
85+
- **Remove unused declaration** - deletes unused variable
86+
- **Delete duplicate function** - removes duplicate function definition
87+
- **Rename duplicate function** - renames to `funcName_2`
4188
- **Spell checking** in comments and strings
4289

4390
### Run Configuration
4491
- **Run Rhai scripts** directly from the IDE
4592
- **Right-click to run** any `.rhai` file
4693
- **Run gutter icon** for quick execution
47-
- Configurable interpreter path
94+
- Configurable interpreter path and arguments
4895

4996
### Rust Integration
5097
- **Auto-detect Rhai registrations** from Rust source files
@@ -61,7 +108,7 @@ Full-featured language support for the [Rhai](https://rhai.rs/) scripting langua
61108
4. Restart the IDE
62109

63110
### Manual Installation
64-
1. Download the plugin `.zip` from [Releases](https://github.com/example/rhai-intellij-plugin/releases)
111+
1. Download the plugin `.zip` from [Releases](https://github.com/your-username/rhai-highlight-plugin/releases)
65112
2. Open **Settings/Preferences > Plugins**
66113
3. Click the gear icon and select **Install Plugin from Disk...**
67114
4. Select the downloaded `.zip` file
@@ -156,13 +203,25 @@ Type the following abbreviations and press Tab to expand:
156203
| Abbreviation | Expands to |
157204
|-------------|-----------|
158205
| `fn` | Function definition |
206+
| `pubfn` | Public function definition |
159207
| `let` | Variable declaration |
208+
| `const` | Constant declaration |
209+
| `pubconst` | Public constant declaration |
160210
| `if` | If statement |
161211
| `ife` | If-else statement |
162212
| `for` | For loop |
213+
| `fori` | For loop with index (0..n) |
214+
| `forr` | For loop with range |
163215
| `while` | While loop |
164216
| `loop` | Infinite loop |
165-
| `match` | Switch statement |
217+
| `match` | Switch expression |
218+
| `trye` | Try-catch block |
219+
| `closure` | Closure expression |
220+
| `mape` | Map expression |
221+
| `filtere` | Filter expression |
222+
| `reducee` | Reduce expression |
223+
| `guard` | Guard clause (if-return pattern) |
224+
| `doc` | Documentation comment |
166225

167226
## File Templates
168227

@@ -175,22 +234,42 @@ Create new Rhai files with predefined templates:
175234
Configure Rhai code style settings:
176235
**Settings > Editor > Code Style > Rhai**
177236

178-
Options include:
179-
- Indentation (tabs vs spaces)
180-
- Continuation indent
181-
- Keep line breaks
237+
### Spacing Options
238+
- Spaces around operators (assignment, logical, equality, relational, etc.)
239+
- Spaces around range and arrow operators
240+
- Spaces after/before commas, colons, semicolons
241+
- Spaces within parentheses, brackets, braces
242+
- Spaces within closure pipes
243+
244+
### Brace & Wrapping Options
245+
- Space before function/if/loop/switch left brace
246+
- Align multiline parameters and arguments
247+
- Align multiline array elements and object fields
248+
- Keep trailing commas
249+
250+
### Indentation Options
251+
- Indent size (default: 4)
252+
- Tab size (default: 4)
253+
- Continuation indent size (default: 4)
254+
- Use tabs or spaces
255+
256+
### Blank Lines
257+
- Blank lines after imports
258+
- Blank lines around functions
259+
- Blank lines around modules
182260

183261
## Requirements
184262

185263
- IntelliJ IDEA 2023.1+ (or compatible JetBrains IDE)
264+
- Java 17+
186265
- For running scripts: Rhai interpreter (`cargo install rhai-repl`)
187266

188267
## Building from Source
189268

190269
```bash
191270
# Clone the repository
192-
git clone https://github.com/example/rhai-intellij-plugin.git
193-
cd rhai-intellij-plugin
271+
git clone https://github.com/your-username/rhai-highlight-plugin.git
272+
cd rhai-highlight-plugin
194273

195274
# Build the plugin
196275
./gradlew buildPlugin
@@ -209,6 +288,36 @@ cd rhai-intellij-plugin
209288

210289
# Run linter
211290
./gradlew detekt
291+
292+
# Verify plugin compatibility
293+
./gradlew verifyPlugin
294+
```
295+
296+
### Project Structure
297+
298+
```
299+
src/
300+
├── main/
301+
│ ├── grammars/ # BNF grammar and JFlex lexer
302+
│ ├── kotlin/org/rhai/
303+
│ │ ├── features/ # Completion, folding, structure view, etc.
304+
│ │ ├── highlighting/ # Syntax highlighter
305+
│ │ ├── inspections/ # Code inspections and quick fixes
306+
│ │ ├── intentions/ # Intention actions
307+
│ │ ├── lang/ # Language and file type definitions
308+
│ │ ├── navigation/ # Go to declaration
309+
│ │ ├── parser/ # Parser definition
310+
│ │ ├── refactoring/ # Rename refactoring
311+
│ │ ├── registry/ # Rust integration registry
312+
│ │ ├── run/ # Run configuration
313+
│ │ ├── settings/ # Settings pages
314+
│ │ └── util/ # Utility classes
315+
│ └── resources/
316+
│ ├── META-INF/ # Plugin descriptor
317+
│ ├── icons/ # Plugin icons
318+
│ └── liveTemplates/ # Live template definitions
319+
└── test/
320+
└── kotlin/org/rhai/ # Unit tests
212321
```
213322

214323
## Contributing
@@ -217,8 +326,9 @@ Contributions are welcome! Please:
217326
1. Fork the repository
218327
2. Create a feature branch
219328
3. Make your changes
220-
4. Run `./gradlew detekt` to check code style
221-
5. Submit a pull request
329+
4. Run `./gradlew test` to ensure tests pass
330+
5. Run `./gradlew detekt` to check code style
331+
6. Submit a pull request
222332

223333
## License
224334

build.gradle.kts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ tasks {
7777
}
7878

7979
patchPluginXml {
80-
sinceBuild.set("231")
81-
untilBuild.set("243.*")
80+
sinceBuild.set("233")
81+
untilBuild.set("251.*")
8282
}
8383

8484
signPlugin {
@@ -133,4 +133,22 @@ sourceSets {
133133
kotlin.srcDirs("src/main/kotlin")
134134
resources.srcDirs("src/main/resources")
135135
}
136+
test {
137+
kotlin.srcDirs("src/test/kotlin")
138+
resources.srcDirs("src/test/resources")
139+
}
140+
}
141+
142+
dependencies {
143+
testImplementation("junit:junit:4.13.2")
144+
}
145+
146+
tasks {
147+
test {
148+
useJUnit()
149+
testLogging {
150+
events("passed", "skipped", "failed")
151+
showStandardStreams = true
152+
}
153+
}
136154
}

0 commit comments

Comments
 (0)