Skip to content

Commit 59b4889

Browse files
author
Yanglin
committed
Add $ as the char of popup parameter completion
1 parent f231e91 commit 59b4889

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

META-INF/plugin.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin version="2" url="https://github.com/seventh7/intellij-mybatis-plugin">
22
<id>com.seventh7.plugin.mybatis</id>
33
<name>MyBatis plugin</name>
4-
<version>2.21</version>
4+
<version>2.22</version>
55
<vendor email="insist.day@gmail.com" url="https://github.com/seventh7">Yanglin</vendor>
66

77
<description><![CDATA[
@@ -10,6 +10,10 @@
1010
]]></description>
1111

1212
<change-notes><![CDATA[
13+
<h4>2.22</h4>
14+
<ul>
15+
<li>Add '$' as the beginning char of popup parameter completion</li>
16+
</ul>
1317
<h4>2.21</h4>
1418
<ul>
1519
<li>Rebuild mapper model</li>

src/com/seventh7/mybatis/action/MybatisTypedHandler.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@ public Result checkAutoPopup(char charTyped, final Project project, final Editor
3131

3232
@Override
3333
public Result charTyped(char c, final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
34+
if (c != '{') {
35+
return Result.CONTINUE;
36+
}
3437
int index = editor.getCaretModel().getOffset() - 2;
38+
if (index < 0) {
39+
return Result.CONTINUE;
40+
}
41+
char beginningChar = editor.getDocument().getText().charAt(index);
42+
if (beginningChar != '#' && beginningChar != '$') {
43+
return Result.CONTINUE;
44+
}
3545
PsiFile topLevelFile = InjectedLanguageUtil.getTopLevelFile(file);
36-
boolean parameterCase = c == '{' &&
37-
index >= 0 &&
38-
editor.getDocument().getText().charAt(index) == '#' &&
39-
file instanceof SqlFile &&
46+
boolean parameterCase = file instanceof SqlFile &&
4047
DomUtils.isMybatisFile(topLevelFile);
4148
if (parameterCase) {
4249
autoPopupParameter(project, editor);

src/com/seventh7/mybatis/contributor/SqlParamCompletionContributor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private boolean shouldAddElement(PsiFile file, int offset) {
5151
String text = file.getText();
5252
for (int i = offset - 1; i > 0; i--) {
5353
char c = text.charAt(i);
54-
if (c == '{' && text.charAt(i - 1) == '#') return true;
54+
if (c == '{' && (text.charAt(i - 1) == '#' || text.charAt(i - 1) == '$')) return true;
5555
}
5656
return false;
5757
}

0 commit comments

Comments
 (0)