本文整理汇总了C#中Microsoft.CodeAnalysis.DocumentState类的典型用法代码示例。如果您正苦于以下问题:C# DocumentState类的具体用法?C# DocumentState怎么用?C# DocumentState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentState类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了DocumentState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Document
internal Document(Project project, DocumentState state)
{
Contract.ThrowIfNull(project);
Contract.ThrowIfNull(state);
this.Project = project;
_state = state;
}
示例2: TouchDocument
public static CompilationTranslationAction TouchDocument(DocumentState oldState, DocumentState newState)
{
return new TouchDocumentAction(oldState, newState);
}
示例3: RemoveDocument
public static CompilationTranslationAction RemoveDocument(DocumentState state)
{
return new RemoveDocumentAction(state);
}
示例4: GetLatestDependentVersions
private void GetLatestDependentVersions(
ImmutableDictionary<DocumentId, DocumentState> newDocumentStates,
DocumentState oldDocument, DocumentState newDocument,
bool recalculateDependentVersions, bool textChanged,
out AsyncLazy<VersionStamp> dependentDocumentVersion, out AsyncLazy<VersionStamp> dependentSemanticVersion)
{
var recalculateDocumentVersion = false;
var recalculateSemanticVersion = false;
if (recalculateDependentVersions)
{
VersionStamp oldVersion;
if (oldDocument.TryGetTextVersion(out oldVersion))
{
VersionStamp documentVersion;
if (!this.lazyLatestDocumentVersion.TryGetValue(out documentVersion) || documentVersion == oldVersion)
{
recalculateDocumentVersion = true;
}
VersionStamp semanticVersion;
if (!this.lazyLatestDocumentTopLevelChangeVersion.TryGetValue(out semanticVersion) || semanticVersion == oldVersion)
{
recalculateSemanticVersion = true;
}
}
}
dependentDocumentVersion = recalculateDocumentVersion ?
new AsyncLazy<VersionStamp>(this.ComputeLatestDocumentVersionAsync, cacheResult: true) :
textChanged ?
new AsyncLazy<VersionStamp>(newDocument.GetTextVersionAsync, cacheResult: true) :
this.lazyLatestDocumentVersion;
dependentSemanticVersion = recalculateSemanticVersion ?
new AsyncLazy<VersionStamp>(c => ComputeLatestDocumentTopLevelChangeVersionAsync(newDocumentStates, c), cacheResult: true) :
textChanged ?
CreateLazyLatestDocumentTopLevelChangeVersion(newDocument, newDocumentStates) :
this.lazyLatestDocumentTopLevelChangeVersion;
}
示例5: UpdateDocument
public ProjectState UpdateDocument(DocumentState newDocument, bool textChanged, bool recalculateDependentVersions)
{
Contract.Requires(this.ContainsDocument(newDocument.Id));
var oldDocument = this.GetDocumentState(newDocument.Id);
if (oldDocument == newDocument)
{
return this;
}
var newDocumentStates = this.DocumentStates.SetItem(newDocument.Id, newDocument);
AsyncLazy<VersionStamp> dependentDocumentVersion;
AsyncLazy<VersionStamp> dependentSemanticVersion;
GetLatestDependentVersions(
newDocumentStates, oldDocument, newDocument, recalculateDependentVersions, textChanged,
out dependentDocumentVersion, out dependentSemanticVersion);
return this.With(
documentStates: newDocumentStates,
latestDocumentVersion: dependentDocumentVersion,
latestDocumentTopLevelChangeVersion: dependentSemanticVersion);
}
示例6: AddDocument
public ProjectState AddDocument(DocumentState document)
{
Contract.Requires(!this.DocumentStates.ContainsKey(document.Id));
return this.With(
projectInfo: this.ProjectInfo.WithVersion(this.Version.GetNewerVersion()),
documentIds: this.DocumentIds.Add(document.Id),
documentStates: this.DocumentStates.Add(document.Id, document));
}
示例7: ComputeTopLevelChangeTextVersionAsync
private static async Task<VersionStamp> ComputeTopLevelChangeTextVersionAsync(VersionStamp oldVersion, DocumentState newDocument, CancellationToken cancellationToken)
{
var newVersion = await newDocument.GetTopLevelChangeTextVersionAsync(cancellationToken).ConfigureAwait(false);
return newVersion.GetNewerVersion(oldVersion);
}
示例8: CreateLazyLatestDocumentTopLevelChangeVersion
private AsyncLazy<VersionStamp> CreateLazyLatestDocumentTopLevelChangeVersion(DocumentState newDocument, ImmutableDictionary<DocumentId, DocumentState> newDocumentStates)
{
VersionStamp oldVersion;
if (this.lazyLatestDocumentTopLevelChangeVersion.TryGetValue(out oldVersion))
{
return new AsyncLazy<VersionStamp>(c => ComputeTopLevelChangeTextVersionAsync(oldVersion, newDocument, c), cacheResult: true);
}
else
{
return new AsyncLazy<VersionStamp>(c => ComputeLatestDocumentTopLevelChangeVersionAsync(newDocumentStates, c), cacheResult: true);
}
}
示例9: FreezePartialStateWithTree
public CompilationTracker FreezePartialStateWithTree(Solution solution, DocumentState docState, SyntaxTree tree, CancellationToken cancellationToken)
{
ProjectState inProgressProject;
Compilation inProgressCompilation;
GetPartialCompilationState(solution, docState.Id, out inProgressProject, out 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.AddDocument(docState);
}
}
// The user is asking for an in progress snap. We don't want to create it and then a
// have the compilation immediately disappear. So we force it to stay around with a ConstantValueSource
return new CompilationTracker(inProgressProject,
new FinalState(new ConstantValueSource<Compilation>(inProgressCompilation)));
}
示例10: WithDocumentState
private SolutionState WithDocumentState(DocumentState newDocument, bool textChanged = false, bool recalculateDependentVersions = false)
{
if (newDocument == null)
{
throw new ArgumentNullException(nameof(newDocument));
}
CheckContainsDocument(newDocument.Id);
if (newDocument == this.GetDocumentState(newDocument.Id))
{
// old and new documents are the same instance
return this;
}
return this.TouchDocument(newDocument.Id, p => p.UpdateDocument(newDocument, textChanged, recalculateDependentVersions));
}
示例11: UpdateDocumentInCompilationAsync
private static async Task<Compilation> UpdateDocumentInCompilationAsync(
Compilation compilation,
DocumentState oldDocument,
DocumentState newDocument,
CancellationToken cancellationToken)
{
return compilation.ReplaceSyntaxTree(
await oldDocument.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false),
await newDocument.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false));
}
示例12: Document
internal Document(Project project, DocumentState state) :
base(project, state)
{
}
示例13: AddDocument
private Solution AddDocument(DocumentState state)
{
if (state == null)
{
throw new ArgumentNullException(nameof(state));
}
CheckContainsProject(state.Id.ProjectId);
var oldProject = this.GetProjectState(state.Id.ProjectId);
var newProject = oldProject.AddDocument(state);
return this.ForkProject(
newProject,
CompilationTranslationAction.AddDocument(state),
newLinkedFilesMap: CreateLinkedFilesMapWithAddedDocuments(newProject, SpecializedCollections.SingletonEnumerable(state.Id)));
}
示例14: DocumentBranch
internal DocumentBranch(SourceText text, DocumentState state)
{
this.Text = text;
this.State = state;
}
示例15: AddDocument
private Solution AddDocument(DocumentState state)
{
if (state == null)
{
throw new ArgumentNullException("document");
}
CheckContainsProject(state.Id.ProjectId);
var oldProject = this.GetProjectState(state.Id.ProjectId);
var newProject = oldProject.AddDocument(state);
return this.ForkProject(newProject, CompilationTranslationAction.AddDocument(state), withDocumentListChange: true);
}