1

How can I have IntelliJ generate more complex code, e.g. a companion object for a class I already programmed?

I searched in "File -> Settings -> Editor -> File and Code Templates -> Code" but did not find anything Scala related.

"Code -> Generate..." only gives me

enter image description here

Make42
  • 12,236
  • 24
  • 79
  • 155
  • Can you give us an idea of what it is you are trying to generate? Is it just the shell, e.g. `object WhateverCompanion {}` or are you actually looking for it to generate some particular functionality? – Idan Waisman Oct 09 '16 at 15:35
  • @IdanWaisman: Honestly I just thought `object WhateverCompanion {}`. But stuff like that makes it easier for me (beginner) to program, because I don't have to look up what the requirements for a companion object are. Also some other stuff would be nice like: "Make me a Cake Pattern" and stuff like that. – Make42 Oct 09 '16 at 16:22
  • You can take a look at Editor > Live Templates, though I don't know if you can get it to pick the right object name. For the record, there aren't any requirements for companion objects though I would read up about case classes and how they automatically generate code (during compilation) in companion objects. – Idan Waisman Oct 09 '16 at 16:44
  • @IdanWaisman: http://fruzenshtein.com/scala-case-class-companion-object/ suggests that it is that the companion object get an `apply` method that is a factory for the `case class`. I couldn't find anything else. Is there anything else? This: http://stackoverflow.com/questions/5827510/how-to-override-apply-in-a-case-class-companion ? – Make42 Oct 09 '16 at 17:11

0 Answers0