protected HlslOptionsPreviewViewModelBase(IServiceProvider serviceProvider)
            : base(serviceProvider, HlslConstants.ContentTypeName)
        {
            var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));

            _optionsService = componentModel.GetService <IHlslOptionsService>();
        }
Ejemplo n.º 2
0
 public SyntaxErrorTagger(ITextView textView, ITextBuffer textBuffer, BackgroundParser backgroundParser,
                          IHlslOptionsService optionsService)
     : base(PredefinedErrorTypeNames.SyntaxError, textView, textBuffer, optionsService)
 {
     backgroundParser.SubscribeToThrottledSyntaxTreeAvailable(BackgroundParserSubscriptionDelay.Medium,
                                                              async x => await InvalidateTags(x.Snapshot, x.CancellationToken));
 }
Ejemplo n.º 3
0
 public SemanticErrorTagger(ITextView textView, BackgroundParser backgroundParser,
     IHlslOptionsService optionsService)
     : base(PredefinedErrorTypeNames.CompilerError, textView, optionsService)
 {
     backgroundParser.SubscribeToThrottledSemanticModelAvailable(BackgroundParserSubscriptionDelay.Medium,
         async x => await InvalidateTags(x.Snapshot, x.CancellationToken));
 }
Ejemplo n.º 4
0
 public BraceCompletionContext(
     ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager, 
     HlslClassificationService classificationService, IHlslOptionsService optionsService)
 {
     _smartIndentationService = smartIndentationService;
     _undoManager = undoManager;
     _classificationService = classificationService;
     _optionsService = optionsService;
 }
Ejemplo n.º 5
0
 public BraceCompletionContext(
     ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager,
     HlslClassificationService classificationService, IHlslOptionsService optionsService)
 {
     _smartIndentationService = smartIndentationService;
     _undoManager             = undoManager;
     _classificationService   = classificationService;
     _optionsService          = optionsService;
 }
Ejemplo n.º 6
0
 public SyntaxErrorManager(BackgroundParser backgroundParser, ITextView textView, IHlslOptionsService optionsService, IServiceProvider serviceProvider, ITextDocumentFactoryService textDocumentFactoryService)
     : base(textView, optionsService, serviceProvider, textDocumentFactoryService)
 {
     backgroundParser.SubscribeToThrottledSyntaxTreeAvailable(BackgroundParserSubscriptionDelay.OnIdle,
         async x => await ExceptionHelper.TryCatchCancellation(() =>
         {
             RefreshErrors(x.Snapshot, x.CancellationToken);
             return Task.FromResult(0);
         }));
 }
Ejemplo n.º 7
0
        protected override void Initialize()
        {
            SyntaxVisualizerToolWindowCommand.Initialize(this);

            base.Initialize();

            Instance = this;

            Options = this.AsVsServiceProvider().GetComponentModel().GetService <IHlslOptionsService>();
        }
Ejemplo n.º 8
0
 public static void Format(this ITextBuffer buffer, TextSpan span, IHlslOptionsService optionsService)
 {
     SyntaxTree syntaxTree;
     if (!TryGetSyntaxTree(buffer, out syntaxTree))
         return;
     var edits = Formatter.GetEdits(syntaxTree,
         span,
         optionsService.FormattingOptions);
     ApplyEdits(buffer, edits);
 }
        public FormatCommandTarget(IVsTextView adapter, IWpfTextView textView, IHlslOptionsService optionsService)
        {
            _textView       = textView;
            _optionsService = optionsService;

            Dispatcher.CurrentDispatcher.InvokeAsync(() =>
            {
                // Add the target later to make sure it makes it in before other command handlers
                ErrorHandler.ThrowOnFailure(adapter.AddCommandFilter(this, out _nextCommandTarget));
            }, DispatcherPriority.ApplicationIdle);
        }
Ejemplo n.º 10
0
        public FormatCommandTarget(IVsTextView adapter, IWpfTextView textView, IHlslOptionsService optionsService)
        {
            _textView = textView;
            _optionsService = optionsService;

            Dispatcher.CurrentDispatcher.InvokeAsync(() =>
            {
                // Add the target later to make sure it makes it in before other command handlers
                ErrorHandler.ThrowOnFailure(adapter.AddCommandFilter(this, out _nextCommandTarget));
            }, DispatcherPriority.ApplicationIdle);
        }
Ejemplo n.º 11
0
 private static bool ShouldFormatOnCharacter(char ch, IHlslOptionsService optionsService)
 {
     switch (ch)
     {
         case '}':
             return optionsService.GeneralOptions.AutomaticallyFormatBlockOnCloseBrace;
         case ';':
             return optionsService.GeneralOptions.AutomaticallyFormatStatementOnSemicolon;
     }
     return false;
 }
Ejemplo n.º 12
0
        private static bool ShouldFormatOnCharacter(char ch, IHlslOptionsService optionsService)
        {
            switch (ch)
            {
            case '}':
                return(optionsService.GeneralOptions.AutomaticallyFormatBlockOnCloseBrace);

            case ';':
                return(optionsService.GeneralOptions.AutomaticallyFormatStatementOnSemicolon);
            }
            return(false);
        }
Ejemplo n.º 13
0
        // https://github.com/Microsoft/nodejstools/blob/master/Nodejs/Product/Nodejs/EditFilter.cs#L866
        public static void FormatAfterTyping(this ITextView textView, char ch, IHlslOptionsService optionsService)
        {
            if (!ShouldFormatOnCharacter(ch, optionsService))
                return;

            SyntaxTree syntaxTree;
            if (!TryGetSyntaxTree(textView.TextBuffer, out syntaxTree))
                return;

            var edits = Formatter.GetEditsAfterKeystroke(syntaxTree,
                textView.Caret.Position.BufferPosition.Position, ch,
                optionsService.FormattingOptions);
            ApplyEdits(textView.TextBuffer, edits);
        }
Ejemplo n.º 14
0
        public static void Format(this ITextBuffer buffer, TextSpan span, IHlslOptionsService optionsService)
        {
            SyntaxTree syntaxTree;

            if (!TryGetSyntaxTree(buffer, out syntaxTree))
            {
                return;
            }
            var edits = Formatter.GetEdits(syntaxTree,
                                           span,
                                           optionsService.FormattingOptions);

            ApplyEdits(buffer, edits);
        }
Ejemplo n.º 15
0
        // https://github.com/Microsoft/nodejstools/blob/master/Nodejs/Product/Nodejs/EditFilter.cs#L866
        public static void FormatAfterTyping(this ITextView textView, char ch, IHlslOptionsService optionsService)
        {
            if (!ShouldFormatOnCharacter(ch, optionsService))
            {
                return;
            }

            SyntaxTree syntaxTree;

            if (!TryGetSyntaxTree(textView.TextBuffer, out syntaxTree))
            {
                return;
            }

            var edits = Formatter.GetEditsAfterKeystroke(syntaxTree,
                                                         textView.Caret.Position.BufferPosition.Position, ch,
                                                         optionsService.FormattingOptions);

            ApplyEdits(textView.TextBuffer, edits);
        }
Ejemplo n.º 16
0
        public OutliningTagger(ITextBuffer textBuffer, BackgroundParser backgroundParser, IHlslOptionsService optionsService)
        {
            _textBuffer = textBuffer;

            backgroundParser.SubscribeToThrottledSyntaxTreeAvailable(BackgroundParserSubscriptionDelay.OnIdle,
                                                                     async x => await InvalidateTags(x.Snapshot, x.CancellationToken));

            _enabled = optionsService.AdvancedOptions.EnterOutliningModeWhenFilesOpen;
        }
 public HlslEditorFormattingService(IHlslOptionsService optionsService)
 {
     _optionsService = optionsService;
 }
Ejemplo n.º 18
0
 public SyntaxErrorManager(BackgroundParser backgroundParser, ITextView textView, IHlslOptionsService optionsService, IServiceProvider serviceProvider, ITextDocumentFactoryService textDocumentFactoryService)
     : base(textView, optionsService, serviceProvider, textDocumentFactoryService)
 {
     backgroundParser.SubscribeToThrottledSyntaxTreeAvailable(BackgroundParserSubscriptionDelay.OnIdle,
                                                              async x => await ExceptionHelper.TryCatchCancellation(() =>
     {
         RefreshErrors(x.Snapshot, x.CancellationToken);
         return(Task.FromResult(0));
     }));
 }
Ejemplo n.º 19
0
 public HlslSyntaxFormattingService(IHlslOptionsService optionsService)
 {
     _optionsService = optionsService;
 }
Ejemplo n.º 20
0
        protected override void Initialize()
        {
            SyntaxVisualizerToolWindowCommand.Initialize(this);

            base.Initialize();

            Instance = this;

            Options = this.AsVsServiceProvider().GetComponentModel().GetService<IHlslOptionsService>();
        }
 protected HlslOptionsPreviewViewModelBase(IServiceProvider serviceProvider)
     : base(serviceProvider, HlslConstants.ContentTypeName)
 {
     var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
     _optionsService = componentModel.GetService<IHlslOptionsService>();
 }