Skip to content

Commit 2f9baa4

Browse files
committed
Add detailed plugin feature descriptions to CLAUDE.md
1 parent 5bcb537 commit 2f9baa4

File tree

1 file changed

+106
-28
lines changed

1 file changed

+106
-28
lines changed

CLAUDE.md

Lines changed: 106 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
1515
./gradlew test
1616

1717
# Run single test class
18-
./gradlew test --tests "org.domaframework.doma.intellij.formatter.SqlFormatterTest"
18+
./gradlew check
1919

2020
# Code formatting and linting
2121
./gradlew spotlessApply
@@ -107,7 +107,7 @@ Feature Package
107107
└── AnAction subclass
108108
```
109109

110-
### Common
110+
## Common
111111

112112
**Accessing `PsiClass` Members**
113113
When retrieving fields and methods from `PsiClass`, use `allFields` and `allMethods` instead of `fields` and `methods`.
@@ -120,6 +120,8 @@ to achieve equivalent functionality with `findField()` and `findMethod()`.
120120
Each feature requires implementing corresponding classes following the IntelliJ platform conventions.
121121
Complex logic should not be implemented directly in these corresponding classes but delegated to separate classes (Processors or Handlers).
122122

123+
## Main Classes of Each Feature
124+
123125
### Actions
124126
Action functionality for navigating between DAO files and SQL files
125127

@@ -130,7 +132,7 @@ Action functionality for navigating between DAO files and SQL files
130132
Class names should have `Action` as a suffix.
131133
Classes should not have properties; necessary information should be obtained within functions.
132134

133-
#### Intention Actions for SQL/Annotation Conversion
135+
### Intention Actions for SQL/Annotation Conversion
134136

135137
**ConvertSqlFileToAnnotationAction**: Converts SQL file content to @Sql annotation
136138
- Extends `PsiElementBaseIntentionAction` for context-sensitive availability
@@ -167,22 +169,30 @@ Code inspection functionality for DAO methods and DOMA directives in SQL
167169
- **[Feature Package](src/main/kotlin/org/domaframework/doma/intellij/inspection)**
168170
- **Main Classes**: `InspectionTool`
169171
- Code inspection class for DAO: `AbstractBaseJavaLocalInspectionTool` subclasses
172+
- **DaoAnnotationOptionParameterInspection**: DAOメソッドに付与されたアノテーションオプション(include/exclude)にEntityクラスで定義されたフィールドが指定されていることを検査
173+
- **DaoAnnotationReturnTypeInspection**: DAOメソッドの戻り値が適切であることを検査
174+
- **DaoMethodParamTypeInspection**: DAOメソッドのパラメータが適切であることを検査
175+
- **SqlFileExistInspection**: DAOメソッドに対応するSQLファイルが存在することを検査
176+
- **UsedDaoMethodParamInspection**: DAOメソッドのパラメータがSQLファイル内で使用されていることを検査
170177
- Code inspection class for SQL: `LocalInspectionTool` subclasses
178+
- **SqlBindVariableInspection**: バインド変数内の要素定義元を検査
179+
- **SqlFunctionCallInspection**: カスタム関数、組み込み関数の定義元を検査
180+
- **SqlLoopDirectiveTypeInspection**: ループディレクティブで指定されている変数の型を検査
181+
- **SqlTestDataInspection**: ディレクティブの後ろにテストデータが存在していることを検査
171182
- **Class Naming Rules**: Use `Inspection` as a suffix
172-
- **Related Classes**
173-
- Processor: Classes that check inspection target elements. Provides common check processing for inspection targets that meet specific conditions
174-
- **Class Naming Rules**: Use `Checker` or `Processor` as a suffix depending on the purpose
175-
- Provider: Provider that returns a list of `InspectionTool` subclasses
176-
- **Class Naming Rules**: Use `Provider` as a suffix
177-
- Visitor: Classes that search for inspection target elements. Called from `InspectionTool`
178-
- **Class Naming Rules**: Have the same name as the calling `InspectionTool` with `Visitor` as a suffix
179-
- QuickFix: Classes that provide fix actions for inspection results
180-
- Consists of a `Factory` object that provides quick fix objects and the main `QuickFix` object
181-
- **Class Naming Rules**
182-
- `Factory` object: Use `QuickFixFactory` as a suffix
183-
- `QuickFix` object: Use `QuickFix` as a suffix
184-
- [ValidationResult](src/main/kotlin/org/domaframework/doma/intellij/common/validation/result): Classes that provide error messages and highlights for code inspection results
185-
- **Class Naming Rules**: Use `ValidationResult` as a suffix. Name classes according to the message resources to be displayed
183+
- Processor: Classes that check inspection target elements. Provides common check processing for inspection targets that meet specific conditions
184+
- **Class Naming Rules**: Use `Checker` or `Processor` as a suffix depending on the purpose
185+
- Provider: Provider that returns a list of `InspectionTool` subclasses
186+
- **Class Naming Rules**: Use `Provider` as a suffix
187+
- Visitor: Classes that search for inspection target elements. Called from `InspectionTool`
188+
- **Class Naming Rules**: Have the same name as the calling `InspectionTool` with `Visitor` as a suffix
189+
- QuickFix: Classes that provide fix actions for inspection results
190+
- Consists of a `Factory` object that provides quick fix objects and the main `QuickFix` object
191+
- **Class Naming Rules**
192+
- `Factory` object: Use `QuickFixFactory` as a suffix
193+
- `QuickFix` object: Use `QuickFix` as a suffix
194+
- [ValidationResult](src/main/kotlin/org/domaframework/doma/intellij/common/validation/result): Classes that provide error messages and highlights for code inspection results
195+
- **Class Naming Rules**: Use `ValidationResult` as a suffix. Name classes according to the message resources to be displayed
186196

187197
**Coding Rule**
188198
For code inspection features, always implement `InspectionTool` and `Visitor` as separate classes.
@@ -191,14 +201,82 @@ When the logic within `Visitor` becomes complex, implement separate Processor cl
191201
### Completion
192202
Code completion functionality for DOMA directive syntax in SQL
193203
- **[Feature Package](src/main/kotlin/org/domaframework/doma/intellij/contributor/sql)**
194-
- **Related Classes**
195-
- CompletionContributor: Entry point for code completion
196-
- **Class Naming Rules**: Use `CompletionContributor` as a suffix
197-
- Provider: Classes that provide completion candidates in specific contexts
198-
- **Class Naming Rules**: Use `CompletionProvider` as a suffix
199-
- Processor: Classes that filter and transform completion candidates
200-
- **Class Naming Rules**: Use `Processor` as a suffix
201-
- [Handler](src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive): Classes that generate suggestion candidates for each directive type
202-
- **Class Naming Rules**: Use `Handler` as a suffix
203-
- [Collector](src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector): Classes that collect directive suggestion candidates. Called from `Handler`
204-
- **Class Naming Rules**: Use `Collector` as a suffix
204+
- CompletionContributor: Entry point for code completion
205+
- **Class Naming Rules**: Use `CompletionContributor` as a suffix
206+
- Provider: Classes that provide completion candidates in specific contexts
207+
- **Class Naming Rules**: Use `CompletionProvider` as a suffix
208+
- Processor: Classes that filter and transform completion candidates
209+
- **Class Naming Rules**: Use `Processor` as a suffix
210+
- [Handler](src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive): Classes that generate suggestion candidates for each directive type
211+
- **Class Naming Rules**: Use `Handler` as a suffix
212+
- [Collector](src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector): Classes that collect directive suggestion candidates. Called from `Handler`
213+
- **Class Naming Rules**: Use `Collector` as a suffix
214+
215+
### Refactoring
216+
Functionality for renaming SQL files and directories when DAO classes or methods are renamed.
217+
- **Feature Package**: `src/main/kotlin/org/domaframework/doma/intellij/refactoring/dao`
218+
- **Processor (Rename Processor Classes)**
219+
- **DaoMethodRenameProcessor**: Detects renaming of DAO method names and renames the corresponding SQL file.
220+
- **DaoPackageRenameListenerProcessor**: Detects renaming of DAO class package names and renames the corresponding SQL directory. Implemented as a subclass of `RefactoringElementListenerProvider` to support changes from the project view.
221+
- **DaoRenameProcessor**: Detects renaming of DAO class names and renames the corresponding SQL directory.
222+
- **Class Naming Rules**: Use the `Processor` suffix.
223+
- Use `canProcessElement()` to determine if the element is a rename target, and `renameElement()` to perform the rename. Since the original rename process is not executed, always call `super.renameElement()` at the end.
224+
225+
### Reference Resolution
226+
Functionality for resolving references to the definition of elements inside Doma bind variables in SQL.
227+
- **Feature Package**: `src/main/kotlin/org/domaframework/doma/intellij/reference`
228+
- **Contributor**: Registers reference resolution extension points in IntelliJ.
229+
- **Class Naming Rules**: Use the `ReferenceContributor` suffix.
230+
- **Provider**: Selects elements for reference resolution and delegates to the appropriate reference class.
231+
- **Class Naming Rules**: Use the `ReferenceProvider` suffix.
232+
- Bind variables may have parent-child relationships such as `SqlElFieldAccessExpr` > `SqlElIdExpr`. Resolution is performed from the smallest granularity upward for the most precise result.
233+
- **Reference**: Performs the actual reference resolution. Implemented as subclasses of `SqlElExprReference` (which extends `PsiReferenceBase`).
234+
- **SqlElClassExprReference**: Resolves fully qualified class names in static field access elements.
235+
- **SqlElIdExprReference**: Resolves the smallest unit of bind variable elements (DAO parameters, fields, etc.).
236+
- **SqlElForDirectiveIdExprReference**: Resolves elements defined within loop directives.
237+
- **SqlElFunctionCallExprReference**: Resolves custom and built-in function references.
238+
- **SqlElStaticFieldReference**: Resolves the top-level static field or method in static field access.
239+
- **Class Naming Rules**: Use the `Reference` suffix.
240+
- **Manipulator**: Supports renaming of reference target elements. Used to determine the reference range when the element text is changed.
241+
- **Class Naming Rules**: Use the `Manipulator` suffix.
242+
243+
### Documentation
244+
Functionality for displaying documentation for the definition of elements inside Doma bind variables in SQL.
245+
- **Feature Package**: `src/main/kotlin/org/domaframework/doma/intellij/document`
246+
- **Provider**: Registers documentation display extension points in IntelliJ.
247+
- **Class Naming Rules**: Use the `DocumentationProvider` suffix.
248+
- **Generator**: Generates HTML for documentation display.
249+
- **DocumentDaoParameterGenerator**: Generates documentation for bind variable elements starting from DAO parameters.
250+
- **DocumentStaticFieldAccessGenerator**: Generates documentation for bind variable elements starting from static field access.
251+
- **Class Naming Rules**: Use the `DocumentationGenerator` suffix.
252+
253+
### Formatter
254+
Functionality for formatting SQL.
255+
- **Feature Package**: `src/main/kotlin/org/domaframework/doma/intellij/formatter`
256+
- **Builder**: Entry point for formatting, implements the `FormattingModelBuilder` class.
257+
- **SqlFormattingModelBuilder**: Provides formatting models for SQL.
258+
- **SqlBlockRelationBuilder**: Sets parent-child relationships between blocks.
259+
- **SqlBlockBuilder**: Manages the start and end blocks of conditional directives and group blocks.
260+
- **SqlCustomSpacingBuilder**: Defines custom spacing settings for element types and blocks.
261+
- **Class Naming Rules**: Use the `FormattingModelBuilder` suffix.
262+
- **Block**: Classes representing the basic unit of formatting blocks.
263+
- The abstract class `SqlBlock` is the base, and blocks are structured hierarchically according to the SQL structure.
264+
- **SqlKeywordGroupBlock**: Represents keyword group blocks.
265+
- **SqlSubGroupBlock**: Represents subgroups enclosed in `()`.
266+
- **SqlElBlockCommentBlock**: Represents directive blocks such as `/*%if*/` and `/*%for*/`.
267+
- Whether to preserve a newline before a block is determined by `isSaveSpace()`.
268+
- The parent group block is held in `parentBlock`.
269+
- The block's own indent is calculated by `createBlockIndentLen()`, and the indent base for child elements in its group is calculated by `createGroupIndentLen()`.
270+
- **Class Naming Rules**: Use the `Block` suffix.
271+
- **Util**: Utility classes related to formatting.
272+
- Provides block object generation by branching and line break determination by keyword combinations.
273+
- **Class Naming Rules**: Use the `Util` suffix.
274+
- **Handler**: Provides custom spacing settings and block class determination according to query type.
275+
- **Processor**: Classes that determine spacing between blocks.
276+
- **InjectionSqlFormatter**: Provides common formatting for injected SQL.
277+
- **SqlInjectionPostProcessor**: Applies formatting to injected SQL in DAOs. Independently invokes formatting and executes reformatting from the `SqlFormatPreProcessor` for SQL.
278+
- **SqlFormatPreProcessor**: Inserts line breaks before the main SQL formatting process. Not automatically executed for injected SQL formatting.
279+
- **SqlFormatPostProcessor**: Removes trailing spaces and adds a newline at the end of SQL after formatting.
280+
- **Class Naming Rules**: Use the `Processor` suffix.
281+
- **Visitor**: Visitor classes for collecting target elements to process within Processor.
282+
- **Class Naming Rules**: Use the `Visitor` suffix

0 commit comments

Comments
 (0)