Skip to content

Commit 38c1cad

Browse files
authored
Remove the "Scope analysis to the current package" feature from the Dart problem view (#43)
1 parent 5c1e0d7 commit 38c1cad

File tree

11 files changed

+19
-124
lines changed

11 files changed

+19
-124
lines changed

third_party/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Vendor change from "JetBrains" to "Google"
66
- Build system change from Basel to Gradle
77
- Removal of the old Code Coverage support, all references to com.intellij.coverage.*
8+
- Remove the "Scope analysis to the current package" feature from the Dart problem view
89
- New Dart language feature: Dot Shorthands (https://youtrack.jetbrains.com/issue/IDEA-370100)
910
- Support new 'Null-Aware Elements’ syntax (https://youtrack.jetbrains.com/issue/IDEA-374053)
1011
- Fix: IDE freezes after inserting a piece of Dart code (https://youtrack.jetbrains.com/issue/IDEA-231468)

third_party/src/main/java/com/jetbrains/lang/dart/analyzer/DartServerRootsHandler.java

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,6 @@ void scheduleDartRootsUpdate(@Nullable Runnable onSuccess) {
8282
final List<String> newIncludedRootPaths = new SmartList<>();
8383
final List<String> newExcludedRootPaths = new SmartList<>();
8484

85-
final boolean isPackageScopedAnalysis =
86-
DartProblemsView.getScopeAnalysisMode(myProject) == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage;
87-
88-
if (isPackageScopedAnalysis) {
89-
final VirtualFile currentFile = DartProblemsView.getInstance(myProject).getCurrentFile();
90-
if (currentFile == null ||
91-
ProjectFileIndex.getInstance(myProject).isInLibraryClasses(currentFile) ||
92-
!currentFile.isInLocalFileSystem()) {
93-
return null; // keep server roots as is until another file is open
94-
}
95-
96-
newIncludedRootPaths.add(getEnclosingDartPackageDirectoryPath(currentFile));
97-
}
98-
9985
final String dotIdeaPath = PathUtil.getParentPath(StringUtil.notNullize(myProject.getProjectFilePath()));
10086
if (dotIdeaPath.endsWith("/.idea")) {
10187
newExcludedRootPaths.add(dotIdeaPath);
@@ -105,9 +91,7 @@ void scheduleDartRootsUpdate(@Nullable Runnable onSuccess) {
10591
for (ContentEntry contentEntry : ModuleRootManager.getInstance(module).getContentEntries()) {
10692
final String contentEntryUrl = contentEntry.getUrl();
10793
if (contentEntryUrl.startsWith(URLUtil.FILE_PROTOCOL + URLUtil.SCHEME_SEPARATOR)) {
108-
if (!isPackageScopedAnalysis) {
109-
newIncludedRootPaths.add(VfsUtilCore.urlToPath(contentEntryUrl));
110-
}
94+
newIncludedRootPaths.add(VfsUtilCore.urlToPath(contentEntryUrl));
11195
for (String excludedUrl : contentEntry.getExcludeFolderUrls()) {
11296
// Analysis Server knows about special 'packages' folders, IDE doesn't need to explicitly list them as excluded.
11397
if (excludedUrl.startsWith(contentEntryUrl) && !excludedUrl.endsWith("/packages")) {
@@ -138,26 +122,15 @@ private void sendSetAnalysisRootsRequest(@NotNull List<String> newIncludedRoots,
138122
boolean isInIncludedRoots(@Nullable VirtualFile vFile) {
139123
if (vFile == null) return false;
140124

141-
final DartProblemsViewSettings.ScopedAnalysisMode scopedAnalysisMode = DartProblemsView.getScopeAnalysisMode(myProject);
142-
if (scopedAnalysisMode == DartProblemsViewSettings.ScopedAnalysisMode.All) {
143-
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
144-
if (fileIndex.isInLibraryClasses(vFile)) return true;
125+
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
126+
if (fileIndex.isInLibraryClasses(vFile)) return true;
145127

146-
final Module module = fileIndex.getModuleForFile(vFile);
147-
if (module != null && DartSdkLibUtil.isDartSdkEnabled(module)) {
148-
return true;
149-
}
150-
else if (vFile.getName().equals("AndroidManifest.xml")) {
151-
// These types of files can be part of an android module, not dart sdk enabled,
152-
// but should still be considered in the root for Dart Analysis errors and warnings.
153-
for (String root : myIncludedRootPaths) {
154-
if (vFile.getPath().startsWith(root + "/")) {
155-
return true;
156-
}
157-
}
158-
}
159-
}
160-
else if (scopedAnalysisMode == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage) {
128+
final Module module = fileIndex.getModuleForFile(vFile);
129+
if (module != null && DartSdkLibUtil.isDartSdkEnabled(module)) {
130+
return true;
131+
} else if (vFile.getName().equals("AndroidManifest.xml")) {
132+
// These types of files can be part of an android module, not dart sdk enabled,
133+
// but should still be considered in the root for Dart Analysis errors and warnings.
161134
for (String root : myIncludedRootPaths) {
162135
if (vFile.getPath().startsWith(root + "/")) {
163136
return true;

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

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.jetbrains.lang.dart.ide.errorTreeView.DartAnalysisServerSettingsForm">
3-
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
3+
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="5" left="10" bottom="10" right="5"/>
55
<constraints>
66
<xy x="20" y="20" width="378" height="257"/>
@@ -10,37 +10,21 @@
1010
<children>
1111
<component id="93a4" class="com.intellij.ui.HoverHyperlinkLabel" binding="myDartSettingsHyperlink" custom-create="true">
1212
<constraints>
13-
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
13+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
1414
</constraints>
1515
<properties>
1616
<text resource-bundle="messages/DartBundle" key="open.dart.plugin.settings"/>
1717
</properties>
1818
</component>
1919
<component id="b6360" class="com.intellij.ui.HoverHyperlinkLabel" binding="myAnalysisDiagnosticsHyperlink" custom-create="true">
2020
<constraints>
21-
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
21+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
2222
</constraints>
2323
<properties>
2424
<text resource-bundle="messages/DartBundle" key="analysis.server.settings.diagnostics"/>
2525
</properties>
2626
</component>
27-
<component id="ea520" class="com.intellij.ui.components.JBCheckBox" binding="packageScopedAnalysisCheckbox">
28-
<constraints>
29-
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
30-
</constraints>
31-
<properties>
32-
<text resource-bundle="messages/DartBundle" key="analysis.server.settings.package.analysis"/>
33-
</properties>
34-
</component>
3527
<component id="4a605" class="com.intellij.ui.TitledSeparator">
36-
<constraints>
37-
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
38-
</constraints>
39-
<properties>
40-
<text value=""/>
41-
</properties>
42-
</component>
43-
<component id="d167a" class="com.intellij.ui.TitledSeparator">
4428
<constraints>
4529
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
4630
</constraints>
@@ -50,7 +34,7 @@
5034
</component>
5135
<vspacer id="cb7e">
5236
<constraints>
53-
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
37+
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
5438
</constraints>
5539
</vspacer>
5640
</children>

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.intellij.openapi.project.Project;
55
import com.intellij.ui.HoverHyperlinkLabel;
66
import com.intellij.ui.HyperlinkAdapter;
7-
import com.intellij.ui.components.JBCheckBox;
87
import com.jetbrains.lang.dart.DartBundle;
98
import com.jetbrains.lang.dart.sdk.DartConfigurable;
109
import org.jetbrains.annotations.NotNull;
@@ -23,7 +22,6 @@ interface ServerSettingsListener {
2322
private JPanel myMainPanel;
2423
private HoverHyperlinkLabel myDartSettingsHyperlink;
2524
private HoverHyperlinkLabel myAnalysisDiagnosticsHyperlink;
26-
private JBCheckBox packageScopedAnalysisCheckbox;
2725

2826
DartAnalysisServerSettingsForm(final @NotNull Project project) {
2927
myProject = project;
@@ -46,22 +44,7 @@ protected void hyperlinkActivated(final @NotNull HyperlinkEvent e) {
4644
});
4745
}
4846

49-
public void reset(final @NotNull DartProblemsPresentationHelper presentationHelper) {
50-
packageScopedAnalysisCheckbox.setSelected(presentationHelper.getScopedAnalysisMode() == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage);
51-
}
52-
53-
public void addListener(final @NotNull ServerSettingsListener serverSettingsListener) {
54-
packageScopedAnalysisCheckbox.addActionListener(e -> serverSettingsListener.settingsChanged());
55-
}
56-
5747
public JPanel getMainPanel() {
5848
return myMainPanel;
5949
}
60-
61-
public @NotNull DartProblemsViewSettings.ScopedAnalysisMode getScopeAnalysisMode() {
62-
if (packageScopedAnalysisCheckbox.isSelected()) {
63-
return DartProblemsViewSettings.ScopedAnalysisMode.DartPackage;
64-
}
65-
return DartProblemsViewSettings.ScopedAnalysisMode.All;
66-
}
6750
}

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,11 @@ void updateFromFilterSettingsUI(@NotNull DartProblemsFilterForm form) {
6666
mySettings.fileFilterMode = form.getFileFilterMode();
6767
}
6868

69-
void updateFromServerSettingsUI(@NotNull DartAnalysisServerSettingsForm form) {
70-
mySettings.scopedAnalysisMode = form.getScopeAnalysisMode();
71-
}
72-
7369
boolean areFiltersApplied() {
7470
if (mySettings.showErrors != DartProblemsViewSettings.SHOW_ERRORS_DEFAULT) return true;
7571
if (mySettings.showWarnings != DartProblemsViewSettings.SHOW_WARNINGS_DEFAULT) return true;
7672
if (mySettings.showHints != DartProblemsViewSettings.SHOW_HINTS_DEFAULT) return true;
77-
return mySettings.fileFilterMode != DartProblemsViewSettings.FILE_FILTER_MODE_DEFAULT;
73+
return mySettings.fileFilterMode != DartProblemsViewSettings.FILE_FILTER_MODE_DEFAULT;
7874
}
7975

8076
boolean setCurrentFile(@Nullable VirtualFile file) {
@@ -121,10 +117,6 @@ DartProblemsViewSettings.FileFilterMode getFileFilterMode() {
121117
return mySettings.fileFilterMode;
122118
}
123119

124-
DartProblemsViewSettings.ScopedAnalysisMode getScopedAnalysisMode() {
125-
return mySettings.scopedAnalysisMode;
126-
}
127-
128120
@Nullable VirtualFile getCurrentFile() {
129121
return myCurrentFile;
130122
}

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

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,14 @@ public void run() {
9090
}
9191

9292
ReadAction.nonBlocking(() -> {
93-
DartProblemsViewSettings.ScopedAnalysisMode scopedAnalysisMode =
94-
getInstance(myProject).myPresentationHelper.getScopedAnalysisMode();
9593
Map<String, List<DartProblem>> filePathToDartProblems = new HashMap<>();
9694

9795
for (Map.Entry<String, List<? extends AnalysisError>> entry : filePathToErrors.entrySet()) {
9896
String filePath = entry.getKey();
9997
List<? extends AnalysisError> analysisErrors = entry.getValue();
10098

10199
VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(filePath);
102-
boolean fileOk = vFile != null && (scopedAnalysisMode != DartProblemsViewSettings.ScopedAnalysisMode.All ||
103-
ProjectFileIndex.getInstance(myProject).isInContent(vFile));
100+
boolean fileOk = vFile != null && ProjectFileIndex.getInstance(myProject).isInContent(vFile);
104101
List<DartProblem> dartProblems = fileOk
105102
? ContainerUtil.map(analysisErrors, analysisError -> new DartProblem(myProject, analysisError))
106103
: Collections.emptyList();
@@ -110,9 +107,7 @@ public void run() {
110107
return filePathToDartProblems;
111108
})
112109
.expireWith(getInstance(myProject))
113-
.finishOnUiThread(ModalityState.nonModal(), filePathToDartProblems -> {
114-
panel.setErrors(filePathToDartProblems);
115-
})
110+
.finishOnUiThread(ModalityState.nonModal(), panel::setErrors)
116111
.submit(AppExecutorUtil.getAppExecutorService());
117112
}
118113
};
@@ -183,13 +178,6 @@ private void updateIcon() {
183178
return project.getService(DartProblemsView.class);
184179
}
185180

186-
public static DartProblemsViewSettings.ScopedAnalysisMode getScopeAnalysisMode(final @NotNull Project project) {
187-
if (!DartAnalysisServerService.getInstance(project).isServerProcessActive()) {
188-
return DartProblemsViewSettings.SCOPED_ANALYSIS_MODE_DEFAULT;
189-
}
190-
return getInstance(project).myPresentationHelper.getScopedAnalysisMode();
191-
}
192-
193181
public VirtualFile getCurrentFile() {
194182
return myPresentationHelper.getCurrentFile();
195183
}
@@ -310,10 +298,6 @@ public void setCurrentFile(final @Nullable VirtualFile file) {
310298
myPresentationHelper.getFileFilterMode() != DartProblemsViewSettings.FileFilterMode.All) {
311299
panel.fireGroupingOrFilterChanged();
312300
}
313-
314-
if (myPresentationHelper.getScopedAnalysisMode() == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage) {
315-
DartAnalysisServerService.getInstance(myProject).ensureAnalysisRootsUpToDate();
316-
}
317301
}
318302

319303
public void updateErrorsForFile(final @NotNull String filePath, @NotNull List<? extends AnalysisError> errors) {

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,6 @@ public void filtersResetRequested() {
322322

323323
private void showAnalysisServerSettingsPopup() {
324324
DartAnalysisServerSettingsForm serverSettingsForm = new DartAnalysisServerSettingsForm(myProject);
325-
serverSettingsForm.reset(myPresentationHelper);
326-
327-
serverSettingsForm.addListener(() -> {
328-
myPresentationHelper.updateFromServerSettingsUI(serverSettingsForm);
329-
DartAnalysisServerService.getInstance(myProject).ensureAnalysisRootsUpToDate();
330-
});
331-
332325
createAndShowPopup(DartBundle.message("dart.problems.view.popup.title.analysis.server.settings"), serverSettingsForm.getMainPanel());
333326
}
334327

@@ -453,8 +446,6 @@ private class AnalysisServerSettingsAction extends DumbAwareAction implements To
453446

454447
@Override
455448
public void update(@NotNull AnActionEvent e) {
456-
boolean asByDefault = myPresentationHelper.getScopedAnalysisMode() == DartProblemsViewSettings.SCOPED_ANALYSIS_MODE_DEFAULT;
457-
Toggleable.setSelected(e.getPresentation(), !asByDefault);
458449
}
459450

460451
@Override

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ public class DartProblemsViewSettings {
77

88
public enum FileFilterMode {All, ContentRoot, DartPackage, Directory, File}
99

10-
public enum ScopedAnalysisMode {All, DartPackage}
11-
1210
static final boolean AUTO_SCROLL_TO_SOURCE_DEFAULT = false;
1311
static final boolean GROUP_BY_SEVERITY_DEFAULT = true;
1412
static final boolean SHOW_ERRORS_DEFAULT = true;
1513
static final boolean SHOW_WARNINGS_DEFAULT = true;
1614
static final boolean SHOW_HINTS_DEFAULT = true;
1715
static final FileFilterMode FILE_FILTER_MODE_DEFAULT = FileFilterMode.All;
18-
static final ScopedAnalysisMode SCOPED_ANALYSIS_MODE_DEFAULT = ScopedAnalysisMode.All;
1916

2017
@Attribute(value = "auto-scroll-to-source")
2118
public boolean autoScrollToSource = AUTO_SCROLL_TO_SOURCE_DEFAULT;
@@ -32,7 +29,4 @@ public enum ScopedAnalysisMode {All, DartPackage}
3229
public boolean showWarnings = SHOW_WARNINGS_DEFAULT;
3330
@Attribute(value = "show-hints")
3431
public boolean showHints = SHOW_HINTS_DEFAULT;
35-
36-
@Attribute(value = "scoped-analysis-mode")
37-
public ScopedAnalysisMode scopedAnalysisMode = SCOPED_ANALYSIS_MODE_DEFAULT;
3832
}

third_party/src/main/java/com/jetbrains/lang/dart/util/DartBuildFileUtil.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ public final class DartBuildFileUtil {
2525
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
2626
VirtualFile parent = contextFile.isDirectory() ? contextFile : contextFile.getParent();
2727

28-
boolean isPackageScopedAnalysis =
29-
DartProblemsView.getScopeAnalysisMode(project) == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage;
30-
31-
while (parent != null && (isPackageScopedAnalysis || fileIndex.isInContent(parent))) {
28+
while (parent != null && (fileIndex.isInContent(parent))) {
3229
final VirtualFile file = parent.findChild(BUILD_FILE_NAME);
3330
if (file != null && !file.isDirectory()) {
3431
final VirtualFile parent2 = parent.getParent();

third_party/src/main/java/com/jetbrains/lang/dart/util/PubspecYamlUtil.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ public static boolean isPubspecFile(final @NotNull VirtualFile file) {
5151
VirtualFile current = contextFile;
5252
VirtualFile parent = contextFile.isDirectory() ? contextFile : contextFile.getParent();
5353

54-
boolean isPackageScopedAnalysis =
55-
DartProblemsView.getScopeAnalysisMode(project) == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage;
56-
57-
while (parent != null && (LIB_DIR_NAME.equals(current.getName()) || isPackageScopedAnalysis || fileIndex.isInContent(parent))) {
54+
while (parent != null && (LIB_DIR_NAME.equals(current.getName()) || fileIndex.isInContent(parent))) {
5855
current = parent;
5956
final VirtualFile file = parent.findChild(PUBSPEC_YAML);
6057
if (file != null && !file.isDirectory()) {

0 commit comments

Comments
 (0)