Adding support for creating sbt files#659
Conversation
|
My suspicion is that most of the users create |
|
I agree that it would be a more convenient UX. I created a similar feature request in IntelliJ some time ago: It would be nice to have a look if the existing API allows to have some predefined file names in the dropdown list when you select "Sbt file" template |
|
@Sa1to Please append |
Also some notes:
|
I think that it might be possible to create
Really good note, I agree |
|
@Sa1to for me this PR is not working :( |
|
|
||
| import javax.swing.Icon | ||
|
|
||
| abstract class NewPredefinedSbtFileAction(@NlsActions.ActionText title: String, @NlsActions.ActionDescription description: String, icon: Icon, fileName: String) extends CreateFromTemplateActionBase(title, description, icon) { |
|
|
||
| abstract class NewPredefinedSbtFileAction(@NlsActions.ActionText title: String, @NlsActions.ActionDescription description: String, icon: Icon, fileName: String) extends CreateFromTemplateActionBase(title, description, icon) { | ||
|
|
||
| override def getTemplate(project: Project, dir: PsiDirectory): FileTemplate = FileTemplateManager.getDefaultInstance.getInternalTemplate(ScalaBundle.message("newclassorfile.menu.action.sbt.text")) |
There was a problem hiding this comment.
FileTemplateManager.getDefaultInstance.getInternalTemplate(ScalaBundle.message("newclassorfile.menu.action.sbt.text")) should be in a new line. It is not readable in IDE
| override def getTargetDirectory(dataContext: DataContext, view: IdeView): PsiDirectory = { | ||
| val directories: Array[PsiDirectory] = view.getDirectories | ||
| directories.find(directory => directory.findFile(fileName + ".sbt") != null).exists(dir => { | ||
| Messages.showErrorDialog(CommonDataKeys.PROJECT.getData(dataContext), |
There was a problem hiding this comment.
each operation on directories should be in a new line
There was a problem hiding this comment.
exists takes a predicate as a parameter. What's your predicate here?
| Icons.SBT_FILE, | ||
| ScalaBundle.message("newclassorfile.menu.action.build.sbt.defaultName") | ||
| ) { | ||
| protected override def getAttributesDefaults(dataContext: DataContext): AttributesDefaults = new AttributesDefaults(ScalaBundle.message("newclassorfile.menu.action.build.sbt.defaultName")).withFixedName(true) |
There was a problem hiding this comment.
new AttributesDefaults(ScalaBundle.message("newclassorfile.menu.action.build.sbt.defaultName")).withFixedName(true) should be in a new line
| Icons.SBT_FILE | ||
| ) { | ||
|
|
||
| override def getTemplate(project: Project, dir: PsiDirectory): FileTemplate = FileTemplateManager.getDefaultInstance.getInternalTemplate(ScalaBundle.message("newclassorfile.menu.action.sbt.text")) |
There was a problem hiding this comment.
FileTemplateManager.getDefaultInstance.getInternalTemplate(ScalaBundle.message("newclassorfile.menu.action.sbt.text")) should be in a new line
| Icons.SBT_FILE, | ||
| ScalaBundle.message("newclassorfile.menu.action.plugin.sbt.defaultName") | ||
| ) { | ||
| protected override def getAttributesDefaults(dataContext: DataContext): AttributesDefaults = new AttributesDefaults(ScalaBundle.message("newclassorfile.menu.action.plugin.sbt.defaultName")).withFixedName(true) |
There was a problem hiding this comment.
the same comment about the new line as above
|
Do I understand that only cosmetic/formatting fixes are left and everything works? |
|
As I remember yes. |




It solves https://youtrack.jetbrains.com/issue/SCL-21374/Support-sbt-files-creation-via-File-New
Screen.Recording.2024-05-08.at.13.28.40.mov