Intellij not Detecting Any Problem with Scala Code
已回答
Trying to learn Scala with intellij community edition on Ubuntu. I have set up intellij 2022.3.2 with the scala plugin. Can build and run codes from my terminal, yet, intellij seems unable to point out basic errors in the code, like look at the attached code (note the class name, an error I introduced deliberately).
class Pearson {
var age: Int = 0
var name: String = ""
def print_person(): Unit = {
println("The name is " + name + " and age is " + age)
}
}
object PersonTest extends App {
val someperson: Person =
new Person() // new keyword is necessary only in scala 3
someperson.print_person()
someperson.age = 21
someperson.name = "John"
someperson.print_person()
}
Yet, according to intellij, there is no problem with the code, as the problem tab is empty. 
Can I expect such functionality from intellij (like what I get in pycharm)? What other plugin I need to install apart from the scala plugin?
Also, usually stuffs like autocomplete of variable names etc. seem to be missing from my installation too.
请先登录再写评论。
Could you please share your logs and diagnostic data: Help > Collect Logs and Diagnostic Data for further troubleshooting?
Also, if possible share your project to check its configuration. You can zip your project folder and diagnostic data and upload here. Just provide us with the upload ID. Thanks!
Ivan Pajic
Upload id: 2023_02_20_uZLna73FR2fuYyYGDR5vup (files: idea-logs-20230220-18544212675270524827179501.zip, scala_testing.tar.gz)
It seems your project doesn't have a sources root directory configured.
It is needed for IntelliJ to identify which directories to compile, scan for code highlight, auto-completion, etc. You can create a new directory (e.g. scala_testing/src) in your project root and set it as sources root:
Project Structure (`Ctrl+Alt+Shift+S`)> Project Settings > Modules > select scala_testing module > select the new (e.g. src) folder > click on 'Mark directory as sources root' button > OK
Then move the hello_world.scala file to the sources (src) folder.
Thanks a lot for getting back. Being a noob in Scala, I am not really aware of the best practices around directory structure and IDE specific settings. Can you point me to any tutorial around these topics (specific to the Scala language)?
Please check the following resources: