一句话:提出基于示例编程合成树自动机的框架,精准抑制 IDE 代码检查中的误报。
IDE 的代码检查通过数据流分析提醒不良或错误代码,但可能在不相关处产生误报。现有避免误报的方法要么过于保守,在整个代码库中抑制同类警告;要么不可持续,需要不断为数据流分析添加启发式规则。本文提出一个基于示例的编程(PBE)框架,根据用户提供的示例合成树自动机(TA),用于在包含相同模式的代码中抑制误报。原型实验表明,生产级 IDE 中若干被启发式抑制的真实模式,可以被系统性地机械转换为 TA。文章还简要讨论基于 TA 的方案在其他 IDE 功能(如代码重构)中的潜在用途。
Integrated development environments (IDEs) are equipped with code inspections to warn developers of malformed or incorrect code by analyzing the code's data flow. However, the data flow analysis performed by the IDE code inspections may issue warnings in code where warnings are irrelevant. Existing methods to prevent any bogus warnings are either too conservative --- suppressing the same type of warnings in the entire codebase --- or are not sustainable as they require adding a set of heuristics to the data flow analysis. We propose a programming-by-example (PBE) framework that synthesizes tree automata (TAs) to suppress bogus warnings in all the code containing the same patterns as the user-provided examples. Experiments with a prototype of the framework demonstrate that several real-world patterns heuristically suppressed in production IDE can be mechanically translated to a TA in a systematic way. Furthermore, we briefly discuss how TA-based solution can be useful in other IDE features such as code refactoring.