internal TestErrorMargin(ITextView textView)
 {
     _textView = textView;
     _testMarginControl = new TestErrorMarginControl();
     _testMarginControl.ThrowError += OnThrowError;
     _textView.Caret.PositionChanged += OnCaretPositionChanged;
 }
		internal static void SetMargin(ITextView textView, ICustomLineNumberMargin margin) {
			if (textView == null)
				throw new ArgumentNullException(nameof(textView));
			if (margin == null)
				throw new ArgumentNullException(nameof(margin));
			textView.Properties.AddProperty(Key, margin);
		}
 public static ITaggerEventSource OnCompletionClosed(
     ITextView textView,
     IIntellisenseSessionStack sessionStack,
     TaggerDelay delay)
 {
     return new CompletionClosedEventSource(textView, sessionStack, delay);
 }
Exemple #4
0
        /// <summary>
        /// Ideally we should be checking for both the correct content type and some tag to indicate
        /// that this is actually hosted in the report expression editor.  I can't find such a tag though
        /// so go with the lesser property of the content type matching
        /// </summary>
        bool IsExpressionView(ITextView textView)
        {
            // First step is to check for the correct content type.  
            if (!textView.TextBuffer.ContentType.IsOfType(RdlContentTypeName))
            {
                return false;
            }

            // Next dig into the shims and look for the report context GUID
            var vsTextBuffer = _vsEditorAdaptersFactoryService.GetBufferAdapter(textView.TextBuffer);
            if (vsTextBuffer == null)
            {
                return false;
            }

            var vsUserData = vsTextBuffer as IVsUserData;
            if (vsUserData == null)
            {
                return false;
            }

            try
            {
                var guid = ReportContextGuid;
                object data;
                return ErrorHandler.Succeeded(vsUserData.GetData(ref guid, out data)) && data != null;
            }
            catch
            {
                return false;
            }
        }
		/// <summary>
		/// Sets the owner and must only be called once
		/// </summary>
		/// <param name="textView">Text view</param>
		/// <param name="owner">Owner</param>
		public static void SetOwner(ITextView textView, ICustomLineNumberMarginOwner owner) {
			if (textView == null)
				throw new ArgumentNullException(nameof(textView));
			if (owner == null)
				throw new ArgumentNullException(nameof(owner));
			GetMargin(textView).SetOwner(owner);
		}
        public ProvisionalText(ITextView textView, Span textSpan)
        {
            IgnoreChange = false;

            _textView = textView;

            var wpfTextView = (IWpfTextView)_textView;
            _layer = wpfTextView.GetAdornmentLayer("HtmlProvisionalTextHighlight");

            var textBuffer = _textView.TextBuffer;
            var snapshot = textBuffer.CurrentSnapshot;
            var provisionalCharSpan = new Span(textSpan.End - 1, 1);

            TrackingSpan = snapshot.CreateTrackingSpan(textSpan, SpanTrackingMode.EdgeExclusive);
            _textView.Caret.PositionChanged += OnCaretPositionChanged;

            textBuffer.Changed += OnTextBufferChanged;
            textBuffer.PostChanged += OnPostChanged;

            var projectionBuffer = _textView.TextBuffer as IProjectionBuffer;
            if (projectionBuffer != null)
            {
                projectionBuffer.SourceSpansChanged += OnSourceSpansChanged;
            }

            Color highlightColor = SystemColors.HighlightColor;
            Color baseColor = Color.FromArgb(96, highlightColor.R, highlightColor.G, highlightColor.B);
            _highlightBrush = new SolidColorBrush(baseColor);

            ProvisionalChar = snapshot.GetText(provisionalCharSpan)[0];
            HighlightSpan(provisionalCharSpan.Start);
        }
 public AbstractSnippetFunctionGenerateSwitchCases(AbstractSnippetExpansionClient snippetExpansionClient, ITextView textView, ITextBuffer subjectBuffer, string caseGenerationLocationField, string switchExpressionField)
     : base(snippetExpansionClient, textView, subjectBuffer)
 {
     this.CaseGenerationLocationField = caseGenerationLocationField;
     this.SwitchExpressionField = (switchExpressionField.Length >= 2 && switchExpressionField[0] == '$' && switchExpressionField[switchExpressionField.Length - 1] == '$')
         ? switchExpressionField.Substring(1, switchExpressionField.Length - 2) : switchExpressionField;
 }
        public ZoomableInlineAdornment(UIElement content, ITextView parent, Size desiredSize) {
            _parent = parent;
            Debug.Assert(parent is IInputElement);
            _originalSize = _desiredSize = new Size(
                Math.Max(double.IsNaN(desiredSize.Width) ? 100 : desiredSize.Width, 10),
                Math.Max(double.IsNaN(desiredSize.Height) ? 100 : desiredSize.Height, 10)
            );

            // First time through, we want to reduce the image to fit within the
            // viewport.
            if (_desiredSize.Width > parent.ViewportWidth) {
                _desiredSize.Width = parent.ViewportWidth;
                _desiredSize.Height = _originalSize.Height / _originalSize.Width * _desiredSize.Width;
            }
            if (_desiredSize.Height > parent.ViewportHeight) {
                _desiredSize.Height = parent.ViewportHeight;
                _desiredSize.Width = _originalSize.Width / _originalSize.Height * _desiredSize.Height;
            }

            ContextMenu = MakeContextMenu();

            Focusable = true;
            MinWidth = MinHeight = 50;

            Children.Add(content);

            GotFocus += OnGotFocus;
            LostFocus += OnLostFocus;
        }
 public ViewSpanChangedEventSource(ITextView textView, TaggerDelay textChangeDelay, TaggerDelay scrollChangeDelay)
 {
     Debug.Assert(textView != null);
     _textView = textView;
     _textChangeDelay = textChangeDelay;
     _scrollChangeDelay = scrollChangeDelay;
 }
Exemple #10
0
 /// <summary>
 /// Creates a new smart tag action for a "from fob import oar" smart tag.
 /// </summary>
 public ImportSmartTagAction(string fromName, string name, ITextBuffer buffer, ITextView view, IServiceProvider serviceProvider)
     : base(serviceProvider, RefactoringIconKind.AddUsing) {
     FromName = fromName;
     Name = name;
     _buffer = buffer;
     _view = view;
 }
        public ISuggestedActionsSource CreateSuggestedActionsSource(ITextView textView, ITextBuffer textBuffer)
        {
            Contract.ThrowIfNull(textView);
            Contract.ThrowIfNull(textBuffer);

            return new Source(this, textView, textBuffer);
        }
		/// <summary>
		/// Returns the <see cref="ScriptControlVM"/> instance if it has been added by <see cref="AddInstance(ScriptControlVM, ITextView)"/>
		/// </summary>
		/// <param name="textView">Text view</param>
		/// <returns></returns>
		public static ScriptControlVM TryGetInstance(ITextView textView) {
			if (textView == null)
				throw new ArgumentNullException(nameof(textView));
			ScriptControlVM vm;
			textView.Properties.TryGetProperty(Key, out vm);
			return vm;
		}
        public bool TryGetController(ITextView textView, ITextBuffer subjectBuffer, out Controller controller)
        {
            AssertIsForeground();

            // check whether this feature is on.
            if (!subjectBuffer.GetOption(InternalFeatureOnOffOptions.CompletionSet))
            {
                controller = null;
                return false;
            }

            // If we don't have a presenter, then there's no point in us even being involved.  Just
            // defer to the next handler in the chain.

            // Also, if there's an inline rename session then we do not want completion.
            if (_completionPresenter == null || _inlineRenameService.ActiveSession != null)
            {
                controller = null;
                return false;
            }

            var autobraceCompletionCharSet = GetAllAutoBraceCompletionChars(subjectBuffer.ContentType);
            controller = Controller.GetInstance(
                textView, subjectBuffer,
                _editorOperationsFactoryService, _undoHistoryRegistry, _completionPresenter,
                new AggregateAsynchronousOperationListener(_asyncListeners, FeatureAttribute.CompletionSet),
                _allCompletionProviders, autobraceCompletionCharSet);

            return true;
        }
        public ShowContextMenuCommand(ITextView textView, Guid packageGuid, Guid cmdSetGuid, int menuId)
            : base(textView, new CommandId(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.SHOWCONTEXTMENU), false) {

            _cmdSetGuid = cmdSetGuid;
            _packageGuid = packageGuid;
            _menuId = menuId;
        }
		/// <summary>
		/// Adds the <see cref="ScriptControlVM"/> instance to the <see cref="ITextView"/> properties
		/// </summary>
		/// <param name="vm">Script control</param>
		/// <param name="textView">REPL editor text view</param>
		public static void AddInstance(ScriptControlVM vm, ITextView textView) {
			if (vm == null)
				throw new ArgumentNullException(nameof(vm));
			if (textView == null)
				throw new ArgumentNullException(nameof(textView));
			textView.Properties.AddProperty(Key, vm);
		}
        public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
        {
            HexColorValue hex = (HexColorValue)item;

            if (!item.IsValid)
                yield break;

            ColorModel model = ColorParser.TryParseColor(hex.Text, ColorParser.Options.None);
            if (model != null)
            {
                if (ColorConverterSmartTagAction.GetNamedColor(model.Color) != null)
                {
                    yield return new ColorConverterSmartTagAction(itemTrackingSpan, hex, model, ColorFormat.Name);
                }

                if (model.Format == ColorFormat.RgbHex6)
                {
                    string hex3 = ColorFormatter.FormatColor(model, ColorFormat.RgbHex3);

                    if (hex3.Length == 4)
                    {
                        yield return new ColorConverterSmartTagAction(itemTrackingSpan, hex, model, ColorFormat.RgbHex3);
                    }
                }

                yield return new ColorConverterSmartTagAction(itemTrackingSpan, hex, model, ColorFormat.Rgb);
                yield return new ColorConverterSmartTagAction(itemTrackingSpan, hex, model, ColorFormat.Hsl);
            }
        }
 public void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
     _textBuffer = _textView.TextBuffer;
     _factory = new MockRepository(MockBehavior.Strict);
     _editOpts = _factory.Create<IEditorOperations>();
     _vimHost = _factory.Create<IVimHost>();
     _vimHost.Setup(x => x.IsDirty(It.IsAny<ITextBuffer>())).Returns(false);
     _operations = _factory.Create<ICommonOperations>();
     _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object);
     _statusUtil = _factory.Create<IStatusUtil>();
     _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
     _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
     _vimData = new VimData();
     _vim = MockObjectFactory.CreateVim(RegisterMap, host: _vimHost.Object, vimData: _vimData, factory: _factory);
     var localSettings = new LocalSettings(Vim.GlobalSettings);
     var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(
         _textBuffer,
         vim: _vim.Object,
         localSettings: localSettings,
         factory: _factory);
     var vimBufferData = CreateVimBufferData(
         vimTextBuffer.Object,
         _textView,
         statusUtil: _statusUtil.Object);
     var vimBuffer = CreateVimBuffer(vimBufferData);
     _interpreter = new Interpreter.VimInterpreter(
         vimBuffer,
         _operations.Object,
         _foldManager.Object,
         _fileSystem.Object,
         _factory.Create<IBufferTrackingService>().Object);
 }
        public ZoomableInlineAdornment(UIElement content, ITextView parent) {
            _parent = parent;
            Debug.Assert(parent is IInputElement);
            Content = new Border { BorderThickness = new Thickness(1), Child = content, Focusable = true };

            _zoom = 1.0;             // config.GetConfig().Repl.InlineMedia.MaximizedZoom
            _zoomStep = 0.25;        // config.GetConfig().Repl.InlineMedia.ZoomStep
            _minimizedZoom = 0.25;   // config.GetConfig().Repl.InlineMedia.MinimizedZoom
            _widthRatio = 0.67;      // config.GetConfig().Repl.InlineMedia.WidthRatio
            _heightRatio = 0.5;      // config.GetConfig().Repl.InlineMedia.HeightRatio

            _isResizing = false;
            UpdateSize();

            GotFocus += OnGotFocus;
            LostFocus += OnLostFocus;

            ContextMenu = MakeContextMenu();

            var trigger = new Trigger { Property = Border.IsFocusedProperty, Value = true };
            var setter = new Setter { Property = Border.BorderBrushProperty, Value = SystemColors.ActiveBorderBrush };
            trigger.Setters.Add(setter);

            var style = new Style();
            style.Triggers.Add(trigger);
            MyContent.Style = style;
        }
Exemple #19
0
 private static QuickInfo GetQuickInfo(ITextView view) {
     QuickInfo quickInfo;
     if (view.Properties.TryGetProperty(typeof(QuickInfo), out quickInfo)) {
         return quickInfo;
     }
     return null;
 }
Exemple #20
0
        /// <summary>
        /// Create a Visual Studio simulation with the specified set of lines
        /// </summary>
        private void CreateCore(bool simulateResharper, bool usePeekRole, params string[] lines)
        {
            if (usePeekRole)
            {
                _textBuffer = CreateTextBuffer(lines);
                _textView = TextEditorFactoryService.CreateTextView(
                    _textBuffer,
                    TextEditorFactoryService.CreateTextViewRoleSet(PredefinedTextViewRoles.Document, PredefinedTextViewRoles.Editable, Constants.TextViewRoleEmbeddedPeekTextView));
            }
            else
            {
                _textView = CreateTextView(lines);
                _textBuffer = _textView.TextBuffer;
            }
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
            _vsSimulation = new VsSimulation(
                _bufferCoordinator,
                simulateResharper: simulateResharper,
                simulateStandardKeyMappings: false,
                editorOperationsFactoryService: EditorOperationsFactoryService,
                keyUtil: KeyUtil);

            VimHost.TryCustomProcessFunc = (textView, insertCommand) =>
                {
                    if (textView == _textView)
                    {
                        return _vsSimulation.VsCommandTarget.TryCustomProcess(insertCommand);
                    }

                    return false;
                };
        }
        public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
        {
            Declaration dec = (Declaration)item;

            if (!item.IsValid || position > dec.Colon.Start)
                yield break;

            RuleBlock rule = dec.FindType<RuleBlock>();
            if (!rule.IsValid)
                yield break;

            ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaRootForBuffer(itemTrackingSpan.TextBuffer);

            if (!dec.IsVendorSpecific())
            {
                IEnumerable<Declaration> vendors = VendorHelpers.GetMatchingVendorEntriesInRule(dec, rule, schema);
                if (vendors.Any(v => v.Start > dec.Start))
                {
                    yield return new VendorOrderSmartTagAction(itemTrackingSpan, vendors.Last(), dec);
                }
            }
            else
            {
                ICssCompletionListEntry entry = VendorHelpers.GetMatchingStandardEntry(dec, schema);
                if (entry != null && !rule.Declarations.Any(d => d.PropertyName != null && d.PropertyName.Text == entry.DisplayText))
                {
                    yield return new MissingStandardSmartTagAction(itemTrackingSpan, dec, entry.DisplayText);
                }
            }
        }
 public AbstractSnippetExpansionClient(Guid languageServiceGuid, ITextView textView, ITextBuffer subjectBuffer, IVsEditorAdaptersFactoryService editorAdaptersFactoryService)
 {
     this.LanguageServiceGuid = languageServiceGuid;
     this.TextView = textView;
     this.SubjectBuffer = subjectBuffer;
     this.EditorAdaptersFactoryService = editorAdaptersFactoryService;
 }
        /// <summary>
        /// Attaches events for invoking Statement completion 
        /// </summary>
        public IntellisenseController(IntellisenseControllerProvider provider, ITextView textView) {
            _textView = textView;
            _provider = provider;
            textView.Properties.AddProperty(typeof(IntellisenseController), this);  // added so our key processors can get back to us

            _intelliSenseManager = new IntelliSenseManager(provider._CompletionBroker, provider.ServiceProvider, null, textView);
        }
 public CompletionModelManager(ITextView textView, ICompletionBroker completionBroker, CompletionProviderService completionProviderService)
 {
     _textView = textView;
     _textView.TextBuffer.PostChanged += OnTextBufferOnPostChanged;
     _completionBroker = completionBroker;
     _completionProviderService = completionProviderService;
 }
		string GenerateHtmlFragmentCore(NormalizedSnapshotSpanCollection spans, ITextView textView, string delimiter, CancellationToken cancellationToken) {
			ISynchronousClassifier classifier = null;
			try {
				int tabSize;
				IClassificationFormatMap classificationFormatMap;
				if (textView != null) {
					classifier = synchronousViewClassifierAggregatorService.GetSynchronousClassifier(textView);
					classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(textView);
					tabSize = textView.Options.GetTabSize();
				}
				else {
					classifier = spans.Count == 0 ? null : synchronousClassifierAggregatorService.GetSynchronousClassifier(spans[0].Snapshot.TextBuffer);
					classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.TextEditor);
					tabSize = defaultTabSize;
				}
				tabSize = OptionsHelpers.FilterTabSize(tabSize);

				var builder = new HtmlBuilder(classificationFormatMap, delimiter, tabSize);
				if (spans.Count != 0)
					builder.Add(classifier, spans, cancellationToken);
				return builder.Create();
			}
			finally {
				(classifier as IDisposable)?.Dispose();
			}
		}
 public void Detach(ITextView detacedTextView)
 {
     if (textView == detacedTextView)
     {
         textView = null;
     }
 }
        internal TypeCharFilter(IVsTextView adapter, ITextView textView, TypingSpeedMeter adornment)
        {
            this.textView = textView;
            this.adornment = adornment;

            adapter.AddCommandFilter(this, out nextCommandHandler);
        }
 public void Detach(ITextView detacedTextView)
 {
     if (textView == detacedTextView)
     {
         textDocument.DirtyStateChanged -= OnDocumentDirtyStateChanged;
     }
 }
 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));
 }
        public SnapshotSpanNavigateToTarget(ITextView textView, SnapshotSpan snapshotSpan)
        {
            Contract.Requires<ArgumentNullException>(textView != null, "textView");

            this._textView = textView;
            this._snapshotSpan = snapshotSpan;
        }
 protected override IEnumerable <SnapshotSpan> GetSpansToTag(ITextView textViewOpt, ITextBuffer subjectBuffer)
 {
     return(textViewOpt.BufferGraph.GetTextBuffers(b => IsSupportedContentType(b.ContentType))
            .Select(b => b.CurrentSnapshot.GetFullSpan())
            .ToList());
 }
        private bool TryGenerateDocumentationCommentAfterEnter(
            SyntaxTree syntaxTree,
            SourceText text,
            int position,
            int originalPosition,
            ITextBuffer subjectBuffer,
            ITextView textView,
            DocumentOptionSet options,
            CancellationToken cancellationToken)
        {
            // Find the documentation comment before the new line that was just pressed
            var token = GetTokenToLeft(syntaxTree, position, cancellationToken);

            if (!IsDocCommentNewLine(token))
            {
                return(false);
            }

            var documentationComment = token.GetAncestor <TDocumentationComment>();

            if (!IsSingleExteriorTrivia(documentationComment))
            {
                return(false);
            }

            var targetMember = GetTargetMember(documentationComment);

            if (targetMember == null)
            {
                return(false);
            }

            // Ensure that the target member is only preceded by a single documentation comment (our ///).
            if (GetPrecedingDocumentationCommentCount(targetMember) != 1)
            {
                return(false);
            }

            var line = text.Lines.GetLineFromPosition(documentationComment.FullSpan.Start);

            if (line.IsEmptyOrWhitespace())
            {
                return(false);
            }

            var lines = GetDocumentationCommentStubLines(targetMember);

            Contract.Assume(lines.Count > 2);

            AddLineBreaks(text, lines);

            // Shave off initial exterior trivia
            lines[0] = lines[0].Substring(3);

            // Add indents
            var lineOffset = line.GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine(options.GetOption(FormattingOptions.TabSize));
            var indentText = lineOffset.CreateIndentationString(options.GetOption(FormattingOptions.UseTabs), options.GetOption(FormattingOptions.TabSize));

            for (int i = 1; i < lines.Count; i++)
            {
                lines[i] = indentText + lines[i];
            }

            var newText = string.Join(string.Empty, lines);
            var offset  = lines[0].Length + lines[1].Length - GetNewLine(text).Length;

            // Shave off final line break or add trailing indent if necessary
            var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position, findInsideTrivia: false);

            if (IsEndOfLineTrivia(trivia))
            {
                newText = newText.Substring(0, newText.Length - GetNewLine(text).Length);
            }
            else
            {
                newText += indentText;
            }

            var replaceSpan         = token.Span.ToSpan();
            var currentLine         = text.Lines.GetLineFromPosition(position);
            var currentLinePosition = currentLine.GetFirstNonWhitespacePosition();

            if (currentLinePosition.HasValue)
            {
                replaceSpan = Span.FromBounds(replaceSpan.Start, currentLinePosition.Value);
            }

            subjectBuffer.Replace(replaceSpan, newText);
            textView.TryMoveCaretToAndEnsureVisible(subjectBuffer.CurrentSnapshot.GetPoint(replaceSpan.Start + offset));

            return(true);
        }
        private bool InsertOnCharacterTyped(
            SyntaxTree syntaxTree,
            SourceText text,
            int position,
            int originalPosition,
            ITextBuffer subjectBuffer,
            ITextView textView,
            DocumentOptionSet options,
            CancellationToken cancellationToken)
        {
            if (!subjectBuffer.GetFeatureOnOffOption(FeatureOnOffOptions.AutoXmlDocCommentGeneration))
            {
                return(false);
            }

            // Only generate if the position is immediately after '///',
            // and that is the only documentation comment on the target member.

            var token = syntaxTree.GetRoot(cancellationToken).FindToken(position, findInsideTrivia: true);

            if (position != token.SpanStart)
            {
                return(false);
            }

            var documentationComment = token.GetAncestor <TDocumentationComment>();

            if (!IsSingleExteriorTrivia(documentationComment))
            {
                return(false);
            }

            var targetMember = GetTargetMember(documentationComment);

            if (targetMember == null)
            {
                return(false);
            }

            // Ensure that the target member is only preceded by a single documentation comment (i.e. our ///).
            if (GetPrecedingDocumentationCommentCount(targetMember) != 1)
            {
                return(false);
            }

            var line = text.Lines.GetLineFromPosition(documentationComment.FullSpan.Start);

            if (line.IsEmptyOrWhitespace())
            {
                return(false);
            }

            var lines = GetDocumentationCommentStubLines(targetMember);

            Contract.Assume(lines.Count > 2);

            AddLineBreaks(text, lines);

            // Shave off initial three slashes
            lines[0] = lines[0].Substring(3);

            // Add indents
            var lineOffset = line.GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine(options.GetOption(FormattingOptions.TabSize));
            var indentText = lineOffset.CreateIndentationString(options.GetOption(FormattingOptions.UseTabs), options.GetOption(FormattingOptions.TabSize));

            for (int i = 1; i < lines.Count - 1; i++)
            {
                lines[i] = indentText + lines[i];
            }

            var lastLine = lines[lines.Count - 1];

            lastLine = indentText + lastLine.Substring(0, lastLine.Length - GetNewLine(text).Length);
            lines[lines.Count - 1] = lastLine;

            var newText = string.Join(string.Empty, lines);
            var offset  = lines[0].Length + lines[1].Length - GetNewLine(text).Length;

            subjectBuffer.Insert(position, newText);
            textView.TryMoveCaretToAndEnsureVisible(subjectBuffer.CurrentSnapshot.GetPoint(position + offset));

            return(true);
        }
Exemple #34
0
 public IIntellisenseController TryCreateIntellisenseController(ITextView textView, IList <ITextBuffer> subjectBuffers)
 {
     return(new XSharpQuickInfoController(textView, subjectBuffers, this));
 }
 public ITagger <T> CreateTagger <T> (ITextView textView, ITextBuffer buffer) where T : ITag
 {
     return(new ReturnStatementTagger(textView) as ITagger <T>);
 }
 public new static ReplCommandController FromTextView(ITextView textView) => textView.GetService <ReplCommandController>();
        public static ReplCommandController Attach(ITextView textView, ITextBuffer textBuffer, IServiceContainer services)
        {
            var controller = FromTextView(textView);

            return(controller ?? new ReplCommandController(textView, textBuffer, services));
        }
 ViewClassificationFormatMap CreateViewClassificationFormatMap(ITextView textView)
 {
     textView.Closed += TextView_Closed;
     return(new TextViewClassificationFormatMap(this, textView));
 }
Exemple #39
0
 internal UnderlineClassifier(ITextView textView, IClassificationType classificationType)
 {
     _textView           = textView;
     _classificationType = classificationType;
     _underlineSpan      = null;
 }
 protected override SnapshotPoint?GetCaretPoint(ITextView textViewOpt, ITextBuffer subjectBuffer)
 {
     return(textViewOpt.Caret.Position.Point.GetPoint(b => IsSupportedContentType(b.ContentType), PositionAffinity.Successor));
 }
Exemple #41
0
 void IObscuringTipManager.PushTip(ITextView view, IObscuringTip tip)
 {
 }
Exemple #42
0
 public SnippetExpansionClient(Guid languageServiceGuid, ITextView textView, ITextBuffer subjectBuffer, IVsEditorAdaptersFactoryService editorAdaptersFactoryService)
     : base(languageServiceGuid, textView, subjectBuffer, editorAdaptersFactoryService)
 {
 }
 protected abstract Task <bool> TryNavigateToItemAsync(Document document, WrappedNavigationBarItem item, ITextView textView, ITextVersion textVersion, CancellationToken cancellationToken);
Exemple #44
0
 void IObscuringTipManager.RemoveTip(ITextView view, IObscuringTip tip)
 {
 }
Exemple #45
0
 public Indent(SmartIndentProvider provider, ITextView view)
 {
     _provider = provider;
     _textView = view;
 }
 public Task <bool> TryNavigateToItemAsync(Document document, NavigationBarItem item, ITextView textView, ITextVersion textVersion, CancellationToken cancellationToken)
 => TryNavigateToItemAsync(document, (WrappedNavigationBarItem)item, textView, textVersion, cancellationToken);
Exemple #47
0
 /// <summary>
 /// Returns whether the <see cref="ITextView"/> is in immediate window.
 /// We use this to make the view temporarily writable during commit (it is typically read-only).
 /// </summary>
 /// <param name="textView">View to examine</param>
 /// <returns>True if the view has "COMMANDVIEW" text view role.</returns>
 internal static bool IsImmediateTextView(ITextView textView) => textView.Roles.Contains("COMMANDVIEW");
Exemple #48
0
 public ISmartIndent CreateSmartIndent(ITextView textView)
 {
     return(new Indent(this, textView));
 }
Exemple #49
0
 /// <summary>
 /// Maps given point to buffers that contain this point. Requires UI thread.
 /// </summary>
 /// <param name="textView"></param>
 /// <param name="point"></param>
 /// <returns></returns>
 internal static IEnumerable <ITextBuffer> GetBuffersForPoint(ITextView textView, SnapshotPoint point)
 {
     // We are looking at the buffer to the left of the caret.
     return(textView.BufferGraph.GetTextBuffers(n =>
                                                textView.BufferGraph.MapDownToBuffer(point, PointTrackingMode.Negative, n, PositionAffinity.Predecessor) != null));
 }
Exemple #50
0
 internal static bool GetNonBlockingCompletionOption(ITextView textView)
 {
     return(textView.Options.GetOptionValue(DefaultOptions.NonBlockingCompletionOptionId));
 }
Exemple #51
0
 internal static bool GetResponsiveCompletionOption(ITextView textView)
 {
     return(textView.Options.GetOptionValue(DefaultOptions.ResponsiveCompletionOptionId));
     //&& textView.Options.GetOptionValue(DefaultOptions.RemoteControlledResponsiveCompletionOptionId);
 }
Exemple #52
0
 /// <summary>
 /// Returns whether the <see cref="ITextView"/> is furnished by the debugger,
 /// e.g. it is a view in the breakpoint settings window or watch window.
 /// We use this to pick an appropriate option with suggestion mode setting.
 /// </summary>
 /// <param name="textView">View to examine</param>
 /// <returns>True if the view has "DEBUGVIEW" text view role.</returns>
 internal static bool IsDebuggerTextView(ITextView textView) => textView.Roles.Contains("DEBUGVIEW");
Exemple #53
0
 ISignatureHelpPresenterSession IIntelliSensePresenter <ISignatureHelpPresenterSession, ISignatureHelpSession> .CreateSession(ITextView textView, ITextBuffer subjectBuffer, ISignatureHelpSession sessionOpt)
 {
     AssertIsForeground();
     return(new SignatureHelpPresenterSession(ThreadingContext, _sigHelpBroker, textView, subjectBuffer));
 }
Exemple #54
0
 internal static int GetResponsiveCompletionThresholdOption(ITextView textView)
 {
     return(textView.Options.GetOptionValue(DefaultOptions.ResponsiveCompletionThresholdOptionId));
 }
 public InvokeCompletionListCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer)
 {
 }
 public static LineSeparatorViewTagger GetInstance(ITextView textView) =>
 textView.Properties.GetOrCreateSingletonProperty(typeof(LineSeparatorViewTagger), () => new LineSeparatorViewTagger(textView));
 bool IVisualModeSelectionOverride.IsInsertModePreferred(ITextView textView)
 {
     return(_inSearch);
 }
Exemple #58
0
 /// <summary>
 /// Creates compound undo action
 /// </summary>
 /// <param name="textView">Text view</param>
 /// <param name="textBuffer">Text buffer</param>
 /// <returns>Undo action instance</returns>
 public ICompoundUndoAction CreateCompoundAction(ITextView textView, ITextBuffer textBuffer)
 {
     return(new CompoundUndoAction(textView, this, addRollbackOnCancel: true));
 }
Exemple #59
0
 public static IEnumerable <PythonTextBufferInfo> GetAllFromView(ITextView view)
 {
     return(view.BufferGraph.GetTextBuffers(_ => true)
            .Select(b => TryGetForBuffer(b))
            .Where(b => b != null));
 }
        private bool Execute(
            ITextBuffer textBuffer,
            ITextView view,
            IUIThreadOperationContext waitContext)
        {
            var cancellationToken = waitContext.UserCancellationToken;

            var spans = view.Selection.GetSnapshotSpansOnBuffer(textBuffer);

            if (spans.Count(s => s.Length > 0) != 1)
            {
                return(false);
            }

            var document = textBuffer.CurrentSnapshot.GetFullyLoadedOpenDocumentInCurrentContextWithChanges(
                waitContext, _threadingContext);

            if (document == null)
            {
                return(false);
            }

            var result = ExtractMethodService.ExtractMethodAsync(
                document, spans.Single().Span.ToTextSpan(), localFunction: false, cancellationToken: cancellationToken).WaitAndGetResult(cancellationToken);

            Contract.ThrowIfNull(result);

            if (!result.Succeeded && !result.SucceededWithSuggestion)
            {
                // if it failed due to out/ref parameter in async method, try it with different option
                var newResult = TryWithoutMakingValueTypesRef(document, spans, result, cancellationToken);
                if (newResult != null)
                {
                    var notificationService = document.Project.Solution.Workspace.Services.GetService <INotificationService>();
                    if (notificationService != null)
                    {
                        // We are about to show a modal UI dialog so we should take over the command execution
                        // wait context. That means the command system won't attempt to show its own wait dialog
                        // and also will take it into consideration when measuring command handling duration.
                        waitContext.TakeOwnership();
                        if (!notificationService.ConfirmMessageBox(
                                EditorFeaturesResources.Extract_method_encountered_the_following_issues + Environment.NewLine + Environment.NewLine +
                                string.Join(Environment.NewLine, result.Reasons) + Environment.NewLine + Environment.NewLine +
                                EditorFeaturesResources.We_can_fix_the_error_by_not_making_struct_out_ref_parameter_s_Do_you_want_to_proceed,
                                title: EditorFeaturesResources.Extract_Method,
                                severity: NotificationSeverity.Error))
                        {
                            // We handled the command, displayed a notification and did not produce code.
                            return(true);
                        }
                    }

                    // reset result
                    result = newResult;
                }
                else if (TryNotifyFailureToUser(document, result, waitContext))
                {
                    // We handled the command, displayed a notification and did not produce code.
                    return(true);
                }
            }

            // apply the change to buffer
            // get method name token
            ApplyChangesToBuffer(result, textBuffer, cancellationToken);

            // start inline rename
            var methodNameAtInvocation  = result.InvocationNameToken;
            var snapshotAfterFormatting = textBuffer.CurrentSnapshot;
            var documentAfterFormatting = snapshotAfterFormatting.GetOpenDocumentInCurrentContextWithChanges();

            _renameService.StartInlineSession(documentAfterFormatting, methodNameAtInvocation.Span, cancellationToken);

            // select invocation span
            view.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(snapshotAfterFormatting, methodNameAtInvocation.Span.End));
            view.SetSelection(
                methodNameAtInvocation.Span.ToSnapshotSpan(snapshotAfterFormatting));

            return(true);
        }