Intellij不会识别antlr生成的源代码 [英] Intellij will not recognize antlr generated source code

查看:353
本文介绍了Intellij不会识别antlr生成的源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让Intellij识别antlr4生成的源代码。对生成的代码的任何引用都显示为错误,代码完成不起作用等。

I am having trouble getting Intellij to recognize the generated source code from antlr4. Any reference to the generated code appears as errors, code completion doesn't work, etc.

我正在使用maven和antlr4-maven-plugin来生成代码。
我的代码,引用生成的代码编译并在maven下构建良好。
生成的代码在/ target / generated-sources / antlr4下,这是Intellij所期望的。

I am using maven and the antlr4-maven-plugin to generate the code. My code, referencing the generated code compiles and builds fine under maven. The generated code is under /target/generated-sources/antlr4, which is what Intellij expects.

我尝试过通常的修复程序,例如reimport maven项目,更新文件夹,使缓存无效等。似乎没有任何效果。

I have tried the usual fixes such as reimport maven projects, update folders, invalidate cache, etc. None of it seems to work.

之前有人见过这个吗?
有没有办法直接在Intellij中指向生成的源?

Anyone seen this before? Is there a way to point to the generated sources directly within Intellij?

推荐答案

我有我认为可能有的一直是个类似的问题。我是IntelliJ的新手,所以我在某种程度上猜测。

I had what I think may have been a similar issue. I am new to IntelliJ, so I am guessing to some extent.

项目中的gen文件夹是棕色(即资源)还是蓝色(源代码)?

Is the gen folder in your project brown (i.e. a resource) or blue (source code)?

我无法让我的项目识别生成的代码,直到我设法将gen文件夹注册为包含源代码的文件夹。

I could not get my project to recognize generated code until I managed to get the gen folder registered as one containing source code.

很抱歉,你可能需要摆弄它 - 我不记得我是怎么做到的 - 但是在我改变它之后一切都很顺利。

Sorry to say you may need to fiddle with it - I cannot recall how I did it - but all was well after I changed this.

这篇关于Intellij不会识别antlr生成的源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆