从分类器 VSIX 获取语义模型 [英] Get semantic model from a classifier VSIX

查看:40
本文介绍了从分类器 VSIX 获取语义模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 R# 不支持 Roslyn Early Preview C# 6.0 功能,代码看起来很枯燥......

As R# is not supporting the Roslyn Early Preview C# 6.0 features, the code looks very dull...

我想使用分类器 VSIX 为代码着色.是否可以从 Roslyn Language Service 获取当前文档的语义模型?

I would like to colorize the code using a classifier VSIX. Is it possible to get the semantic model from the Roslyn Language Service for the current document?

推荐答案

需要添加对Microsoft.CodeAnalysis.EditorFeatures.Text.dll的引用,然后使用如下代码.

You need to add a reference to Microsoft.CodeAnalysis.EditorFeatures.Text.dll, then use the following code.

var doc = point.Snapshot.GetOpenDocumentInCurrentContextWithChanges();
var model = await doc.GetSemanticModelAsync();

这需要 Microsoft.CodeAnalysis.EditorFeatures.Text NuGet 包(需要 .NET 4.6)

This requires the Microsoft.CodeAnalysis.EditorFeatures.Text NuGet package (.NET 4.6 required)

这篇关于从分类器 VSIX 获取语义模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆