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

查看:30
本文介绍了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.

我已经尝试了常用的修复方法,例如重新导入 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天全站免登陆