本文整理汇总了C#中Microsoft.CodeAnalysis.DocumentInfo类的典型用法代码示例。如果您正苦于以下问题:C# DocumentInfo类的具体用法?C# DocumentInfo怎么用?C# DocumentInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentInfo类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了DocumentInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAdditionalDocumentUndoUnit
public AddAdditionalDocumentUndoUnit(
VisualStudioWorkspaceImpl workspace,
DocumentInfo docInfo,
SourceText text)
: base(workspace, docInfo, text)
{
}
示例2: Create
public static DocumentState Create(
DocumentInfo info,
ParseOptions options,
HostLanguageServices language,
SolutionServices services)
{
var textSource = info.TextLoader != null
? CreateRecoverableText(info.TextLoader, info.Id, services)
: CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, Encoding.UTF8), VersionStamp.Default, info.FilePath));
var treeSource = CreateLazyFullyParsedTree(
textSource,
GetSyntaxTreeFilePath(info),
options,
languageServices: language);
// remove any initial loader so we don't keep source alive
info = info.WithTextLoader(null);
return new DocumentState(
languageServices: language,
solutionServices: services,
info: info,
options: options,
textSource: textSource,
treeSource: treeSource);
}
示例3: AbstractAddDocumentUndoUnit
protected AbstractAddDocumentUndoUnit(
VisualStudioWorkspaceImpl workspace,
DocumentInfo docInfo,
SourceText text)
: base(workspace, docInfo.Id.ProjectId)
{
DocumentInfo = docInfo;
Text = text;
}
示例4: TextDocumentState
protected TextDocumentState(
SolutionServices solutionServices,
DocumentInfo info,
ValueSource<TextAndVersion> textSource)
{
this.solutionServices = solutionServices;
this.info = info;
this.textSource = textSource;
}
示例5: DocumentState
private DocumentState(
HostLanguageServices languageServices,
SolutionServices solutionServices,
DocumentInfo info,
ParseOptions options,
ValueSource<TextAndVersion> textSource,
ValueSource<TreeAndVersion> treeSource)
: base(solutionServices, info, textSource)
{
_languageServices = languageServices;
_options = options;
_treeSource = treeSource;
}
示例6: Create
public static TextDocumentState Create(DocumentInfo info, SolutionServices services)
{
var textSource = info.TextLoader != null
? CreateRecoverableText(info.TextLoader, info.Id, services, reportInvalidDataException: false)
: CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, Encoding.UTF8), VersionStamp.Default, info.FilePath));
// remove any initial loader so we don't keep source alive
info = info.WithTextLoader(null);
return new TextDocumentState(
solutionServices: services,
info: info,
textSource: textSource);
}
示例7: DocumentState
private DocumentState(
HostLanguageServices languageServices,
SolutionServices solutionServices,
DocumentInfo info,
ParseOptions options,
ValueSource<TextAndVersion> textSource,
ValueSource<TreeAndVersion> treeSource)
{
this.languageServices = languageServices;
this.solutionServices = solutionServices;
this.info = info;
this.options = options;
this.textSource = textSource;
this.treeSource = treeSource;
}
示例8: CreateSimpleWorkspace
private void CreateSimpleWorkspace(out OmnisharpWorkspace workspace, out ChangeBufferService controller, out DocumentInfo document, string filename, string contents)
{
workspace = new OmnisharpWorkspace(new HostServicesBuilder(Enumerable.Empty<ICodeActionProvider>()));
controller = new ChangeBufferService(workspace);
var projectInfo = ProjectInfo.Create(ProjectId.CreateNewId(), VersionStamp.Create(),
"ProjectNameVal", "AssemblyNameVal", LanguageNames.CSharp);
document = DocumentInfo.Create(DocumentId.CreateNewId(projectInfo.Id), filename,
null, SourceCodeKind.Regular,
TextLoader.From(TextAndVersion.Create(SourceText.From(contents), VersionStamp.Create())),
filename);
workspace.AddProject(projectInfo);
workspace.AddDocument(document);
}
示例9: CreateSimpleWorkspace
private void CreateSimpleWorkspace(out OmnisharpWorkspace workspace, out OmnisharpController controller, out DocumentInfo document, string filename, string contents)
{
workspace = new OmnisharpWorkspace();
controller = new OmnisharpController(workspace, null);
var projectInfo = ProjectInfo.Create(ProjectId.CreateNewId(), VersionStamp.Create(),
"ProjectNameVal", "AssemblyNameVal", LanguageNames.CSharp);
document = DocumentInfo.Create(DocumentId.CreateNewId(projectInfo.Id), filename,
null, SourceCodeKind.Regular,
TextLoader.From(TextAndVersion.Create(SourceText.From(contents), VersionStamp.Create())),
filename);
workspace.AddProject(projectInfo);
workspace.AddDocument(document);
}
示例10: TextDocumentState
protected TextDocumentState(
SolutionServices solutionServices,
DocumentInfo info,
SourceText sourceTextOpt,
ValueSource<TextAndVersion> textAndVersionSource,
ValueSource<DocumentStateChecksums> lazyChecksums)
{
this.solutionServices = solutionServices;
this.info = info;
this.sourceTextOpt = sourceTextOpt;
this.textAndVersionSource = textAndVersionSource;
// for now, let it re-calculate if anything changed.
// TODO: optimize this so that we only re-calcuate checksums that are actually changed
_lazyChecksums = new AsyncLazy<DocumentStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
}
示例11: DocumentState
private DocumentState(
HostLanguageServices languageServices,
SolutionServices solutionServices,
DocumentInfo info,
ParseOptions options,
ValueSource<TextAndVersion> textSource,
ValueSource<TreeAndVersion> treeSource)
: base(solutionServices, info, textSource)
{
_languageServices = languageServices;
_options = options;
// If this is document that doesn't support syntax, then don't even bother holding
// onto any tree source. It will never be used to get a tree, and can only hurt us
// by possibly holding onto data that might cause a slow memory leak.
_treeSource = this.SupportsSyntaxTree
? treeSource
: ValueSource<TreeAndVersion>.Empty;
}
示例12: AddDocument
/// <summary>
/// Adds a document to the workspace.
/// </summary>
public Document AddDocument(DocumentInfo documentInfo)
{
if (documentInfo == null)
{
throw new ArgumentNullException(nameof(documentInfo));
}
this.OnDocumentAdded(documentInfo);
return this.CurrentSolution.GetDocument(documentInfo.Id);
}
示例13: ApplyDocumentAdded
protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text)
{
System.Diagnostics.Debug.Assert(_applyChangesProjectFile != null);
var project = this.CurrentSolution.GetProject(info.Id.ProjectId);
IProjectFileLoader loader;
if (this.TryGetLoaderFromProjectPath(project.FilePath, ReportMode.Ignore, out loader))
{
var extension = _applyChangesProjectFile.GetDocumentExtension(info.SourceCodeKind);
var fileName = Path.ChangeExtension(info.Name, extension);
var relativePath = (info.Folders != null && info.Folders.Count > 0)
? Path.Combine(Path.Combine(info.Folders.ToArray()), fileName)
: fileName;
var fullPath = GetAbsolutePath(relativePath, Path.GetDirectoryName(project.FilePath));
var newDocumentInfo = info.WithName(fileName)
.WithFilePath(fullPath)
.WithTextLoader(new FileTextLoader(fullPath, text.Encoding));
// add document to project file
_applyChangesProjectFile.AddDocument(relativePath);
// add to solution
this.OnDocumentAdded(newDocumentInfo);
// save text to disk
if (text != null)
{
this.SaveDocumentText(info.Id, fullPath, text, text.Encoding ?? Encoding.UTF8);
}
}
}
示例14: OnAdditionalDocumentAdded
public void OnAdditionalDocumentAdded(DocumentInfo documentInfo) { }
示例15: AddAdditionalDocument
public Solution AddAdditionalDocument(DocumentInfo documentInfo)
{
var newState = _state.AddAdditionalDocument(documentInfo);
if (newState == _state)
{
return this;
}
return new Solution(newState);
}