/* Ċ The ĠMIT ĠLicense Ġ( MIT ) Ċ Ċ Copyright Ġ( c ) Ġ 2 0 1 6 ĠTom ĠNeed ham Ċ Ċ Permission Ġis Ġhereby Ġgranted , Ġfree Ġof Ġcharge , Ġto Ġany Ġperson Ġobtaining Ġa Ġcopy Ċ of Ġthis Ġsoftware Ġand Ġassociated Ġdocumentation Ġfiles Ġ( the Ġ" Software "), Ġto Ġdeal Ċ in Ġthe ĠSoftware Ġwithout Ġrestriction , Ġincluding Ġwithout Ġlimitation Ġthe Ġrights Ċ to Ġuse , Ġcopy , Ġmodify , Ġmerge , Ġpublish , Ġdistribute , Ġsublicense , Ġand / or Ġsell Ċ copies Ġof Ġthe ĠSoftware , Ġand Ġto Ġpermit Ġpersons Ġto Ġwhom Ġthe ĠSoftware Ġis Ċ furnished Ġto Ġdo Ġso , Ġsubject Ġto Ġthe Ġfollowing Ġconditions : Ċ Ċ The Ġabove Ġcopyright Ġnotice Ġand Ġthis Ġpermission Ġnotice Ġshall Ġbe Ġincluded Ġin Ġall Ċ copies Ġor Ġsubstantial Ġportions Ġof Ġthe ĠSoftware . Ċ Ċ THE ĠSOFTWARE ĠIS ĠPROVIDED Ġ" AS ĠIS ", ĠWITHOUT ĠWARRANTY ĠOF ĠANY ĠKIND , ĠEXPRESS ĠOR Ċ IMPLIED , ĠINCLUDING ĠBUT ĠNOT ĠLIMITED ĠTO ĠTHE ĠWARRANTIES ĠOF ĠMERCHANTABILITY , Ċ FITNESS ĠFOR ĠA ĠPARTICULAR ĠPURPOSE ĠAND ĠNONINFRINGEMENT . ĠIN ĠNO ĠEVENT ĠSHALL ĠTHE Ċ AUTHORS ĠOR ĠCOPYRIGHT ĠHOLDERS ĠBE ĠLIABLE ĠFOR ĠANY ĠCLAIM , ĠDAMAGES ĠOR ĠOTHER Ċ LIABILITY , ĠWHETHER ĠIN ĠAN ĠACTION ĠOF ĠCONTRACT , ĠTORT ĠOR ĠOTHERWISE , ĠARISING ĠFROM , Ċ OUT ĠOF ĠOR ĠIN ĠCONNECTION ĠWITH ĠTHE ĠSOFTWARE ĠOR ĠTHE ĠUSE ĠOR ĠOTHER ĠDEALINGS ĠIN ĠTHE Ċ SOFTWARE . Ċ Ġ*/ Ċ package Ġcom . th omas . need ham . ne uro ph idea . actions ĊĊ Ċ import Ġcom . intellij . openapi . action System . An Action Ċ import Ġcom . intellij . openapi . action System . An ActionEvent Ċ import Ġcom . intellij . openapi . file Editor . File Document Manager Ċ import Ġcom . intellij . openapi . file Editor . File Editor Manager Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . ui . Messages Ċ import Ġcom . intellij . util . Platform Icons Ċ import Ġcom . th omas . need ham . ne uro ph idea . Tuple 3 Ċ import Ġcom . th omas . need ham . ne uro ph idea . designer . psi . sn net . compiler . generator . Sn net Generator Ċ import Ġcom . th omas . need ham . ne uro ph idea . designer . psi . sn net . compiler . lexer . Sn net Lexer Ċ import Ġcom . th omas . need ham . ne uro ph idea . designer . psi . sn net . compiler . parser . Sn net Parser Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġth oma Ġon Ġ 2 9 / 0 6 / 2 0 1 6 . Ċ Ġ*/ Ċ class ĠCompile Sn net File Action Ġ: ĠAn Action () Ġ{ ĊĉĊ ĉ comp anion Ġobject ĠProject Info Ġ{ Ċĉ ĉ var Ġproject : ĠProject ? Ġ= Ġnull Ċĉ ĉ var Ġproject Directory : ĠString ? Ġ= Ġ"" Ċĉ ĉ var ĠisOpen : ĠBoolean ? Ġ= Ġfalse Ċ ĉ } ĊĉĊ ĉ override Ġfun ĠactionPerformed ( p 0 : ĠAn ActionEvent ) Ġ{ Ċĉ ĉ project Ġ= Ġp 0 . project Ċĉ ĉ project Directory Ġ= Ġproject ?. basePath Ċĉ ĉ isOpen Ġ= Ġproject ?. isOpen Ċĉ ĉ val Ġdoc Ġ= ĠFile Editor Manager . getInstance ( project !! ). selected Text Editor ?. document Ċĉ ĉ val Ġfile Ġ= ĠFile Document Manager . getInstance (). getFile ( doc !! ) Ċĉ ĉ val Ġlexer Ġ= ĠSn net Lexer ( file ) Ċĉ ĉ if Ġ(! lexer . Start ()) Ġ{ Ċĉĉ ĉ Messages . show Error Dialog ( project , Ġ" Error ĠLex ing ĠFile Ġ${ file ?. path }", Ġ" Error ") Ċĉĉ ĉ return Ċĉ ĉ } Ċĉ ĉ val Ġtokens Ġ= Ġlexer . token List Ċĉ ĉ val Ġparser Ġ= ĠSn net Parser ( tokens ) Ċĉ ĉ if Ġ(! parser . Start ()) Ġ{ Ċĉĉ ĉ Messages . show Error Dialog ( project , Ġ" Error ĠParsing ĠFile Ġ${ file ?. path }", Ġ" Error ") Ċĉĉ ĉ return Ċĉ ĉ } Ċĉ ĉ var Ġfailed Ġ= Ġfalse Ċĉ ĉ var Ġnames Ġ= Ġ"" Ċĉ ĉ for Ġ( prop : ĠTuple 3 < *, Ġ*, Ġ*> Ġin Ġparser . properties . properties !! ) Ġ{ Ċĉĉ ĉ if Ġ( prop . value Z Ġ== Ġnull ) Ġ{ Ċĉĉĉ ĉ failed Ġ= Ġtrue Ċĉĉĉ ĉ names Ġ+= Ġprop . value Y Ġas ĠString Ġ+ Ġ", Ġ" Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ if Ġ( failed ) Ġ{ Ċĉĉ ĉ Messages . show Error Dialog ( project , Ġ" Error ĠCompiling Ġfile Ġ${ file ?. path } ĠThe Ġfollowing ĠProperties Ġare Ġnot Ġset Ġ${ names }", Ġ" ERROR ") Ċĉĉ ĉ return Ċĉ ĉ } Ċĉ ĉ val Ġpath Ġ= Ġfile ?. path ?. substring ( 0 , Ġfile . path . length Ġ- Ġfile . name . length ) Ġ+ Ġ" Compiled . conf " Ċĉ ĉ val Ġgenerator Ġ= ĠSn net Generator ( parser . properties ) Ċĉ ĉ generator . Save Network ( path ) Ċĉ ĉ Messages . show Ok Cancel Dialog ( project , Ġ" Network ĠSuccessfully ĠComp iled ĠTo Ġ${ path }", Ġ" Success ", ĠPlatform Icons . CHECK _ ICON ) Ċ ĉ } Ċ } Ċ