码迷,mamicode.com
首页 > 其他好文 > 详细

四、注释的折叠

时间:2020-03-02 21:00:10      阅读:68      评论:0      收藏:0      [点我收藏+]

标签:eal   start   support   creat   Fix   can   alt   source   mos   

原文地址

Folding in comment

四、注释的折叠

This keyword set is new in UDL 2.1.
It allows you to fold anything as long as your language supports comments.
Let’s demonstrate it by using C++ comments.

Example 1

技术图片

Note: When selecting keywords that turn comments into folding points, it is important to select unique keywords. Don’t use stuff that is part of your source code, that will create unexpected folding points when you comment out parts of your source code.

技术图片

Notice how comments that have ‘folding in comment’ keywords embedded in them, create folding points in your code. I even mixed line comments and normal comments, and it works. So, any comment with ‘folding in comment’ keywords embedded can become a folding point. And remember, these are just comments, you can put them anywhere you like. In fact, you can use this feature to organize your code. For one way to do it, see next example.

Example 2

Let’s steal some ideas from C#. Our code will be organized in ‘regions’.

技术图片

One keyword group will be anything that starts with ‘at sign’ (@), so check Prefix mode option.

技术图片

We’ll define comments as standard C++ comments:

/* cpp comment */
// cpp line comment

The important thing here is to allow nesting of keyword group two (words that start with ‘@’ sign)

技术图片

Finally, the magic happens.
I organized my code in three logical groups:

  • initialization
  • execution
  • clean up

These three keywords are not defined anywhere, I can call my regions anything I like, as long as I use ‘@’ prefix.

Notice how ‘region’ and ‘end’ keywords have the same color as comments, but region name uses distinct color to be easily noticeable.

技术图片

Folding in comment keywords support multi-part keywords too.

In the end, I would just like to say that, if used properly, this could be the single most useful feature of UDL 2.1.

四、注释的折叠

标签:eal   start   support   creat   Fix   can   alt   source   mos   

原文地址:https://www.cnblogs.com/xin04/p/12397534.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!