Bug 29458 Templates for constructor
When I have an existing constructor within a class, which has a single line comment and I attempt to convert this comment to a multi lie comment, it inserts the 'typecomment' tempalte. In addition, the comment is not correctly indented. For example: before: /** * My typecomment */ public class MyClass { /** my constructor */ public MyClass() { } } after (placing cursor before 'my contructor' and hitting enter): /** * My typecomment */ public class MyClass { /** * My typecomment */ my constructor */ public MyClass() { } }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocAutoIndentStrategy.java
default:
			return null;
		}		
	}
	
	/*
	 * Removes start and end of a comment and corrects indentation and line delimiters.
	 */
	private String prepareTemplateComment(String comment, String indentation, String lineDelimiter) {
		
		if (comment.endsWith("*/")) 
			comment= comment.substring(0, comment.length() - 2);
		comment= comment.trim();
		if (comment.startsWith("/*")) { 
			if (comment.length() > 2 && comment.charAt(2) == '*') {
				comment= comment.substring(3); 
			} else {
				comment= comment.substring(2); 
			}
		}
		return Strings.changeIndent(comment, 0, CodeFormatterUtil.getTabWidth(), indentation, lineDelimiter);
	}
	
	private String createTypeTags(IDocument document, DocumentCommand command, String indentation, String lineDelimiter, IType type)
		throws CoreException, BadLocationException
	{
		String comment= StubUtility.getTypeComment(type);
		if (comment != null) {
			comment= prepareTemplateComment(comment.trim(), indentation, lineDelimiter);
		}