コード例 #1
0
 public QuickInfoManager(ITextView textView, IQuickInfoBroker quickInfoBroker, QuickInfoModelProviderService quickInfoModelProviderService, VisualStudioSourceTextFactory sourceTextFactory)
 {
     _textView = textView;
     _quickInfoBroker = quickInfoBroker;
     _quickInfoModelProviderService = quickInfoModelProviderService;
     _sourceTextFactory = sourceTextFactory;
 }
コード例 #2
0
        public SyntaxVisualizerToolWindowControl()
        {
            InitializeComponent();
            InitializeRunningDocTable();

            var componentModel = HlslToolsPackage.Instance.AsVsServiceProvider().GetComponentModel();
            _sourceTextFactory = componentModel.GetService<VisualStudioSourceTextFactory>();
        }
コード例 #3
0
 public SignatureHelpManager(ITextView textView, ISignatureHelpBroker signatureHelpBroker, SignatureHelpModelProviderService signatureHelpModelProviderService, VisualStudioSourceTextFactory sourceTextFactory)
 {
     _textView = textView;
     _textView.Caret.PositionChanged += CaretOnPositionChanged;
     _textView.TextBuffer.PostChanged += TextBufferOnPostChanged;
     _signatureHelpBroker = signatureHelpBroker;
     _signatureHelpModelProviderService = signatureHelpModelProviderService;
     _sourceTextFactory = sourceTextFactory;
 }
コード例 #4
0
ファイル: Extensions.cs プロジェクト: pminiszewski/HlslTools
 public static SemanticModel GetSemanticModel(this ITextSnapshot snapshot, VisualStudioSourceTextFactory sourceTextFactory, CancellationToken cancellationToken)
 {
     return CachedSemanticModels.GetValue(snapshot, key =>
     {
         var syntaxTree = key.GetSyntaxTree(sourceTextFactory, cancellationToken);
         var compilation = new Compilation.Compilation(syntaxTree);
         return compilation.GetSemanticModel();
     });
 }
コード例 #5
0
        public EditorNavigationSource(ITextBuffer textBuffer, BackgroundParser backgroundParser, DispatcherGlyphService glyphService, VisualStudioSourceTextFactory sourceTextFactory)
        {
            _textBuffer = textBuffer;
            _glyphService = glyphService;
            _sourceTextFactory = sourceTextFactory;

            _navigationTargets = new List<EditorTypeNavigationTarget>();

            backgroundParser.RegisterSyntaxTreeHandler(BackgroundParserHandlerPriority.Medium, this);
        }
コード例 #6
0
 public static void Format(this ITextBuffer buffer, TextSpan span, IOptionsService optionsService, VisualStudioSourceTextFactory sourceTextFactory)
 {
     SyntaxTree syntaxTree;
     if (!TryGetSyntaxTree(buffer, sourceTextFactory, out syntaxTree))
         return;
     var edits = Formatter.GetEdits(syntaxTree,
         span,
         optionsService.FormattingOptions);
     ApplyEdits(buffer, edits);
 }
コード例 #7
0
 public BraceCompletionContext(
     ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager, 
     HlslClassificationService classificationService, IOptionsService optionsService,
     VisualStudioSourceTextFactory sourceTextFactory)
 {
     _smartIndentationService = smartIndentationService;
     _undoManager = undoManager;
     _classificationService = classificationService;
     _optionsService = optionsService;
     _sourceTextFactory = sourceTextFactory;
 }
コード例 #8
0
        public FormatCommandTarget(IVsTextView adapter, IWpfTextView textView, IOptionsService optionsService, VisualStudioSourceTextFactory sourceTextFactory)
        {
            _textView = textView;
            _optionsService = optionsService;
            _sourceTextFactory = sourceTextFactory;

            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);
        }
コード例 #9
0
 public NavigateToItemProvider(
     IBufferGraphFactoryService bufferGraphFactoryService, 
     NavigateToItemProviderFactory navigateToItemProviderFactory, 
     DispatcherGlyphService glyphService,
     IServiceProvider serviceProvider,
     VisualStudioSourceTextFactory sourceTextFactory)
 {
     _bufferGraphFactoryService = bufferGraphFactoryService;
     _navigateToItemProviderFactory = navigateToItemProviderFactory;
     _glyphService = glyphService;
     _serviceProvider = serviceProvider;
     _sourceTextFactory = sourceTextFactory;
 }
コード例 #10
0
ファイル: Extensions.cs プロジェクト: pminiszewski/HlslTools
        public static SyntaxTree GetSyntaxTree(this ITextSnapshot snapshot, VisualStudioSourceTextFactory sourceTextFactory, CancellationToken cancellationToken)
        {
            return CachedSyntaxTrees.GetValue(snapshot, key =>
            {
                var sourceText = key.ToSourceText();

                var options = new ParserOptions();
                options.PreprocessorDefines.Add("__INTELLISENSE__");

                var fileSystem = key.TextBuffer.GetIncludeFileSystem(sourceTextFactory);

                return SyntaxFactory.ParseSyntaxTree(sourceText, options, fileSystem, cancellationToken);
            });
        }
コード例 #11
0
        // https://github.com/Microsoft/nodejstools/blob/master/Nodejs/Product/Nodejs/EditFilter.cs#L866
        public static void FormatAfterTyping(this ITextView textView, char ch, IOptionsService optionsService, VisualStudioSourceTextFactory sourceTextFactory)
        {
            if (!ShouldFormatOnCharacter(ch, optionsService))
                return;

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

            var edits = Formatter.GetEditsAfterKeystroke(syntaxTree,
                textView.Caret.Position.BufferPosition.Position, ch,
                optionsService.FormattingOptions);
            ApplyEdits(textView.TextBuffer, edits);
        }
コード例 #12
0
        public BackgroundParser(ITextBuffer textBuffer, VisualStudioSourceTextFactory sourceTextFactory)
        {
            _textBuffer = textBuffer;
            _sourceTextFactory = sourceTextFactory;

            _shutdownToken = new CancellationTokenSource();

            _hasWork = new ManualResetEventSlim(false);

            _syntaxTreeAvailableEventHandlers = new SortedList<BackgroundParserHandlerPriority, List<IBackgroundParserSyntaxTreeHandler>>();

            _textBuffer.ChangedHighPriority += OnTextBufferChanged;

            Task.Run(() => DoWork(), _shutdownToken.Token);
        }
コード例 #13
0
        private static bool TryGetSyntaxTree(ITextBuffer textBuffer, VisualStudioSourceTextFactory sourceTextFactory, out SyntaxTree syntaxTree)
        {
            try
            {
                var syntaxTreeTask = Task.Run(() => textBuffer.CurrentSnapshot.GetSyntaxTree(sourceTextFactory, CancellationToken.None));

                if (!syntaxTreeTask.Wait(TimeSpan.FromSeconds(5)))
                {
                    Logger.Log("Parsing timeout");
                    syntaxTree = null;
                    return false;
                }

                syntaxTree = syntaxTreeTask.Result;
                return true;
            }
            catch (Exception ex)
            {
                Logger.Log("Parsing error: " + ex);
                syntaxTree = null;
                return false;
            }
        }
コード例 #14
0
ファイル: Extensions.cs プロジェクト: pminiszewski/HlslTools
 public static BackgroundParser GetBackgroundParser(this ITextBuffer textBuffer, VisualStudioSourceTextFactory sourceTextFactory)
 {
     return textBuffer.Properties.GetOrCreateSingletonProperty(BackgroundParserKey,
         () => new BackgroundParser(textBuffer, sourceTextFactory));
 }
コード例 #15
0
ファイル: Extensions.cs プロジェクト: pminiszewski/HlslTools
 public static IIncludeFileSystem GetIncludeFileSystem(this ITextBuffer textBuffer, VisualStudioSourceTextFactory sourceTextFactory)
 {
     return textBuffer.Properties.GetOrCreateSingletonProperty(IncludeFileSystemKey,
         () => new VisualStudioFileSystem(textBuffer.GetTextContainer(), sourceTextFactory));
 }
コード例 #16
0
ファイル: SmartIndent.cs プロジェクト: pminiszewski/HlslTools
 public SmartIndent(SVsServiceProvider serviceProvider, VisualStudioSourceTextFactory sourceTextFactory)
 {
     _languagePreferences = serviceProvider.GetHlslToolsService().LanguagePreferences;
     _sourceTextFactory = sourceTextFactory;
 }
コード例 #17
0
 public VisualStudioFileSystem(VisualStudioSourceTextContainer textContainer, VisualStudioSourceTextFactory sourceTextFactory)
 {
     _sourceTextFactory = sourceTextFactory;
     if (textContainer.Filename != null)
         _parentDirectory = Path.GetDirectoryName(textContainer.Filename);
 }