"use strict" ; import * as vscode from "vscode" ; import * as config from "./../config/Configuration" ; import { RegionProvider , CustomRegion } from "./CustomRegions" ; export class RegionService { regionProvider : RegionProvider ; document : vscode . TextDocument ; regions : CustomRegion [ ] ; /**
     *
     */ constructor ( configService , document ) { this . regionProvider = new RegionProvider ( configService ) ; this . document = document ; this . regions = [ ] ; } public update ( ) { var result = this . regionProvider . getRegions ( this . document ) ; this . regions = result . completedRegions ; } public getRegions ( ) { this . update ( ) ; return this . regions ; } public currentRegions ( ) { this . update ( ) ; var ate = vscode . window . activeTextEditor ; if ( ! ate ) { return [ ] ; } if ( this . document !== ate . document ) { return [ ] ; } var surroundingRegions = [ ] ; for ( let reg of this . regions ) { if ( reg . contains ( ate . selection . active ) ) { surroundingRegions . push ( reg ) ; } } return surroundingRegions ; } public currentRegion ( ) { var currentRegions = this . currentRegions ( ) ; if ( currentRegions . length === 0 ) { return null ; } return currentRegions [ 0 ] ; return currentRegions [ currentRegions . length - 1 ] ; } }