本文整理汇总了C#中HostLanguageServices类的典型用法代码示例。如果您正苦于以下问题:C# HostLanguageServices类的具体用法?C# HostLanguageServices怎么用?C# HostLanguageServices使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HostLanguageServices类属于命名空间,在下文中一共展示了HostLanguageServices类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProjectState
internal ProjectState(ProjectInfo projectInfo, HostLanguageServices languageServices, SolutionServices solutionServices)
{
Contract.ThrowIfNull(projectInfo);
Contract.ThrowIfNull(languageServices);
Contract.ThrowIfNull(solutionServices);
_languageServices = languageServices;
_solutionServices = solutionServices;
_projectInfo = FixProjectInfo(projectInfo);
_documentIds = _projectInfo.Documents.Select(d => d.Id).ToImmutableArray();
_additionalDocumentIds = this.ProjectInfo.AdditionalDocuments.Select(d => d.Id).ToImmutableArray();
var docStates = ImmutableDictionary.CreateRange<DocumentId, DocumentState>(
_projectInfo.Documents.Select(d =>
new KeyValuePair<DocumentId, DocumentState>(d.Id,
CreateDocument(this.ProjectInfo, d, languageServices, solutionServices))));
_documentStates = docStates;
var additionalDocStates = ImmutableDictionary.CreateRange<DocumentId, TextDocumentState>(
_projectInfo.AdditionalDocuments.Select(d =>
new KeyValuePair<DocumentId, TextDocumentState>(d.Id, TextDocumentState.Create(d, solutionServices))));
_additionalDocumentStates = additionalDocStates;
_lazyLatestDocumentVersion = new AsyncLazy<VersionStamp>(c => ComputeLatestDocumentVersionAsync(docStates, additionalDocStates, c), cacheResult: true);
_lazyLatestDocumentTopLevelChangeVersion = new AsyncLazy<VersionStamp>(c => ComputeLatestDocumentTopLevelChangeVersionAsync(docStates, additionalDocStates, c), cacheResult: true);
}
示例2: ProjectState
private ProjectState(
ProjectInfo projectInfo,
HostLanguageServices languageServices,
SolutionServices solutionServices,
IEnumerable<DocumentId> documentIds,
IEnumerable<DocumentId> additionalDocumentIds,
ImmutableDictionary<DocumentId, DocumentState> documentStates,
ImmutableDictionary<DocumentId, TextDocumentState> additionalDocumentStates,
AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion,
ValueSource<ProjectStateChecksums> lazyChecksums)
{
_projectInfo = projectInfo;
_solutionServices = solutionServices;
_languageServices = languageServices;
_documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
_additionalDocumentIds = additionalDocumentIds.ToImmutableReadOnlyListOrEmpty();
_documentStates = documentStates;
_additionalDocumentStates = additionalDocumentStates;
_lazyLatestDocumentVersion = lazyLatestDocumentVersion;
_lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;
// 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<ProjectStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
}
示例3: 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);
}
示例4: TestHostSolution
public TestHostSolution(
HostLanguageServices languageServiceProvider,
CompilationOptions compilationOptions,
ParseOptions parseOptions,
params MetadataReference[] references)
: this(new TestHostProject(languageServiceProvider, compilationOptions, parseOptions, references))
{
}
示例5: CSharpCodeModelService
internal CSharpCodeModelService(
HostLanguageServices languageServiceProvider,
IEditorOptionsFactoryService editorOptionsFactoryService,
IEnumerable<IRefactorNotifyService> refactorNotifyServices)
: base(languageServiceProvider,
editorOptionsFactoryService,
refactorNotifyServices,
new BlankLineInGeneratedMethodFormattingRule(),
new EndRegionFormattingRule())
{
}
示例6: CreateLazyFullyParsedTree
private static ValueSource<TreeAndVersion> CreateLazyFullyParsedTree(
ValueSource<TextAndVersion> newTextSource,
string filePath,
ParseOptions options,
HostLanguageServices languageServices,
PreservationMode mode = PreservationMode.PreserveValue)
{
return new AsyncLazy<TreeAndVersion>(
c => FullyParseTreeAsync(newTextSource, filePath, options, languageServices, mode, c),
cacheResult: true);
}
示例7: 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;
}
示例8: CodeModelState
public CodeModelState(
IServiceProvider serviceProvider,
HostLanguageServices languageServices,
VisualStudioWorkspace workspace)
{
Debug.Assert(serviceProvider != null);
Debug.Assert(languageServices != null);
Debug.Assert(workspace != null);
this.ServiceProvider = serviceProvider;
this.CodeModelService = languageServices.GetService<ICodeModelService>();
this.SyntaxFactsService = languageServices.GetService<ISyntaxFactsService>();
this.CodeGenerator = languageServices.GetService<ICodeGenerationService>();
this.Workspace = workspace;
}
示例9: 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;
}
示例10: ProjectState
private ProjectState(
ProjectInfo projectInfo,
HostLanguageServices languageServices,
SolutionServices solutionServices,
IEnumerable<DocumentId> documentIds,
ImmutableDictionary<DocumentId, DocumentState> documentStates,
AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion)
{
this.projectInfo = projectInfo;
this.solutionServices = solutionServices;
this.languageServices = languageServices;
this.documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
this.documentStates = documentStates;
this.lazyLatestDocumentVersion = lazyLatestDocumentVersion;
this.lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;
}
示例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: ProjectState
private ProjectState(
ProjectInfo projectInfo,
HostLanguageServices languageServices,
SolutionServices solutionServices,
IEnumerable<DocumentId> documentIds,
IEnumerable<DocumentId> additionalDocumentIds,
ImmutableDictionary<DocumentId, DocumentState> documentStates,
ImmutableDictionary<DocumentId, TextDocumentState> additionalDocumentStates,
AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion)
{
_projectInfo = projectInfo;
_solutionServices = solutionServices;
_languageServices = languageServices;
_documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
_additionalDocumentIds = additionalDocumentIds.ToImmutableReadOnlyListOrEmpty();
_documentStates = documentStates;
_additionalDocumentStates = additionalDocumentStates;
_lazyLatestDocumentVersion = lazyLatestDocumentVersion;
_lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;
_lazyChecksums = new AsyncLazy<ProjectStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
}
示例13: CreateDocument
private static TestHostDocument CreateDocument(
TestWorkspace workspace,
XElement workspaceElement,
XElement documentElement,
string language,
ExportProvider exportProvider,
HostLanguageServices languageServiceProvider,
Dictionary<string, ITextBuffer> filePathToTextBufferMap,
ref int documentId)
{
string markupCode;
string filePath;
var isLinkFileAttribute = documentElement.Attribute(IsLinkFileAttributeName);
bool isLinkFile = isLinkFileAttribute != null && ((bool?)isLinkFileAttribute).HasValue && ((bool?)isLinkFileAttribute).Value;
if (isLinkFile)
{
// This is a linked file. Use the filePath and markup from the referenced document.
var originalProjectName = documentElement.Attribute(LinkAssemblyNameAttributeName);
var originalDocumentPath = documentElement.Attribute(LinkFilePathAttributeName);
if (originalProjectName == null || originalDocumentPath == null)
{
throw new ArgumentException("Linked file specified without LinkAssemblyName or LinkFilePath.");
}
var originalProjectNameStr = originalProjectName.Value;
var originalDocumentPathStr = originalDocumentPath.Value;
var originalProject = workspaceElement.Elements(ProjectElementName).First(p =>
{
var assemblyName = p.Attribute(AssemblyNameAttributeName);
return assemblyName != null && assemblyName.Value == originalProjectNameStr;
});
if (originalProject == null)
{
throw new ArgumentException("Linked file's LinkAssemblyName '{0}' project not found.", originalProjectNameStr);
}
var originalDocument = originalProject.Elements(DocumentElementName).First(d =>
{
var documentPath = d.Attribute(FilePathAttributeName);
return documentPath != null && documentPath.Value == originalDocumentPathStr;
});
if (originalDocument == null)
{
throw new ArgumentException("Linked file's LinkFilePath '{0}' file not found.", originalDocumentPathStr);
}
markupCode = originalDocument.NormalizedValue();
filePath = GetFilePath(workspace, originalDocument, ref documentId);
}
else
{
markupCode = documentElement.NormalizedValue();
filePath = GetFilePath(workspace, documentElement, ref documentId);
}
var folders = GetFolders(documentElement);
var optionsElement = documentElement.Element(ParseOptionsElementName);
// TODO: Allow these to be specified.
var codeKind = SourceCodeKind.Regular;
if (optionsElement != null)
{
var attr = optionsElement.Attribute(KindAttributeName);
codeKind = attr == null
? SourceCodeKind.Regular
: (SourceCodeKind)Enum.Parse(typeof(SourceCodeKind), attr.Value);
}
var contentTypeLanguageService = languageServiceProvider.GetService<IContentTypeLanguageService>();
var contentType = contentTypeLanguageService.GetDefaultContentType();
string code;
int? cursorPosition;
IDictionary<string, IList<TextSpan>> spans;
MarkupTestFile.GetPositionAndSpans(markupCode, out code, out cursorPosition, out spans);
// For linked files, use the same ITextBuffer for all linked documents
ITextBuffer textBuffer;
if (!filePathToTextBufferMap.TryGetValue(filePath, out textBuffer))
{
textBuffer = EditorFactory.CreateBuffer(contentType.TypeName, exportProvider, code);
filePathToTextBufferMap.Add(filePath, textBuffer);
}
return new TestHostDocument(exportProvider, languageServiceProvider, textBuffer, filePath, cursorPosition, spans, codeKind, folders, isLinkFile);
}
示例14: GetParseOptionsWorker
private static ParseOptions GetParseOptionsWorker(XElement projectElement, string language, HostLanguageServices languageServices)
{
ParseOptions parseOptions;
var preprocessorSymbolsAttribute = projectElement.Attribute(PreprocessorSymbolsAttributeName);
if (preprocessorSymbolsAttribute != null)
{
parseOptions = GetPreProcessorParseOptions(language, preprocessorSymbolsAttribute);
}
else
{
parseOptions = languageServices.GetService<ISyntaxTreeFactoryService>().GetDefaultParseOptions();
}
var languageVersionAttribute = projectElement.Attribute(LanguageVersionAttributeName);
if (languageVersionAttribute != null)
{
parseOptions = GetParseOptionsWithLanguageVersion(language, parseOptions, languageVersionAttribute);
}
var documentationMode = GetDocumentationMode(projectElement);
if (documentationMode != null)
{
parseOptions = parseOptions.WithDocumentationMode(documentationMode.Value);
}
return parseOptions;
}
示例15: GetParseOptions
private static ParseOptions GetParseOptions(XElement projectElement, string language, HostLanguageServices languageServices)
{
return language == LanguageNames.CSharp || language == LanguageNames.VisualBasic
? GetParseOptionsWorker(projectElement, language, languageServices)
: null;
}