From b1ca3b2b6c3fcbb0b23e3414731c0f749582154f Mon Sep 17 00:00:00 2001 From: spawlak Date: Thu, 11 Apr 2024 16:48:00 +0200 Subject: [PATCH] Adding support for creating sbt files #SCL-21374 --- .../resources/META-INF/scala-plugin-common.xml | 4 ++++ .../fileTemplates/internal/Sbt File.sbt.ft | 0 .../fileTemplates/internal/Sbt File.sbt.html | 14 ++++++++++++++ .../resources/messages/ScalaBundle.properties | 3 +++ .../scala/actions/NewSbtFileAction.scala | 18 ++++++++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 scala/scala-impl/resources/fileTemplates/internal/Sbt File.sbt.ft create mode 100644 scala/scala-impl/resources/fileTemplates/internal/Sbt File.sbt.html create mode 100644 scala/scala-impl/src/org/jetbrains/plugins/scala/actions/NewSbtFileAction.scala diff --git a/scala/scala-impl/resources/META-INF/scala-plugin-common.xml b/scala/scala-impl/resources/META-INF/scala-plugin-common.xml index a771e85916d..aec23f45797 100644 --- a/scala/scala-impl/resources/META-INF/scala-plugin-common.xml +++ b/scala/scala-impl/resources/META-INF/scala-plugin-common.xml @@ -311,6 +311,7 @@ + @@ -1982,6 +1983,9 @@ class="org.jetbrains.plugins.scala.components.TypeAwareWidgetFactory$Listener"/> + + + diff --git a/scala/scala-impl/resources/fileTemplates/internal/Sbt File.sbt.ft b/scala/scala-impl/resources/fileTemplates/internal/Sbt File.sbt.ft new file mode 100644 index 00000000000..e69de29bb2d diff --git a/scala/scala-impl/resources/fileTemplates/internal/Sbt File.sbt.html b/scala/scala-impl/resources/fileTemplates/internal/Sbt File.sbt.html new file mode 100644 index 00000000000..8abada1f17e --- /dev/null +++ b/scala/scala-impl/resources/fileTemplates/internal/Sbt File.sbt.html @@ -0,0 +1,14 @@ + + + + + + +
+ + This is a built-in template used by IntelliJ IDEA each time you create a + Sbt File + +
+ + diff --git a/scala/scala-impl/resources/messages/ScalaBundle.properties b/scala/scala-impl/resources/messages/ScalaBundle.properties index 06ca1194fea..224a7e1a428 100644 --- a/scala/scala-impl/resources/messages/ScalaBundle.properties +++ b/scala/scala-impl/resources/messages/ScalaBundle.properties @@ -40,6 +40,9 @@ newclassorfile.menu.action.description=Creates new Scala Class or File create.new.scala.class.or.file=Create New Scala Class/File this.is.not.a.valid.scala.qualified.name=This is not a valid Scala qualified name +newclassorfile.menu.action.sbt.text=Sbt File +newclassorfile.menu.action.sbt.description=Create new Sbt File + ### org/jetbrains/plugins/scala/actions/ShowTypeInfoAction.scala type.info.text=Type Info type.info.description=Show Type Info diff --git a/scala/scala-impl/src/org/jetbrains/plugins/scala/actions/NewSbtFileAction.scala b/scala/scala-impl/src/org/jetbrains/plugins/scala/actions/NewSbtFileAction.scala new file mode 100644 index 00000000000..37b3cb20f85 --- /dev/null +++ b/scala/scala-impl/src/org/jetbrains/plugins/scala/actions/NewSbtFileAction.scala @@ -0,0 +1,18 @@ +package org.jetbrains.plugins.scala.actions + +import com.intellij.ide.fileTemplates.actions.CreateFromTemplateActionBase +import com.intellij.ide.fileTemplates.{FileTemplate, FileTemplateManager} +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiDirectory +import org.jetbrains.sbt.icons.Icons +import org.jetbrains.plugins.scala.ScalaBundle + +final class NewSbtFileAction extends CreateFromTemplateActionBase( + ScalaBundle.message("newclassorfile.menu.action.sbt.text"), + ScalaBundle.message("newclassorfile.menu.action.sbt.description"), + Icons.SBT_FILE +) { + + override def getTemplate(project: Project, dir: PsiDirectory): FileTemplate = FileTemplateManager.getDefaultInstance.getInternalTemplate("Sbt File") + +}