diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 475c3c9a..a74a3372 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,11 @@
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index bec1c3df..63073009 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -6,7 +6,4 @@
-
-
-
\ No newline at end of file
diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml
index bdd6c23c..9c386088 100644
--- a/resources/META-INF/plugin.xml
+++ b/resources/META-INF/plugin.xml
@@ -1,7 +1,7 @@
de.endrullis.idea.postfixtemplates
Custom Postfix Templates
- 2.6.2.183
+ 2.6.3.183
Stefan Endrullis
code editing
@@ -13,20 +13,21 @@
This plugin lets you define your own postfix templates for Java, Scala, SQL, PHP, Kotlin, Python, Dart, JavaScript, Rust, and Groovy.
+ It also comes with hundreds of useful postfix templates shared by the community. You're welcome to contribute your templates as well.
- So what is the difference to IDEA's postfix templates?
+ Apart from the community approach, how does the plugin differ from IDEA's postfix templates?
- Since IDEA 2018 you are now able to define your own postfix templates in the settings UI (Editor → General → Postfix Templates ).
+ Since IDEA 2018 you are now able to define your own postfix templates for some languages in the settings UI (Editor → General → Postfix Templates ).
However, this is a pretty new feature and it's less functional than this plugin.
Here are some of the advantages of this plugin:
- You can define different template rules for the same template name, e.g. .toList
should behave differently for arrays and for sets.
- You can use template variables (e.g. $varName$
) which are filled by the user while applying the template.
+ You can define different template rules (context based) for the same template name, e.g. .toList
should behave differently for arrays and for sets.
+ You can use template variables (e.g. $varName$
) which are filled in by the user while applying the template.
You can use live template macros to automatically fill some of the template variables (e.g. $var:suggestVariableName()$
) as well as you can define default values.
You can restrict the availability of templates or template rules to the availability of certain classes or libraries (e.g. expand "test".val
to val s = "test"
if Lombok is available).
It allows you to use static imports instead of class imports (e.g. array.toList
can be expanded to asList(array)
instead of Arrays.asList(array)
if you add [USE_STATIC_IMPORTS]
to the rule).
@@ -38,13 +39,18 @@
file.getName().val → final String name = file.getName();
- The text based format for defining your templates allows you to easily share them via copy and paste.
+ There are multiple ways to easily share your templates with others .
]]>
Version 2.6.3
+
+ Underscores can be used in template names.
+
+
Version 2.6.2
Fixed bug #85: NoClassDefFoundError: com/intellij/psi/PsiType in PHPStorm and PyCharm.
diff --git a/src/de/endrullis/idea/postfixtemplates/language/Cpt.flex b/src/de/endrullis/idea/postfixtemplates/language/Cpt.flex
index 6d97009b..d30933f4 100644
--- a/src/de/endrullis/idea/postfixtemplates/language/Cpt.flex
+++ b/src/de/endrullis/idea/postfixtemplates/language/Cpt.flex
@@ -25,7 +25,7 @@ DOT=[.]
BRACKET_OPEN=\[
BRACKET_CLOSE=\]
MAP=("->"|"→")
-NAME_CHAR=[a-zA-Z0-9]
+NAME_CHAR=[a-zA-Z0-9_]
CLASS_NAME_CHAR=[a-zA-Z0-9._]
TEMPLATE_VARIABLE_START_CHAR=[$]
TEMPLATE_VARIABLE_CHAR=[^$\r\n\f\t\\:]
diff --git a/src/de/endrullis/idea/postfixtemplates/language/CptLexer.java b/src/de/endrullis/idea/postfixtemplates/language/CptLexer.java
index 310917e2..12922e99 100644
--- a/src/de/endrullis/idea/postfixtemplates/language/CptLexer.java
+++ b/src/de/endrullis/idea/postfixtemplates/language/CptLexer.java
@@ -3,9 +3,9 @@
package de.endrullis.idea.postfixtemplates.language;
import com.intellij.lexer.FlexLexer;
-import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import de.endrullis.idea.postfixtemplates.language.psi.CptTypes;
+import com.intellij.psi.TokenType;
/**
@@ -64,8 +64,8 @@ public static int ZZ_CMAP(int ch) {
/* The ZZ_CMAP_A table has 384 entries */
static final char ZZ_CMAP_A[] = zzUnpackCMap(
- "\11\0\1\4\1\2\1\1\1\5\1\3\22\0\1\6\2\0\1\7\1\21\10\0\1\14\1\11\1\0\12\17\1"+
- "\23\2\0\1\10\1\15\2\0\32\17\1\12\1\22\1\13\1\0\1\20\1\0\32\17\12\0\1\1\242"+
+ "\11\0\1\4\1\2\1\1\1\5\1\3\22\0\1\6\2\0\1\7\1\20\10\0\1\14\1\11\1\0\12\17\1"+
+ "\22\2\0\1\10\1\15\2\0\32\17\1\12\1\21\1\13\1\0\1\17\1\0\32\17\12\0\1\1\242"+
"\0\2\1\50\0\1\16\55\0");
/**
@@ -106,14 +106,14 @@ private static int zzUnpackAction(String packed, int offset, int [] result) {
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
- "\0\0\0\24\0\50\0\74\0\120\0\144\0\170\0\214"+
- "\0\240\0\264\0\310\0\334\0\360\0\u0104\0\334\0\u0118"+
- "\0\334\0\334\0\u012c\0\334\0\u0140\0\334\0\u0154\0\u0168"+
- "\0\u017c\0\u0190\0\u01a4\0\u01b8\0\u01cc\0\u01e0\0\334\0\u01f4"+
- "\0\u0208\0\u021c\0\u0230\0\u0244\0\u0258\0\334\0\334\0\334"+
- "\0\u026c\0\u0280\0\334\0\334\0\u0294\0\u02a8\0\u02bc\0\u02d0"+
- "\0\u02e4\0\334\0\u02f8\0\u030c\0\u0320\0\u0118\0\u0168\0\u0334"+
- "\0\u01b8";
+ "\0\0\0\23\0\46\0\71\0\114\0\137\0\162\0\205"+
+ "\0\230\0\253\0\276\0\321\0\344\0\367\0\321\0\u010a"+
+ "\0\321\0\321\0\u011d\0\321\0\u0130\0\321\0\u0143\0\u0156"+
+ "\0\u0169\0\u017c\0\u018f\0\u01a2\0\u01b5\0\u01c8\0\321\0\u01db"+
+ "\0\u01ee\0\u0201\0\u0214\0\u0227\0\u023a\0\321\0\321\0\321"+
+ "\0\u024d\0\u0260\0\321\0\321\0\u0273\0\u0286\0\u0299\0\u02ac"+
+ "\0\u02bf\0\321\0\u02d2\0\u02e5\0\u02f8\0\u010a\0\u0156\0\u030b"+
+ "\0\u01a2";
private static int [] zzUnpackRowMap() {
int [] result = new int[57];
@@ -140,40 +140,40 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
private static final String ZZ_TRANS_PACKED_0 =
"\1\14\6\15\1\16\1\17\1\20\1\21\1\22\1\23"+
- "\1\14\1\24\2\25\1\26\1\14\1\17\1\27\1\30"+
- "\1\15\1\30\1\31\1\15\1\32\15\27\1\33\1\34"+
- "\1\15\1\34\1\35\1\15\1\36\12\33\1\26\1\37"+
- "\2\33\1\34\1\15\1\34\1\40\1\15\1\40\12\33"+
- "\1\26\1\37\1\33\1\41\2\42\1\43\3\42\15\41"+
- "\1\44\1\45\4\15\1\45\12\44\1\46\3\14\6\15"+
- "\12\14\1\47\1\14\1\50\1\51\1\52\4\15\1\52"+
- "\12\51\1\47\1\53\1\54\1\55\2\56\1\57\3\56"+
- "\15\55\1\60\1\61\4\15\1\61\12\60\1\47\1\62"+
- "\1\54\1\63\2\64\1\65\3\64\15\63\25\0\6\15"+
- "\15\0\2\16\2\0\20\16\11\0\1\25\5\0\1\66"+
- "\1\25\20\0\1\24\17\0\1\25\5\0\2\25\3\0"+
- "\2\27\1\0\2\27\1\0\17\27\1\67\1\15\2\67"+
- "\1\15\1\67\16\27\1\70\1\15\1\70\1\31\1\15"+
- "\1\31\15\27\1\0\3\15\1\32\1\15\1\32\15\0"+
- "\2\33\1\0\2\33\1\0\13\33\2\0\2\33\1\71"+
- "\1\15\2\71\1\15\1\71\12\33\2\0\2\33\1\40"+
- "\1\15\1\40\1\35\1\15\1\35\12\33\2\0\1\33"+
- "\1\0\3\15\1\36\1\15\1\36\15\0\1\33\1\40"+
- "\1\15\2\40\1\15\1\40\12\33\2\0\1\33\4\0"+
- "\1\41\1\0\1\41\16\0\3\15\1\42\1\15\1\42"+
- "\16\0\1\15\1\42\1\15\1\42\1\15\1\42\15\0"+
- "\2\44\4\0\13\44\3\0\1\44\1\45\4\15\1\45"+
- "\12\44\3\0\2\51\4\0\13\51\3\0\1\51\1\52"+
- "\4\15\1\52\12\51\7\0\1\55\1\0\1\55\16\0"+
- "\3\15\1\56\1\15\1\56\16\0\1\15\1\56\1\15"+
- "\1\56\1\15\1\56\15\0\2\60\4\0\13\60\3\0"+
- "\1\60\1\61\4\15\1\61\12\60\7\0\1\63\1\0"+
- "\1\63\16\0\3\15\1\64\1\15\1\64\16\0\1\15"+
- "\1\64\1\15\1\64\1\15\1\64\15\0\1\27\1\70"+
- "\1\15\2\70\1\15\1\70\15\27";
+ "\1\14\1\24\1\25\1\26\1\14\1\17\1\27\1\30"+
+ "\1\15\1\30\1\31\1\15\1\32\14\27\1\33\1\34"+
+ "\1\15\1\34\1\35\1\15\1\36\11\33\1\26\1\37"+
+ "\2\33\1\34\1\15\1\34\1\40\1\15\1\40\11\33"+
+ "\1\26\1\37\1\33\1\41\2\42\1\43\3\42\14\41"+
+ "\1\44\1\45\4\15\1\45\11\44\1\46\3\14\6\15"+
+ "\11\14\1\47\1\14\1\50\1\51\1\52\4\15\1\52"+
+ "\11\51\1\47\1\53\1\54\1\55\2\56\1\57\3\56"+
+ "\14\55\1\60\1\61\4\15\1\61\11\60\1\47\1\62"+
+ "\1\54\1\63\2\64\1\65\3\64\14\63\24\0\6\15"+
+ "\14\0\2\16\2\0\17\16\11\0\1\25\5\0\1\66"+
+ "\20\0\1\24\16\0\1\25\5\0\1\25\3\0\2\27"+
+ "\1\0\2\27\1\0\16\27\1\67\1\15\2\67\1\15"+
+ "\1\67\15\27\1\70\1\15\1\70\1\31\1\15\1\31"+
+ "\14\27\1\0\3\15\1\32\1\15\1\32\14\0\2\33"+
+ "\1\0\2\33\1\0\12\33\2\0\2\33\1\71\1\15"+
+ "\2\71\1\15\1\71\11\33\2\0\2\33\1\40\1\15"+
+ "\1\40\1\35\1\15\1\35\11\33\2\0\1\33\1\0"+
+ "\3\15\1\36\1\15\1\36\14\0\1\33\1\40\1\15"+
+ "\2\40\1\15\1\40\11\33\2\0\1\33\4\0\1\41"+
+ "\1\0\1\41\15\0\3\15\1\42\1\15\1\42\15\0"+
+ "\1\15\1\42\1\15\1\42\1\15\1\42\14\0\2\44"+
+ "\4\0\12\44\3\0\1\44\1\45\4\15\1\45\11\44"+
+ "\3\0\2\51\4\0\12\51\3\0\1\51\1\52\4\15"+
+ "\1\52\11\51\7\0\1\55\1\0\1\55\15\0\3\15"+
+ "\1\56\1\15\1\56\15\0\1\15\1\56\1\15\1\56"+
+ "\1\15\1\56\14\0\2\60\4\0\12\60\3\0\1\60"+
+ "\1\61\4\15\1\61\11\60\7\0\1\63\1\0\1\63"+
+ "\15\0\3\15\1\64\1\15\1\64\15\0\1\15\1\64"+
+ "\1\15\1\64\1\15\1\64\14\0\1\27\1\70\1\15"+
+ "\2\70\1\15\1\70\14\27";
private static int [] zzUnpackTrans() {
- int [] result = new int[840];
+ int [] result = new int[798];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
diff --git a/src/de/endrullis/idea/postfixtemplates/language/CptUtil.java b/src/de/endrullis/idea/postfixtemplates/language/CptUtil.java
index a273b8e9..2f5dd0ee 100644
--- a/src/de/endrullis/idea/postfixtemplates/language/CptUtil.java
+++ b/src/de/endrullis/idea/postfixtemplates/language/CptUtil.java
@@ -123,7 +123,12 @@ public static List findMappings(Project project) {
*/
public static String getDefaultTemplates(String language) {
InputStream stream = CptUtil.class.getResourceAsStream("defaulttemplates/" + language + ".postfixTemplates");
- return getContent(stream);
+ try {
+ return getContent(stream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "";
+ }
}
/**
@@ -134,7 +139,12 @@ public static String getDefaultTemplates(String language) {
* @throws FileNotFoundException
*/
public static String getContent(@NotNull File file) throws FileNotFoundException {
- return getContent(new FileInputStream(file));
+ try {
+ return getContent(new FileInputStream(file));
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "";
+ }
}
/**
@@ -143,7 +153,7 @@ public static String getContent(@NotNull File file) throws FileNotFoundException
* @param stream input stream
* @return content of the given input stream
*/
- private static String getContent(@NotNull InputStream stream) {
+ private static String getContent(@NotNull InputStream stream) throws IOException {
StringBuilder sb = new StringBuilder();
// convert system newlines into UNIX newlines, because IDEA works only with UNIX newlines
@@ -154,11 +164,7 @@ private static String getContent(@NotNull InputStream stream) {
}
return sb.toString();
- } catch (IOException e) {
- e.printStackTrace();
}
-
- return "";
}
/**