Added file templates for new class/trait/enum.
#KT-1010 fixed
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};
|
||||||
|
|
||||||
|
#end
|
||||||
|
#parse("File Header.java")
|
||||||
|
public class ${NAME} {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse">
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<font face="verdana" size="-1">
|
||||||
|
This is a built-in template used by <b>IDEA</b> each time you create a
|
||||||
|
Kotlin class
|
||||||
|
</font>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};
|
||||||
|
|
||||||
|
#end
|
||||||
|
#parse("File Header.java")
|
||||||
|
public enum class ${NAME} {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse">
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<font face="verdana" size="-1">
|
||||||
|
This is a built-in template used by <b>IDEA</b> each time you create a
|
||||||
|
Kotlin enum class
|
||||||
|
</font>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};
|
||||||
|
|
||||||
|
#end
|
||||||
|
#parse("File Header.java")
|
||||||
|
public trait ${NAME} {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse">
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<font face="verdana" size="-1">
|
||||||
|
This is a built-in template used by <b>IDEA</b> each time you create a
|
||||||
|
Kotlin trait
|
||||||
|
</font>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -49,6 +49,9 @@
|
|||||||
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
|
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
|
||||||
|
|
||||||
<internalFileTemplate name="Kotlin File"/>
|
<internalFileTemplate name="Kotlin File"/>
|
||||||
|
<internalFileTemplate name="Kotlin Class"/>
|
||||||
|
<internalFileTemplate name="Kotlin Enum"/>
|
||||||
|
<internalFileTemplate name="Kotlin Trait"/>
|
||||||
|
|
||||||
<fileTypeFactory implementation="org.jetbrains.jet.plugin.JetFileFactory"/>
|
<fileTypeFactory implementation="org.jetbrains.jet.plugin.JetFileFactory"/>
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ replace.with.dot.call=Replace with dot call
|
|||||||
replace.with.safe.call=Replace with safe call
|
replace.with.safe.call=Replace with safe call
|
||||||
change.to.backing.field=Change reference to backing field
|
change.to.backing.field=Change reference to backing field
|
||||||
implement.members=Implement members
|
implement.members=Implement members
|
||||||
|
new.kotlin.file.action=Kotlin File
|
||||||
|
|
||||||
livetemplate.description.main=main() function
|
livetemplate.description.main=main() function
|
||||||
livetemplate.description.soutp=Prints function parameter names and values to System.out
|
livetemplate.description.soutp=Prints function parameter names and values to System.out
|
||||||
|
|||||||
@@ -16,23 +16,44 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.plugin.actions;
|
package org.jetbrains.jet.plugin.actions;
|
||||||
|
|
||||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
import com.intellij.ide.actions.CreateFileFromTemplateAction;
|
||||||
import com.intellij.ide.fileTemplates.actions.CreateFromTemplateAction;
|
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
import com.intellij.openapi.project.Project;
|
||||||
import org.jetbrains.jet.plugin.JetIconProvider;
|
import com.intellij.psi.PsiDirectory;
|
||||||
|
import com.intellij.util.PlatformIcons;
|
||||||
|
import org.jetbrains.jet.plugin.JetBundle;
|
||||||
|
import org.jetbrains.jet.plugin.JetFileType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nikolay Krasko
|
* @author Nikolay Krasko
|
||||||
*/
|
*/
|
||||||
public class NewKotlinFileAction extends CreateFromTemplateAction {
|
public class NewKotlinFileAction extends CreateFileFromTemplateAction {
|
||||||
|
|
||||||
public NewKotlinFileAction() {
|
public NewKotlinFileAction() {
|
||||||
super(FileTemplateManager.getInstance().getInternalTemplate("Kotlin File"));
|
super(JetBundle.message("new.kotlin.file.action"), "Creates new Kotlin file", JetFileType.INSTANCE.getIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(AnActionEvent e) {
|
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
|
||||||
super.update(e);
|
builder
|
||||||
e.getPresentation().setIcon(JetIconProvider.KOTLIN_ICON);
|
.setTitle(JetBundle.message("new.kotlin.file.action"))
|
||||||
|
.addKind("Class", PlatformIcons.CLASS_ICON, "Kotlin Class")
|
||||||
|
.addKind("Trait", PlatformIcons.INTERFACE_ICON, "Kotlin Trait")
|
||||||
|
.addKind("Enum class", PlatformIcons.ENUM_ICON, "Kotlin Enum")
|
||||||
|
.addKind("Kotlin file", JetFileType.INSTANCE.getIcon(), "Kotlin File");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getActionName(PsiDirectory directory, String newName, String templateName) {
|
||||||
|
return JetBundle.message("new.kotlin.file.action");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return obj instanceof NewKotlinFileAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<caret>
|
||||||
Reference in New Issue
Block a user