IntelliJ在键入期间进行编译时会将.class文件放在哪里 [英] Where does IntelliJ put .class files when it compiles during typing

查看:456
本文介绍了IntelliJ在键入期间进行编译时会将.class文件放在哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于出现错误时IntelliJ用红色的蠕变线告诉我,因此IntelliJ一直在编译吗? (除了自动完成功能之外)还是在进行某种伪编译?

Is IntelliJ compiling all the time since it tells me with red squiggly lines when there is an error? (in addition to the autocomplete features) Or is it doing some sort of psuedo compiling?

如果正在进行合法的编译,那么将这些编译后的类放在哪里?我想将我的JRebel指向该目录,而不是单个模块目标文件夹.

If it is doing legit compiling, where does it put these compiled classes? I'de like to point my JRebel to that directory instead of the individual module target folders.

推荐答案

Meo是正确的,从我为自定义语言开发插件时所学到的知识,IntelliJ不会编译任何内容,除非您明确创建项目.在键入时,其词法分析器/解析器会检测到任何无效的标记或代码构造.同时,它维护项目中每个类和方法及其依赖项以及它们的签名等的索引.

Meo is right, from what I learned when I developed plugins for custom languages, IntelliJ does not compile anything until you explicitly make your project. While you are typing, its lexer/parser detects any invalid token or code construct. In the meantime, it maintains an index of every class and method in your project and its dependencies, along with their signature, etc.

停止键入后,您将在右侧装订线的顶部看到彩色的眼睛.它指示IDE正在运行注释器"和代码检查".他们能够根据当前索引和文件的当前状态(导入,声明等)判断类,方法和变量是否有效.未使用的变量,方法调用中的无效参数等也是如此.

After you stop typing, you'll see a little colored eye in the top part of the right gutter. It indicates that the IDE is running "annotators" and "code inspections". They are able to tell whether or not classes, methods and variable are valid based on the current index and the current state of your file (imports, declarations, etc.). The same goes for unused variables, invalid parameters in method calls, etc.

优点:

  • 注释者直接在他们所谓的PSI树上工作,这基本上是代表您当前文件的增强型AST
  • 每次编译可能会更快(它使用索引并且不需要重新编译每个依赖类)
  • 注释者可以检测到javac无关的东西,例如潜在的错误(例如在while条件下使用=代替==)
  • annotators work directly on what they call a PSI tree, which is basically an enhanced AST representing your current file
  • it may be faster that compiling every time (it uses an index and does not need to recompile every dependent class)
  • annotators can detect things javac don't care about, such as potential bugs (e.g. using = instead of == in a while condition)

缺点:

  • 这是一项工作,基本上,他们需要重写逻辑以查找javac可能产生的每个错误(这就是为什么您可以在其Bugtracker上找到许多问题的原因,该问题标记为"
  • that's a loooot of work, basically they need to rewrite the logic to find every error that javac can produce (which is why you can find many issues on their bugtracker labelled "good code is red" or "bad code is green", meaning there is a difference between what they detect and what the compiler would output)

TL; DR:在创建项目之前,它不会产生任何.class,所有操作都是手动"完成的

TL;DR: it does not produce any .class until you make your project, everything is done "by hand"

这篇关于IntelliJ在键入期间进行编译时会将.class文件放在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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