// ĠCopyright Ġ 2 0 0 0 - 2 0 2 0 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġcom . intellij . file Prediction . features . history Ċ Ċ import Ġcom . intellij . openapi . application . Application Manager Ċ import Ġcom . intellij . openapi . components . service Ċ import Ġcom . intellij . openapi . components . service If Created Ċ import Ġcom . intellij . openapi . project . Project Ċ Ċ class ĠFile Prediction History ( project : ĠProject ) Ġ{ ĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġprivate Ġconst Ġval ĠMAX _ N GRAM _ SEQUENCE Ġ= Ġ 3 ĊĊĠĠĠ Ġinternal Ġfun ĠgetInstance If Created ( project : ĠProject ) Ġ= Ġproject . service If Created < File Prediction History >() ĊĊĠĠĠ Ġfun ĠgetInstance ( project : ĠProject ) Ġ= Ġproject . service < File Prediction History >() ĊĠ Ġ} ĊĊĠ Ġprivate Ġvar Ġmanager : ĠFile History Manager Ġ= ĠFile History Manager ( File History Persistence . load N Gr ams ( project , ĠMAX _ N GRAM _ SEQUENCE )) ĊĊĠ Ġinit Ġ{ ĊĠĠĠ ĠFile History Persistence . delete Legacy File ( project ) ĊĠ Ġ} ĊĊĠ Ġfun Ġsave File Prediction History ( project : ĠProject ) Ġ{ ĊĠĠĠ ĠApplication Manager . getApplication (). execute On P ooled Thread Ġ{ ĊĠĠĠĠĠ Ġmanager . save File History ( project ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġfun Ġon File Selected ( file Url : ĠString ) Ġ= Ġmanager . on File Opened ( file Url ) ĊĊĠ Ġfun Ġbatch Calculate N Gr ams ( candidates : ĠList < String >) Ġ= Ġmanager . calc NG ram Features ( candidates ) Ċ }