Lines 3041-3046
Link Here
|
3041 |
preferences.putBoolean("absoluteLabelIndent", false); |
3041 |
preferences.putBoolean("absoluteLabelIndent", false); |
3042 |
} |
3042 |
} |
3043 |
|
3043 |
|
|
|
3044 |
public void testJavadoc() throws Exception { |
3045 |
testFile = new File(getWorkDir(), "Test.java"); |
3046 |
TestUtilities.copyStringToFile(testFile, |
3047 |
"package hierbas.del.litoral;\n\n" |
3048 |
+ "public class Test {\n" |
3049 |
+ " public void taragui(CharSequence cs, Object obj) {\n" |
3050 |
+ " }\n" |
3051 |
+ "}\n"); |
3052 |
FileObject testSourceFO = FileUtil.toFileObject(testFile); |
3053 |
DataObject testSourceDO = DataObject.find(testSourceFO); |
3054 |
EditorCookie ec = (EditorCookie)testSourceDO.getCookie(EditorCookie.class); |
3055 |
final Document doc = ec.openDocument(); |
3056 |
doc.putProperty(Language.class, JavaTokenId.language()); |
3057 |
String content = |
3058 |
"package hierbas.del.litoral;\n" |
3059 |
+ "public class Test{\n" |
3060 |
+ "/**\n" |
3061 |
+ "*This is a test JavaDoc for the taragui method.\n" |
3062 |
+ "* Method description is here.\n" |
3063 |
+ "*<pre>\n" |
3064 |
+ "* Test t = new Test();\n" |
3065 |
+ "* try {\n" |
3066 |
+ "* t.taragui(\"TEST\", t);\n" |
3067 |
+ "* } catch (Exception e) {}\n" |
3068 |
+ "*</pre>\n" |
3069 |
+ "* @param cs this is the first parameter description.\n" |
3070 |
+ "* @param obj this is the second parameter description.\n" |
3071 |
+ "*@return this is the return value description.\n" |
3072 |
+ "* @throws MyRuntimeException the first exception description.\n" |
3073 |
+ "* @throws AnException the second exception description.\n" |
3074 |
+ "*/\n" |
3075 |
+ "public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3076 |
+ "/* This is a block comment.*/\n" |
3077 |
+ "return null;\n" |
3078 |
+ "}\n" |
3079 |
+ "}\n"; |
3080 |
|
3081 |
Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class); |
3082 |
preferences.putInt("text-limit-width", 45); |
3083 |
|
3084 |
String golden = |
3085 |
"package hierbas.del.litoral;\n" |
3086 |
+ "\n" |
3087 |
+ "public class Test {\n" |
3088 |
+ "\n" |
3089 |
+ " /**\n" |
3090 |
+ " * This is a test JavaDoc for the taragui\n" |
3091 |
+ " * method. Method description is here.\n" |
3092 |
+ " * <pre>\n" |
3093 |
+ " * Test t = new Test();\n" |
3094 |
+ " * try {\n" |
3095 |
+ " * t.taragui(\"TEST\", t);\n" |
3096 |
+ " * } catch (Exception e) {}\n" |
3097 |
+ " * </pre>\n" |
3098 |
+ " * <p/>\n" |
3099 |
+ " * @param cs this is the first parameter\n" |
3100 |
+ " * description.\n" |
3101 |
+ " * @param obj this is the second\n" |
3102 |
+ " * parameter description.\n" |
3103 |
+ " * @return this is the return value\n" |
3104 |
+ " * description.\n" |
3105 |
+ " * @throws MyRuntimeException the first\n" |
3106 |
+ " * exception description.\n" |
3107 |
+ " * @throws AnException the second\n" |
3108 |
+ " * exception description.\n" |
3109 |
+ " */\n" |
3110 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3111 |
+ " /*\n" |
3112 |
+ " * This is a block comment.\n" |
3113 |
+ " */\n" |
3114 |
+ " return null;\n" |
3115 |
+ " }\n" |
3116 |
+ "}\n"; |
3117 |
reformat(doc, content, golden); |
3118 |
|
3119 |
golden = |
3120 |
"package hierbas.del.litoral;\n" |
3121 |
+ "\n" |
3122 |
+ "public class Test {\n" |
3123 |
+ "\n" |
3124 |
+ " /**\n" |
3125 |
+ " *This is a test JavaDoc for the taragui method.\n" |
3126 |
+ " * Method description is here.\n" |
3127 |
+ " *<pre>\n" |
3128 |
+ " * Test t = new Test();\n" |
3129 |
+ " * try {\n" |
3130 |
+ " * t.taragui(\"TEST\", t);\n" |
3131 |
+ " * } catch (Exception e) {}\n" |
3132 |
+ " *</pre>\n" |
3133 |
+ " * @param cs this is the first parameter description.\n" |
3134 |
+ " * @param obj this is the second parameter description.\n" |
3135 |
+ " *@return this is the return value description.\n" |
3136 |
+ " * @throws MyRuntimeException the first exception description.\n" |
3137 |
+ " * @throws AnException the second exception description.\n" |
3138 |
+ " */\n" |
3139 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3140 |
+ " /* This is a block comment.*/\n" |
3141 |
+ " return null;\n" |
3142 |
+ " }\n" |
3143 |
+ "}\n"; |
3144 |
preferences.putBoolean("enableCommentFormatting", false); |
3145 |
reformat(doc, content, golden); |
3146 |
preferences.remove("enableCommentFormatting"); |
3147 |
|
3148 |
golden = |
3149 |
"package hierbas.del.litoral;\n" |
3150 |
+ "\n" |
3151 |
+ "public class Test {\n" |
3152 |
+ "\n" |
3153 |
+ " /**\n" |
3154 |
+ " * This is a test JavaDoc for the taragui method.\n" |
3155 |
+ " * Method description is here.\n" |
3156 |
+ " * <pre>\n" |
3157 |
+ " * Test t = new Test();\n" |
3158 |
+ " * try {\n" |
3159 |
+ " * t.taragui(\"TEST\", t);\n" |
3160 |
+ " * } catch (Exception e) {}\n" |
3161 |
+ " * </pre>\n" |
3162 |
+ " * <p/>\n" |
3163 |
+ " * @param cs this is the first parameter description.\n" |
3164 |
+ " * @param obj this is the second parameter description.\n" |
3165 |
+ " * @return this is the return value description.\n" |
3166 |
+ " * @throws MyRuntimeException the first exception description.\n" |
3167 |
+ " * @throws AnException the second exception description.\n" |
3168 |
+ " */\n" |
3169 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3170 |
+ " /*\n" |
3171 |
+ " * This is a block comment.\n" |
3172 |
+ " */\n" |
3173 |
+ " return null;\n" |
3174 |
+ " }\n" |
3175 |
+ "}\n"; |
3176 |
preferences.putBoolean("wrapCommentText", false); |
3177 |
reformat(doc, content, golden); |
3178 |
preferences.remove("wrapCommentText"); |
3179 |
|
3180 |
golden = |
3181 |
"package hierbas.del.litoral;\n" |
3182 |
+ "\n" |
3183 |
+ "public class Test {\n" |
3184 |
+ "\n" |
3185 |
+ " /**\n" |
3186 |
+ " This is a test JavaDoc for the taragui\n" |
3187 |
+ " method. Method description is here.\n" |
3188 |
+ " <pre>\n" |
3189 |
+ " Test t = new Test();\n" |
3190 |
+ " try {\n" |
3191 |
+ " t.taragui(\"TEST\", t);\n" |
3192 |
+ " } catch (Exception e) {}\n" |
3193 |
+ " </pre>\n" |
3194 |
+ " <p/>\n" |
3195 |
+ " @param cs this is the first parameter\n" |
3196 |
+ " description.\n" |
3197 |
+ " @param obj this is the second parameter\n" |
3198 |
+ " description.\n" |
3199 |
+ " @return this is the return value\n" |
3200 |
+ " description.\n" |
3201 |
+ " @throws MyRuntimeException the first\n" |
3202 |
+ " exception description.\n" |
3203 |
+ " @throws AnException the second exception\n" |
3204 |
+ " description.\n" |
3205 |
+ " */\n" |
3206 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3207 |
+ " /*\n" |
3208 |
+ " This is a block comment.\n" |
3209 |
+ " */\n" |
3210 |
+ " return null;\n" |
3211 |
+ " }\n" |
3212 |
+ "}\n"; |
3213 |
preferences.putBoolean("addLeadingStarInComment", false); |
3214 |
reformat(doc, content, golden); |
3215 |
|
3216 |
golden = |
3217 |
"package hierbas.del.litoral;\n" |
3218 |
+ "\n" |
3219 |
+ "public class Test {\n" |
3220 |
+ "\n" |
3221 |
+ " /**\n" |
3222 |
+ " This is a test JavaDoc for the taragui\n" |
3223 |
+ " method.\n" |
3224 |
+ " Method description is here.\n" |
3225 |
+ " <pre>\n" |
3226 |
+ " Test t = new Test();\n" |
3227 |
+ " try {\n" |
3228 |
+ " t.taragui(\"TEST\", t);\n" |
3229 |
+ " } catch (Exception e) {}\n" |
3230 |
+ " </pre>\n" |
3231 |
+ " <p/>\n" |
3232 |
+ " @param cs this is the first parameter\n" |
3233 |
+ " description.\n" |
3234 |
+ " @param obj this is the second parameter\n" |
3235 |
+ " description.\n" |
3236 |
+ " @return this is the return value\n" |
3237 |
+ " description.\n" |
3238 |
+ " @throws MyRuntimeException the first\n" |
3239 |
+ " exception description.\n" |
3240 |
+ " @throws AnException the second exception\n" |
3241 |
+ " description.\n" |
3242 |
+ " */\n" |
3243 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3244 |
+ " /*\n" |
3245 |
+ " This is a block comment.\n" |
3246 |
+ " */\n" |
3247 |
+ " return null;\n" |
3248 |
+ " }\n" |
3249 |
+ "}\n"; |
3250 |
preferences.putBoolean("preserveNewLinesInComments", true); |
3251 |
reformat(doc, content, golden); |
3252 |
preferences.remove("addLeadingStarInComment"); |
3253 |
|
3254 |
golden = |
3255 |
"package hierbas.del.litoral;\n" |
3256 |
+ "\n" |
3257 |
+ "public class Test {\n" |
3258 |
+ "\n" |
3259 |
+ " /**\n" |
3260 |
+ " * This is a test JavaDoc for the taragui\n" |
3261 |
+ " * method.\n" |
3262 |
+ " * Method description is here.\n" |
3263 |
+ " * <pre>\n" |
3264 |
+ " * Test t = new Test();\n" |
3265 |
+ " * try {\n" |
3266 |
+ " * t.taragui(\"TEST\", t);\n" |
3267 |
+ " * } catch (Exception e) {}\n" |
3268 |
+ " * </pre>\n" |
3269 |
+ " * <p/>\n" |
3270 |
+ " * @param cs this is the first parameter\n" |
3271 |
+ " * description.\n" |
3272 |
+ " * @param obj this is the second\n" |
3273 |
+ " * parameter description.\n" |
3274 |
+ " * @return this is the return value\n" |
3275 |
+ " * description.\n" |
3276 |
+ " * @throws MyRuntimeException the first\n" |
3277 |
+ " * exception description.\n" |
3278 |
+ " * @throws AnException the second\n" |
3279 |
+ " * exception description.\n" |
3280 |
+ " */\n" |
3281 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3282 |
+ " /*\n" |
3283 |
+ " * This is a block comment.\n" |
3284 |
+ " */\n" |
3285 |
+ " return null;\n" |
3286 |
+ " }\n" |
3287 |
+ "}\n"; |
3288 |
reformat(doc, content, golden); |
3289 |
preferences.remove("preserveNewLinesInComments"); |
3290 |
|
3291 |
golden = |
3292 |
"package hierbas.del.litoral;\n" |
3293 |
+ "\n" |
3294 |
+ "public class Test {\n" |
3295 |
+ "\n" |
3296 |
+ " /**\n" |
3297 |
+ " * This is a test JavaDoc for the taragui\n" |
3298 |
+ " * method. Method description is here.\n" |
3299 |
+ " * <pre>\n" |
3300 |
+ " * Test t = new Test();\n" |
3301 |
+ " * try {\n" |
3302 |
+ " * t.taragui(\"TEST\", t);\n" |
3303 |
+ " * } catch (Exception e) {}\n" |
3304 |
+ " * </pre>\n" |
3305 |
+ " *\n" |
3306 |
+ " * @param cs this is the first parameter\n" |
3307 |
+ " * description.\n" |
3308 |
+ " * @param obj this is the second\n" |
3309 |
+ " * parameter description.\n" |
3310 |
+ " * @return this is the return value\n" |
3311 |
+ " * description.\n" |
3312 |
+ " * @throws MyRuntimeException the first\n" |
3313 |
+ " * exception description.\n" |
3314 |
+ " * @throws AnException the second\n" |
3315 |
+ " * exception description.\n" |
3316 |
+ " */\n" |
3317 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3318 |
+ " /*\n" |
3319 |
+ " * This is a block comment.\n" |
3320 |
+ " */\n" |
3321 |
+ " return null;\n" |
3322 |
+ " }\n" |
3323 |
+ "}\n"; |
3324 |
preferences.putBoolean("generateParagraphTagOnBlankLines", false); |
3325 |
reformat(doc, content, golden); |
3326 |
|
3327 |
golden = |
3328 |
"package hierbas.del.litoral;\n" |
3329 |
+ "\n" |
3330 |
+ "public class Test {\n" |
3331 |
+ "\n" |
3332 |
+ " /**\n" |
3333 |
+ " This is a test JavaDoc for the taragui\n" |
3334 |
+ " method. Method description is here.\n" |
3335 |
+ " <pre>\n" |
3336 |
+ " Test t = new Test();\n" |
3337 |
+ " try {\n" |
3338 |
+ " t.taragui(\"TEST\", t);\n" |
3339 |
+ " } catch (Exception e) {}\n" |
3340 |
+ " </pre>\n" |
3341 |
+ "\n" |
3342 |
+ " @param cs this is the first parameter\n" |
3343 |
+ " description.\n" |
3344 |
+ " @param obj this is the second parameter\n" |
3345 |
+ " description.\n" |
3346 |
+ " @return this is the return value\n" |
3347 |
+ " description.\n" |
3348 |
+ " @throws MyRuntimeException the first\n" |
3349 |
+ " exception description.\n" |
3350 |
+ " @throws AnException the second exception\n" |
3351 |
+ " description.\n" |
3352 |
+ " */\n" |
3353 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3354 |
+ " /*\n" |
3355 |
+ " This is a block comment.\n" |
3356 |
+ " */\n" |
3357 |
+ " return null;\n" |
3358 |
+ " }\n" |
3359 |
+ "}\n"; |
3360 |
preferences.putBoolean("addLeadingStarInComment", false); |
3361 |
reformat(doc, content, golden); |
3362 |
preferences.remove("addLeadingStarInComment"); |
3363 |
preferences.remove("generateParagraphTagOnBlankLines"); |
3364 |
|
3365 |
golden = |
3366 |
"package hierbas.del.litoral;\n" |
3367 |
+ "\n" |
3368 |
+ "public class Test {\n" |
3369 |
+ "\n" |
3370 |
+ " /**\n" |
3371 |
+ " * This is a test JavaDoc for the taragui\n" |
3372 |
+ " * method. Method description is here.\n" |
3373 |
+ " * <pre>\n" |
3374 |
+ " * Test t = new Test();\n" |
3375 |
+ " * try {\n" |
3376 |
+ " * t.taragui(\"TEST\", t);\n" |
3377 |
+ " * } catch (Exception e) {}\n" |
3378 |
+ " * </pre>\n" |
3379 |
+ " * <p/>\n" |
3380 |
+ " * @param cs this is the first parameter\n" |
3381 |
+ " * description.\n" |
3382 |
+ " * @param obj this is the second\n" |
3383 |
+ " * parameter description.\n" |
3384 |
+ " * @return this is the return value\n" |
3385 |
+ " * description.\n" |
3386 |
+ " * @throws MyRuntimeException the first\n" |
3387 |
+ " * exception description.\n" |
3388 |
+ " * @throws AnException the second\n" |
3389 |
+ " * exception description.\n" |
3390 |
+ " */\n" |
3391 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3392 |
+ " /* This is a block comment. */\n" |
3393 |
+ " return null;\n" |
3394 |
+ " }\n" |
3395 |
+ "}\n"; |
3396 |
preferences.putBoolean("wrapOneLineComment", false); |
3397 |
reformat(doc, content, golden); |
3398 |
preferences.remove("wrapOneLineComment"); |
3399 |
|
3400 |
golden = |
3401 |
"package hierbas.del.litoral;\n" |
3402 |
+ "\n" |
3403 |
+ "public class Test {\n" |
3404 |
+ "\n" |
3405 |
+ " /**\n" |
3406 |
+ " * This is a test JavaDoc for the taragui\n" |
3407 |
+ " * method. Method description is here.\n" |
3408 |
+ " * <pre>\n" |
3409 |
+ " * Test t = new Test();\n" |
3410 |
+ " * try {\n" |
3411 |
+ " * t.taragui(\"TEST\", t);\n" |
3412 |
+ " * } catch (Exception e) {}\n" |
3413 |
+ " * </pre>\n" |
3414 |
+ " * @param cs this is the first parameter\n" |
3415 |
+ " * description.\n" |
3416 |
+ " * @param obj this is the second\n" |
3417 |
+ " * parameter description.\n" |
3418 |
+ " * @return this is the return value\n" |
3419 |
+ " * description.\n" |
3420 |
+ " * @throws MyRuntimeException the first\n" |
3421 |
+ " * exception description.\n" |
3422 |
+ " * @throws AnException the second\n" |
3423 |
+ " * exception description.\n" |
3424 |
+ " */\n" |
3425 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3426 |
+ " /*\n" |
3427 |
+ " * This is a block comment.\n" |
3428 |
+ " */\n" |
3429 |
+ " return null;\n" |
3430 |
+ " }\n" |
3431 |
+ "}\n"; |
3432 |
preferences.putBoolean("blankLineAfterJavadocDescription", false); |
3433 |
reformat(doc, content, golden); |
3434 |
preferences.remove("blankLineAfterJavadocDescription"); |
3435 |
|
3436 |
golden = |
3437 |
"package hierbas.del.litoral;\n" |
3438 |
+ "\n" |
3439 |
+ "public class Test {\n" |
3440 |
+ "\n" |
3441 |
+ " /**\n" |
3442 |
+ " * This is a test JavaDoc for the taragui\n" |
3443 |
+ " * method. Method description is here.\n" |
3444 |
+ " * <pre>\n" |
3445 |
+ " * Test t = new Test();\n" |
3446 |
+ " * try {\n" |
3447 |
+ " * t.taragui(\"TEST\", t);\n" |
3448 |
+ " * } catch (Exception e) {}\n" |
3449 |
+ " * </pre>\n" |
3450 |
+ " * <p/>\n" |
3451 |
+ " * @param cs this is the first parameter\n" |
3452 |
+ " * description.\n" |
3453 |
+ " * @param obj this is the second\n" |
3454 |
+ " * parameter description.\n" |
3455 |
+ " * @return this is the return value\n" |
3456 |
+ " * description.\n" |
3457 |
+ " * @throws MyRuntimeException the first\n" |
3458 |
+ " * exception\n" |
3459 |
+ " * description.\n" |
3460 |
+ " * @throws AnException the second\n" |
3461 |
+ " * exception\n" |
3462 |
+ " * description.\n" |
3463 |
+ " */\n" |
3464 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3465 |
+ " /*\n" |
3466 |
+ " * This is a block comment.\n" |
3467 |
+ " */\n" |
3468 |
+ " return null;\n" |
3469 |
+ " }\n" |
3470 |
+ "}\n"; |
3471 |
preferences.putBoolean("alignJavadocParameterDescriptions", true); |
3472 |
preferences.putBoolean("alignJavadocReturnDescription", true); |
3473 |
preferences.putBoolean("alignJavadocExceptionDescriptions", true); |
3474 |
reformat(doc, content, golden); |
3475 |
preferences.remove("alignJavadocExceptionDescriptions"); |
3476 |
preferences.remove("alignJavadocReturnDescription"); |
3477 |
preferences.remove("alignJavadocParameterDescriptions"); |
3478 |
|
3479 |
golden = |
3480 |
"package hierbas.del.litoral;\n" |
3481 |
+ "\n" |
3482 |
+ "public class Test {\n" |
3483 |
+ "\n" |
3484 |
+ " /**\n" |
3485 |
+ " * This is a test JavaDoc for the taragui\n" |
3486 |
+ " * method. Method description is here.\n" |
3487 |
+ " * <pre>\n" |
3488 |
+ " * Test t = new Test();\n" |
3489 |
+ " * try {\n" |
3490 |
+ " * t.taragui(\"TEST\", t);\n" |
3491 |
+ " * } catch (Exception e) {}\n" |
3492 |
+ " * </pre>\n" |
3493 |
+ " * <p/>\n" |
3494 |
+ " * @param cs this is the first parameter\n" |
3495 |
+ " * description.\n" |
3496 |
+ " * @param obj this is the second\n" |
3497 |
+ " * parameter description.\n" |
3498 |
+ " * <p/>\n" |
3499 |
+ " * @return this is the return value\n" |
3500 |
+ " * description.\n" |
3501 |
+ " * <p/>\n" |
3502 |
+ " * @throws MyRuntimeException the first\n" |
3503 |
+ " * exception description.\n" |
3504 |
+ " * @throws AnException the second\n" |
3505 |
+ " * exception description.\n" |
3506 |
+ " */\n" |
3507 |
+ " public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n" |
3508 |
+ " /*\n" |
3509 |
+ " * This is a block comment.\n" |
3510 |
+ " */\n" |
3511 |
+ " return null;\n" |
3512 |
+ " }\n" |
3513 |
+ "}\n"; |
3514 |
preferences.putBoolean("blankLineAfterJavadocParameterDescriptions", true); |
3515 |
preferences.putBoolean("blankLineAfterJavadocReturnTag", true); |
3516 |
reformat(doc, content, golden); |
3517 |
preferences.remove("blankLineAfterJavadocReturnTag"); |
3518 |
preferences.remove("blankLineAfterJavadocParameterDescriptions"); |
3519 |
|
3520 |
preferences.remove("text-limit-width"); |
3521 |
} |
3522 |
|
3044 |
/** |
3523 |
/** |
3045 |
* Do not put spaces to parenthesis when method declaration has no |
3524 |
* Do not put spaces to parenthesis when method declaration has no |
3046 |
* parameters. The same rule should be applied to method invocation. |
3525 |
* parameters. The same rule should be applied to method invocation. |
Lines 3281-3287
Link Here
|
3281 |
+ " /**\n" |
3760 |
+ " /**\n" |
3282 |
+ " *\n" |
3761 |
+ " *\n" |
3283 |
+ " *\n" |
3762 |
+ " *\n" |
3284 |
+ " }\n"; |
3763 |
+ " * }\n"; |
3285 |
reformat(doc, content, golden); |
3764 |
reformat(doc, content, golden); |
3286 |
} |
3765 |
} |
3287 |
|
3766 |
|