Skip to content

Commit 5cd0297

Browse files
committed
Update test case guidelines to include parent-child entity relationships and PsiClass member access
1 parent 93ebd3d commit 5cd0297

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

.claude/guidelines/TEST_CASE_GUIDELINE.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Follow the rules below when implementing test code.
44
## Code Inspection Functionality
55
Implement tests for code inspection functionality using the following steps:
66

7-
### **Implementation of Test Case Classes**
7+
## Implementation of Test Case Classes
88
- Implement test case classes in `@src/test/kotlin/org/domaframework/doma/intellij/inspection`.
99
- Implement test cases for each subclass of **AbstractBaseJavaLocalInspectionTool**.
1010
- Name the test case class as `<InspectionToolName>InspectionTest`.
@@ -17,14 +17,31 @@ Implement tests for code inspection functionality using the following steps:
1717
Create the target Dao class or SQL file for inspection.
1818
Wrap the elements to be error-highlighted with the **<error>** tag and specify the error message to be displayed using the **descr** option.
1919

20-
#### Test Data for Dao Classes
20+
**Test Data for Dao Classes**
2121
- Implement test data Dao classes in **Java**.
2222
- Annotate test data Dao classes with **@Dao**.
2323
- Place them under the appropriate subpackage in `@src/test/testData/src/main/java/doma/example/dao/inspection`.
2424
- Implement any other necessary classes as needed.
2525

26+
**Entity Test Data**
27+
When creating test cases, prepare and verify the following Entity classes to test parent-child relationships:
28+
- Parent class annotated with @Entity
29+
- Subclass without @Entity annotation
30+
- Subclass annotated with @Entity
31+
32+
Using the above, create the following test cases for features that use `PsiClass`:
33+
- Test cases using fields/methods defined in parent classes
34+
- Test cases using fields/methods defined in subclasses
35+
36+
**Examples**
37+
- Test that bind variable definition inspection doesn't highlight errors when using fields defined in parent classes
38+
- Test that include/exclude option checking in DAO method annotations doesn't highlight errors when using fields defined in parent classes
39+
- Test that code completion shows fields/methods defined in parent classes as completion candidates
40+
2641
#### Test Data for SQL Files
2742
- Create and place SQL files in a directory named after the corresponding Dao class under `@src/test/testData/src/main/resources/META-INF/doma/example/dao`.
43+
- When creating test cases for bind variables, prepare test data that checks instance field methods, static field methods, field methods of elements defined in loop directives, custom functions, and built-in functions.
44+
For cases combining multiple variables, ensure comprehensive coverage of all variable combination patterns.
2845

2946
### Reference
3047
For actual implementation examples using Doma, refer to the [Doma GitHub repository](https://github.com/domaframework/doma/tree/master/integration-test-java/src/main/java/org/seasar/doma/it/dao).

CLAUDE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ Feature Package
107107
└── AnAction subclass
108108
```
109109

110+
### Common
111+
112+
**Accessing `PsiClass` Members**
113+
When retrieving fields and methods from `PsiClass`, use `allFields` and `allMethods` instead of `fields` and `methods`.
114+
This is necessary to include members defined in parent classes.
115+
116+
Alternatively, you can use [PsiParentClass](src/main/kotlin/org/domaframework/doma/intellij/common/psi/PsiParentClass.kt)
117+
to achieve equivalent functionality with `findField()` and `findMethod()`.
118+
119+
**Separating Complex Logic**
120+
Each feature requires implementing corresponding classes following the IntelliJ platform conventions.
121+
Complex logic should not be implemented directly in these corresponding classes but delegated to separate classes (Processors or Handlers).
122+
110123
### Actions
111124
Action functionality for navigating between DAO files and SQL files
112125

@@ -171,6 +184,10 @@ Code inspection functionality for DAO methods and DOMA directives in SQL
171184
- [ValidationResult](src/main/kotlin/org/domaframework/doma/intellij/common/validation/result): Classes that provide error messages and highlights for code inspection results
172185
- **Class Naming Rules**: Use `ValidationResult` as a suffix. Name classes according to the message resources to be displayed
173186

187+
**Coding Rule**
188+
For code inspection features, always implement `InspectionTool` and `Visitor` as separate classes.
189+
When the logic within `Visitor` becomes complex, implement separate Processor classes for main processing or Handler classes for error highlighting.
190+
174191
### Completion
175192
Code completion functionality for DOMA directive syntax in SQL
176193
- **[Feature Package](src/main/kotlin/org/domaframework/doma/intellij/contributor/sql)**

0 commit comments

Comments
 (0)