智能缩进算法文档? [英] Smart Indent algorithm documentation?

查看:29
本文介绍了智能缩进算法文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常喜欢记录 IDE 功能的正确行为,这些功能对编码流程有微妙但重要的影响 - 例如自动完成选择注释/取消注释代码 你可能没有意识到你利用了,但在一天结束时,你所做的只是比你可能做的多一点.我这样做是希望我必须使用的其他语言服务包含这些功能,从而改善我的日常编码生活.真正的"智能缩进,即 Visual Studio 2008 C# 编辑器,就是这些功能之一.

I'm a big fan of documenting the proper behavior of IDE features that have a subtle but significant impact on coding flow - things like auto-completion selection and commenting/uncommenting code you might not realize you take advantage of but at the end of the day you got just a bit more done than you might have. I do so in hopes that other language services I have to use incorporate the feature(s), subsequently improving my daily coding life. "Real" Smart Indent, i.e. the Visual Studio 2008 C# editor, is one of those features.

基本块代码缩进相当简单,可以在合理的时间内很好地完成工作.另一方面,真正的智能缩进很可能是迄今为止我必须在 IDE 中实现的最具技术挑战性的任务,而且我已经实现了我的公平份额.即使是成熟的即时自动代码重新格式化也更容易;它只是让 Smart Indent 完成繁重的工作.

Basic block code indentation is reasonably straightforward and can be hacked together in a reasonable amount of time well enough to get the job done. True Smart Indent, on the other hand, is quite possibly the most technically challenging task I've had to implement in the IDE to date, and I've implemented my fair share. Even full-blown on-the-fly automatic code reformatting is easier; it just defers to Smart Indent for the heavy lifting.

我正在寻找有关通用智能缩进算法的高级讨论.特别是,我正在寻找有关智能缩进策略的研究,或者对所有正常和边缘"情况的客观描述,以确保可重复、无错误的结果.最终,我'想提供功能的详细工作流程,实际实现该功能的具体基础,最后从中组装一个特定于语言的版本并将其集成到我的语言服务中.

I'm looking for high-level discussions of general purpose Smart Indent algorithms. In particular, I'm looking for either research on smart indent strategies, or an objective description of all normal and "edge" cases that could be tested to ensure repeatable, bug-free results. Eventually, I'd like to provide both a detailed workflow of the functionality, a concrete foundation for actually implementing the feature, and finally assembling a language-specific version from that and integrating it into my language services.

PS:Visual Studio 2010 的 C# 编辑器在此功能中有几个小错误.我自己实现了它,我对完善它所需要的工作有了全新的尊重.

PS: Visual Studio 2010's C# editor has several small bugs in this feature. Having implemented it myself, I have a whole new respect for the work it takes to polish it.

编辑 (8/25): 我设法 写下我认为当智能缩进在代码注释中时应该如何处理的规则草案.我可能会从 C++/C# 的角度研究规则,但稍后它们应该能够针对其他语言的各个方面进行参数化.

Edit (8/25): I managed to write down a draft the rules for how I think things should be handled when the smart indent is inside a code comment. I'll probably be working from a C++/C# perspective on the rules, but later they should be able to be parameterized for aspects of other languages.

推荐答案

Emacs CC 模式手册:缩进引擎基础知识.

史蒂夫·耶格博客咆哮:js2-mode:Emacs 的新 JavaScript 模式.

引用后者:令人惊讶的是,缩进问题与解析和语法验证几乎完全正交."

Quote from the latter: "Amazingly, surprisingly, counterintuitively, the indentation problem is almost totally orthogonal to parsing and syntax validation."

这篇关于智能缩进算法文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆