public static void initState(
     ErrorState state, PsiBuilder builder, IElementType root, TokenSet[] extendsSets) {
   state.extendsSets = extendsSets;
   PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
   state.completionState = file == null ? null : file.getUserData(COMPLETION_STATE_KEY);
   Language language = file == null ? root.getLanguage() : file.getLanguage();
   state.caseSensitive = language.isCaseSensitive();
   PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language);
   state.braces = matcher == null ? null : matcher.getPairs();
   if (state.braces != null && state.braces.length == 0) state.braces = null;
 }
 private static void initState(IElementType root, PsiBuilder builder, ErrorState state) {
   PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
   state.completionState = file == null ? null : file.getUserData(COMPLETION_STATE_KEY);
   Language language = file == null ? root.getLanguage() : file.getLanguage();
   state.caseSensitive = language.isCaseSensitive();
   ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
   if (parserDefinition != null) {
     state.commentTokens = parserDefinition.getCommentTokens();
     state.whitespaceTokens = parserDefinition.getWhitespaceTokens();
   }
   PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language);
   state.braces = matcher == null ? null : matcher.getPairs();
   if (state.braces != null && state.braces.length == 0) state.braces = null;
 }