アイデアライブテンプレートの高度な知識、高度な
为了解决用一个命令(宏)给方法,类,js方法添加注释,经过几天的研究.终于得到结果了.
实现的效果如下:
给Java中的method添加方法:
/** * * @Method : addMenu * @Description : * @param menu : * @return : cn.yiyizuche.common.base.ResultMsg * @author : Rush.D.Xzj * @CreateDate : 2017-06-12 星期一 18:17:42 * */public ResultMsg addMenu(Menu menu){ ResultMsg result = null;return result; }
给 Java class 添加注释:
/** * * @Project : 壹壹OA * @Package : cn.yiyizuche.common.ou.menu.controller * @Class : MenuController * @Description : * @author : Rush.D.Xzj * @CreateDate : 2017-06-12 星期一 18:15:32 * @version : V1.0.0 * @Copyright : 2017 yizukeji Inc. All rights reserved. * @Reviewed : * @UpateLog : Name Date Reason/Contents * --------------------------------------- * *** **** **** * */public class MenuController { }
给js 的方法添加注释
/** * * @Method : standardShowBatchCheckBox * @Description : * @return : * @author : Rush.D.Xzj * @CreateDate : 2017-06-12 星期一 18:15:21 * */function standardShowBatchCheckBox(jspElement, dataList, max, valueIdFunction, textFunction, selectedFunction) { }
现在把答案公布如下
Abbreviation:
cmj
Template text(注1):
** *$context$ */
Edit variables:
$context$的代码(主要代码)如下:
groovyScript("def methodName = \"${_1}\"; def jsMethodName = \"${_2}\"; def outputMethodName = \"${_3}\"; def outputDesc = \"${_4}\"; def outputParams = \"${_5}\"; def outputAuthor = \"${_6}\"; def outputReturnType = \"${_7}\"; def outputDateTime = \"${_8}\"; def outputPackage = \"${_9}\"; def outputClass = \"${_10}\"; def outputClassOtherInfo = \"${_11}\"; def outputProject = \"${_12}\"; def outputVersion = \"${_13}\"; def outputJsMethodName = \"${_14}\"; def outputJsReturnType = \"${_15}\"; def result = ''; if (methodName != 'null') { result += '\\n'; result += outputMethodName; result += outputDesc; result += outputParams; result += outputReturnType; result += outputAuthor; result += outputDateTime; result += ' *'; return result; } else if (jsMethodName != 'null') { result += '\\n'; result += outputJsMethodName; result += outputDesc; result += outputJsReturnType; result += outputAuthor; result += outputDateTime; result += ' *'; return result; } else { result += '\\n'; result += outputProject; result += outputPackage; result += outputClass; result += outputDesc; result += outputAuthor; result += outputDateTime; result += outputVersion; result += outputClassOtherInfo; result += ' *'; return result; } ", methodName(), jsMethodName(), groovyScript("def methodName = \"${_1}\"; def result = ' * @Method : ' + methodName + '\\n'; return result;", methodName()), groovyScript("def result = ' * @Description : ' + '\\n'; return result;"), groovyScript("if(\"${_1}\".length() == 2) { return ''; } else { def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) { result+=' * @param ' + params[i] + ' : ' + '\\n' }; return result;}", methodParameters()), groovyScript("def author = 'Rush.D.Xzj'; def result = ' * @author : ' + author + '\\n'; return result;"), groovyScript("def returnType = \"${_1}\"; def result = ' * @return : ' + returnType + '\\n'; return result;", methodReturnType()), groovyScript("def date = \"${_1}\"; def time = \"${_2}\"; def result = ' * @CreateDate : ' + date + ' ' + time + '\\n'; return result;", date("yyyy-MM-dd E"), time("HH:mm:ss")), groovyScript("def currentPackage = \"${_1}\"; def result = ' * @Package : ' + currentPackage + '\\n'; return result;", currentPackage()), groovyScript("def className = \"${_1}\"; def result = ' * @Class : ' + className + '\\n'; return result;", className()), groovyScript("def result = ' * @Copyright : 2017 yizukeji Inc. All rights reserved.' + '\\n'; result += ' * @Reviewed : ' + '\\n'; result += ' * @UpateLog : Name Date Reason/Contents' + '\\n'; result += ' * ---------------------------------------' + '\\n'; result += ' * *** **** **** ' + '\\n'; return result;"), groovyScript("def result = ' * @Project : 壹壹OA' + '\\n'; return result;"), groovyScript("def result = ' * @version : V1.0.0' + '\\n'; return result;"), groovyScript("def jsMethodName = \"${_1}\"; def result = ' * @Method : ' + jsMethodName + '\\n'; return result;", jsMethodName()), groovyScript("def result = ' * @return : ' + '\\n'; return result;"))
使用如下:
在xx.java或者 xx.js中输出(注2):
/cmj
后 按 tab键(此键是默认的,可以更改成其他的)
注1 和注2
也可以换成第二种方法(网上大部分的方法):
Template text
* *$context$ */
跟注1比较第一行少了一个*,
因此注2就是变成了:
/*cmj
我感觉用我的方法比第二种方法好.
Edit Variable中代码详解
首先我分解了如下的 10几个函数(是小函数):
// 输出方法名groovyScript("def methodName = \"${_1}\"; def result = ' * @Method : ' + methodName + '\\n'; return result;", methodName()) // 输出描述 groovyScript("def result = ' * @Description : ' + '\\n'; return result;") // 输出参数列表的子函数 groovyScript("if(\"${_1}\".length() == 2) {return ''; } else { def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+=' * @param ' + params[i] + ' : ' + '\\n'}; return result;}", methodParameters()) // 输出 作者的 子函数 这里可以改作者 groovyScript("def author = 'Rush.D.Xzj'; def result = ' * @author : ' + author + '\\n'; return result;") // 输出 返回值的 子函数 groovyScript("def returnType = \"${_1}\"; def result = ' * @return : ' + returnType + '\\n'; return result;", methodReturnType()) // 输出 日期的 字函数, 这个可以更改日期格式 groovyScript("def date = \"${_1}\"; def time = \"${_2}\"; def result = ' * @CreateDate : ' + date + ' ' + time + '\\n'; return result;", date("yyyy-MM-dd E"), time("HH:mm:ss")) // 输出Project groovyScript("def result = ' * @Project : 壹壹OA' + '\\n'; return result;") // 输出package groovyScript("def currentPackage = \"${_1}\"; def result = ' * @Package : ' + currentPackage + '\\n'; return result;", currentPackage()) // 输出class groovyScript("def className = \"${_1}\"; def result = ' * @Class : ' + className + '\\n'; return result;", className()) // 输出copyright/reviewd/updatelog groovyScript("def result = ' * @Copyright : 2017 yizukeji Inc. All rights reserved.' + '\\n'; result += ' * @Reviewed : ' + '\\n'; result += ' * @UpateLog : Name Date Reason/Contents' + '\\n'; result += ' * ---------------------------------------' + '\\n'; result += ' * *** **** **** ' + '\\n'; return result;") // 输出version groovyScript("def result = ' * @version : V1.0.0' + '\\n'; return result;") // 输出jsMethodName groovyScript("def jsMethodName = \"${_1}\"; def result = ' * @Method : ' + jsMethodName + '\\n'; return result;", jsMethodName()) // 输出 js 的return groovyScript("def result = ' * @return : ' + '\\n'; return result;")
然后在主要代码中,需要把上述的10几个函数当做参数供给主要代码使用.
判断是函数,类,js函数主要是通过如下的2个内置变量来实现的:
methodName() jsMethodName()
当methodName()不为空的时候, 生成 方法的 注释
当jsMethodName()不为空的时候, 生成 js方法的注释
否则生成类的注释
所以上述的代码可以简单的做如下的归类了:
获取相关参数:
def methodName = \"${_1}\"; def jsMethodName = \"${_2}\"; def outputMethodName = \"${_3}\"; def outputDesc = \"${_4}\"; def outputParams = \"${_5}\"; def outputAuthor = \"${_6}\"; def outputReturnType = \"${_7}\"; def outputDateTime = \"${_8}\"; def outputPackage = \"${_9}\"; def outputClass = \"${_10}\"; def outputClassOtherInfo = \"${_11}\"; def outputProject = \"${_12}\"; def outputVersion = \"${_13}\"; def outputJsMethodName = \"${_14}\"; def outputJsReturnType = \"${_15}\"; def result = '';
判断是哪一种类型的注释(代码片段2):
if (methodName != 'null') { result += '\\n'; result += outputMethodName; result += outputDesc; result += outputParams; result += outputReturnType; result += outputAuthor; result += outputDateTime; result += ' *';return result; } else if (jsMethodName != 'null') { result += '\\n'; result += outputJsMethodName; result += outputDesc; result += outputJsReturnType; result += outputAuthor; result += outputDateTime; result += ' *';return result; } else { result += '\\n'; result += outputProject; result += outputPackage; result += outputClass; result += outputDesc; result += outputAuthor; result += outputDateTime; result += outputVersion; result += outputClassOtherInfo; result += ' *';return result; }
这下就可以了.就把整个这么难看(groopscript搞的?)代码整理的比较清晰了.
我还有如下的几个疑惑/问题需要解决, 如果有朋友能给我答案那就好了.
问题1. 不知道可以通过什么方法获取js方法中的参数列表
问题2. 代码片段2中如果我改成了:
result += '\\n';if (methodName != 'null') { result += outputMethodName; result += outputDesc; result += outputParams; result += outputReturnType; result += outputAuthor; result += outputDateTime; } else if (jsMethodName != 'null') { result += '\\n'; result += outputJsMethodName; result += outputDesc; result += outputJsReturnType; result += outputAuthor; result += outputDateTime; } else { result += '\\n'; result += outputProject; result += outputPackage; result += outputClass; result += outputDesc; result += outputAuthor; result += outputDateTime; result += outputVersion; result += outputClassOtherInfo; } result += ' *';return result;
会出现如下的错误:
startup failed: Script1.groovy: 1: expecting EOF, found 'result' @ line 1, column 1036. lt += outputClassOtherInfo; } result += ^ 1 error
问题3: 不知道怎么获取Override方法对应的接口方法(父类方法)
关于问题3: 实际上给这种方法加注释是没有意义的,具体可以参考:
但是如果非要加该怎么去判断.
最后可以把 缩写(abbreviation) 改成: *
这样以后只需要输入:
/*
然后按一下 tab 键就出现结果了
哈哈!!!
以上がアイデアライブテンプレートの高度な知識、高度なの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









Baidu 詳細検索の使用方法 Baidu 検索エンジンは現在中国で最も一般的に使用されている検索エンジンの 1 つであり、豊富な検索機能を提供しており、その 1 つが詳細検索です。高度な検索は、ユーザーが必要な情報をより正確に検索し、検索効率を向上させるのに役立ちます。では、Baidu の高度な検索を使用するにはどうすればよいでしょうか?最初のステップは、Baidu 検索エンジンのホームページを開くことです。まず、Baidu の公式 Web サイト (www.baidu.com) を開く必要があります。ここが百度検索の入り口です。 2 番目のステップでは、「詳細検索」ボタンをクリックします。 Baidu の検索ボックスの右側に、

JavaScript チュートリアル: HTTP ステータス コードを取得する方法、特定のコード例が必要です 序文: Web 開発では、サーバーとのデータ対話が頻繁に発生します。サーバーと通信するとき、多くの場合、返された HTTP ステータス コードを取得して操作が成功したかどうかを判断し、さまざまなステータス コードに基づいて対応する処理を実行する必要があります。この記事では、JavaScript を使用して HTTP ステータス コードを取得する方法を説明し、いくつかの実用的なコード例を示します。 XMLHttpRequestの使用

設定手順: 1. IntelliJ IDEA を開いてプロジェクトに入ります; 2. トップメニューで [実行] をクリックします; 3. 左上隅のプラス記号を選択し、[Tomcat サーバー] > [ローカル] を選択します; 4. 「サーバー」オプションで「構成」をクリックし、Tomcat インストール ディレクトリを選択します。 5. 「展開」オプションで、プラス記号をクリックしてプロジェクトを追加します。 6. 「起動前」に保存します。

IDEA (IntelliJIDEA) は、開発者がさまざまな Java アプリケーションを迅速かつ効率的に開発できるようにする強力な統合開発環境です。 Java プロジェクト開発では、Maven をプロジェクト管理ツールとして使用すると、依存ライブラリの管理やプロジェクトのビルドなどをより適切に行うことができます。この記事では、IDEA で Maven プロジェクトを作成する基本的な手順を詳しく説明し、具体的なコード例を示します。ステップ 1: IDEA を開いて新しいプロジェクトを作成する IntelliJIDEA を開く

この記事では、Xbox Live への接続または Xbox One へのログイン時に接続タイムアウトの問題を引き起こす 0x87dd0019 Xbox ログイン エラーを修正する方法を説明します。 Xbox のエラー コード 0x87e00019 とは何ですか? Xbox 本体でゲームをインストールまたは更新するときにエラー コード 0x87e00019 が発生した場合は、Xbox ハード ドライブの記憶域スペースが不足しているか、ほぼいっぱいである可能性があります。この問題を解決するには、ストレージ領域を解放する必要があります。同時に、Xbox Live サービスのステータスも確認する必要があります。このエラーは Xbox サーバーの問題が原因である可能性があります。これらのヒントを使用して 0x87dd0019 Xbox ログイン エラーを修正する方法

JavaScript で HTTP ステータス コードを取得する方法の紹介: フロントエンド開発では、バックエンド インターフェイスとの対話を処理する必要があることが多く、HTTP ステータス コードはその非常に重要な部分です。 HTTP ステータス コードを理解して取得すると、インターフェイスから返されたデータをより適切に処理できるようになります。この記事では、JavaScript を使用して HTTP ステータス コードを取得する方法と、具体的なコード例を紹介します。 1. HTTP ステータス コードとは何ですか? HTTP ステータス コードとは、ブラウザがサーバーへのリクエストを開始したときに、サービスが

設定方法: 1. IntelliJ IDEA を開き、ツールバーのドロップダウン メニューから [設定の編集] を選択します; 2. 新しいウィンドウに入り、[+] 記号をクリックしてドロップダウン メニューに入り、[ローカル] を選択します。 「Tomcat サーバー」の「」 3. 新しいインターフェースで、Tomcat のインストール ディレクトリを選択します。ディレクトリを選択した後、「OK」をクリックします。 4. Tomcat を起動するようにブラウザを設定します。

IDEA で Tomcat ソース コードを表示する手順: 1. Tomcat ソース コードをダウンロードする; 2. Tomcat ソース コードを IDEA にインポートする; 3. Tomcat ソース コードを表示する; 4. Tomcat の動作原理を理解する; 5. 注意事項; 6. 継続的な学習と更新する; 7. ツールとプラグインを使用する; 8. コミュニティに参加して貢献する。詳細な紹介: 1. Tomcat ソース コードをダウンロードします。ソース コード パッケージは、Apache Tomcat の公式 Web サイトからダウンロードできます。通常、これらのソース コード パッケージは ZIP または TAR 形式などです。
