Bug 50194 Indenting Java breaks comments
When correcting indentation (ctrl-I in my configuration), java comments are not properly preserved. My original code [1] is 'indented' to code [2], which is unexpected and syntactically incorrect. thanks PhF .. [1] try{ /* for(int i=0; i<8; i++){ System.out.println("something");} */ somethingElse(); .. [2] try{ /* */ for(int i=0; i<8; i++){ System.out.println("something");} */ somethingElse();
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocAutoIndentStrategy.java
int length = d.getLineLength(line);
        String lineDelimiter= d.getLineDelimiter(line);
        if (lineDelimiter != null)
            length= length - lineDelimiter.length();
		String lineContents = d.get(offset, length);
		int trim = jdocExtractLinePrefix(d, line).length();
		return lineContents.substring(trim);
	}
	
	private static String getLine(IDocument document, int line) throws BadLocationException {
		IRegion region= document.getLineInformation(line);		
		return document.get(region.getOffset(), region.getLength());		
	}
	/**
	 * Returns <code>true</code> if the javadoc line is too short, <code>false</code> otherwise.
	 */
	private boolean isLineTooShort(IDocument document, int line) throws BadLocationException {
		if (!isJavaDocLine(document, line + 1))
			return false;
		String nextLine= getLineContents(document, line + 1);
		if (nextLine.trim().length() == 0)
			return false;
		return true;
	}
	/**
	 * Returns <code>true</code> if the line is too long, <code>false</code> otherwise.
	 */
	private boolean isLineTooLong(IDocument document, int line) throws BadLocationException {
		String lineContents= getLine(document, line);
		return calculateDisplayedWidth(lineContents) > getMargin();