Skip to content
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
2 changes: 2 additions & 0 deletions .agents/skills/xtend-to-java/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Use this table for quick mechanical transforms. Full details in the rule files.
| `var x = expr` | `ExplicitType x = expr;` |
| `typeof(MyClass)` | `MyClass.class` |
| `def dispatch method(Type1 x)` | Keep as `_method(Type1 x)` with `@SuppressWarnings` |
| `@Inject extension Foo _foo` (field) | `private Foo foo;` — strip `_` prefix; names must match `[a-z][a-zA-Z0-9]*` |
| Field `my_field` / `_my_field` | Rename to `myField` (camelCase, no underscores) |

### Operators and null handling

Expand Down
43 changes: 40 additions & 3 deletions .agents/skills/xtend-to-java/rules/02-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,44 @@ Always add explicit visibility (`private` unless a wider scope is genuinely need

Always add explicit visibility.

## 2.5 No leading underscore on non-dispatch fields
## 2.5 Field member names must match `[a-z][a-zA-Z0-9]*`

Non-dispatch private fields that got `_fieldName` from the converter: rename to `fieldName`.
The `_` prefix is reserved for dispatch methods only (see [`rules/09-misc-syntax.md`](./09-misc-syntax.md)).
The Checkstyle `MemberName` rule (default pattern `[a-z][a-zA-Z0-9]*`) is enforced on all
non-constant instance and static-non-final fields. Every field name **must**:

- Start with a lowercase letter.
- Contain only ASCII letters and digits — **no underscores anywhere**.

### Leading underscore from Xtend extension fields

Xtend generates `_fieldName` for extension-injected fields. Strip the prefix:

```java
// Bad — Xtend-generated name
private MyHelper _myHelper;

// Good
private MyHelper myHelper;
```

### Underscores inside the name — convert to camelCase

Any underscore inside a name (rare in Xtend source but can appear when porting
older code) must be removed by camelCasing the following word:

| Original | Renamed |
|----------|---------|
| `my_helper` | `myHelper` |
| `some_long_name` | `someLongName` |
| `_some_field` | `someField` |

### Scope of this rule

Applies to **all non-constant member fields** — instance fields and non-final static
fields. It does **not** apply to:

- `static final` constants, which are validated by Checkstyle `ConstantName`
(pattern `[A-Z][A-Z0-9]*(_[A-Z0-9]+)*`, e.g. `LOGGER`, `DEFAULT_SIZE`).
- Dispatch method parameters / local variables in dispatch methods (the `_` prefix
on dispatch methods themselves is intentional — see
[`rules/09-misc-syntax.md`](./09-misc-syntax.md)).
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Run through this list before declaring a conversion done. Every item is a hard g
| 3 | No `val`/`var` | Always use explicit types. `var` is banned. |
| 4 | No unnecessary boxing | `Integer.valueOf(i)` only when signature requires boxed type. |
| 14 | LooseCoupling | Interface types (`List`, `Map`, `Set`, `EList`) in fields/params/returns, not `ArrayList`/`HashMap`/`BasicEList`. |
| 16 | No leading underscore on non-dispatch fields | Rename `_fieldName` → `fieldName`. |
| 16 | Field names match `[a-z][a-zA-Z0-9]*` | Rename `_fieldName` → `fieldName`. Convert any underscore inside a name to camelCase (`my_field` → `myField`). Applies to all non-constant member fields; `static final` constants are exempt (they follow `ConstantName`). |

### String building

Expand Down