18

We have a build.xml in our project, but IntelliJ is unable to import from it. I get a:

Cannot import anything from <path_to>/build.xml file.

On Eclipse I can do a:

File -> Import -> General -> Existing Projects into workspace.

and chose top-level folder. I did the same in IJ. The project imported and indexed fine, I can do a search for any class. However, it does not recognize protobuf compiled class files. I installed the proto plugin, so it syntax highlights my .proto files, but still doesn't realize that there's a compiled class output that it needs to refer to. Do I need to do something special to get it to recognize those files?

Chris Bolton
  • 2,162
  • 4
  • 36
  • 75
Siddhartha
  • 4,296
  • 6
  • 44
  • 65

2 Answers2

39

since this is pretty much the only place I could find an exact description for the issue I was facing with Idea, I'm replying even if it's an old question.

It turns out that if the .java file that's generated by the protocol buffers compiler is larger than 2.5MB (default setting), Idea ignores it altogether. Even if there is a .class file, even if compile/make succeed, even if you build your project just fine with Maven.

To fix that, simply edit your idea.properties file (it's inside the bin folder in your Idea installation folder), and either comment out this setting, or set it to something larger than your generated .java file (in my case, I set it to 15000, as my generated file is currently about 8MB in size):

#---------------------------------------------------------------------
# Maximum file size (kilobytes) IDE should provide code assistance for.
# The larger file is the slower its editor works and higher overall system memory requirements are
# if code assistance is enabled. Remove this property or set to very large number if you need
# code assistance for any files available regardless their size.
#---------------------------------------------------------------------
idea.max.intellisense.filesize=2500

Note: at least on Linux, where the default update policy seems to be "overwrite the old Idea folder with what you just downloaded", this change must be applied after every update/upgrade.

michele b
  • 1,825
  • 2
  • 20
  • 26
  • Also works for me, but I still find that documentation confusing. I don't *want* to open the file in the editor and also don't want code assistance for it. Quite the contrary I want to avoid code assistance if I happen to open the file accidentely in idea, in order not to crash/block it. Isn't there any way to configure the limit for compilation independent of the limit for code assistance in the editor? – David Ongaro Oct 21 '16 at 01:12
  • 5
    spent hours trying to figure this out, thank you so much! – Kevin Zhao Oct 31 '17 at 21:56
3

An extension to Michele's answer,

You can do this directly from your IntelliJ.

In macOS, when Intellij is unable to recognize proto compiled Java class files,

From the Help menu ---> select Edit Custom Properties. It might ask you to create idea.properties file under

$HOME//Library/Application\ Support/JetBrains/IdeaIC2020.1/

create property idea.max.intellisense.filesize=2500 and set the value to accommodate your big fat proto compiled file for IntelliJ to recognize.

Prakash Palnati
  • 3,231
  • 22
  • 35