Eclipse aCute for C# and .NET Core
Eclipse aCute is one of the newest community projects brought into the Eclipse Tools Project ecosystem. It is a language based extension that provides development tools for C# and .NET Core inside the Eclipse IDE. Recent technologies have allowed aCute's C# editor to be developed with ease allowing for more resource allocation towards other language features, making it a great example for all developers looking to build an editor of their own.
The name aCute is derived from the C in C# and "acute" being a synonym for "sharp". However, I personally like to think it is because the project is a "Cute" and efficient implementation of a C# editor. Beginning as a proof of concept showing the value of using language server technology to create more efficient editors implementations, the project has grown to include a full suite of editor features along with wizards and tools that implement .NET Core commands within the Eclipse IDE.
If you are a C# developer, you may have already been presented with the Marketplace suggestion popup when opening a C# file telling you that better editor support for C# files is available. However, you can find aCute within the Eclipse Marketplace by searching for "aCute: C# edition in Eclipse IDE".
As with all community projects, aCute's priorities are chosen by the community. If you have a feature that you think would benefit users, then join in on the discussion and help aCute grow. Also, if you wish to join the development yourself, new contributors are always welcomed.
Behind The Editor
When it comes to building an editor, there are two major components: (1) Generating the content for each of its features and (2) Displaying the content in the editor. The C# editor within aCute has all the features you'd expect to find in a language based editor including syntax coloring, auto-complete suggestions, code diagnostics, and code navigation tools. Each of these features is generated by the Omnisharp Language Server (excluding syntax coloring which is provided by Textmate) and displayed using Eclipe's Generic Editor.
What are Language Servers
The Omnisharp Language Server that aCute uses can be described as a C# parser that when given the text of a document and a request type, uses the language server protocol to return the results of the requests. This means that the language server contains all the logic for parsing the language, which obfuscates this from the actual development of the editor. It is able to return auto-completion suggestions, information on a specific character index which is used for hover information, and errors within the current code base. The major bonus of using the language server protocol for communication with language servers is that it is universal for languages and consuming tools. That means that this same language server can be used to build a C# editor in any other editor without any extra work for language parsing.
Why the Eclipse Generic Editor
The Eclipse Generic Editor is a text editor designed to be extended to supply basic support for multiple languages. Developers can extend the Generic Editor with the content for syntax highlighting or auto-completion suggestions for a certain context type. When a file is opened within the Generic Editor that matches a context type provided, the specified set of extensions are applied. This means there is only one editor but uses context types to decided when to employ a specific plugin's extensions. So in the example of aCute, C# files will be opened not in an 'aCute Editor' but instead in the Generic Text Editor and the language server will work on the document through the Generic Editor's extension points.
How These Work Together
These two technologies combined are the reason why providing support for new languages has become easier and faster within Eclipse. Language Servers obfuscates code parsing away from the editor developer and the Generic Editor provides the majority of the boilerplate code required to connect a language server to the editor. Along with functions to start, stop and communicate with the language server, the code snippet below take from aCute's plugin.xml file is all the coding required to connect the language server results to the Generic Editor enabling all of the features shown above:
<extension point="org.eclipse.ui.editors"> <editorContentTypeBinding contentTypeId="org.eclipse.acute.csharp" editorId="org.eclipse.ui.genericeditor.GenericEditor" </editorContentTypeBinding> </extension> <extension point="org.eclipse.lsp4e.languageServer"> <server class="org.eclipse.acute.OmnisharpStreamConnectionProvider" id="org.eclipse.acute.omnisharp" label="org.eclipse.acute.OmniSharp" </server> <contentTypeMapping contentType="org.eclipse.acute.csharp" id="org.eclipse.acute.omnisharp" </contentTypeMapping> </extension>
The language server is defined and a content type, being all .cs files, is given to both the Generic Editor and the language server to know on what documents they should be used. That is the core of aCute's C# editor.
.NET Core Integration
The other large feature presented through aCute is that the entire life cycle of a .NET Core project can be completed without having to leave the Eclipse IDE thanks to the integration of the .NET Core Command Line Interface. Each of this feature's parts should feel very natural to Eclipse users as they are integrated with similar methods as most other languages. This is not only important to ensure easy adoption, but simplifies the development process as the majority of the frameworks are built to accompany new language integration.
- .NET Core projects are able to be created from the New Project wizard and with .NET Core 2.0, various templates are available for generation.
- Running a project is as simple as clicking "Run" and the capability of editing the run configuration is also available.
- Projects with accompanying test suites built using frameworks such as MSTest and XUnit are able to be run directly within the Eclipse IDE against your programs. The results are currently printed to the console, but aCute can be improved with a dedicated UI element for visualizing the results.
- Finally, once a project is created, built, and tested it can be shared using the export wizard.
To assist with .NET Core development, a debug feature can be added to aCute, which is currently missing. This along with other additions are an opportunity for future development and will allow users to work more extensively with .NET Core projects within Eclipse. If you are interested in being a part of these developments, the aCute Team would love to onboard new contributors.
The Future of aCute
Up until now, aCute as been focused on getting the core components in aCute to a project ready state. As aCute has achieved this goal, its plan will be to use the influx of feedback retrieved from becoming a certified project to perfect the current suite of features and implement further additions that are requested by the user community. After this, hopefully more users and more contributors will join Team aCute and assist in making Eclipse a go to IDE for C# development. aCute stands as an example of how creating language based projects for Eclipse has become simplified. Hopefully aCute will inspire more developers to take on the task of developing other language based projects for themselves.