ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android studio插件相关(逐步完成系列)

2019-02-27 13:53:16  阅读:288  来源: 互联网

标签:插件 code working 代码 should 导包 studio 整理 android


插件相关内容:只是日常看点英文,并且为有需要的人提供一点帮助,如果有意见,那代表你并不是本文适合的服务对象,请点击退出键退出,如果有建议,我们可以详细探讨。

 

Whitespaces and Imports

When working with PSI modification functions, you should never create individual whitespace nodes (spaces or line breaks) from text. Instead, all whitespace modifications are performed by the formatter, which follows the code style settings selected by the user. Formatting is automatically performed at the end of every command, and if you need, you can also perform it manually using the reformat(PsiElement) method in the CodeStyleManager class.

Also, when working with Java code (or with code in other languages with a similar import mechanism such as Groovy or Python), you should never create imports manually. Instead, you should insert fully-qualified names into the code you’re generating, and then call the shortenClassReferences() method in the JavaCodeStyleManager (or the equivalent API for the language you’re working with). This ensures that the imports are created according to the user’s code style settings and inserted into the correct place of the file.

译:

空白代码片段(此处指空行,和空格)和导包操作

当使用PSI修改功能时,你绝不该以text文字的方式新建独立的空白代码片段。而应该使用格式整理器来进行代码的整理工作,代码整理器的整理效果是按照用户设定的代码格式而定的。代码整理在每一条指令之后都会自动执行,但是如果你有迫切的需要的话,你也可以手动通过调用CodeStyleManager类中的reformat(PsiElement)方法来执行它。

另外,运作的目标语言为Java(或者其他相似导包操作的的语言例如Groovy或者Python时),你绝不应该尝试手动创建导包代码。而应该在你生成的代码中插入该类的全路径名,然后调用JavaCodeStyleManager的shortenClassReferences()方法(或者你当前正在使用的相应的API)来达成相应的目的。这确保了导包的代码是符合用户的代码风格并且能正确地插入到文件中的合适位置。

标签:插件,code,working,代码,should,导包,studio,整理,android
来源: https://blog.csdn.net/qq_31433709/article/details/87970998

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有