Skip to content

Commit ea6beba

Browse files
Re-sync with internal repository
The internal and external repositories are out of sync. This Pull Request attempts to brings them back in sync by patching the GitHub repository. Please carefully review this patch. You must disable ShipIt for your project in order to merge this pull request. DO NOT IMPORT this pull request. Instead, merge it directly on GitHub using the MERGE BUTTON. Re-enable ShipIt after merging.
1 parent e0c5e94 commit ea6beba

File tree

2 files changed

+62
-352
lines changed

2 files changed

+62
-352
lines changed

.llms/rules/elp_development.md

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ llms-gk: 'devmate_elp_development_md'
33
apply_to_regex: '^(.*\.rs|.*\.md)$'
44
oncalls: ['vscode_erlang']
55
---
6-
7-
# ELP Development Rules for LLMs
8-
6+
# ELP Development Rules for LLMs (OSS)
97

108
## Project Overview
119

12-
ELP (Erlang Language Platform) is a language server and development tools suite for Erlang, built in Rust. This project provides IDE features, diagnostics, and code analysis for Erlang codebases.
10+
ELP (Erlang Language Platform) is a language server and development tools suite
11+
for Erlang, built in Rust. This project provides IDE features, diagnostics, and
12+
code analysis for Erlang codebases.
1313

1414
## Diagnostic Code Management
1515

1616
### Adding New Diagnostic Codes
1717

1818
When adding new diagnostic codes to `DiagnosticCode` enum:
1919

20-
1. **Naming Convention**: Use descriptive PascalCase names that clearly indicate the issue
20+
1. **Naming Convention**: Use descriptive PascalCase names that clearly indicate
21+
the issue
2122
- Good: `UnusedFunctionArg`, `MissingCompileWarnMissingSpec`
2223
- Bad: `Error1`, `BadCode`
2324

2425
2. **Code Assignment**: Follow the established numbering scheme
2526
- `W0000-W9999`: Native ELP diagnostics, visible in the OSS version
26-
- `WA000-WA999`: WhatsApp-specific warnings, only visible in Meta builds
2727
- Use the next available number in the appropriate range
2828
- Never change the number of an existing diagnostic code
2929
- Never change the label of an existing diagnostic code
@@ -37,7 +37,8 @@ When adding new diagnostic codes to `DiagnosticCode` enum:
3737

3838
4. **Documentation**: Add comments explaining complex diagnostic codes
3939

40-
5. **Documentation File**: Create a corresponding documentation file in the website
40+
5. **Documentation File**: Create a corresponding documentation file in the
41+
website
4142
- Location: `website/docs/erlang-error-index/{namespace}/{code}.md`
4243
- Example: `W0051``website/docs/erlang-error-index/w/W0051.md`
4344
- Include frontmatter with `sidebar_position` matching the code number
@@ -51,16 +52,19 @@ When adding new diagnostic codes to `DiagnosticCode` enum:
5152

5253
### Creating DiagnosticDescriptor
5354

54-
Every diagnostic must have a corresponding `DiagnosticDescriptor` that defines when and how the diagnostic runs:
55+
Every diagnostic must have a corresponding `DiagnosticDescriptor` that defines
56+
when and how the diagnostic runs:
5557

56-
1. **Static Descriptor Declaration**: Create a public static descriptor in your diagnostic module
58+
1. **Static Descriptor Declaration**: Create a public static descriptor in your
59+
diagnostic module
5760
- Use `pub(crate) static DESCRIPTOR: DiagnosticDescriptor` pattern
5861
- Define `DiagnosticConditions` with appropriate flags
5962
- Provide a checker function that implements the diagnostic logic
6063

6164
2. **Diagnostic Conditions**: Configure when the diagnostic should run
6265
- `experimental`: Mark as true for experimental/unstable diagnostics
63-
- `include_generated`: Set to false if diagnostic shouldn't run on generated code
66+
- `include_generated`: Set to false if diagnostic shouldn't run on generated
67+
code
6468
- `include_tests`: Set to false if diagnostic shouldn't run on test files
6569
- `default_disabled`: Set to true if diagnostic requires explicit enabling
6670

@@ -69,7 +73,8 @@ Every diagnostic must have a corresponding `DiagnosticDescriptor` that defines w
6973
- Push diagnostics to the `diags` vector using `Diagnostic::new()`
7074
- Use helper functions to keep the checker clean and focused
7175

72-
4. **Registration**: Add the descriptor to `diagnostics_descriptors()` function in `diagnostics.rs`
76+
4. **Registration**: Add the descriptor to `diagnostics_descriptors()` function
77+
in `diagnostics.rs`
7378
- Include your module's `DESCRIPTOR` in the returned vector
7479

7580
5. **Module Structure**: Follow the established pattern
@@ -78,12 +83,6 @@ Every diagnostic must have a corresponding `DiagnosticDescriptor` that defines w
7883
- Include comprehensive tests with `#[cfg(test)]`
7984
- Use SSR patterns when appropriate for complex matching
8085

81-
### Meta-Only vs OSS Code
82-
83-
- Use `@fb-only` and `@oss-only` comments to mark platform-specific code
84-
- Meta-only diagnostics should use `MetaOnlyDiagnosticCode` wrapper
85-
- Ensure OSS builds work by providing fallbacks for Meta-only features
86-
8786
## Rust Code Style
8887

8988
### Error Handling
@@ -120,23 +119,33 @@ Every diagnostic must have a corresponding `DiagnosticDescriptor` that defines w
120119

121120
### Declarative Test Fixtures
122121

123-
ELP uses a declarative test fixture system that allows you to write tests with inline annotations and markers directly in test strings. This system is defined in `/data/sandcastle/boxes/fbsource/fbcode/whatsapp/elp/crates/project_model/src/test_fixture.rs`.
122+
ELP uses a declarative test fixture system that allows you to write tests with
123+
inline annotations and markers directly in test strings. This system is defined
124+
in `crates/project_model/src/test_fixture.rs`.
124125

125126
#### Key Features
126127

127-
1. **File Organization**: Use `//- /path/to/file.erl` to define multiple files in a single test
128-
2. **Metadata Markers**: Specify app names, include paths, OTP apps, etc. using metadata after the path
128+
1. **File Organization**: Use `//- /path/to/file.erl` to define multiple files
129+
in a single test
130+
2. **Metadata Markers**: Specify app names, include paths, OTP apps, etc. using
131+
metadata after the path
129132
3. **Annotations**: Mark expected diagnostics or ranges using `%% ^^^` syntax
130-
4. **Cursors and Ranges**: Use `~` markers to indicate positions or ranges in test code
133+
4. **Cursors and Ranges**: Use `~` markers to indicate positions or ranges in
134+
test code
131135

132136
#### Annotation Syntax
133137

134-
Annotations allow you to mark expected diagnostics, types, or other information directly in test code:
135-
136-
- **Basic annotation**: `%% ^^^ some text` - Points to the range above matching the caret length
137-
- **Top-of-file marker**: `%% <<< text` (at file start) - Creates annotation at position 0..0
138-
- **File-wide annotation**: `%% ^^^file text` - Annotation spans the entire file contents
139-
- **Left-margin annotation**: `%%<^^^ text` - Annotation starts at `%%` position instead of first `^`
138+
Annotations allow you to mark expected diagnostics, types, or other information
139+
directly in test code:
140+
141+
- **Basic annotation**: `%% ^^^ some text` - Points to the range above matching
142+
the caret length
143+
- **Top-of-file marker**: `%% <<< text` (at file start) - Creates annotation at
144+
position 0..0
145+
- **File-wide annotation**: `%% ^^^file text` - Annotation spans the entire file
146+
contents
147+
- **Left-margin annotation**: `%%<^^^ text` - Annotation starts at `%%` position
148+
instead of first `^`
140149
- **Multiline annotations**: Use continuation lines with `%% | next line`
141150

142151
#### Example Test Fixture
@@ -146,9 +155,8 @@ let fixture = r#"
146155
//- /src/main.erl
147156
-module(main).
148157
149-
foo(X) ->
150-
X + undefined.
151-
%% ^^^^^^^^^ error: type mismatch
158+
foo( -> ok. %%
159+
%% ^ error: W0004: Missing ')'~
152160
"#;
153161
```
154162

@@ -160,34 +168,37 @@ foo(X) ->
160168

161169
### Running Tests for Specific Crates
162170

163-
When running tests for a specific crate, you need to specify the crate name, not the directory name. The mapping is:
171+
When running tests for a specific crate, you need to specify the crate name, not
172+
the directory name. The mapping is:
164173

165-
| Crate Name | Directory Name |
166-
|------------|----------------|
167-
| `elp_base_db` | `crates/base_db` |
168-
| `elp_eqwalizer` | `crates/eqwalizer` |
174+
| Crate Name | Directory Name |
175+
| -------------------- | ----------------------- |
176+
| `elp` | `crates/elp` |
177+
| `elp_base_db` | `crates/base_db` |
178+
| `elp_eqwalizer` | `crates/eqwalizer` |
169179
| `elp_erlang_service` | `crates/erlang_service` |
170-
| `elp_ide` | `crates/ide` |
171-
| `elp_ide_assists` | `crates/ide_assists` |
180+
| `elp_ide` | `crates/ide` |
181+
| `elp_ide_assists` | `crates/ide_assists` |
172182
| `elp_ide_completion` | `crates/ide_completion` |
173-
| `elp_ide_db` | `crates/ide_db` |
174-
| `elp_ide_ssr` | `crates/ide_ssr` |
175-
| `elp_log` | `crates/elp_log` |
176-
| `elp_project_model` | `crates/project_model` |
177-
| `elp_syntax` | `crates/syntax` |
178-
| `elp_text_edit` | `crates/text_edit` |
179-
| `elp_types_db` | `crates/types_db` |
180-
| `hir` | `crates/hir` |
181-
| `erl_ast` | `crates/erl_ast` |
183+
| `elp_ide_db` | `crates/ide_db` |
184+
| `elp_ide_ssr` | `crates/ide_ssr` |
185+
| `elp_log` | `crates/elp_log` |
186+
| `elp_project_model` | `crates/project_model` |
187+
| `elp_syntax` | `crates/syntax` |
188+
| `elp_text_edit` | `crates/text_edit` |
189+
| `elp_types_db` | `crates/types_db` |
190+
| `hir` | `crates/hir` |
182191

183192
Example: To run tests for the `elp_ide` crate:
193+
184194
```bash
185-
./meta/cargo.sh test -p elp_ide
195+
cargo test -p elp_ide
186196
```
187197

188198
Or to run tests in a specific directory:
199+
189200
```bash
190-
./meta/cargo.sh test --manifest-path crates/ide/Cargo.toml
201+
cargo test --manifest-path crates/ide/Cargo.toml
191202
```
192203

193204
### Existing tests
@@ -277,14 +288,8 @@ Or to run tests in a specific directory:
277288
- Collect multiple errors rather than failing on the first one
278289
- Provide partial results when full analysis isn't possible
279290

280-
### Tools
281-
282-
- ELP uses a cargo workspace.
283-
- Inside Meta, use `./meta/cargo.sh` instead of `cargo`
284-
- Inside Meta, use `./meta/clippy.sh` to run clippy
285-
- Use `arc lint --apply-patches` for formatting.
286-
287291
### Process
288292

289-
- Always run tests before finishing.
290-
- Always run `./meta/cargo.sh clippy --tests` before submitting a diff
293+
- Always run tests before finishing
294+
- Always run `cargo clippy --tests` before submitting PRs
295+
- Use `cargo fmt` for code formatting

0 commit comments

Comments
 (0)