|
| 1 | +# Copilot Instructions for BSL Language Server |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +BSL Language Server is an implementation of the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) for 1C (BSL) - the 1C:Enterprise 8 language and [OneScript](http://oscript.io). |
| 6 | + |
| 7 | +This is a Java-based language server that provides code analysis, diagnostics, code actions, and other language features for 1C development. |
| 8 | + |
| 9 | +**Key Resources:** |
| 10 | +- Project site: https://1c-syntax.github.io/bsl-language-server |
| 11 | +- Documentation: [docs/index.md](../docs/index.md) (Russian), [docs/en/index.md](../docs/en/index.md) (English) |
| 12 | +- Contributor's Guide: [docs/en/contributing/index.md](../docs/en/contributing/index.md) |
| 13 | + |
| 14 | +## Technology Stack |
| 15 | + |
| 16 | +- **Language:** Java 17 |
| 17 | +- **Build System:** Gradle with Kotlin DSL |
| 18 | +- **Frameworks:** Spring Boot |
| 19 | +- **Key Technologies:** |
| 20 | + - ANTLR for parsing |
| 21 | + - Lombok for reducing boilerplate |
| 22 | + - JUnit for testing |
| 23 | + - Language Server Protocol implementation |
| 24 | + |
| 25 | +## Environment Setup |
| 26 | + |
| 27 | +### Prerequisites |
| 28 | +- Java Development Kit 17 |
| 29 | +- Gradle (wrapper included in the repository) |
| 30 | + |
| 31 | +### Building the Project |
| 32 | +```bash |
| 33 | +./gradlew build |
| 34 | +``` |
| 35 | + |
| 36 | +### Running Tests |
| 37 | +```bash |
| 38 | +./gradlew test |
| 39 | +``` |
| 40 | + |
| 41 | +### Running Quality Checks |
| 42 | +```bash |
| 43 | +./gradlew check |
| 44 | +``` |
| 45 | + |
| 46 | +## Development Workflow |
| 47 | + |
| 48 | +### For Diagnostics Development |
| 49 | + |
| 50 | +When developing new diagnostics or modifying existing ones: |
| 51 | + |
| 52 | +1. **Study the Documentation:** |
| 53 | + - Review [Diagnostic Development Workflow](../docs/en/contributing/DiagnosticDevWorkFlow.md) |
| 54 | + - Check [Diagnostic Structure](../docs/en/contributing/DiagnosticStructure.md) |
| 55 | + - Understand [Diagnostic Types and Severity](../docs/en/contributing/DiagnosticTypeAndSeverity.md) |
| 56 | + |
| 57 | +2. **Implementation Guidelines:** |
| 58 | + - Each diagnostic should have: |
| 59 | + - Java implementation class |
| 60 | + - Resource bundle for localized messages |
| 61 | + - Unit tests |
| 62 | + - Documentation |
| 63 | + - Follow naming conventions from existing diagnostics |
| 64 | + - Use appropriate diagnostic tags and severity levels |
| 65 | + |
| 66 | +3. **Testing:** |
| 67 | + - Write comprehensive unit tests for each diagnostic |
| 68 | + - Include test cases for edge cases |
| 69 | + - Follow existing test patterns in the codebase |
| 70 | + |
| 71 | +4. **Documentation:** |
| 72 | + - Update diagnostic documentation in both Russian and English |
| 73 | + - Include examples of problematic code and fixes |
| 74 | + - Document configuration parameters if applicable |
| 75 | + |
| 76 | +### For Core Functionality Development |
| 77 | + |
| 78 | +1. **Code Structure:** |
| 79 | + - Main source: `src/main/java` |
| 80 | + - Tests: `src/test/java` |
| 81 | + - Resources: `src/main/resources`, `src/test/resources` |
| 82 | + |
| 83 | +2. **Testing:** |
| 84 | + - Always run tests before submitting changes: `./gradlew test` |
| 85 | + - Maintain or improve test coverage |
| 86 | + - Use appropriate test frameworks (JUnit, AssertJ, Mockito) |
| 87 | + |
| 88 | +## Code Style and Conventions |
| 89 | + |
| 90 | +### General Guidelines |
| 91 | +- **Follow the [Style Guide](../docs/en/contributing/StyleGuide.md)** |
| 92 | +- Use Lombok annotations to reduce boilerplate code |
| 93 | +- Enable annotation processing in your IDE |
| 94 | +- Use EditorConfig for consistent formatting (`.editorconfig` is provided) |
| 95 | + |
| 96 | +### Import Management |
| 97 | +- Optimize imports before committing |
| 98 | +- Use automatic import optimization provided by the IDE |
| 99 | +- DO NOT optimize imports across the entire project unless specifically working on that task |
| 100 | + |
| 101 | +### Naming Conventions |
| 102 | +- Follow Java naming conventions |
| 103 | +- Use meaningful, descriptive names |
| 104 | +- Keep class and method names concise but clear |
| 105 | + |
| 106 | +### Documentation |
| 107 | +- Write JavaDoc for public APIs |
| 108 | +- Include comments for complex logic |
| 109 | +- Keep documentation up to date with code changes |
| 110 | + |
| 111 | +## Important Files and Directories |
| 112 | + |
| 113 | +- `build.gradle.kts` - Main build configuration |
| 114 | +- `src/main/java/com/github/_1c_syntax/bsl/languageserver/` - Main source code |
| 115 | + - `diagnostics/` - Diagnostic implementations |
| 116 | + - `context/` - Language context and parsing |
| 117 | + - `providers/` - LSP providers |
| 118 | +- `src/main/resources/` - Resources, including diagnostic descriptions |
| 119 | +- `src/test/java/` - Unit tests |
| 120 | +- `docs/` - Documentation in Russian |
| 121 | +- `docs/en/` - Documentation in English |
| 122 | + |
| 123 | +## Continuous Integration |
| 124 | + |
| 125 | +The project uses GitHub Actions for CI/CD: |
| 126 | +- **Quality Assurance:** `qa.yml` - Runs tests and code quality checks |
| 127 | +- **Pre-QA:** `pre-qa.yml` - Quick validation |
| 128 | +- **CodeQL:** `codeql-analysis.yml` - Security analysis |
| 129 | +- **Releases:** `release.yml` - Automated release process |
| 130 | + |
| 131 | +Always ensure your changes pass all CI checks before finalizing. |
| 132 | + |
| 133 | +## Bilingual Requirements |
| 134 | + |
| 135 | +This project maintains documentation in **both Russian and English**. When making changes: |
| 136 | +- Update documentation in both languages |
| 137 | +- Maintain consistency between translations |
| 138 | +- Resource bundles should have both Russian and English versions |
| 139 | + |
| 140 | +## Testing Strategy |
| 141 | + |
| 142 | +### Unit Tests |
| 143 | +- Test each diagnostic with multiple scenarios |
| 144 | +- Include positive and negative test cases |
| 145 | +- Test configuration parameters if applicable |
| 146 | +- Use the existing test infrastructure and patterns |
| 147 | + |
| 148 | +### Integration Tests |
| 149 | +- Some diagnostics may require integration testing |
| 150 | +- Follow patterns from existing integration tests |
| 151 | + |
| 152 | +### Running Specific Tests |
| 153 | +```bash |
| 154 | +# Run all tests |
| 155 | +./gradlew test |
| 156 | + |
| 157 | +# Run tests for a specific class |
| 158 | +./gradlew test --tests "ClassName" |
| 159 | + |
| 160 | +# Run tests matching a pattern |
| 161 | +./gradlew test --tests "*DiagnosticTest" |
| 162 | +``` |
| 163 | + |
| 164 | +## Common Tasks |
| 165 | + |
| 166 | +### Adding a New Diagnostic |
| 167 | +1. Create diagnostic class in `src/main/java/.../diagnostics/` |
| 168 | +2. Create resource bundles in `src/main/resources/.../diagnostics/` |
| 169 | +3. Add unit tests in `src/test/java/.../diagnostics/` |
| 170 | +4. Add documentation in `docs/diagnostics/` and `docs/en/diagnostics/` |
| 171 | +5. Register the diagnostic if needed |
| 172 | +6. Run tests and ensure they pass |
| 173 | + |
| 174 | +### Fixing a Bug |
| 175 | +1. Write a failing test that reproduces the bug |
| 176 | +2. Fix the bug with minimal changes |
| 177 | +3. Ensure all tests pass |
| 178 | +4. Update documentation if the behavior changes |
| 179 | + |
| 180 | +### Updating Dependencies |
| 181 | +- Dependencies are managed in `build.gradle.kts` |
| 182 | +- Always test thoroughly after dependency updates |
| 183 | +- Check for breaking changes in release notes |
| 184 | + |
| 185 | +## Security Considerations |
| 186 | + |
| 187 | +- Never commit sensitive data or credentials |
| 188 | +- Be cautious with external dependencies |
| 189 | +- Review security alerts from CodeQL and Dependabot |
| 190 | +- Follow secure coding practices |
| 191 | + |
| 192 | +## Additional Resources |
| 193 | + |
| 194 | +- [FAQ](../docs/en/faq.md) |
| 195 | +- [System Requirements](../docs/en/systemRequirements.md) |
| 196 | +- [Events API](../docs/en/contributing/EventsApi.md) |
| 197 | +- [Performance Measurement](../docs/en/contributing/Measures.md) |
| 198 | +- [Diagnostic Tags](../docs/en/contributing/DiagnosticTag.md) |
| 199 | +- [Adding Parameters to Diagnostics](../docs/en/contributing/DiagnostcAddSettings.md) |
| 200 | +- [Adding QuickFixes](../docs/en/contributing/DiagnosticQuickFix.md) |
| 201 | + |
| 202 | +## Notes for AI Coding Agents |
| 203 | + |
| 204 | +- This is a mature, production-quality project with high standards |
| 205 | +- Maintain backward compatibility unless explicitly breaking changes are planned |
| 206 | +- Follow the existing patterns and conventions strictly |
| 207 | +- When in doubt, refer to similar existing code for guidance |
| 208 | +- Always run the full test suite before considering a task complete |
| 209 | +- Respect the bilingual nature of documentation and resources |
0 commit comments