Skip to content

Commit c80588f

Browse files
committed
[cq] Using IJ inspections, simplify Java returns statements and other inspections
1 parent 3fd0336 commit c80588f

20 files changed

+22
-66
lines changed

third_party/src/main/java/com/jetbrains/lang/dart/highlight/DartHighlightingErrorFilter.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ public boolean shouldHighlightErrorElement(final @NotNull PsiErrorElement elemen
1515
if (!(element.getLanguage() == DartLanguage.INSTANCE)) return true;
1616

1717
final VirtualFile file = DartResolveUtil.getRealVirtualFile(element.getContainingFile());
18-
if (file != null && file.isInLocalFileSystem() && ProjectFileIndex.getInstance(element.getProject()).isInContent(file)) {
19-
return false;
20-
}
21-
22-
return true;
18+
return file == null || !file.isInLocalFileSystem() || !ProjectFileIndex.getInstance(element.getProject()).isInContent(file);
2319
}
2420
}

third_party/src/main/java/com/jetbrains/lang/dart/ide/DartBraceMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public final class DartBraceMatcher implements PairedBraceMatcher {
2424

2525
@Override
2626
public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType contextType) {
27-
return contextType == null || !DartTokenTypesSets.STRINGS.contains(contextType);
27+
return !DartTokenTypesSets.STRINGS.contains(contextType);
2828
}
2929

3030
@Override

third_party/src/main/java/com/jetbrains/lang/dart/ide/actions/AbstractDartFileProcessingAction.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ private static boolean isApplicableFile(final @NotNull Project project, final @N
164164

165165
final Module module = ModuleUtilCore.findModuleForFile(file, project);
166166
if (module == null) return false;
167-
if (!DartSdkLibUtil.isDartSdkEnabled(module)) return false;
168-
169-
return true;
167+
return DartSdkLibUtil.isDartSdkEnabled(module);
170168
}
171169

172170
private static boolean mayHaveApplicableDartFiles(final @NotNull Project project,

third_party/src/main/java/com/jetbrains/lang/dart/ide/annotator/DartProblemGroup.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ private static boolean hasIgnoreCommentOnPrevLine(@NotNull Document document, in
193193
case '/' -> {
194194
if (prevLine.length() > index + 1 && prevLine.charAt(index + 1) == '/') {
195195
final String comment = prevLine.subSequence(index + 2, prevLine.length()).toString();
196-
if (StringUtil.trimLeading(comment, ' ').startsWith(IGNORE_PREFIX)) {
197-
return true;
198-
}
196+
return StringUtil.trimLeading(comment, ' ').startsWith(IGNORE_PREFIX);
199197
}
200198
return false;
201199
}

third_party/src/main/java/com/jetbrains/lang/dart/ide/editor/DartLineWrapPositionStrategy.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ protected boolean canUseOffset(@NotNull Document document, int offset, boolean v
4141

4242
if (charAtOffset == '.') {
4343
// Do not split the cascade token, but allow wrapping in front of it.
44-
if (offset > 0 && chars.charAt(offset - 1) == '.') {
45-
return false;
46-
}
44+
return offset <= 0 || chars.charAt(offset - 1) != '.';
4745
}
4846
return true;
4947
}

third_party/src/main/java/com/jetbrains/lang/dart/ide/editor/DartQuoteHandler.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@ public boolean isOpeningQuote(final HighlighterIterator iterator, final int offs
1818

1919
if (type == DartTokenTypes.OPEN_QUOTE) return true;
2020

21-
if (type == DartTokenTypes.RAW_SINGLE_QUOTED_STRING && offset == iterator.getStart() + 1) {
2221
// start of the raw string like r'
23-
return true;
24-
}
25-
26-
return false;
22+
return type == DartTokenTypes.RAW_SINGLE_QUOTED_STRING && offset == iterator.getStart() + 1;
2723
}
2824

2925
@Override

third_party/src/main/java/com/jetbrains/lang/dart/ide/editor/DartSelectionFilter.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
public final class DartSelectionFilter implements Condition<PsiElement> {
1414
@Override
1515
public boolean value(final @NotNull PsiElement psiElement) {
16-
if (getSiblingSemicolonIfExpression(psiElement) != null) {
17-
return false; // DartWordSelectionHandler will select this expression with the following semicolon
18-
}
19-
return true;
16+
return getSiblingSemicolonIfExpression(psiElement) == null; // DartWordSelectionHandler will select this expression with the following semicolon
2017
}
2118

2219
public static @Nullable PsiElement getSiblingSemicolonIfExpression(final @NotNull PsiElement psiElement) {

third_party/src/main/java/com/jetbrains/lang/dart/ide/errorTreeView/DartAnalysisServerSettingsForm.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ protected void hyperlinkActivated(final @NotNull HyperlinkEvent e) {
4747
}
4848

4949
public void reset(final @NotNull DartProblemsPresentationHelper presentationHelper) {
50-
if (presentationHelper.getScopedAnalysisMode() == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage) {
51-
packageScopedAnalysisCheckbox.setSelected(true);
52-
}
53-
else {
54-
packageScopedAnalysisCheckbox.setSelected(false);
55-
}
50+
packageScopedAnalysisCheckbox.setSelected(presentationHelper.getScopedAnalysisMode() == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage);
5651
}
5752

5853
public void addListener(final @NotNull ServerSettingsListener serverSettingsListener) {

third_party/src/main/java/com/jetbrains/lang/dart/ide/errorTreeView/DartProblemsPresentationHelper.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ boolean areFiltersApplied() {
7474
if (mySettings.showErrors != DartProblemsViewSettings.SHOW_ERRORS_DEFAULT) return true;
7575
if (mySettings.showWarnings != DartProblemsViewSettings.SHOW_WARNINGS_DEFAULT) return true;
7676
if (mySettings.showHints != DartProblemsViewSettings.SHOW_HINTS_DEFAULT) return true;
77-
if (mySettings.fileFilterMode != DartProblemsViewSettings.FILE_FILTER_MODE_DEFAULT) return true;
78-
79-
return false;
77+
return mySettings.fileFilterMode != DartProblemsViewSettings.FILE_FILTER_MODE_DEFAULT;
8078
}
8179

8280
boolean setCurrentFile(@Nullable VirtualFile file) {
@@ -160,9 +158,7 @@ boolean shouldShowProblem(@NotNull DartProblem problem) {
160158

161159
if (getFileFilterMode() == DartProblemsViewSettings.FileFilterMode.ContentRoot) {
162160
ensureContentRootUpToDate();
163-
if (myCurrentContentRoot == null || !myCurrentContentRoot.equals(problem.getContentRoot())) {
164-
return false;
165-
}
161+
return myCurrentContentRoot != null && myCurrentContentRoot.equals(problem.getContentRoot());
166162
}
167163

168164
return true;

third_party/src/main/java/com/jetbrains/lang/dart/ide/formatter/DartPostFormatProcessor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ private static boolean isApplicable(final @NotNull PsiFile psiFile) {
4040
final Module module = ModuleUtilCore.findModuleForPsiElement(psiFile);
4141
if (module == null || !DartSdkLibUtil.isDartSdkEnabled(module)) return false;
4242
if (!ProjectFileIndex.getInstance(project).isInContent(vFile)) return false;
43-
if (!DartAnalysisServerService.getInstance(project).serverReadyForRequest()) return false;
44-
45-
return true;
43+
return DartAnalysisServerService.getInstance(project).serverReadyForRequest();
4644
}
4745
}

0 commit comments

Comments
 (0)