Atitit. ide technical principles and practices attilax summary, atitit. ideattilax
Atitit. ide technical principles and practices attilax Summary
1.1. Syntax coloring 1
1.2. Smart tip 1
1.3. class member outline .. func list1
1.4. type inference: 1
1.5. Remote debug1
1.6. debugging api package a gui is enough. 1
1.7. expression evaluation 2
1.8. For example, Java Compiler API2
1.9. Statistics on the number of codes in each part of the Ide 3
1.1.
Syntax coloring
Syntax highlighting depends on parser. to jump to the definition, the compiler must provide the symbol and source code dictionary. to reconstruct the compiler, the ast must be rewritten. You must support running expressions in the debugging window or even directly calling functions, this is supported during running. Compile
1.2.
Smart notification1.3.
Class member outline .. func list1.4.
Type inference ):1.5.
Remote debug
Attach
1.6.
One gui is enough for the debugging api package.
1.7.
Expression evaluation
This kind of black magic is the same thing (it should be much easier to say this only for compiled languages). It should have spent a lot of energy on development;
Author ::★(Attilax)> nickname: old wow's paw (full name: Attilax Akbar Al Rapanui Attila Akba Arla Panui) Chinese name: AI long, EMAIL: 1466519819@qq.com
Reprinted please indicate Source: http://www.cnblogs.com/attilax/
1.8. For example, Java Compiler API
I am mainly concerned with the compiler, so let's talk a few more words about the compiler and IDE.
Of course, in reality, developing an IDE may also have to implement the compiler of the source language.
SharpDevelop/MonoDevelop mentioned above, the new version has been changed to provide C # support based on Microsoft's Roslyn compiler, and syntax highlighting, error prompts, and smart prompts are all done well. However, its earlier versions are actually very weak. You can refer to this document for the so-called "syntax highlighting. Later, in order to implement smart prompts and other functions, we finally decided to implement a true C # parser. However, it does not support IDE functions based on any off-the-shelf compiler, but writes it by itself. Chapter 12th in the above book introduces this parser, but it is a bit messy.
Taking the Eclipse Java Development Environment (JDT) as an example, to implement accurate syntax highlighting and syntax error prompts, you must implement a complete parser according to the Java syntax; to implement real-time Semantic Error prompts, you must implement a complete semantic analyzer according to the Java semantics, and for a good user experience, it may require more checks and prompts on the error mode. By doing this, there is only one simple and intuitive code generator (code generator) available from a complete Java source code compiler. Therefore, Eclipse implements ECJ -- Eclipse Compiler for Java, which is integrated into Eclipse JDT.
On this basis, Eclipse JDT also has a project model to manage various resources in the project using a unified model, from workspace to project, package, and file, and the class/interface in it keeps going. At the class/interface level, this model uses the AST of ECJ.
In fact, if there is a ready-made compiler that supports the IDE well, you do not have to spend so much time writing the compiler to implement an IDE. However, when Eclipse was born, the mainstream Java source code compiler javac was not open source, while IBM's mainstream Java source code compiler Jikes was written in C ++ at that time, it is not convenient to integrate it into Eclipse written in Java, so you must write it yourself.
With this compiler, Eclipse can do many "unconventional" tasks. For example, a Class file can be generated for an incorrect source code file, in addition, this Class file can be executed until there is something wrong in the source code and then thrown an exception-this kind of thing javac is unlikely to do.
Later, javac was open-source, and many APIs (such as Java Compiler API) were opened to facilitate IDE to implement its own functions ), later, Netbeans simply used javac to implement various functions such as syntax highlighting and error reporting. For the story, refer to this blog: NetBeans IDE 6.0
Another counterexample is the C ++ support in Microsoft Visual Studio. Visual C ++ itself is an excellent optimization compiler, but its front-end part (lexical/syntax/Semantic Analysis + intermediate code generation) has a very long history ", the original design did not consider supporting IDE functions, so the C ++ support in Visual Studio IDE actually uses another completely different C ++ parser (purchased from EDG ), it increases complexity and cannot guarantee full compatibility between the two parser sets.
Of course, Microsoft has long been aware of this problem. Recently, with the Support for C ++ 14, Microsoft has greatly updated the front-end of its Visual C ++ Compiler (refer to Rejuvenating the Microsoft C/C ++ Compiler ), if you follow this path, you can replace the edg c ++ parser in the IDE with Visual C ++, which is also possible in the future.
1.9.
Statistics on the number of codes in each part of the Ide
Category |
Included content |
Source code lines |
Code Analysis |
Code model, analysis, and generation |
123957 |
IDE |
IDE programs and interfaces |
62940 |
Visual Editor |
Visual editor |
30760 |
Text Editor |
Text Editor |
20264 |
Tools |
Auxiliary Tools such as version control and help |
11556 |
Language |
Language binding, including C # and VB |
9292 |
Debugger |
Debugger |
9238 |
Framework |
Asp. Net Mvc and other frameworks |
8513 |
Misc |
Miscellaneous |
2289 |
Builder |
Build and MsBuild |
1774 |
Data |
Database Support |
1396 |
Corresponding chart:
Project Analysis
It can be seen that the most complex part of the entire IDE is the code model processing. The number of codes is almost twice that of the second (IDE), and the proportion of code in the entire project is close to 50%. I did not analyze it further, but I can imagine that the text coloring, syntax prompts, code generation, Auxiliary Analysis, and refactoring functions during code editing should all be related to this. If you really want to write an IDE by yourself, this part is definitely a hard nut to crack.
References
Real-world Analysis of IDE-answers to the question "how difficult it is to develop an IDE" _ shuhari's blog. html
How difficult it is to develop an IDE _-programming-zhiyun.html