/// <summary> /// Gets the documentId in this solution with the specified syntax tree. /// </summary> public DocumentId GetDocumentId(SyntaxTree syntaxTree, ProjectId projectId) { if (syntaxTree != null) { // is this tree known to be associated with a document? var documentId = DocumentState.GetDocumentIdForTree(syntaxTree); if (documentId != null && (projectId == null || documentId.ProjectId == projectId)) { // does this solution even have the document? if (this.ContainsDocument(documentId)) { return(documentId); } } } return(null); }
public ProjectState UpdateDocument(DocumentState newDocument, bool textChanged, bool recalculateDependentVersions) { Debug.Assert(this.ContainsDocument(newDocument.Id)); var oldDocument = this.GetDocumentState(newDocument.Id); if (oldDocument == newDocument) { return(this); } var newDocumentStates = _documentStates.SetItem(newDocument.Id, newDocument); GetLatestDependentVersions( newDocumentStates, _additionalDocumentStates, oldDocument, newDocument, recalculateDependentVersions, textChanged, out var dependentDocumentVersion, out var dependentSemanticVersion); return(this.With( documentStates: newDocumentStates, latestDocumentVersion: dependentDocumentVersion, latestDocumentTopLevelChangeVersion: dependentSemanticVersion)); }
internal Document GetDocument(SyntaxTree syntaxTree, ProjectId projectId) { if (syntaxTree != null) { // is this tree known to be associated with a document? var docId = DocumentState.GetDocumentIdForTree(syntaxTree); if (docId != null && (projectId == null || docId.ProjectId == projectId)) { // does this solution even have the document? var document = this.GetDocument(docId); if (document != null) { // does this document really have the syntax tree? if (document.TryGetSyntaxTree(out var documentTree) && documentTree == syntaxTree) { return(document); } } } } return(null); }
internal Document(Project project, DocumentState state) : base(project, state) { }
/// <summary> /// True if the Text has changed /// </summary> public bool HasTextChanged(DocumentState oldState) { return(oldState.sourceTextOpt != this.sourceTextOpt || oldState.textAndVersionSource != this.textAndVersionSource); }
public TouchDocumentAction(DocumentState oldState, DocumentState newState) { _oldState = oldState; _newState = newState; }
public static CompilationTranslationAction TouchDocument(DocumentState oldState, DocumentState newState) { return(new TouchDocumentAction(oldState, newState)); }
public static CompilationTranslationAction RemoveDocument(DocumentState state) { return(new RemoveDocumentAction(state)); }
public CompilationTracker FreezePartialStateWithTree(SolutionState solution, DocumentState docState, SyntaxTree tree, CancellationToken cancellationToken) { GetPartialCompilationState(solution, docState.Id, out var inProgressProject, out var inProgressCompilation, cancellationToken); if (!inProgressCompilation.SyntaxTrees.Contains(tree)) { var existingTree = inProgressCompilation.SyntaxTrees.FirstOrDefault(t => t.FilePath == tree.FilePath); if (existingTree != null) { inProgressCompilation = inProgressCompilation.ReplaceSyntaxTree(existingTree, tree); inProgressProject = inProgressProject.UpdateDocument(docState, textChanged: false, recalculateDependentVersions: false); } else { inProgressCompilation = inProgressCompilation.AddSyntaxTrees(tree); Debug.Assert(!inProgressProject.DocumentIds.Contains(docState.Id)); inProgressProject = inProgressProject.AddDocuments(ImmutableArray.Create(docState)); } } // The user is asking for an in progress snap. We don't want to create it and then // have the compilation immediately disappear. So we force it to stay around with a ConstantValueSource. // As a policy, all partial-state projects are said to have incomplete references, since the state has no guarantees. return(new CompilationTracker(inProgressProject, new FinalState(new ConstantValueSource <Compilation>(inProgressCompilation), hasSuccessfullyLoaded: false))); }