Merge branch 'javadoc-continuation-indent' of https://github.com/c2nes/intellij-community

This commit is contained in:
Yaroslav Lepenkin
2017-05-24 15:33:01 +03:00
7 changed files with 44 additions and 19 deletions
@@ -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() {
@@ -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));
}
}
@@ -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);
}
@@ -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');
@@ -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)));
}
}
}
@@ -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
@@ -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
title.save.color.scheme.as=Duplicate Color Scheme As