Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ does not recognize generated sources

There are already many similar questions, but none of the proposed solutions (mainly "Clear caches and restart IntelliJ) solves my problem.

I have a maven project that I imported into IntelliJ Community Edition 2017.1 . My maven build automatically creates some java sources from Google protobuf specifications.

Excerpt from pom.xml

         <plugin>
            <groupId>com.github.os72</groupId>
            <artifactId>protoc-jar-maven-plugin</artifactId>
            <version>3.2.0</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <protocVersion>3.1.0</protocVersion> <!-- 2.4.1, 2.5.0, 2.6.1, 3.1.0 -->
                        <inputDirectories>
                            <include>src/main/protobuf</include>
                        </inputDirectories>
                        <outputDirectory>${project.build.directory}/generated-sources/protobuf</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

The folder /generated-sources/protobuf is correctly recognized as "generated-sources" with a blue icon and the wheel for generated sources under IntelliJ -> File -> Project Structure -> Modules -> Sources

The maven target "compile" also works fine.

But the IntelliJ "internal" java compiler complains "Cannot resolve symbol" for my generated class.

Solutions I tired so far

  1. add an intermediate folder /target/generated-sources/protobuf/ => did not help
  2. Invalidate caches, delete project file, reimport, restart IDE => did not help
  3. Maven -> Reimport all projects => did not help

Any more suggestions?

like image 225
Robert Avatar asked Apr 25 '17 14:04

Robert


2 Answers

In IntelliJ IDEA 2016 and newer you can change this setting in Help > Edit Custom Properties.

On older versions, there's no GUI to do it. But you can change it if you edit the IntelliJ IDEA Platform Properties file as described here: https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties

# Maximum file size (kilobytes) IDE should provide code assistance for.
idea.max.intellisense.filesize=50000

# Maximum file size (kilobytes) IDE is able to open.
idea.max.content.load.filesize=50000

Don't forget to save and restart IntelliJ IDEA.

like image 190
Johnny Avatar answered Oct 13 '22 12:10

Johnny


SOLUTION: The generated files were to large. Had to increase

idea.max.intellisense.filesize=2500

in IDE_HOME\bin\idea.properties as described here: File size exceeds configured limit (2560000), code insight features not available

like image 37
Robert Avatar answered Oct 13 '22 13:10

Robert