diff --git a/java/java-impl/src/com/intellij/application/options/JavaDocFormattingPanel.java b/java/java-impl/src/com/intellij/application/options/JavaDocFormattingPanel.java index ac6e1f3bfaa8..8ef4cb58677f 100644 --- a/java/java-impl/src/com/intellij/application/options/JavaDocFormattingPanel.java +++ b/java/java-impl/src/com/intellij/application/options/JavaDocFormattingPanel.java @@ -99,6 +99,8 @@ public class JavaDocFormattingPanel extends OptionTreeWithPreviewPanel { initBooleanField("JD_DO_NOT_WRAP_ONE_LINE_COMMENTS", ApplicationBundle.message("checkbox.do.not.wrap.one.line.comments"), OTHER_GROUP); initBooleanField("JD_PRESERVE_LINE_FEEDS", ApplicationBundle.message("checkbox.preserve.line.feeds"), OTHER_GROUP); initBooleanField("JD_PARAM_DESCRIPTION_ON_NEW_LINE", ApplicationBundle.message("checkbox.param.description.on.new.line"), OTHER_GROUP); + + initBooleanField("JD_INDENT_ON_CONTINUATION", ApplicationBundle.message("checkbox.param.indent.on.continuation"), OTHER_GROUP); } protected int getRightMargin() { diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDClassComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDClassComment.java index 129619c08dda..721deffb07f9 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDClassComment.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDClassComment.java @@ -37,15 +37,20 @@ public class JDClassComment extends JDParamListOwnerComment { @Override protected void generateSpecial(@NotNull String prefix, @NotNull StringBuilder sb) { super.generateSpecial(prefix, sb); + String continuationPrefix = getContinuationPrefix(prefix); if (!isNull(myAuthorsList)) { JDTag tag = JDTag.AUTHOR; for (String author : myAuthorsList) { - sb.append(myFormatter.getParser().formatJDTagDescription(author, prefix + tag.getWithEndWhitespace(), prefix)); + sb.append(myFormatter.getParser().formatJDTagDescription(author, + prefix + tag.getWithEndWhitespace(), + continuationPrefix)); } } if (!isNull(myVersion)) { JDTag tag = JDTag.VERSION; - sb.append(myFormatter.getParser().formatJDTagDescription(myVersion, prefix + tag.getWithEndWhitespace(), prefix)); + sb.append(myFormatter.getParser().formatJDTagDescription(myVersion, + prefix + tag.getWithEndWhitespace(), + continuationPrefix)); } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java index 27c7a60da4a5..5a9f15a25948 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java @@ -15,6 +15,10 @@ */ package com.intellij.psi.impl.source.codeStyle.javadoc; +import com.intellij.formatting.IndentInfo; +import com.intellij.ide.highlighter.JavaFileType; +import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,6 +56,20 @@ public class JDComment { myMultiLineComment = value; } + protected String getContinuationIndent() { + CodeStyleSettings settings = myFormatter.getSettings(); + CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaFileType.INSTANCE); + return new IndentInfo(0, indentOptions.CONTINUATION_INDENT_SIZE, 0).generateNewWhiteSpace(indentOptions); + } + + protected String getContinuationPrefix(String prefix) { + if (myFormatter.getSettings().JD_INDENT_ON_CONTINUATION) { + return prefix + getContinuationIndent(); + } else { + return prefix; + } + } + @Nullable public String generate(@NotNull String indent) { final String prefix; @@ -76,9 +94,11 @@ public class JDComment { generateSpecial(prefix, sb); + final String continuationPrefix = getContinuationPrefix(prefix); + if (!isNull(myUnknownList) && myFormatter.getSettings().JD_KEEP_INVALID_TAGS) { for (String aUnknownList : myUnknownList) { - sb.append(myFormatter.getParser().formatJDTagDescription(aUnknownList, prefix)); + sb.append(myFormatter.getParser().formatJDTagDescription(aUnknownList, prefix, continuationPrefix)); } } @@ -86,7 +106,7 @@ public class JDComment { JDTag tag = JDTag.SEE; for (String aSeeAlsoList : mySeeAlsoList) { StringBuilder tagDescription = myFormatter.getParser() - .formatJDTagDescription(aSeeAlsoList, prefix + tag.getWithEndWhitespace(), prefix); + .formatJDTagDescription(aSeeAlsoList, prefix + tag.getWithEndWhitespace(), continuationPrefix); sb.append(tagDescription); } } @@ -94,14 +114,14 @@ public class JDComment { if (!isNull(mySince)) { JDTag tag = JDTag.SINCE; StringBuilder tagDescription = myFormatter.getParser() - .formatJDTagDescription(mySince, prefix + tag.getWithEndWhitespace(), prefix); + .formatJDTagDescription(mySince, prefix + tag.getWithEndWhitespace(), continuationPrefix); sb.append(tagDescription); } if (myDeprecated != null) { JDTag tag = JDTag.DEPRECATED; StringBuilder tagDescription = myFormatter.getParser() - .formatJDTagDescription(myDeprecated, prefix + tag.getWithEndWhitespace(), prefix); + .formatJDTagDescription(myDeprecated, prefix + tag.getWithEndWhitespace(), continuationPrefix); sb.append(tagDescription); } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java index 457b426c9048..86a798ed97d6 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java @@ -41,7 +41,9 @@ public class JDMethodComment extends JDParamListOwnerComment { if (myReturnTag != null) { if (myFormatter.getSettings().JD_KEEP_EMPTY_RETURN || !myReturnTag.trim().isEmpty()) { JDTag tag = JDTag.RETURN; - sb.append(myFormatter.getParser().formatJDTagDescription(myReturnTag, prefix + tag.getWithEndWhitespace(), prefix)); + sb.append(myFormatter.getParser().formatJDTagDescription(myReturnTag, + prefix + tag.getWithEndWhitespace(), + getContinuationPrefix(prefix))); if (myFormatter.getSettings().JD_ADD_BLANK_AFTER_RETURN) { sb.append(prefix); sb.append('\n'); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java index 34494d75e3a1..9f26bcfed08b 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java @@ -16,11 +16,7 @@ package com.intellij.psi.impl.source.codeStyle.javadoc; -import com.intellij.formatting.IndentInfo; -import com.intellij.ide.highlighter.JavaFileType; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.codeStyle.CodeStyleSettings; -import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -87,10 +83,6 @@ public class JDParamListOwnerComment extends JDComment { boolean generate_empty_tags, boolean wrapDescription) { - CodeStyleSettings settings = myFormatter.getSettings(); - CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaFileType.INSTANCE); - String continuationIndent = new IndentInfo(0, indentOptions.CONTINUATION_INDENT_SIZE, 0).generateNewWhiteSpace(indentOptions); - int max = 0; if (align_comments && !wrapDescription) { @@ -108,7 +100,7 @@ public class JDParamListOwnerComment extends JDComment { fill.append(prefix); StringUtil.repeatSymbol(fill, ' ', max + 1 + tag.length()); - String wrapParametersPrefix = prefix + continuationIndent; + String wrapParametersPrefix = prefix + getContinuationIndent(); for (NameDesc nd : list) { if (isNull(nd.desc) && !generate_empty_tags) continue; if (wrapDescription && !isNull(nd.desc)) { @@ -123,7 +115,9 @@ public class JDParamListOwnerComment extends JDComment { } else { String description = (nd.desc == null) ? "" : nd.desc; - sb.append(myFormatter.getParser().formatJDTagDescription(tag + nd.name + " " + description, prefix)); + sb.append(myFormatter.getParser().formatJDTagDescription(tag + nd.name + " " + description, + prefix, + getContinuationPrefix(prefix))); } } } diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java index 755fddd382cc..b9b43f5e3b0c 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java @@ -410,10 +410,11 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea public boolean JD_LEADING_ASTERISKS_ARE_ENABLED = true; - public boolean JD_PRESERVE_LINE_FEEDS; public boolean JD_PARAM_DESCRIPTION_ON_NEW_LINE; + public boolean JD_INDENT_ON_CONTINUATION = false; + // endregion // region Legacy(!) XML formatting options diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties index 2f9e581e3c92..9668a52b2261 100644 --- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties +++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties @@ -509,6 +509,7 @@ checkbox.keep.empty.lines=Keep empty lines checkbox.do.not.wrap.one.line.comments=Do not wrap one line comments checkbox.preserve.line.feeds=Preserve line feeds checkbox.param.description.on.new.line=Parameter descriptions on new line +checkbox.param.indent.on.continuation=Indent continuation lines title.javadoc=JavaDoc option.table.sizing.text=Chop down if long. title.choose.code.style.scheme=Choose Code Style Scheme @@ -793,4 +794,4 @@ settings.editor.scheme.copy.to.project.message=Overwrite project settings with v settings.editor.scheme.import.success={0} was imported to {1} scheme. settings.editor.scheme.import.failure=Import failed: {0} is not a valid scheme. title.save.code.style.scheme.as=Duplicate Code Style Scheme As -title.save.color.scheme.as=Duplicate Color Scheme As \ No newline at end of file +title.save.color.scheme.as=Duplicate Color Scheme As