コード例 #1
0
        protected HlslOptionsPreviewViewModelBase(IServiceProvider serviceProvider)
            : base(serviceProvider, HlslConstants.ContentTypeName)
        {
            var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));

            _optionsService = componentModel.GetService <IHlslOptionsService>();
        }
コード例 #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));
 }
コード例 #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));
 }
コード例 #4
0
 public BraceCompletionContext(
     ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager, 
     HlslClassificationService classificationService, IHlslOptionsService optionsService)
 {
     _smartIndentationService = smartIndentationService;
     _undoManager = undoManager;
     _classificationService = classificationService;
     _optionsService = optionsService;
 }
コード例 #5
0
 public BraceCompletionContext(
     ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager,
     HlslClassificationService classificationService, IHlslOptionsService optionsService)
 {
     _smartIndentationService = smartIndentationService;
     _undoManager             = undoManager;
     _classificationService   = classificationService;
     _optionsService          = optionsService;
 }
コード例 #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);
         }));
 }
コード例 #7
0
        protected override void Initialize()
        {
            SyntaxVisualizerToolWindowCommand.Initialize(this);

            base.Initialize();

            Instance = this;

            Options = this.AsVsServiceProvider().GetComponentModel().GetService <IHlslOptionsService>();
        }
コード例 #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);
 }
コード例 #9
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);
        }
コード例 #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);
        }
コード例 #11
0
 private static bool ShouldFormatOnCharacter(char ch, IHlslOptionsService optionsService)
 {
     switch (ch)
     {
         case '}':
             return optionsService.GeneralOptions.AutomaticallyFormatBlockOnCloseBrace;
         case ';':
             return optionsService.GeneralOptions.AutomaticallyFormatStatementOnSemicolon;
     }
     return false;
 }
コード例 #12
0
        private static bool ShouldFormatOnCharacter(char ch, IHlslOptionsService optionsService)
        {
            switch (ch)
            {
            case '}':
                return(optionsService.GeneralOptions.AutomaticallyFormatBlockOnCloseBrace);

            case ';':
                return(optionsService.GeneralOptions.AutomaticallyFormatStatementOnSemicolon);
            }
            return(false);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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;
        }
コード例 #17
0
 public HlslEditorFormattingService(IHlslOptionsService optionsService)
 {
     _optionsService = optionsService;
 }
コード例 #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));
     }));
 }
コード例 #19
0
 public HlslSyntaxFormattingService(IHlslOptionsService optionsService)
 {
     _optionsService = optionsService;
 }
コード例 #20
0
ファイル: HlslPackage.cs プロジェクト: tgjones/HlslTools
        protected override void Initialize()
        {
            SyntaxVisualizerToolWindowCommand.Initialize(this);

            base.Initialize();

            Instance = this;

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