-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for creating sbt files #659
base: idea241.x
Are you sure you want to change the base?
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 |
scala/scala-impl/src/org/jetbrains/plugins/scala/actions/NewSbtPluginFileAction.scala
Outdated
Show resolved
Hide resolved
@Sa1to for me this PR is not working :( |
scala/scala-impl/src/org/jetbrains/plugins/scala/actions/NewSbtBuildFileAction.scala
Outdated
Show resolved
Hide resolved
scala/scala-impl/src/org/jetbrains/plugins/scala/actions/NewSbtBuildFileAction.scala
Outdated
Show resolved
Hide resolved
|
||
import javax.swing.Icon | ||
|
||
abstract class NewPredefinedSbtFileAction(@NlsActions.ActionText title: String, @NlsActions.ActionDescription description: String, icon: Icon, fileName: String) extends CreateFromTemplateActionBase(title, description, icon) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each operation on directories
should be in a new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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