private DirectiveTriviaSyntax ParseEndRegionDirective( SyntaxToken hash, SyntaxToken keyword, bool isActive ) { var eod = this.ParseEndOfDirectiveWithOptionalPreprocessingMessage(); if (_context.HasUnfinishedRegion()) { return(SyntaxFactory.EndRegionDirectiveTrivia(hash, keyword, eod, isActive)); } else if (_context.HasUnfinishedIf()) { return(this.AddError( SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_EndifDirectiveExpected )); } else { return(this.AddError( SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive), ErrorCode.ERR_UnexpectedDirective )); } }