📜 ⬆️ ⬇️

DLang plugin for IntelliJ IDEA (Alpha, EAP, POC)

Good day. Are there any experts in the programming language D? The first acquaintance with this language often comes up against the problem of finding a suitable IDE. I also encountered this problem. And, as a typical type programmer, I undertook to write a plugin to support the D language on the IntelliJ IDEA 14 platform.

Disclaimer 1: This is version 0.0.8, as long as the minimum of functionality is implemented, there will surely be bugs, it will probably seem to you that the plugin does not know how. I realize that there is a lot of work to be done to bring the plugin to the state of "can be used."

Disclaimer 2: If you still decide to look at the source code, I want to warn you that this is my first programming experience for IntelliJ IDEA. Criticism is welcome. As well as pull requests.
')

DLang plugin 0.0.8





What is:
  1. Syntax highlighting;
  2. Parsing and building a syntax tree;
  3. Class navigation;
  4. Call an external dmd compiler or dub build system;
  5. Connecting external LIB files and source libraries;


What remains to be:
  1. Code formatting;
  2. Handling parsing errors;
  3. Links inside the code. That is, the ability to go to the declaration of a variable / function / method / class / module / template by its name.
  4. Tips and code completion;
  5. Checks, checks, checks. IDEA should be able to check the type of the variable and the value that is written into it, check the argument list of functions and methods, the scope of the variables / functions / classes used, the correct use of patterns, constancy and immutability, and many other semantic checks. All this logic needs to write code. You can, of course, rely on the compiler in the search for errors, but why then the IDE?
  6. Run and debug the application. Honestly, I still have no idea how IDEA can interact with the program being debugged (analyze the stack, set breakpoints, view the values ​​of variables, etc.) It’s good that there are intellij-erlang and intellij-haxe sources as an example.
  7. Integration with the DUB assembly system and its configuration files in JSON format.


So far, there is one beta tester with Mac OS X in the “team” and I am a Windows programmer.

Installation and Setup


Plugin requires version IntelliJ IDEA 14 and higher. Open Settings> Plugins. Enter “D Language” in the search field and click “Install Plugin”.


Now you can create a new DLang project.

How to create a new project


There are two types of project "D Application" and "D Application with DUB". They differ only in the assembly settings. In projects of the first type, a configuration is created by default for building a project using the DMD compiler (Digital Mars D). In another type - build configuration via DUB (officially recommended build system for DLang projects).

DMD is a compiler developed by Digital Mars. It is proposed to download it on the page dlang.org/download.html .
Whichever option you choose, it is always possible to reconfigure assemblies from DMD to DUB and vice versa.

After creating your first project, you need to configure the DLang SDK. Open the Project Structure (Strl + Alt + Shift + S) and add the "Digital Mars D Compiler"


You will need to select the folder where the dmd executable file (or dmd.exe ) is located. For example E:\dmd2\windows\bin\
Now you can build and run your D projects.

Module settings


The project in IntelliJ IDEA consists of modules. The DLang module has settings that almost repeat the settings of the Java module:


How to run a build using DUB


The recommended application build system is DUB. The project is configured using the dub.json file, which specifies the meta information, submodules, external dependencies, compilation parameters. See http://code.dlang.org/package-format for details. The plugin can run the build command directly from the IDE:



Unfortunately, integration with DUB is incomplete. A plugin should be able to import a project from a dub.json file, analyze dependencies, and many other things, like the Maven plugin in IDEA. This task is for the future.

Development plans


Unfortunately, I cannot devote to developing a plugin 8 hours a day, since this is not my main work. But the development will definitely continue. The list of vital features is above . Install, use, send bugs. If you know Java and want to help - welcome on Github .

PS If you ever decide to create your own programming language, please never call it in one or two letters. It is very difficult to google anything by the letter “D” or the word “Go”. Let the name of your programming language be an abbreviation of eight letters, or a word from Ndebele, or the name of a monster from D & D, or a fictional planet from the TV series Stargate. The more unique the word, the easier it is to find information on the Web. Sorry, boiling!

Source: https://habr.com/ru/post/256151/


All Articles