// ĠCopyright Ġ 2 0 0 0 - 2 0 1 8 Ġ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 Ġorg . editor config . language . code insight . completion . providers Ċ Ċ import Ġcom . intellij . code Insight . completion . Completion Parameters Ċ import Ġcom . intellij . code Insight . completion . Completion ResultSet Ċ import Ġcom . intellij . code Insight . completion . Completion Util Core . D UMMY _ IDENTIFIER _ TRIM MED Ċ import Ġcom . intellij . patterns . Platform Patterns . psi Element Ċ import Ġcom . intellij . patterns . Psi Element Pattern Ċ import Ġcom . intellij . psi . Psi Element Ċ import Ġcom . intellij . util . Processing Context Ċ import Ġorg . editor config . language . code insight . completion . providers . Editor Config Completion Provider Util . create Lookup And Check De precation Ċ import Ġorg . editor config . language . code insight . completion . with Separator In Ċ import Ġorg . editor config . language . psi . Editor Config Element Types Ċ import Ġorg . editor config . language . psi . Editor Config Option Ċ import Ġorg . editor config . language . psi . Editor Config Section Ċ import Ġorg . editor config . language . services . Editor Config Option Descriptor Manager Ċ import Ġorg . editor config . language . util . Editor Config Psi Tree Util . getParent OfType Ċ Ċ object ĠEditor Config Simple Option Key Completion Provider Ġ: ĠEditor Config Completion Provider Base () Ġ{ ĊĠ Ġoverride Ġval Ġdestination : ĠPsi Element Pattern . Capture < Psi Element > Ġ= ĊĠĠĠ Ġpsi Element () ĊĠĠĠĠĠ Ġ. after Leaf ( psi Element (). and Or ( ĊĠĠĠĠĠĠĠ Ġpsi Element ( Editor Config Element Types . IDENTIFIER ), ĊĠĠĠĠĠĠĠ Ġpsi Element ( Editor Config Element Types . R _ BRACK ET ) ĊĠĠĠĠĠ Ġ)) ĊĠĠĠĠĠ Ġ. with Super Parent ( 3 , ĠEditor Config Section :: class . java ) ĊĠĠĠĠĠ Ġ. and Not ( psi Element (). with Parent ( psi Element ( Editor Config Element Types . PATTERN ))) ĊĠĠĠĠĠ Ġ. and Not ( psi Element (). before Leaf ( psi Element ( Editor Config Element Types . COL ON ))) ĊĊĠ Ġoverride Ġfun Ġadd Comp letions ( parameters : ĠCompletion Parameters , Ġcontext : ĠProcessing Context , Ġresult : ĠCompletion ResultSet ) Ġ{ ĊĠĠĠ Ġval Ġposition Ġ= Ġparameters . position ĊĠĠĠ Ġval Ġoption Ġ= Ġposition . parent . parent Ġas ĠEditor Config Option ĊĠĠĠ Ġval Ġtext Ġ= Ġposition . text ĊĠĠĠ Ġval Ġfirst Char Ġ= Ġtext . first (). take Unless Ġ{ Ġtext . startsWith ( D UMMY _ IDENTIFIER _ TRIM MED ) Ġ} ĊĠĠĠ Ġval Ġsection Ġ= Ġposition . getParent OfType < Editor Config Section >() Ġ?: Ġreturn ĊĠĠĠ Ġval Ġoption Keys Ġ= Ġsection . option List . map NotNull ( Editor Config Option :: get Flat Option Key ) ĊĠĠĠ Ġval Ġraw Completion Items Ġ= ĠEditor Config Option Descriptor Manager ĊĠĠĠĠĠ Ġ. instance ĊĠĠĠĠĠ Ġ. getSimple Key Descriptors ( false ) ĊĠĠĠĠĠ Ġ. as Sequence () ĊĠĠĠĠĠ Ġ. filter Ġ{ Ġoption Keys . none ( it :: matches ) Ġ} ĊĠĠĠĠĠ Ġ. flatMap Ġ{ ĠEditor Config Completion Provider Util . select Simple Parts ( it , Ġfirst Char ). as Sequence () Ġ} ĊĠĠĠĠĠ Ġ. map (:: create Lookup And Check De precation ) ĊĊĠĠĠ Ġval Ġcompletion Items Ġ= Ġif Ġ( need Separator After ( option . next Sibling )) Ġ{ ĊĠĠĠĠĠ Ġraw Completion Items . map Ġ{ Ġit . with Separator In ( section . containing File ) Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġelse Ġraw Completion Items ĊĠĠĠ Ġcompletion Items . forEach ( result :: addElement ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġneed Separator After ( space : ĠPsi Element ?) Ġ= ĊĠĠĠ Ġspace ?. text Matches (" Ġ") Ġ!= Ġtrue Ċ } Ċ