简体   繁体   中英

IntelliJ IDEA - How to enable code completion / debugging for Java files in non-java project

Often I will have a big repo full of various bits and pieces (some bash, php, config dumps etc). It is often convenient to be able to open as a single project from the root of the repo.

However when a Java file is thrown into the mix IntelliJ doesn't seem to accept that it is Java and will not have all the helpful debugging / package import magic.

How can I force this to be enabled?

(Taking the java file out, putting it in a Project/src directory and then opening that Project directory as a project will make things work fine - but this is annoying for simple scratch files).

In case it makes any difference I am running:

IntelliJ IDEA 2020.1.1 (Ultimate Edition)
Build #IU-201.7223.91, built on April 30, 2020
Licensed to Ingmar Boddington
Subscription is active until December 2, 2020
Runtime version: 11.0.6+8-b765.40 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.4
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8
Non-Bundled Plugins: io.gulp.intellij, com.jetbrains.php

Configure a new Java module with the source roots set to the folders with your Java files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM