diff options
| author | Carsten Hammer | 2020-11-16 19:47:29 +0000 |
|---|---|---|
| committer | Fabrice Tiercelin | 2021-09-21 05:28:51 +0000 |
| commit | 6ff95d2a3b4f16a3eb181511885ed251df282412 (patch) | |
| tree | 8878c000c74cb1ccb4f11c8b26a904d2935bf8f7 | |
| parent | 4d6015ee4e813cd4845be21b68c4d226056c7c2d (diff) | |
| download | eclipse.jdt.core-6ff95d2a3b4f16a3eb181511885ed251df282412.tar.gz eclipse.jdt.core-6ff95d2a3b4f16a3eb181511885ed251df282412.tar.xz eclipse.jdt.core-6ff95d2a3b4f16a3eb181511885ed251df282412.zip | |
Bug 572180 - dogfooding "Ternary operator" on jdt.core codebase
related to Bug 568822 - [AutoRefactor immigration #46/145] [cleanup &
saveaction]
Ternary operator
Change-Id: I2d9c46f2ea33092ce4f4c23f848b7c197ebc71df
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/172331
Tested-by: JDT Bot <jdt-bot@eclipse.org>
Reviewed-by: Fabrice Tiercelin <fabrice.tiercelin@yahoo.fr>
5 files changed, 9 insertions, 17 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java index 53f60af773..466f04e046 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java @@ -62,8 +62,7 @@ public class EqualExpression extends BinaryExpression { checkVariableComparison(scope, flowContext, flowInfo, initsWhenTrue, initsWhenFalse, local, rightStatus, this.left); } } else if (this.left instanceof Reference - && ((!contextualCheckEquality && rightStatus == FlowInfo.NULL) - || (contextualCheckEquality && rightStatus == FlowInfo.NON_NULL)) + && ((contextualCheckEquality ? rightStatus == FlowInfo.NON_NULL : rightStatus == FlowInfo.NULL)) && scope.compilerOptions().enableSyntacticNullAnalysisForFields) { FieldBinding field = ((Reference)this.left).lastFieldBinding(); @@ -79,8 +78,7 @@ public class EqualExpression extends BinaryExpression { checkVariableComparison(scope, flowContext, flowInfo, initsWhenTrue, initsWhenFalse, local, leftStatus, this.right); } } else if (this.right instanceof Reference - && ((!contextualCheckEquality && leftStatus == FlowInfo.NULL) - || (contextualCheckEquality && leftStatus == FlowInfo.NON_NULL)) + && ((contextualCheckEquality ? leftStatus == FlowInfo.NON_NULL : leftStatus == FlowInfo.NULL)) && scope.compilerOptions().enableSyntacticNullAnalysisForFields) { FieldBinding field = ((Reference)this.right).lastFieldBinding(); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java index 6f7299cf8a..2ee59b83a0 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java @@ -797,8 +797,7 @@ public class JavadocParser extends AbstractCommentParser { } // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=267833 // Report a problem if a block tag is being used in the context of an inline tag and vice versa. - if ((this.inlineTagStarted && JAVADOC_TAG_TYPE[this.tagValue] == TAG_TYPE_BLOCK) - || (!this.inlineTagStarted && JAVADOC_TAG_TYPE[this.tagValue] == TAG_TYPE_INLINE)) { + if ((this.inlineTagStarted ? JAVADOC_TAG_TYPE[this.tagValue] == TAG_TYPE_BLOCK : JAVADOC_TAG_TYPE[this.tagValue] == TAG_TYPE_INLINE)) { valid = false; this.tagValue = TAG_OTHERS_VALUE; this.tagWaitingForDescription = NO_TAG_VALUE; diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java index 4be5335e40..bf2625a495 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java @@ -163,8 +163,7 @@ public class CommentsPreparator extends ASTVisitor { && this.tm.countLineBreaksBetween(this.lastLineComment, commentToken) == 1; boolean isHeader = this.tm.isInHeader(commentIndex); - boolean formattingEnabled = (this.options.comment_format_line_comment && !isHeader) - || (this.options.comment_format_header && isHeader); + boolean formattingEnabled = (isHeader ? this.options.comment_format_header : this.options.comment_format_line_comment); if (!formattingEnabled) { preserveWhitespace(commentToken, commentIndex); if (isContinuation) { @@ -382,8 +381,7 @@ public class CommentsPreparator extends ASTVisitor { return; boolean isHeader = this.tm.isInHeader(commentIndex); - boolean formattingEnabled = (this.options.comment_format_block_comment && !isHeader) - || (this.options.comment_format_header && isHeader); + boolean formattingEnabled = (isHeader ? this.options.comment_format_header : this.options.comment_format_block_comment); if (this.tm.charAt(commentToken.originalStart + 2) == '-') { if (commentToken.getLineBreaksBefore() > 0 || commentIndex == 0 || this.tm.get(commentIndex - 1).getLineBreaksAfter() > 0) { @@ -560,8 +558,7 @@ public class CommentsPreparator extends ASTVisitor { return false; boolean isHeader = this.tm.isInHeader(commentIndex); - boolean formattingEnabled = (this.options.comment_format_javadoc_comment && !isHeader) - || (this.options.comment_format_header && isHeader); + boolean formattingEnabled = (isHeader ? this.options.comment_format_header : this.options.comment_format_javadoc_comment); if (!formattingEnabled || !tokenizeMultilineComment(commentToken)) { commentToken.setInternalStructure(commentToLines(commentToken, -1)); return false; @@ -736,8 +733,7 @@ public class CommentsPreparator extends ASTVisitor { } } - boolean extraIndent = (paramName != null && this.options.comment_indent_parameter_description) - || (paramName == null && this.options.comment_indent_tag_description); + boolean extraIndent = (paramName != null ? this.options.comment_indent_parameter_description : this.options.comment_indent_tag_description); for (int i = 2; i < tagTokens.size(); i++) { Token token = tagTokens.get(i); token.setAlign(descriptionAlign); diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/CommentWrapExecutor.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/CommentWrapExecutor.java index b00c8cfa5e..c259ad3b93 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/CommentWrapExecutor.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/CommentWrapExecutor.java @@ -228,8 +228,7 @@ public class CommentWrapExecutor extends TokenTraverser { return; int commentIndex = this.tm.indexOf(commentToken); boolean isHeader = this.tm.isInHeader(commentIndex); - boolean formattingEnabled = (this.options.comment_format_line_comment && !isHeader) - || (this.options.comment_format_header && isHeader); + boolean formattingEnabled = (isHeader ? this.options.comment_format_header : this.options.comment_format_line_comment); if (!formattingEnabled) return; diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java index 33967f8407..bc55a2de6f 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java @@ -656,7 +656,7 @@ public class SourceTypeConverter extends TypeConverter { if ((methodInfo.getModifiers() & ClassFileConstants.AccAbstract) != 0) { hasAbstractMethods = true; } - if ((isConstructor && needConstructor) || (!isConstructor && needMethod)) { + if ((isConstructor ? needConstructor : needMethod)) { AbstractMethodDeclaration method = convert(sourceMethod, methodInfo, compilationResult); if (isAbstract || method.isAbstract()) { // fix-up flag method.modifiers |= ExtraCompilerModifiers.AccSemicolonBody; |
