This paper presents Squid, a new conjunctive query synthesis algorithm for searching code with target patterns. Given positive and negative examples along with a natural language description, Squid analyzes the relations derived from the examples by a Datalog-based program analyzer and synthesizes a conjunctive query expressing the search intent. The synthesized query can be further used to search for desired grammatical constructs in the editor. To achieve high efficiency, we prune the huge search space by removing unnecessary relations and enumerating query candidates via refinement. We also introduce two quantitative metrics for query prioritization to select the queries from multiple candidates, yielding desired queries for code search. We have evaluated Squid on over thirty code search tasks. It is shown that Squid successfully synthesizes the conjunctive queries for all the tasks, taking only 2.56 seconds on average.
翻译:本文提出Squid,一种面向目标模式代码搜索的新型合取查询合成算法。给定正负样本以及自然语言描述,Squid通过基于Datalog的程序分析器分析从样本中导出的关系,并合成表达搜索意图的合取查询。该合成查询可进一步用于在编辑器中搜索所需的语法结构。为实现高效性,我们通过移除无关关系以及通过细化枚举候选查询来修剪庞大的搜索空间。同时引入两种用于查询优先级的量化指标,从多个候选中筛选出符合代码搜索需求的目标查询。我们在三十余项代码搜索任务上评估了Squid。结果表明,Squid成功为所有任务合成了合取查询,平均仅耗时2.56秒。