当前位置: 首页>>代码示例>>C#>>正文


C# ITextBuffer.AsTextContainer方法代码示例

本文整理汇总了C#中ITextBuffer.AsTextContainer方法的典型用法代码示例。如果您正苦于以下问题:C# ITextBuffer.AsTextContainer方法的具体用法?C# ITextBuffer.AsTextContainer怎么用?C# ITextBuffer.AsTextContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITextBuffer的用法示例。


在下文中一共展示了ITextBuffer.AsTextContainer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TagComputer

            public TagComputer(
                ITextBuffer subjectBuffer,
                IForegroundNotificationService notificationService,
                IAsynchronousOperationListener asyncListener,
                ClassificationTypeMap typeMap,
                SyntacticClassificationTaggerProvider taggerProvider)
            {
                _subjectBuffer = subjectBuffer;
                _notificationService = notificationService;
                _listener = asyncListener;
                _typeMap = typeMap;
                _taggerProvider = taggerProvider;

                _workQueue = new AsynchronousSerialWorkQueue(asyncListener);
                _reportChangeCancellationSource = new CancellationTokenSource();

                _lastLineCache = new LastLineCache();

                _workspaceRegistration = Workspace.GetWorkspaceRegistration(subjectBuffer.AsTextContainer());
                _workspaceRegistration.WorkspaceChanged += OnWorkspaceRegistrationChanged;

                if (_workspaceRegistration.Workspace != null)
                {
                    ConnectToWorkspace(_workspaceRegistration.Workspace);
                }
            }
开发者ID:jkotas,项目名称:roslyn,代码行数:26,代码来源:SyntacticClassificationTaggerProvider.TagComputer.cs

示例2: NavigationBarController

        public NavigationBarController(
            INavigationBarPresenter presenter,
            ITextBuffer subjectBuffer,
            IWaitIndicator waitIndicator,
            IAsynchronousOperationListener asyncListener)
        {
            _presenter = presenter;
            _subjectBuffer = subjectBuffer;
            _waitIndicator = waitIndicator;
            _asyncListener = asyncListener;
            _workspaceRegistration = Workspace.GetWorkspaceRegistration(subjectBuffer.AsTextContainer());
            _workspaceRegistration.WorkspaceChanged += OnWorkspaceRegistrationChanged;

            presenter.CaretMoved += OnCaretMoved;
            presenter.ViewFocused += OnViewFocused;

            presenter.DropDownFocused += OnDropDownFocused;
            presenter.ItemSelected += OnItemSelected;

            subjectBuffer.PostChanged += OnSubjectBufferPostChanged;

            // Initialize the tasks to be an empty model so we never have to deal with a null case.
            _modelTask = Task.FromResult(
                new NavigationBarModel(
                    SpecializedCollections.EmptyList<NavigationBarItem>(),
                    default(VersionStamp),
                    null));

            _selectedItemInfoTask = Task.FromResult(new NavigationBarSelectedTypeAndMember(null, null));

            if (_workspaceRegistration.Workspace != null)
            {
                ConnectToWorkspace(_workspaceRegistration.Workspace);
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:35,代码来源:NavigationBarController.cs

示例3: TryGetTextUndoHistory

            public bool TryGetTextUndoHistory(Workspace editorWorkspace, ITextBuffer textBuffer, out ITextUndoHistory undoHistory)
            {
                undoHistory = null;

                if (!(editorWorkspace is VisualStudioWorkspaceImpl) &&
                    !(editorWorkspace is MiscellaneousFilesWorkspace))
                {
                    return false;
                }

                // TODO: Handle undo if context changes
                var documentId = editorWorkspace.GetDocumentIdInCurrentContext(textBuffer.AsTextContainer());
                if (documentId == null)
                {
                    return false;
                }

                var document = GetDocument(editorWorkspace, documentId);
                if (document == null)
                {
                    return false;
                }

                undoHistory = document.GetTextUndoHistory();
                return true;
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:26,代码来源:VisualStudioTextUndoHistoryWorkspaceServiceFactory.cs

示例4: CreateDocument

        ///<summary>Creates a new document linked to an existing text buffer.</summary>
        public DocumentId CreateDocument(ProjectId projectId, ITextBuffer buffer, string debugName = null)
        {
            var id = DocumentId.CreateNewId(projectId, debugName);

            TryApplyChanges(CurrentSolution.AddDocument(id, debugName ?? "Sample Document", TextLoader.From(buffer.AsTextContainer(), VersionStamp.Create())));
            OpenDocument(id, buffer);
            return id;
        }
开发者ID:blinds52,项目名称:VSEmbed,代码行数:9,代码来源:EditorWorkspace.cs

示例5: CreateDocument

            ///<summary>Creates a new document linked to an existing text buffer.</summary>
            public DocumentId CreateDocument(ProjectId projectId, ITextBuffer buffer)
            {
                // Our GetFileName() extension (which should probably be deleted) doesn't work on projection buffers
                var debugName = TextBufferExtensions.GetFileName(buffer) ?? "Markdown Embedded Code";
                var id = DocumentId.CreateNewId(projectId, debugName);

                TryApplyChanges(CurrentSolution.AddDocument(
                    id, debugName,
                    TextLoader.From(buffer.AsTextContainer(), VersionStamp.Create())
                ));
                OpenDocument(id, buffer);
                return id;
            }
开发者ID:jvanrhyn,项目名称:WebEssentials2015,代码行数:14,代码来源:RoslynEmbedder.cs

示例6: CreateDocument

            ///<summary>Creates a new document linked to an existing text buffer.</summary>
            public Document CreateDocument(ProjectId projectId, ITextBuffer buffer)
            {
                var id = DocumentId.CreateNewId(projectId);
                documentBuffers.Add(id, buffer);

                // Our GetFileName() extension (which should probably be deleted) doesn't work on projection buffers
                var docInfo = DocumentInfo.Create(id, TextBufferExtensions.GetFileName(buffer) ?? "Markdown Embedded Code",
                    loader: TextLoader.From(buffer.AsTextContainer(), VersionStamp.Create()),
                    sourceCodeKind: SourceCodeKind.Script
                );
                OnDocumentAdded(docInfo);
                OnDocumentOpened(id, buffer.AsTextContainer());
                buffer.Changed += delegate { OnDocumentContextUpdated(id); };
                return CurrentSolution.GetDocument(id);
            }
开发者ID:irongiant,项目名称:WebEssentials2015,代码行数:16,代码来源:RoslynEmbedder.cs

示例7: SetSubmissionDocument

        private void SetSubmissionDocument(ITextBuffer buffer, Project project)
        {
            var documentId = DocumentId.CreateNewId(project.Id, debugName: project.Name);
            var solution = project.Solution
                .AddDocument(documentId, project.Name, buffer.CurrentSnapshot.AsText());

            _workspace.SetCurrentSolution(solution);

            // opening document will start workspace listening to changes in this text container
            _workspace.OpenDocument(documentId, buffer.AsTextContainer());
        }
开发者ID:nevinclement,项目名称:roslyn,代码行数:11,代码来源:InteractiveEvaluator.cs

示例8: Source

            public Source(SuggestedActionsSourceProvider owner, ITextView textView, ITextBuffer textBuffer)
            {
                _owner = owner;
                _textView = textView;
                _textView.Closed += OnTextViewClosed;

                _subjectBuffer = textBuffer;
                _registration = Workspace.GetWorkspaceRegistration(textBuffer.AsTextContainer());

                _lastSolutionVersionReported = InvalidSolutionVersion;
                var updateSource = (IDiagnosticUpdateSource)_owner._diagnosticService;
                updateSource.DiagnosticsUpdated += OnDiagnosticsUpdated;

                if (_registration.Workspace != null)
                {
                    _workspace = _registration.Workspace;
                    _workspace.DocumentActiveContextChanged += OnActiveContextChanged;
                }

                _registration.WorkspaceChanged += OnWorkspaceChanged;
            }
开发者ID:JackWangCUMT,项目名称:roslyn,代码行数:21,代码来源:SuggestedActionsSourceProvider.cs

示例9: TagComputer

            public TagComputer(
                ITextBuffer subjectBuffer,
                IForegroundNotificationService notificationService,
                IAsynchronousOperationListener asyncListener,
                ClassificationTypeMap typeMap,
                SyntacticClassificationTaggerProvider taggerProvider,
                IViewSupportsClassificationService viewSupportsClassificationServiceOpt,
                ITextBufferAssociatedViewService associatedViewService,
                IEditorClassificationService editorClassificationService,
                string languageName)
            {
                _subjectBuffer = subjectBuffer;
                _notificationService = notificationService;
                _listener = asyncListener;
                _typeMap = typeMap;
                _taggerProvider = taggerProvider;
                _viewSupportsClassificationServiceOpt = viewSupportsClassificationServiceOpt;
                _associatedViewService = associatedViewService;
                _editorClassificationService = editorClassificationService;
                _languageName = languageName;

                _workQueue = new AsynchronousSerialWorkQueue(asyncListener);
                _reportChangeCancellationSource = new CancellationTokenSource();

                _lastLineCache = new LastLineCache();

                _workspaceRegistration = Workspace.GetWorkspaceRegistration(subjectBuffer.AsTextContainer());
                _workspaceRegistration.WorkspaceChanged += OnWorkspaceRegistrationChanged;

                ConnectToWorkspace(_workspaceRegistration.Workspace);
            }
开发者ID:JackWangCUMT,项目名称:roslyn,代码行数:31,代码来源:SyntacticClassificationTaggerProvider.TagComputer.cs

示例10: OpenDocument

 ///<summary>Links an existing <see cref="Document"/> to an <see cref="ITextBuffer"/>, synchronizing their contents.</summary>
 public void OpenDocument(DocumentId documentId, ITextBuffer buffer)
 {
     documentBuffers.Add(documentId, buffer);
     OnDocumentOpened(documentId, buffer.AsTextContainer());
     buffer.Changed += delegate { OnDocumentContextUpdated(documentId); };
 }
开发者ID:jvanrhyn,项目名称:WebEssentials2015,代码行数:7,代码来源:RoslynEmbedder.cs

示例11: SetSubmissionDocument

        private void SetSubmissionDocument(ITextBuffer buffer, Project project)
        {
            // Try to unregister our buffer with our workspace. This is a bit of a hack,
            // but we may have registered the buffer with the workspace if it was
            // transitioned to an Interactive Command buffer.
            _workspace.UnregisterText(buffer.AsTextContainer());

            var documentId = DocumentId.CreateNewId(project.Id, debugName: project.Name);
            var solution = project.Solution
                .AddDocument(documentId, project.Name, buffer.CurrentSnapshot.AsText());

            _workspace.SetCurrentSolution(solution);

            // opening document will start workspace listening to changes in this text container
            _workspace.OpenDocument(documentId, buffer.AsTextContainer());
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:16,代码来源:InteractiveEvaluator.cs

示例12: AbstractWorkspaceTrackingTaggerEventSource

 protected AbstractWorkspaceTrackingTaggerEventSource(ITextBuffer subjectBuffer, TaggerDelay delay) : base(delay)
 {
     this.SubjectBuffer = subjectBuffer;
     _workspaceRegistration = Workspace.GetWorkspaceRegistration(subjectBuffer.AsTextContainer());
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:5,代码来源:AbstractWorkspaceTrackingTaggerEventSource.cs

示例13: InitializeAsync

		async Task InitializeAsync(ITextBuffer buffer, string code, MetadataReference[] refs, string languageName, ISynchronousTagger<IClassificationTag> tagger, CompilationOptions compilationOptions, ParseOptions parseOptions) {
			using (var workspace = new AdhocWorkspace(RoslynMefHostServices.DefaultServices)) {
				var documents = new List<DocumentInfo>();
				var projectId = ProjectId.CreateNewId();
				documents.Add(DocumentInfo.Create(DocumentId.CreateNewId(projectId), "main.cs", null, SourceCodeKind.Regular, TextLoader.From(buffer.AsTextContainer(), VersionStamp.Create())));

				var projectInfo = ProjectInfo.Create(projectId, VersionStamp.Create(), "compilecodeproj", Guid.NewGuid().ToString(), languageName,
					compilationOptions: compilationOptions
							.WithOptimizationLevel(OptimizationLevel.Release)
							.WithPlatform(Platform.AnyCpu)
							.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default),
					parseOptions: parseOptions,
					documents: documents,
					metadataReferences: refs,
					isSubmission: false, hostObjectType: null);
				workspace.AddProject(projectInfo);
				foreach (var doc in documents)
					workspace.OpenDocument(doc.Id);

				buffer.Replace(new Span(0, buffer.CurrentSnapshot.Length), code);

				{
					// Initialize classification code paths
					var spans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length));
					foreach (var tagSpan in tagger.GetTags(spans, CancellationToken.None)) { }
				}

				{
					// Initialize completion code paths
					var info = CompletionInfo.Create(buffer.CurrentSnapshot);
					Debug.Assert(info != null);
					if (info != null) {
						var completionTrigger = CompletionTrigger.Default;
						var completionList = await info.Value.CompletionService.GetCompletionsAsync(info.Value.Document, 0, completionTrigger);
					}
				}

				{
					// Initialize signature help code paths
					var info = SignatureHelpInfo.Create(buffer.CurrentSnapshot);
					Debug.Assert(info != null);
					if (info != null) {
						int sigHelpIndex = code.IndexOf("sighelp");
						Debug.Assert(sigHelpIndex >= 0);
						var triggerInfo = new SignatureHelpTriggerInfo(SignatureHelpTriggerReason.InvokeSignatureHelpCommand);
						var items = await info.Value.SignatureHelpService.GetItemsAsync(info.Value.Document, sigHelpIndex, triggerInfo);
					}
				}

				{
					// Initialize quick info code paths
					var info = QuickInfoState.Create(buffer.CurrentSnapshot);
					Debug.Assert(info != null);
					if (info != null) {
						int quickInfoIndex = code.IndexOf("Equals");
						Debug.Assert(quickInfoIndex >= 0);
						var item = await info.Value.QuickInfoService.GetItemAsync(info.Value.Document, quickInfoIndex);
					}
				}
			}
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:61,代码来源:FirstUseOptimization.cs


注:本文中的ITextBuffer.AsTextContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。