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


C# DocumentId类代码示例

本文整理汇总了C#中DocumentId的典型用法代码示例。如果您正苦于以下问题:C# DocumentId类的具体用法?C# DocumentId怎么用?C# DocumentId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: AddDocument

            public void AddDocument(DocumentId id)
            {
                var vsWorkspace = (VisualStudioWorkspaceImpl)_workspace;
                Contract.ThrowIfNull(vsWorkspace);

                var solution = vsWorkspace.CurrentSolution;
                if (!solution.ContainsDocument(id))
                {
                    // document is not part of the workspace (newly created document that is not applied to the workspace yet?)
                    return;
                }

                if (vsWorkspace.IsDocumentOpen(id))
                {
                    var document = vsWorkspace.GetHostDocument(id);
                    var undoHistory = _undoHistoryRegistry.RegisterHistory(document.GetOpenTextBuffer());

                    using (var undoTransaction = undoHistory.CreateTransaction(_description))
                    {
                        undoTransaction.AddUndo(new NoOpUndoPrimitive());
                        undoTransaction.Complete();
                    }

                    return;
                }

                // open and close the document so that it is included in the global undo transaction
                using (vsWorkspace.OpenInvisibleEditor(id))
                {
                    // empty
                }
            }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:32,代码来源:GlobalUndoServiceFactory.WorkspaceGlobalUndoTransaction.cs

示例2: GetFileCodeModel

        public override EnvDTE.FileCodeModel GetFileCodeModel(DocumentId documentId)
        {
            if (documentId == null)
            {
                throw new ArgumentNullException("documentId");
            }

            var project = ProjectTracker.GetProject(documentId.ProjectId);
            if (project == null)
            {
                throw new ArgumentException(ServicesVSResources.DocumentIdNotFromWorkspace, "documentId");
            }

            var document = project.GetDocumentOrAdditionalDocument(documentId);
            if (document == null)
            {
                throw new ArgumentException(ServicesVSResources.DocumentIdNotFromWorkspace, "documentId");
            }

            var provider = project as IProjectCodeModelProvider;
            if (provider != null)
            {
                var projectCodeModel = provider.ProjectCodeModel;
                if (projectCodeModel.CanCreateFileCodeModelThroughProject(document.FilePath))
                {
                    return (EnvDTE.FileCodeModel)projectCodeModel.CreateFileCodeModelThroughProject(document.FilePath);
                }
            }

            return null;
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:31,代码来源:RoslynVisualStudioWorkspace.cs

示例3: GetAdjustedDiagnosticSpan

        public void GetAdjustedDiagnosticSpan(
            DocumentId documentId, Location location,
            out TextSpan sourceSpan, out FileLinePositionSpan originalLineInfo, out FileLinePositionSpan mappedLineInfo)
        {
            sourceSpan = location.SourceSpan;
            originalLineInfo = location.GetLineSpan();
            mappedLineInfo = location.GetMappedLineSpan();

            // check quick bail out case.
            if (location == Location.None)
            {
                return;
            }
            // Update the original source span, if required.
            if (!TryAdjustSpanIfNeededForVenus(documentId, originalLineInfo, mappedLineInfo, out var originalSpan, out var mappedSpan))
            {
                return;
            }

            if (originalSpan.Start != originalLineInfo.StartLinePosition || originalSpan.End != originalLineInfo.EndLinePosition)
            {
                originalLineInfo = new FileLinePositionSpan(originalLineInfo.Path, originalSpan.Start, originalSpan.End);

                var textLines = location.SourceTree.GetText().Lines;
                var startPos = textLines.GetPosition(originalSpan.Start);
                var endPos = textLines.GetPosition(originalSpan.End);

                sourceSpan = TextSpan.FromBounds(startPos, Math.Max(startPos, endPos));
            }

            if (mappedSpan.Start != mappedLineInfo.StartLinePosition || mappedSpan.End != mappedLineInfo.EndLinePosition)
            {
                mappedLineInfo = new FileLinePositionSpan(mappedLineInfo.Path, mappedSpan.Start, mappedSpan.End);
            }
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:35,代码来源:VisualStudioVenusSpanMappingService.cs

示例4: RaiseWorkspaceChangedEventAsync

        protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solution oldSolution, Solution newSolution, ProjectId projectId = null, DocumentId documentId = null)
        {
            if (newSolution == null)
            {
                throw new ArgumentNullException("newSolution");
            }

            if (oldSolution == newSolution)
            {
                return SpecializedTasks.EmptyTask;
            }

            if (projectId == null && documentId != null)
            {
                projectId = documentId.ProjectId;
            }

            var handlers = this.eventMap.GetEventHandlers<EventHandler<WorkspaceChangeEventArgs>>(WorkspaceChangeEventName);
            if (handlers.Length > 0)
            {
                return this.ScheduleTask(() =>
                {
                    var args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId);
                    foreach (var handler in handlers)
                    {
                        handler(this, args);
                    }
                }, "Workspace.WorkspaceChanged");
            }
            else
            {
                return SpecializedTasks.EmptyTask;
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:34,代码来源:Workspace_Events.cs

示例5: DiagnosticDataLocation

 public DiagnosticDataLocation(
     DocumentId documentId = null,
     TextSpan? sourceSpan = null,
     string originalFilePath = null,
     int originalStartLine = 0,
     int originalStartColumn = 0,
     int originalEndLine = 0,
     int originalEndColumn = 0,
     string mappedFilePath = null,
     int mappedStartLine = 0,
     int mappedStartColumn = 0,
     int mappedEndLine = 0,
     int mappedEndColumn = 0)
 {
     DocumentId = documentId;
     SourceSpan = sourceSpan;
     MappedFilePath = mappedFilePath;
     MappedStartLine = mappedStartLine;
     MappedStartColumn = mappedStartColumn;
     MappedEndLine = mappedEndLine;
     MappedEndColumn = mappedEndColumn;
     OriginalFilePath = originalFilePath;
     OriginalStartLine = originalStartLine;
     OriginalStartColumn = originalStartColumn;
     OriginalEndLine = originalEndLine;
     OriginalEndColumn = originalEndColumn;
 }
开发者ID:robertoenbarcelona,项目名称:roslyn,代码行数:27,代码来源:DiagnosticData.cs

示例6: DocumentInfo

        /// <summary>
        /// Create a new instance of a <see cref="DocumentInfo"/>.
        /// </summary>
        private DocumentInfo(
            DocumentId id,
            string name,
            IEnumerable<string> folders,
            SourceCodeKind sourceCodeKind,
            TextLoader loader,
            string filePath,
            bool isGenerated)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            this.Id = id;
            this.Name = name;
            this.Folders = folders.ToImmutableReadOnlyListOrEmpty();
            this.SourceCodeKind = sourceCodeKind;
            this.TextLoader = loader;
            this.FilePath = filePath;
            this.IsGenerated = isGenerated;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:DocumentInfo.cs

示例7: RaiseWorkspaceChangedEventAsync

        protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solution oldSolution, Solution newSolution, ProjectId projectId = null, DocumentId documentId = null)
        {
            if (newSolution == null)
            {
                throw new ArgumentNullException(nameof(newSolution));
            }

            if (oldSolution == newSolution)
            {
                return SpecializedTasks.EmptyTask;
            }

            if (projectId == null && documentId != null)
            {
                projectId = documentId.ProjectId;
            }

            var ev = _eventMap.GetEventHandlers<EventHandler<WorkspaceChangeEventArgs>>(WorkspaceChangeEventName);
            if (ev.HasHandlers)
            {
                return this.ScheduleTask(() =>
                {
                    var args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId);
                    ev.RaiseEvent(handler => handler(this, args));
                }, "Workspace.WorkspaceChanged");
            }
            else
            {
                return SpecializedTasks.EmptyTask;
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:31,代码来源:Workspace_Events.cs

示例8: DiagnosticsUpdatedArgs

 public DiagnosticsUpdatedArgs(
     object id, Workspace workspace, Solution solution, ProjectId projectId, DocumentId documentId, ImmutableArray<DiagnosticData> diagnostics) :
         base(id, workspace, projectId, documentId)
 {
     this.Solution = solution;
     this.Diagnostics = diagnostics;
 }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:7,代码来源:DiagnosticsUpdatedArgs.cs

示例9: SolutionPreviewItem

 public SolutionPreviewItem(ProjectId projectId, DocumentId documentId, string text)
 {
     ProjectId = projectId;
     DocumentId = documentId;
     Text = text;
     LazyPreview = c => Task.FromResult<object>(text);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:7,代码来源:SolutionPreviewItem.cs

示例10: TodoItem

        public TodoItem(
            int priority,
            string message,
            Workspace workspace,
            DocumentId documentId,
            int mappedLine,
            int originalLine,
            int mappedColumn,
            int originalColumn,
            string mappedFilePath,
            string originalFilePath)
        {
            Priority = priority;
            Message = message;

            Workspace = workspace;
            DocumentId = documentId;

            MappedLine = mappedLine;
            MappedColumn = mappedColumn;
            MappedFilePath = mappedFilePath;

            OriginalLine = originalLine;
            OriginalColumn = originalColumn;
            OriginalFilePath = originalFilePath;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:26,代码来源:TodoItem.cs

示例11: ConflictLocationInfo

 public ConflictLocationInfo(RelatedLocation location)
 {
     Debug.Assert(location.ComplexifiedTargetSpan.Contains(location.ConflictCheckSpan) || location.Type == RelatedLocationType.UnresolvableConflict);
     this.ComplexifiedSpan = location.ComplexifiedTargetSpan;
     this.DocumentId = location.DocumentId;
     this.OriginalIdentifierSpan = location.ConflictCheckSpan;
 }
开发者ID:nagyist,项目名称:roslyn,代码行数:7,代码来源:ConflictResolver.Session.cs

示例12: Session

            public Session(
                RenameLocations renameLocationSet,
                Location renameSymbolDeclarationLocation,
                string originalText,
                string replacementText,
                OptionSet optionSet,
                Func<IEnumerable<ISymbol>, bool?> newSymbolsAreValid,
                CancellationToken cancellationToken)
            {
                _renameLocationSet = renameLocationSet;
                _renameSymbolDeclarationLocation = renameSymbolDeclarationLocation;
                _originalText = originalText;
                _replacementText = replacementText;
                _optionSet = optionSet;
                _hasConflictCallback = newSymbolsAreValid;
                _cancellationToken = cancellationToken;

                _renamedSymbolDeclarationAnnotation = new RenameAnnotation();

                _conflictLocations = SpecializedCollections.EmptySet<ConflictLocationInfo>();
                _replacementTextValid = true;
                _possibleNameConflicts = new List<string>();

                // only process documents which possibly contain the identifiers.
                _documentsIdsToBeCheckedForConflict = new HashSet<DocumentId>();
                _documentIdOfRenameSymbolDeclaration = renameLocationSet.Solution.GetDocument(renameSymbolDeclarationLocation.SourceTree).Id;

                _renameAnnotations = new AnnotationTable<RenameAnnotation>(RenameAnnotation.Kind);
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:29,代码来源:ConflictResolver.Session.cs

示例13: TryAdjustSpanIfNeededForVenus

        private bool TryAdjustSpanIfNeededForVenus(
            DocumentId documentId, FileLinePositionSpan originalLineInfo, FileLinePositionSpan mappedLineInfo, out LinePositionSpan originalSpan, out LinePositionSpan mappedSpan)
        {
            var startChanged = true;
            MappedSpan startLineColumn;
            if (!TryAdjustSpanIfNeededForVenus(_workspace, documentId, originalLineInfo.StartLinePosition.Line, originalLineInfo.StartLinePosition.Character, out startLineColumn))
            {
                startChanged = false;
                startLineColumn = new MappedSpan(originalLineInfo.StartLinePosition.Line, originalLineInfo.StartLinePosition.Character, mappedLineInfo.StartLinePosition.Line, mappedLineInfo.StartLinePosition.Character);
            }

            var endChanged = true;
            MappedSpan endLineColumn;
            if (!TryAdjustSpanIfNeededForVenus(_workspace, documentId, originalLineInfo.EndLinePosition.Line, originalLineInfo.EndLinePosition.Character, out endLineColumn))
            {
                endChanged = false;
                endLineColumn = new MappedSpan(originalLineInfo.EndLinePosition.Line, originalLineInfo.EndLinePosition.Character, mappedLineInfo.EndLinePosition.Line, mappedLineInfo.EndLinePosition.Character);
            }

            // start and end position can be swapped when mapped between primary and secondary buffer if start position is within visible span (at the edge)
            // but end position is outside of visible span. in that case, swap start and end position.
            originalSpan = GetLinePositionSpan(startLineColumn.OriginalLinePosition, endLineColumn.OriginalLinePosition);
            mappedSpan = GetLinePositionSpan(startLineColumn.MappedLinePosition, endLineColumn.MappedLinePosition);

            return startChanged || endChanged;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:26,代码来源:VisualStudioVenusSpanMappingService.cs

示例14: SearchRefactoringWorkitem

 internal SearchRefactoringWorkitem(ICodeHistoryRecord latestRecord, 
     DocumentId documentId)
 {
     this.latestRecord = latestRecord;
     this.documentId = documentId;
     logger = NLoggerUtil.GetNLogger(typeof(SearchRefactoringWorkitem));
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:7,代码来源:SearchRefactoringComponent.cs

示例15: CreateRecoverableText

 protected static ValueSource<TextAndVersion> CreateRecoverableText(TextLoader loader, DocumentId documentId, SolutionServices services)
 {
     return new RecoverableTextAndVersion(
         new AsyncLazy<TextAndVersion>(c => LoadTextAsync(loader, documentId, services, c), cacheResult: false),
         services.TemporaryStorage,
         services.TextCache);
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:7,代码来源:TextDocumentState.cs


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