Skip to content

Commit f67404f

Browse files
committed
settings for toggle show words in file
1 parent ad1ef0e commit f67404f

File tree

4 files changed

+105
-36
lines changed

4 files changed

+105
-36
lines changed

src/main/java/com/tang/intellij/lua/editor/completion/LuaCompletionContributor.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.intellij.psi.tree.TokenSet
2525
import com.intellij.util.ProcessingContext
2626
import com.intellij.util.containers.HashSet
2727
import com.tang.intellij.lua.lang.LuaIcons
28+
import com.tang.intellij.lua.project.LuaSettings
2829
import com.tang.intellij.lua.psi.*
2930

3031
/**
@@ -67,7 +68,7 @@ class LuaCompletionContributor : CompletionContributor() {
6768
val session = CompletionSession(parameters, result)
6869
parameters.editor.putUserData(CompletionSession.KEY, session)
6970
super.fillCompletionVariants(parameters, result)
70-
if (suggestWords && session.isSuggestWords && !result.isStopped) {
71+
if (LuaSettings.instance.isShowWordsInFile && suggestWords && session.isSuggestWords && !result.isStopped) {
7172
suggestWordsInFile(parameters)
7273
}
7374
}

src/main/java/com/tang/intellij/lua/project/LuaSettings.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class LuaSettings : PersistentStateComponent<LuaSettings> {
3939
//在代码完成时使用参数完成模板
4040
var autoInsertParameters: Boolean = false
4141

42+
var isShowWordsInFile: Boolean = true
43+
4244
override fun getState(): LuaSettings? {
4345
return this
4446
}
Lines changed: 96 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,112 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.tang.intellij.lua.project.LuaSettingsPanel">
3-
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
4-
<margin top="0" left="0" bottom="0" right="0"/>
3+
<grid id="27dc6" binding="myPanel" layout-manager="FormLayout">
4+
<rowspec value="center:d:noGrow"/>
5+
<rowspec value="top:4dlu:noGrow"/>
6+
<rowspec value="center:max(d;4px):noGrow"/>
7+
<colspec value="fill:d:grow"/>
58
<constraints>
69
<xy x="20" y="20" width="500" height="400"/>
710
</constraints>
811
<properties/>
912
<border type="none"/>
1013
<children>
11-
<component id="63b06" class="javax.swing.JTextField" binding="constructorNames">
14+
<grid id="27dc8" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
15+
<margin top="0" left="0" bottom="0" right="0"/>
1216
<constraints>
13-
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
14-
<preferred-size width="150" height="-1"/>
15-
</grid>
17+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
18+
<forms/>
1619
</constraints>
1720
<properties/>
18-
</component>
19-
<vspacer id="76fca">
20-
<constraints>
21-
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
22-
</constraints>
23-
</vspacer>
24-
<component id="e57e1" class="javax.swing.JLabel">
25-
<constraints>
26-
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
27-
</constraints>
28-
<properties>
29-
<text resource-bundle="LuaBundle" key="ui.settings.constructor_names"/>
30-
</properties>
31-
</component>
32-
<component id="cc088" class="javax.swing.JCheckBox" binding="strictDoc">
21+
<border type="none"/>
22+
<children>
23+
<component id="63b06" class="javax.swing.JTextField" binding="constructorNames">
24+
<constraints>
25+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
26+
<preferred-size width="150" height="-1"/>
27+
</grid>
28+
</constraints>
29+
<properties/>
30+
</component>
31+
<vspacer id="76fca">
32+
<constraints>
33+
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
34+
</constraints>
35+
</vspacer>
36+
<component id="e57e1" class="javax.swing.JLabel">
37+
<constraints>
38+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
39+
</constraints>
40+
<properties>
41+
<text resource-bundle="LuaBundle" key="ui.settings.constructor_names"/>
42+
</properties>
43+
</component>
44+
<component id="cc088" class="javax.swing.JCheckBox" binding="strictDoc">
45+
<constraints>
46+
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
47+
</constraints>
48+
<properties>
49+
<text resource-bundle="LuaBundle" key="ui.settings.strict_doc"/>
50+
</properties>
51+
</component>
52+
<component id="267d4" class="javax.swing.JCheckBox" binding="smartCloseEnd">
53+
<constraints>
54+
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
55+
</constraints>
56+
<properties>
57+
<text resource-bundle="LuaBundle" key="ui.settings.smart_close_end"/>
58+
</properties>
59+
</component>
60+
</children>
61+
</grid>
62+
<grid id="9700" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
63+
<margin top="0" left="0" bottom="0" right="0"/>
3364
<constraints>
34-
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
65+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
66+
<forms/>
3567
</constraints>
36-
<properties>
37-
<text resource-bundle="LuaBundle" key="ui.settings.strict_doc"/>
38-
</properties>
39-
</component>
40-
<component id="267d4" class="javax.swing.JCheckBox" binding="smartCloseEnd">
41-
<constraints>
42-
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
43-
</constraints>
44-
<properties>
45-
<text resource-bundle="LuaBundle" key="ui.settings.smart_close_end"/>
46-
</properties>
47-
</component>
68+
<properties/>
69+
<border type="none"/>
70+
<children>
71+
<grid id="48443" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
72+
<margin top="0" left="0" bottom="0" right="0"/>
73+
<constraints>
74+
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
75+
</constraints>
76+
<properties/>
77+
<border type="none"/>
78+
<children>
79+
<component id="d52b2" class="javax.swing.JLabel">
80+
<constraints>
81+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
82+
</constraints>
83+
<properties>
84+
<text value="Completion"/>
85+
</properties>
86+
</component>
87+
<component id="44b38" class="javax.swing.JSeparator">
88+
<constraints>
89+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
90+
</constraints>
91+
<properties/>
92+
</component>
93+
</children>
94+
</grid>
95+
<vspacer id="85496">
96+
<constraints>
97+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
98+
</constraints>
99+
</vspacer>
100+
<component id="9cc67" class="javax.swing.JCheckBox" binding="showWordsInFile">
101+
<constraints>
102+
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
103+
</constraints>
104+
<properties>
105+
<text value="show words in file"/>
106+
</properties>
107+
</component>
108+
</children>
109+
</grid>
48110
</children>
49111
</grid>
50112
</form>

src/main/java/com/tang/intellij/lua/project/LuaSettingsPanel.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ public class LuaSettingsPanel implements SearchableConfigurable, Configurable.No
3939
private JTextField constructorNames;
4040
private JCheckBox strictDoc;
4141
private JCheckBox smartCloseEnd;
42+
private JCheckBox showWordsInFile;
4243

4344
public LuaSettingsPanel(LuaSettings settings) {
4445
this.settings = settings;
4546
constructorNames.setText(settings.getConstructorNamesString());
4647
strictDoc.setSelected(settings.isStrictDoc());
4748
smartCloseEnd.setSelected(settings.isSmartCloseEnd());
49+
showWordsInFile.setSelected(settings.isShowWordsInFile());
4850
}
4951

5052
@NotNull
@@ -69,7 +71,8 @@ public JComponent createComponent() {
6971
public boolean isModified() {
7072
return !StringUtil.equals(settings.getConstructorNamesString(), constructorNames.getText()) ||
7173
settings.isStrictDoc() != strictDoc.isSelected() ||
72-
settings.isSmartCloseEnd() != smartCloseEnd.isSelected();
74+
settings.isSmartCloseEnd() != smartCloseEnd.isSelected() ||
75+
settings.isShowWordsInFile() != showWordsInFile.isSelected();
7376
}
7477

7578
@Override
@@ -78,6 +81,7 @@ public void apply() throws ConfigurationException {
7881
constructorNames.setText(settings.getConstructorNamesString());
7982
settings.setStrictDoc(strictDoc.isSelected());
8083
settings.setSmartCloseEnd(smartCloseEnd.isSelected());
84+
settings.setShowWordsInFile(showWordsInFile.isSelected());
8185

8286
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
8387
DaemonCodeAnalyzer.getInstance(project).restart();

0 commit comments

Comments
 (0)