Skip to content

Commit 1a63431

Browse files
committed
add postfix template "if_not"
1 parent 26babff commit 1a63431

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

src/main/java/com/tang/intellij/lua/codeInsight/postfix/LuaPostfixTemplateProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public LuaPostfixTemplateProvider() {
4141
new LuaForIPostfixTemplate(),
4242
new LuaForPPostfixTemplate(),
4343
new LuaIfPostfixTemplate(),
44+
new LuaIfNotPostfixTemplate(),
4445
new LuaCheckNilPostfixTemplate(),
4546
new LuaCheckIfNotNilPostfixTemplate(),
4647
new LuaReturnPostfixTemplate(),
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2017. tangzx([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.tang.intellij.lua.codeInsight.postfix.templates
18+
19+
import com.intellij.codeInsight.template.postfix.templates.StringBasedPostfixTemplate
20+
import com.intellij.psi.PsiElement
21+
import com.tang.intellij.lua.codeInsight.postfix.LuaPostfixUtils.selectorTopmost
22+
23+
class LuaIfNotPostfixTemplate : StringBasedPostfixTemplate("if_not", "if not expr then end", selectorTopmost()) {
24+
override fun getTemplateString(psiElement: PsiElement): String? {
25+
return "if not \$expr$ then\n\$END$\nend"
26+
}
27+
28+
override fun getElementToRemove(expr: PsiElement): PsiElement {
29+
return expr
30+
}
31+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if not expr then
2+
3+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<spot>expr</spot>$key
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
~ Copyright (c) 2017. tangzx([email protected])
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<html>
18+
<body>
19+
if not expr then
20+
end
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)