神刀安全网

Auto-complete from Stack Overflow

Autocomplete from Stack Overflow

byEmil Schutte ( LinkedIn , jsreports )

Tired of writing code? Me too! Let’s have Stack Overflow do it.

// Boss wants this function done by tomorrow :( function contains(needle, haystack) {   var

(Try typing a space)

How it works

I grabbed a Stack Overflow data dump from https://archive.org/details/stackexchange and scraped out any code snippets from

  • accepted answers
  • with more than 50 points
  • on posts tagged "javascript"

Then I processed it by walking the ASTs of those snippets and creating a "completion" fragment for each node, pairing a trace of the left-hand context with the code snippet for the right-hand side.

To complete at run time, it uses the same logic to find the left-hand trace at the current cursor position, and tries to match that up against the database of completion fragments. Available completions are sorted by a proprietary blend of post score, left-hand context similarity, and nearby identifiers.

Thanks to

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Auto-complete from Stack Overflow

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮