Example #1
0
        internal AntlrClassifier(
            ITextView view,
            ITextBuffer buffer,
            ITagAggregator <AntlrTokenTag> aggregator,
            IClassificationTypeRegistryService service)
        {
            _view   = view;
            _buffer = buffer;
            _buffer_to_classifier[buffer] = this;

            _aggregator = aggregator;
            _antlrtype_to_classifiertype = new Dictionary <AntlrTagTypes, IClassificationType>();
            _antlrtype_to_classifiertype[AntlrTagTypes.Nonterminal] = service.GetClassificationType(Constants.ClassificationNameNonterminal);
            _antlrtype_to_classifiertype[AntlrTagTypes.Terminal]    = service.GetClassificationType(Constants.ClassificationNameTerminal);
            _antlrtype_to_classifiertype[AntlrTagTypes.Comment]     = service.GetClassificationType(Constants.ClassificationNameComment);
            _antlrtype_to_classifiertype[AntlrTagTypes.Keyword]     = service.GetClassificationType(Constants.ClassificationNameKeyword);
            _antlrtype_to_classifiertype[AntlrTagTypes.Literal]     = service.GetClassificationType(Constants.ClassificationNameLiteral);
            _antlrtype_to_classifiertype[AntlrTagTypes.Other]       = service.GetClassificationType("other");

            // Ensure package is loaded.
            AntlrLanguagePackage package = AntlrLanguagePackage.Instance;

            buffer.Changed += BufferChanged;
            // buffer.ContentTypeChanged += BufferContentTypeChanged;
        }
Example #2
0
        internal AntlrClassifier(ITextBuffer buffer)
        {
            try
            {
                _buffer          = buffer;
                _buffer.Changed += new EventHandler <TextContentChangedEventArgs>(OnTextChanged);

                var ffn = _buffer.GetFFN().Result;
                if (ffn == null)
                {
                    return;
                }
                _grammar_description = LanguageServer.GrammarDescriptionFactory.Create(ffn);
                if (_grammar_description == null)
                {
                    return;
                }
                var document = Workspaces.Workspace.Instance.FindDocument(ffn);
                if (document == null)
                {
                    Workspaces.Loader.LoadAsync().Wait();
                    var to_do = LanguageServer.Module.Compile();
                    document = Workspaces.Workspace.Instance.FindDocument(ffn);
                }
                AntlrLanguagePackage package = AntlrLanguagePackage.Instance;
            }
            catch (Exception exception)
            {
                Logger.Log.Notify(exception.ToString());
            }
        }
Example #3
0
        public ITagger <T> CreateTagger <T>(ITextBuffer buffer) where T : ITag
        {
            ITagger <T> result = null;

            try
            {
                AntlrLanguagePackage package = AntlrLanguagePackage.Instance;
                VSColorTheme.ThemeChanged += UpdateTheme;
                result = buffer.Properties.GetOrCreateSingletonProperty(() => new AntlrClassifier(buffer)) as ITagger <T>;
                var classifier = result as AntlrClassifier;
                classifier.Initialize(aggregatorFactory,
                                      ClassificationTypeRegistry, ClassificationFormatMapService);
            }
            catch (Exception exception)
            {
                Logger.Log.Notify(exception.StackTrace);
            }
            return(result);
        }