初めに

Javaは、IDEのサポートを受けて、テストファーストで、リファクタリングで洗練していくことが得意な言語だと思っております。

欠点は、ボイラープレートという、冗長さです。

が、長所でもあり、解析のしやすさというか、透明性が高いのがいいところです。

競馬でたとえると、先行逃げ切りタイプが、Rubyとかで、後でまくるタイプなのが、Javaです。

よく、最初は、Rubyでやっていたけど、あとから、Javaで作り直したというプロジェクトは多いです。その逆よりは多いです。

エクリプスのテンプレート機能

前置きがながくなりましたが、

人間の労力がすくないんだったら、ボイラープレートもいいんじゃない?というのが、このドキュメントの趣旨でございます。

エクリプスには、テンプレート機能がありまして、メニューから

[ウィンドウ] --> [Java] ---> [エディター] ---> [テンプレート]

で設定画面が開きます。

使う言語は、ファイルの拡張子とか、コードの解析した位置を認識してくれるみたいで、設定しておきましょう(デフォルトだとJavaになってなくて、Javaに修正が必要なのは、なんとかしてほしい)

コードを動的に解析した変数がテンプレートに使える

下記のコードをsampleとか、てきとうな名前て登録しましょう

activeTaskKey: ${activeTaskKey}
activeTaskPrefix: ${activeTaskPrefix}
argType: ${argType}
array: ${array}
array_element: ${array_element}
array_type: ${array_type}
collection: ${collection}
cursor: ${cursor}
date: ${date}
$$: $$
elemType: ${elemType}
enclosing_method: ${enclosing_method}
enclosing_method_arguments: ${enclosing_method_arguments}
enclosing_package: ${enclosing_package}
enclosing_project: ${enclosing_project}
enclosing_type: ${enclosing_type}
exception_variable_name: ${exception_variable_name}
field: ${field}
file: ${file}
git_config: ${git_config}
import: ${import}
importStatic: ${importStatic}
index: ${index}
iterable_element: ${iterable_element}
iterable_type: ${iterable_type}
iterator: ${iterator}
line_selection: ${line_selection}
link: ${link}
localVar: ${localVar}
newName: ${newName}
newType: ${newType}
primary_type_name: ${primary_type_name}
return_type: ${return_type}
time: ${time}
todo: ${todo}
user: ${user}
var: ${var}
word_selection: ${word_selection}
year: ${year}
トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS