Built-in C#/VB.Net editor with intellisense - Roslyn, VSTA, or something else?

▼魔方 西西 提交于 2019-12-05 04:52:15

I'm ceretainly not an expert in this area. But since you haven't received any other replies, I'll take a shot.

I think the short answer is "yes".

Looking at the code in AvalonEdit and SharpDevelop, it appears that code completion is one of the most difficult parts. Essentially, you have to write a compiler (or a parser, anyway) to figure out what items should be on the completion list. It appears that Roslyn provides tools for constructing the completion list. In older versions, these tools were tied to the VS editor, but I have seen statements saying that they are independent in the latest release. If so, these tools will be very useful in implementing code completion.

I haven't really looked into the details at all, but I intend to, since I have some of the same goals as you, and Roslyn looks like it will be helpful (based on what I know so far, which is not very much).

You made a very interesting claim that "after looking at products like AvalonEdit, SharpDevelop and ScintillaNet, they don't seem to provide true code-completion intellisense". SharpDevelop is a complete IDE, and why don't you find "true" code completion Intellisense? You will have to provide some evidence, or that statement is invalid.

What you want to achieve can only be achieved with two important pieces of components,

  • A language parser, with which you can get context and elements for code completion. That is what Roslyn offers, but Roslyn is not yet mature enough to parse all existing C# syntax. SharpDevelop (as well as MonoDevelop) uses NRefactory, which serves the same goal.

  • A UI element that supports syntax highlighting. This can be achieved by AvalonEdit, or ScintillaNet based on the UI framework you choose.

Visual Studio Shell might provide you some assistance, as @Mystere Man pointed out. But personally I don't know much about it.

I tried really hard to use one of those built in components, but ended up implementing one myself. After a day exploring RichTextBox api, you can comfortably build this support. Just play with PreviewKeyDown/Up, make sure a batch of work play with the undo support and such.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!