View | Details | Raw Unified | Return to bug 260011 | Differences between
and this patch

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java (-13 / +13 lines)
Lines 142-154 Link Here
142
	int length = htmlTag == null ? 0 : htmlTag.length;
142
	int length = htmlTag == null ? 0 : htmlTag.length;
143
	int tagId = 0;
143
	int tagId = 0;
144
	if (length > 0) {
144
	if (length > 0) {
145
		for (int i=0, max=JAVADOC_SPECIAL_TAGS.length; i<max; i++) {
145
//		for (int i=0, max=JAVADOC_SPECIAL_TAGS.length; i<max; i++) {
146
			char[] tag = JAVADOC_SPECIAL_TAGS[i];
146
//			char[] tag = JAVADOC_SPECIAL_TAGS[i];
147
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
147
//			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
148
				tagId = JAVADOC_SPECIAL_TAGS_ID;
148
//				tagId = JAVADOC_SPECIAL_TAGS_ID;
149
				break;
149
//				break;
150
			}
150
//			}
151
		}
151
//		}
152
		for (int i=0, max=JAVADOC_SINGLE_BREAK_TAG.length; i<max; i++) {
152
		for (int i=0, max=JAVADOC_SINGLE_BREAK_TAG.length; i<max; i++) {
153
			char[] tag = JAVADOC_SINGLE_BREAK_TAG[i];
153
			char[] tag = JAVADOC_SINGLE_BREAK_TAG[i];
154
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
154
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
Lines 273-290 Link Here
273
    			return false;
273
    			return false;
274
	    }
274
	    }
275
	    if ((token = readTokenAndConsume()) != TerminalTokens.TokenNameGREATER) {
275
	    if ((token = readTokenAndConsume()) != TerminalTokens.TokenNameGREATER) {
276
	    	if ((htmlIndex & JAVADOC_SPECIAL_TAGS_ID) == JAVADOC_SPECIAL_TAGS_ID) {
276
//	    	if ((htmlIndex & JAVADOC_SPECIAL_TAGS_ID) == JAVADOC_SPECIAL_TAGS_ID) {
277
	    		// Special tags may have attributes, so consume tokens until the greater token is encountered
277
	    		// tags may have attributes, so consume tokens until the greater token is encountered
278
	    		while (token != TerminalTokens.TokenNameGREATER) {
278
	    		while (token != TerminalTokens.TokenNameGREATER) {
279
	    			token = readTokenAndConsume();
279
	    			token = readTokenAndConsume();
280
	    			if (token == TerminalTokens.TokenNameEOF) {
280
	    			if (token == TerminalTokens.TokenNameEOF) {
281
	    				return false;
281
	    				return false;
282
	    			}
282
	    			}
283
	    		}
283
	    		}
284
	    	} else {
284
//	    	} else {
285
		    	// invalid syntax
285
//		    	// invalid syntax
286
				return false;
286
//				return false;
287
	    	}
287
//	    	}
288
	    }
288
	    }
289
289
290
	    // Push texts
290
	    // Push texts
(-)formatter/org/eclipse/jdt/internal/formatter/comment/IJavaDocTagConstants.java (-13 / +2 lines)
Lines 67-74 Link Here
67
	};
67
	};
68
68
69
	/** Javadoc parameter tags */
69
	/** Javadoc parameter tags */
70
	// TODO (eric) should have another name than 'param' for the following tags
70
	// TODO (frederic) should have another name than 'param' for the following tags
71
	// TODO (eric) investigate how and why this list was created
71
	// TODO (frederic) investigate how and why this list was created
72
	public static final char[][] JAVADOC_PARAM_TAGS= new char[][] {
72
	public static final char[][] JAVADOC_PARAM_TAGS= new char[][] {
73
			"@exception".toCharArray(), //$NON-NLS-1$
73
			"@exception".toCharArray(), //$NON-NLS-1$
74
			"@param".toCharArray(), //$NON-NLS-1$
74
			"@param".toCharArray(), //$NON-NLS-1$
Lines 89-104 Link Here
89
			"tr".toCharArray(), //$NON-NLS-1$
89
			"tr".toCharArray(), //$NON-NLS-1$
90
	};
90
	};
91
91
92
	/**
93
	 * Following table is used to identify special tags which may have more complex
94
	 * opening than just &lt;name&gt;
95
	 */
96
	public static final char[][] JAVADOC_SPECIAL_TAGS= new char[][] {
97
			"table".toCharArray(), //$NON-NLS-1$
98
			"tr".toCharArray(), //$NON-NLS-1$
99
			"td".toCharArray(), //$NON-NLS-1$
100
	};
101
102
	/** Javadoc tag prefix */
92
	/** Javadoc tag prefix */
103
	public static final char JAVADOC_TAG_PREFIX= '@';
93
	public static final char JAVADOC_TAG_PREFIX= '@';
104
94
Lines 151-155 Link Here
151
	static final int JAVADOC_SEPARATOR_TAGS_ID = 0x1000;
141
	static final int JAVADOC_SEPARATOR_TAGS_ID = 0x1000;
152
	static final int JAVADOC_SINGLE_TAGS_ID = JAVADOC_SINGLE_BREAK_TAG_ID; // ID max for tags ID with no opening/closing (e.g. <bla>....</bla>)
142
	static final int JAVADOC_SINGLE_TAGS_ID = JAVADOC_SINGLE_BREAK_TAG_ID; // ID max for tags ID with no opening/closing (e.g. <bla>....</bla>)
153
	static final int JAVADOC_CLOSED_TAG = 0x10000;
143
	static final int JAVADOC_CLOSED_TAG = 0x10000;
154
	static final int JAVADOC_SPECIAL_TAGS_ID = 0x20000;
155
}
144
}
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (+96 lines)
Lines 3229-3234 Link Here
3229
}
3229
}
3230
3230
3231
/**
3231
/**
3232
 * @bug 260011: [formatter] Formatting of html in javadoc comments doesn't work with style attributes
3233
 * @test Ensure that the comment formatter understand <p> html tag with attributes
3234
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260011"
3235
 */
3236
public void testBug260011() throws JavaModelException {
3237
	String source = 
3238
		"public class Test {\n" + 
3239
		"    /**\n" + 
3240
		"     * some comment text here\n" + 
3241
		"     * <p style=\"font-variant:small-caps;\">\n" + 
3242
		"     * some text to be styled a certain way\n" + 
3243
		"     * </p>\n" + 
3244
		"     */\n" + 
3245
		"    void foo() {}\n" + 
3246
		"\n" + 
3247
		"}\n";
3248
	formatSource(source,
3249
		"public class Test {\n" + 
3250
		"	/**\n" + 
3251
		"	 * some comment text here\n" + 
3252
		"	 * <p style=\"font-variant:small-caps;\">\n" + 
3253
		"	 * some text to be styled a certain way\n" + 
3254
		"	 * </p>\n" + 
3255
		"	 */\n" + 
3256
		"	void foo() {\n" + 
3257
		"	}\n" + 
3258
		"\n" + 
3259
		"}\n"
3260
	);
3261
}
3262
public void testBug260011a() throws JavaModelException {
3263
	String source = 
3264
		"public class Test {\n" + 
3265
		"    /**\n" + 
3266
		"     * some comment text here\n" + 
3267
		"     * <ul style=\"font-variant:small-caps;\"><li style=\"font-variant:small-caps;\">\n" + 
3268
		"     * some text to be styled a certain way</li></ul>\n" + 
3269
		"     * end of comment\n" + 
3270
		"     */\n" + 
3271
		"    void foo() {}\n" + 
3272
		"\n" + 
3273
		"}\n";
3274
	formatSource(source,
3275
		"public class Test {\n" + 
3276
		"	/**\n" + 
3277
		"	 * some comment text here\n" + 
3278
		"	 * <ul style=\"font-variant:small-caps;\">\n" + 
3279
		"	 * <li style=\"font-variant:small-caps;\">\n" + 
3280
		"	 * some text to be styled a certain way</li>\n" + 
3281
		"	 * </ul>\n" + 
3282
		"	 * end of comment\n" + 
3283
		"	 */\n" + 
3284
		"	void foo() {\n" + 
3285
		"	}\n" + 
3286
		"\n" + 
3287
		"}\n"
3288
	);
3289
}
3290
public void testBug260011b() throws JavaModelException {
3291
	String source = 
3292
		"public class Test {\n" + 
3293
		"    /**\n" + 
3294
		"     * some comment text here\n" + 
3295
		"     * <pre style=\"font-variant:small-caps;\">\n" + 
3296
		"     *      some text\n" + 
3297
		"     *           to be styled\n" + 
3298
		"     *                 a certain way\n" + 
3299
		"     *      \n" + 
3300
		"     * </pre>\n" + 
3301
		"     * end of comment\n" + 
3302
		"     */\n" + 
3303
		"    void foo() {}\n" + 
3304
		"\n" + 
3305
		"}\n";
3306
	formatSource(source,
3307
		"public class Test {\n" + 
3308
		"	/**\n" + 
3309
		"	 * some comment text here\n" + 
3310
		"	 * \n" + 
3311
		"	 * <pre style=\"font-variant:small-caps;\">\n" + 
3312
		"	 *      some text\n" + 
3313
		"	 *           to be styled\n" + 
3314
		"	 *                 a certain way\n" + 
3315
		"	 * \n" + 
3316
		"	 * </pre>\n" + 
3317
		"	 * \n" + 
3318
		"	 * end of comment\n" + 
3319
		"	 */\n" + 
3320
		"	void foo() {\n" + 
3321
		"	}\n" + 
3322
		"\n" + 
3323
		"}\n"
3324
	);
3325
}
3326
3327
/**
3232
 * @bug 260274: [formatter] * character is removed while formatting block comments
3328
 * @bug 260274: [formatter] * character is removed while formatting block comments
3233
 * @test Ensure that the comment formatter keep '*' characters while formatting block comments
3329
 * @test Ensure that the comment formatter keep '*' characters while formatting block comments
3234
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260274"
3330
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260274"

Return to bug 260011