Skip to content

Commit e423ad6

Browse files
committed
Add document for intention actions for bidirectional SQL/annotation conversion.
1 parent 41dbfa2 commit e423ad6

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

CLAUDE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,28 @@ Action functionality for navigating between DAO files and SQL files
117117
Class names should have `Action` as a suffix.
118118
Classes should not have properties; necessary information should be obtained within functions.
119119

120+
#### Intention Actions for SQL/Annotation Conversion
121+
122+
**ConvertSqlFileToAnnotationAction**: Converts SQL file content to @Sql annotation
123+
- Extends `PsiElementBaseIntentionAction` for context-sensitive availability
124+
- Available when:
125+
- Current file is a SQL file with corresponding DAO method
126+
- DAO method doesn't have @Sql annotation
127+
- DAO method has supported annotation (@Select, @Insert, @Update, @Delete, etc.) with sqlFile=true
128+
- Uses `SqlAnnotationConverter` to perform the conversion
129+
- Invoked via Alt+Enter on SQL file
130+
131+
**ConvertSqlAnnotationToFileAction**: Converts @Sql annotation to SQL file
132+
- Extends `PsiElementBaseIntentionAction` for context-sensitive availability
133+
- Available when:
134+
- Cursor is on a DAO method with @Sql annotation
135+
- Method has supported annotation (@Select, @Insert, @Update, @Delete, etc.)
136+
- Uses `SqlAnnotationConverter` to perform the conversion
137+
- Creates SQL file in appropriate directory structure (META-INF/...)
138+
- Invoked via Alt+Enter on DAO method with @Sql annotation
139+
140+
Both actions use `WriteCommandAction` to ensure changes are undoable and properly tracked by IntelliJ's local history.
141+
120142
### LineMarker
121143
Line marker functionality for DAO methods and DOMA directives in SQL
122144

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ such as generating SQL template files, navigating between files, and inspecting
1515

1616
# Features
1717

18+
## Intention Action
19+
20+
Provides Intention Action features for automatically generating SQL templates between SQL annotations and SQL files bidirectionally.
21+
22+
- **Generate corresponding SQL file from SQL annotation on DAO method**
23+
- When a DAO method has an `@Sql` annotation but the corresponding SQL template file does not exist, you can automatically generate it from the intention action (Alt+Enter).
24+
- **Generate corresponding SQL annotation from SQL file**
25+
- When a SQL file exists but the corresponding DAO method doesn't have an `@Sql` annotation, you can automatically add the annotation from the intention action (Alt+Enter) on the SQL file.
26+
27+
![IntentionAction](images/gif/IntentionAction.gif)
28+
29+
This streamlines the association between DAOs and SQL files and makes template creation more efficient.
30+
1831
## Actions
1932
The plugin adds several actions and gutter icons.
2033
Shortcut keys can be used for these actions.

images/gif/IntentionAction.gif

419 KB
Loading

0 commit comments

Comments
 (0)