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秒。