{-# LANGUAGE CPP #-}-- | Functions which give precise syntax highlighting info to Emacs.moduleAgda.Interaction.Highlighting.Emacs(showHighlightingInfo,Agda.Interaction.Highlighting.Emacs.tests)whereimportAgda.Interaction.FindFileimportAgda.Interaction.Highlighting.PreciseimportAgda.Interaction.Highlighting.RangeimportAgda.Syntax.Abstract(QName)importAgda.Syntax.CommonimportqualifiedAgda.Syntax.PositionasPimportAgda.Syntax.Translation.ConcreteToAbstract(TopLevelInfo)importAgda.TypeChecking.Errors(prettyError)importAgda.Utils.FileNameimportAgda.Utils.StringimportAgda.Utils.TestHelpersimportAgda.Utils.Impossible#include "../../undefined.h"importControl.Monad.TransimportData.ListimportqualifiedData.MapasMapimportData.CharimportData.Maybe-------------------------------------------------------------------------- Read/show functions-- | Converts the 'aspect' and 'otherAspects' fields to atoms readable-- by the Emacs interface.toAtoms::MetaInfo->[String]toAtomsm=maptoAtom(otherAspectsm)++toAtoms'(aspectm)wheretoAtomx=maptoLower(showx)kindToAtom(ConstructorInductive)="inductiveconstructor"kindToAtom(ConstructorCoInductive)="coinductiveconstructor"kindToAtomk=toAtomktoAtoms'Nothing=[]toAtoms'(Just(NamemKindop))=mapkindToAtom(maybeToListmKind)++opAtomwhereopAtom|op=["operator"]|otherwise=[]toAtoms'(Justa)=[toAtoma]-- | Shows meta information in such a way that it can easily be read-- by Emacs.showMetaInfo::ModuleToSource-- ^ Must contain a mapping for the definition site's-- module, if any.->(Range,MetaInfo)->StringshowMetaInfomodFile(r,m)="("++show(fromr)++" "++show(tor)++" ("++concat(intersperse" "(toAtomsm))++")"++(maybe" nil"((" "++).quote)$notem)++defSite++")"wheredefSite=casedefinitionSitemofNothing->""Just(m,p)->caseMap.lookupmmodFileofNothing->__IMPOSSIBLE__Justf->" ("++quote(filePathf)++" . "++showp++")"-- | Shows syntax highlighting information in an Emacsy fashion.showHighlightingInfo::Maybe(HighlightingInfo,ModuleToSource)-- ^ The 'ModuleToSource' must contain a mapping for every-- definition site's module.->StringshowHighlightingInfoNothing=""showHighlightingInfo(Just(h,modFile))="("++unlines(map(showMetaInfomodFile)h)++")"-------------------------------------------------------------------------- All tests-- TODO: One could check that the show functions are invertible.-- | All the properties.tests::IOBooltests=runTests"Agda.Interaction.Highlighting.Emacs"[]