Esempio n. 1
0
        private System.Windows.Media.Color GetColor(string text)
        {
            IComponentModel     componentModel          = Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel;
            var                 service                 = componentModel.GetService <Microsoft.VisualStudio.Text.Classification.IClassificationFormatMapService>();
            var                 classificationFormatMap = service.GetClassificationFormatMap(category: "text");
            var                 list_of_formats         = classificationFormatMap.CurrentPriorityOrder;
            IClassificationType selected                = list_of_formats.Where(t => { if (t != null)
                                                                                       {
                                                                                           return(t.Classification == text);
                                                                                       }
                                                                                       return(false); }).FirstOrDefault();

            if (selected == null)
            {
                return(System.Windows.Media.Color.FromArgb(0, 0, 0, 0));
            }
            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap.GetExplicitTextProperties(selected);
            var brush = identifierProperties.ForegroundBrush;
            var tttt  = brush.GetType();

            if (brush is SolidColorBrush)
            {
                var b = brush as SolidColorBrush;
                System.Windows.Media.Color color = b.Color;
                return(System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B));
            }
            return(System.Windows.Media.Color.FromArgb(0, 0, 0, 0));
        }
Esempio n. 2
0
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> qiContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;
            if (XSharpProjectPackage.Instance.DebuggerIsRunning)
            {
                return;
            }
            try
            {
                XSharpModel.ModelWalker.Suspend();
                var package     = XSharp.Project.XSharpProjectPackage.Instance;
                var optionsPage = package.GetIntellisenseOptionsPage();
                if (optionsPage.DisableQuickInfo)
                {
                    return;
                }


                // Map the trigger point down to our buffer.
                SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(_subjectBuffer.CurrentSnapshot);
                if (!subjectTriggerPoint.HasValue)
                {
                    return;
                }
                ITextSnapshot currentSnapshot = subjectTriggerPoint.Value.Snapshot;
                WriteOutputMessage($"Triggerpoint: {subjectTriggerPoint.Value.Position}");

                if ((subjectTriggerPoint.Value.Position == lastTriggerPoint) && (lastVersion == currentSnapshot.Version.VersionNumber))
                {
                    if (lastHelp != null)
                    {
                        var description = new TextBlock();
                        description.Inlines.AddRange(lastHelp);
                        qiContent.Add(description);
                        if (lastxmldoc != null)
                        {
                            qiContent.Add(lastxmldoc);
                        }
                        WriteOutputMessage($"Return last help content: {lastHelp}");
                    }
                    if (lastSpan != null)
                    {
                        applicableToSpan = lastSpan;
                    }
                    return;
                }
                // We don't want to lex the buffer. So get the tokens from the last lex run
                // and when these are too old, then simply bail out
                var tokens = _subjectBuffer.GetTokens();
                if (tokens != null)
                {
                    if (tokens.SnapShot.Version != currentSnapshot.Version)
                    {
                        return;
                    }
                }

                lastTriggerPoint = subjectTriggerPoint.Value.Position;

                //look for occurrences of our QuickInfo words in the span
                ITextStructureNavigator navigator = _provider.NavigatorService.GetTextStructureNavigator(_subjectBuffer);
                TextExtent extent     = navigator.GetExtentOfWord(subjectTriggerPoint.Value);
                string     searchText = extent.Span.GetText();

                // First, where are we ?
                int caretPos   = subjectTriggerPoint.Value.Position;
                int lineNumber = subjectTriggerPoint.Value.GetContainingLine().LineNumber;
                var snapshot   = session.TextView.TextBuffer.CurrentSnapshot;
                if (_file == null)
                {
                    return;
                }
                // Then, the corresponding Type/Element if possible
                IToken stopToken;
                //ITokenStream tokenStream;
                XSharpModel.XTypeMember member           = XSharpLanguage.XSharpTokenTools.FindMember(lineNumber, _file);
                XSharpModel.XType       currentNamespace = XSharpLanguage.XSharpTokenTools.FindNamespace(caretPos, _file);
                // adjust caretpos, for other completions we need to stop before the caret. Now we include the caret
                List <String> tokenList = XSharpLanguage.XSharpTokenTools.GetTokenList(caretPos + 1, lineNumber, tokens.TokenStream, out stopToken, true, _file, false, member);
                // Check if we can get the member where we are
                //if (tokenList.Count > 1)
                //{
                //    tokenList.RemoveRange(0, tokenList.Count - 1);
                //}
                // LookUp for the BaseType, reading the TokenList (From left to right)
                XSharpLanguage.CompletionElement gotoElement;
                String currentNS = "";
                if (currentNamespace != null)
                {
                    currentNS = currentNamespace.Name;
                }

                XSharpModel.CompletionType cType = XSharpLanguage.XSharpTokenTools.RetrieveType(_file, tokenList, member, currentNS, stopToken, out gotoElement, snapshot, lineNumber, _file.Project.Dialect);
                //
                //
                if ((gotoElement != null) && (gotoElement.IsInitialized))
                {
                    IClassificationType      kwType = _registry.GetClassificationType("keyword");
                    IClassificationFormatMap fmap   = _formatMap.GetClassificationFormatMap(category: "text");
                    Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties kwFormat = fmap.GetTextProperties(kwType);
                    kwType = _registry.GetClassificationType("text");
                    fmap   = _formatMap.GetClassificationFormatMap(category: "text");
                    Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties txtFormat = fmap.GetTextProperties(kwType);
                    //
                    // Ok, find it ! Let's go ;)
                    applicableToSpan = currentSnapshot.CreateTrackingSpan
                                       (
                        extent.Span.Start, searchText.Length, SpanTrackingMode.EdgeInclusive
                                       );

                    if (gotoElement.XSharpElement != null)
                    {
                        if (gotoElement.XSharpElement.Kind == XSharpModel.Kind.Constructor)
                        {
                            if (gotoElement.XSharpElement.Parent != null)
                            {
                                var xtype       = gotoElement.XSharpElement.Parent as XType;
                                var qitm        = new QuickInfoTypeAnalysis(xtype, kwFormat.ForegroundBrush, txtFormat.ForegroundBrush);
                                var description = new TextBlock();
                                description.Inlines.AddRange(qitm.WPFDescription);
                                qiContent.Add(description);
                            }
                        }
                        else if (gotoElement.XSharpElement is XSharpModel.XTypeMember)
                        {
                            QuickInfoTypeMember qitm = new QuickInfoTypeMember((XSharpModel.XTypeMember)gotoElement.XSharpElement, kwFormat.ForegroundBrush, txtFormat.ForegroundBrush);
                            var description          = new TextBlock();
                            description.Inlines.AddRange(qitm.WPFDescription);
                            qiContent.Add(description);
                        }
                        else if (gotoElement.XSharpElement is XSharpModel.XVariable)
                        {
                            QuickInfoVariable qitm = new QuickInfoVariable((XSharpModel.XVariable)gotoElement.XSharpElement, kwFormat.ForegroundBrush, txtFormat.ForegroundBrush);
                            var description        = new TextBlock();
                            description.Inlines.AddRange(qitm.WPFDescription);
                            qiContent.Add(description);
                        }
                        else if (gotoElement.XSharpElement is XSharpModel.XType)
                        {
                            var xtype       = gotoElement.XSharpElement as XType;
                            var qitm        = new QuickInfoTypeAnalysis(xtype, kwFormat.ForegroundBrush, txtFormat.ForegroundBrush);
                            var description = new TextBlock();
                            description.Inlines.AddRange(qitm.WPFDescription);
                            qiContent.Add(description);
                        }
                        else
                        {
                            var description = new TextBlock();
                            Run temp;
                            temp            = new Run(gotoElement.XSharpElement.Description);
                            temp.Foreground = txtFormat.ForegroundBrush;
                            //
                            description.Inlines.Add(temp);
                            qiContent.Add(description);
                        }
                    }
                    else if (gotoElement.SystemElement is TypeInfo)
                    {
                        var    ti     = gotoElement.SystemElement as TypeInfo;
                        string xmldoc = XSharpXMLDocMember.GetTypeSummary(ti, member.File.Project);
                        QuickInfoTypeAnalysis analysis = new QuickInfoTypeAnalysis(ti, kwFormat.ForegroundBrush, txtFormat.ForegroundBrush);
                        var description = new TextBlock();
                        description.Inlines.AddRange(analysis.WPFDescription);
                        qiContent.Add(description);
                        if (xmldoc != null)
                        {
                            qiContent.Add(xmldoc);
                        }
                    }
                    else
                    {
                        // This works with System.MemberInfo AND
                        QuickInfoMemberAnalysis analysis = null;
                        if (gotoElement.SystemElement is MemberInfo)
                        {
                            string xmldoc = XSharpXMLDocMember.GetMemberSummary(gotoElement.SystemElement, member.File.Project);

                            analysis = new QuickInfoMemberAnalysis(gotoElement.SystemElement, kwFormat.ForegroundBrush, txtFormat.ForegroundBrush);
                            if (analysis.IsInitialized)
                            {
                                if ((analysis.Kind == XSharpModel.Kind.Constructor) && (cType != null) && (cType.SType != null))
                                {
                                    QuickInfoTypeAnalysis typeAnalysis;
                                    typeAnalysis = new QuickInfoTypeAnalysis(cType.SType.GetTypeInfo(), kwFormat.ForegroundBrush, txtFormat.ForegroundBrush);
                                    if (typeAnalysis.IsInitialized)
                                    {
                                        var description = new TextBlock();
                                        description.Inlines.AddRange(typeAnalysis.WPFDescription);
                                        qiContent.Add(description);
                                    }
                                }
                                else
                                {
                                    var description = new TextBlock();
                                    description.Inlines.AddRange(analysis.WPFDescription);
                                    qiContent.Add(description);
                                }
                                if (xmldoc != null)
                                {
                                    qiContent.Add(xmldoc);
                                }
                            }
                        }
                    }
                    if (qiContent.Count > 0)
                    {
                        TextBlock description;
                        description = qiContent[0] as TextBlock;
                        if (qiContent.Count > 1)
                        {
                            lastxmldoc = qiContent[1] as String;
                        }
                        else
                        {
                            lastxmldoc = null;
                        }
                        if (description != null)
                        {
                            lastHelp = new Inline[description.Inlines.Count];
                            description.Inlines.CopyTo(lastHelp, 0);
                            lastSpan    = applicableToSpan;
                            lastVersion = currentSnapshot.Version.VersionNumber;
                            WriteOutputMessage($"Found new help content: {lastHelp}");
                        }
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                XSharpProjectPackage.Instance.DisplayOutPutMessage("XSharpQuickInfo.AugmentQuickInfoSession failed : ");
                XSharpProjectPackage.Instance.DisplayException(ex);
            }
            finally
            {
                XSharpModel.ModelWalker.Resume();
            }
        }
Esempio n. 3
0
        internal void Initialize(IClassificationTypeRegistryService service,
                                 IClassificationFormatMapService ClassificationFormatMapService)
        {
            try
            {
                if (initialized)
                {
                    return;
                }

                string ffn = _buffer.GetFFN().Result;
                if (ffn == null)
                {
                    return;
                }

                LanguageServer.IGrammarDescription _grammar_description = LanguageServer.GrammarDescriptionFactory.Create(ffn);
                if (_grammar_description == null)
                {
                    return;
                }

                Workspaces.Document document = Workspaces.Workspace.Instance.FindDocument(ffn);
                _lsptype_to_classifiertype = new Dictionary <int, IClassificationType>();
                for (int i = 0; i < _grammar_description.Map.Length; ++i)
                {
                    int    key = i;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType == null?service.CreateClassificationType(val, new IClassificationType[] { })
                                                                          : identiferClassificationType;

                    IClassificationFormatMap classificationFormatMap = ClassificationFormatMapService.GetClassificationFormatMap(category: "text");
                    Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                              .GetExplicitTextProperties(classificationType);
                    System.Drawing.Color color = !Themes.IsInvertedTheme() ? _grammar_description.MapColor[key]
                        : _grammar_description.MapInvertedColor[key];
                    System.Windows.Media.Color newColor = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B);
                    Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties newProperties = identifierProperties.SetForeground(newColor);
                    classificationFormatMap.AddExplicitTextProperties(classificationType, newProperties);
                }
                {
                    int    key = (int)SymbolKind.Variable;
                    string val = _grammar_description.Map[0];
                    _lsptype_to_classifiertype[key] = service.GetClassificationType(val);
                }
                {
                    int    key = (int)SymbolKind.Enum;
                    string val = _grammar_description.Map[1];
                    _lsptype_to_classifiertype[key] = service.GetClassificationType(val);
                }
                initialized = true;
            }
            catch (Exception)
            {
                //Logger.Log.Notify(exception.StackTrace);
            }
        }
Esempio n. 4
0
        internal void Initialize(IClassificationTypeRegistryService service,
                                 IClassificationFormatMapService ClassificationFormatMapService)
        {
            try
            {
                if (initialized)
                {
                    return;
                }

                string ffn = _buffer.GetFFN();
                if (ffn == null)
                {
                    return;
                }

                Workspaces.Document document = Workspaces.Workspace.Instance.FindDocument(ffn);
                LanguageServer.IParserDescription _grammar_description = LanguageServer.ParserDescriptionFactory.Create(document);
                if (_grammar_description == null)
                {
                    return;
                }

                _to_classifiertype = new Dictionary <int, IClassificationType>();

                IClassificationFormatMap classificationFormatMap = ClassificationFormatMapService.GetClassificationFormatMap(category: "text");
                // hardwire colors to VS's colors of selected types.
                System.Collections.ObjectModel.ReadOnlyCollection <IClassificationType> list_of_formats = classificationFormatMap.CurrentPriorityOrder;

                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationNonterminalDef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrNonterminalDef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable CS0168 // Variable is declared but never used
                        catch (Exception eeks) { }
#pragma warning restore CS0168 // Variable is declared but never used
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationNonterminalRef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrNonterminalRef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationTerminalDef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrTerminalDef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationTerminalRef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrTerminalRef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationComment;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrComment")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationKeyword;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrKeyword")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationLiteral;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrLiteral")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationModeDef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrModeDef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationModeRef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrModeRef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationChannelDef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrChannelDef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationChannelRef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrChannelRef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationPunctuation;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrPunctuation")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationOperator;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrOperator")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                initialized = true;
            }
#pragma warning disable 0168
            catch (Exception eeks) { }
#pragma warning restore 0168
        }