Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions third_party/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Vendor change from "JetBrains" to "Google"
- Build system change from Basel to Gradle
- Removal of the old Code Coverage support, all references to com.intellij.coverage.*
- Remove the "Scope analysis to the current package" feature from the Dart problem view
- New Dart language feature: Dot Shorthands (https://youtrack.jetbrains.com/issue/IDEA-370100)
- Support new 'Null-Aware Elements’ syntax (https://youtrack.jetbrains.com/issue/IDEA-374053)
- Fix: IDE freezes after inserting a piece of Dart code (https://youtrack.jetbrains.com/issue/IDEA-231468)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,6 @@ void scheduleDartRootsUpdate(@Nullable Runnable onSuccess) {
final List<String> newIncludedRootPaths = new SmartList<>();
final List<String> newExcludedRootPaths = new SmartList<>();

final boolean isPackageScopedAnalysis =
DartProblemsView.getScopeAnalysisMode(myProject) == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage;

if (isPackageScopedAnalysis) {
final VirtualFile currentFile = DartProblemsView.getInstance(myProject).getCurrentFile();
if (currentFile == null ||
ProjectFileIndex.getInstance(myProject).isInLibraryClasses(currentFile) ||
!currentFile.isInLocalFileSystem()) {
return null; // keep server roots as is until another file is open
}

newIncludedRootPaths.add(getEnclosingDartPackageDirectoryPath(currentFile));
}

final String dotIdeaPath = PathUtil.getParentPath(StringUtil.notNullize(myProject.getProjectFilePath()));
if (dotIdeaPath.endsWith("/.idea")) {
newExcludedRootPaths.add(dotIdeaPath);
Expand All @@ -105,9 +91,7 @@ void scheduleDartRootsUpdate(@Nullable Runnable onSuccess) {
for (ContentEntry contentEntry : ModuleRootManager.getInstance(module).getContentEntries()) {
final String contentEntryUrl = contentEntry.getUrl();
if (contentEntryUrl.startsWith(URLUtil.FILE_PROTOCOL + URLUtil.SCHEME_SEPARATOR)) {
if (!isPackageScopedAnalysis) {
newIncludedRootPaths.add(VfsUtilCore.urlToPath(contentEntryUrl));
}
newIncludedRootPaths.add(VfsUtilCore.urlToPath(contentEntryUrl));
for (String excludedUrl : contentEntry.getExcludeFolderUrls()) {
// Analysis Server knows about special 'packages' folders, IDE doesn't need to explicitly list them as excluded.
if (excludedUrl.startsWith(contentEntryUrl) && !excludedUrl.endsWith("/packages")) {
Expand Down Expand Up @@ -138,26 +122,15 @@ private void sendSetAnalysisRootsRequest(@NotNull List<String> newIncludedRoots,
boolean isInIncludedRoots(@Nullable VirtualFile vFile) {
if (vFile == null) return false;

final DartProblemsViewSettings.ScopedAnalysisMode scopedAnalysisMode = DartProblemsView.getScopeAnalysisMode(myProject);
if (scopedAnalysisMode == DartProblemsViewSettings.ScopedAnalysisMode.All) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
if (fileIndex.isInLibraryClasses(vFile)) return true;
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
if (fileIndex.isInLibraryClasses(vFile)) return true;

final Module module = fileIndex.getModuleForFile(vFile);
if (module != null && DartSdkLibUtil.isDartSdkEnabled(module)) {
return true;
}
else if (vFile.getName().equals("AndroidManifest.xml")) {
// These types of files can be part of an android module, not dart sdk enabled,
// but should still be considered in the root for Dart Analysis errors and warnings.
for (String root : myIncludedRootPaths) {
if (vFile.getPath().startsWith(root + "/")) {
return true;
}
}
}
}
else if (scopedAnalysisMode == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage) {
final Module module = fileIndex.getModuleForFile(vFile);
if (module != null && DartSdkLibUtil.isDartSdkEnabled(module)) {
return true;
} else if (vFile.getName().equals("AndroidManifest.xml")) {
// These types of files can be part of an android module, not dart sdk enabled,
// but should still be considered in the root for Dart Analysis errors and warnings.
for (String root : myIncludedRootPaths) {
if (vFile.getPath().startsWith(root + "/")) {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.jetbrains.lang.dart.ide.errorTreeView.DartAnalysisServerSettingsForm">
<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">
<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">
<margin top="5" left="10" bottom="10" right="5"/>
<constraints>
<xy x="20" y="20" width="378" height="257"/>
Expand All @@ -10,37 +10,21 @@
<children>
<component id="93a4" class="com.intellij.ui.HoverHyperlinkLabel" binding="myDartSettingsHyperlink" custom-create="true">
<constraints>
<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"/>
<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"/>
</constraints>
<properties>
<text resource-bundle="messages/DartBundle" key="open.dart.plugin.settings"/>
</properties>
</component>
<component id="b6360" class="com.intellij.ui.HoverHyperlinkLabel" binding="myAnalysisDiagnosticsHyperlink" custom-create="true">
<constraints>
<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"/>
<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"/>
</constraints>
<properties>
<text resource-bundle="messages/DartBundle" key="analysis.server.settings.diagnostics"/>
</properties>
</component>
<component id="ea520" class="com.intellij.ui.components.JBCheckBox" binding="packageScopedAnalysisCheckbox">
<constraints>
<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"/>
</constraints>
<properties>
<text resource-bundle="messages/DartBundle" key="analysis.server.settings.package.analysis"/>
</properties>
</component>
<component id="4a605" class="com.intellij.ui.TitledSeparator">
<constraints>
<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"/>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
<component id="d167a" class="com.intellij.ui.TitledSeparator">
<constraints>
<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"/>
</constraints>
Expand All @@ -50,7 +34,7 @@
</component>
<vspacer id="cb7e">
<constraints>
<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"/>
<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"/>
</constraints>
</vspacer>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.intellij.openapi.project.Project;
import com.intellij.ui.HoverHyperlinkLabel;
import com.intellij.ui.HyperlinkAdapter;
import com.intellij.ui.components.JBCheckBox;
import com.jetbrains.lang.dart.DartBundle;
import com.jetbrains.lang.dart.sdk.DartConfigurable;
import org.jetbrains.annotations.NotNull;
Expand All @@ -23,7 +22,6 @@ interface ServerSettingsListener {
private JPanel myMainPanel;
private HoverHyperlinkLabel myDartSettingsHyperlink;
private HoverHyperlinkLabel myAnalysisDiagnosticsHyperlink;
private JBCheckBox packageScopedAnalysisCheckbox;

DartAnalysisServerSettingsForm(final @NotNull Project project) {
myProject = project;
Expand All @@ -46,22 +44,7 @@ protected void hyperlinkActivated(final @NotNull HyperlinkEvent e) {
});
}

public void reset(final @NotNull DartProblemsPresentationHelper presentationHelper) {
packageScopedAnalysisCheckbox.setSelected(presentationHelper.getScopedAnalysisMode() == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage);
}

public void addListener(final @NotNull ServerSettingsListener serverSettingsListener) {
packageScopedAnalysisCheckbox.addActionListener(e -> serverSettingsListener.settingsChanged());
}

public JPanel getMainPanel() {
return myMainPanel;
}

public @NotNull DartProblemsViewSettings.ScopedAnalysisMode getScopeAnalysisMode() {
if (packageScopedAnalysisCheckbox.isSelected()) {
return DartProblemsViewSettings.ScopedAnalysisMode.DartPackage;
}
return DartProblemsViewSettings.ScopedAnalysisMode.All;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,11 @@ void updateFromFilterSettingsUI(@NotNull DartProblemsFilterForm form) {
mySettings.fileFilterMode = form.getFileFilterMode();
}

void updateFromServerSettingsUI(@NotNull DartAnalysisServerSettingsForm form) {
mySettings.scopedAnalysisMode = form.getScopeAnalysisMode();
}

boolean areFiltersApplied() {
if (mySettings.showErrors != DartProblemsViewSettings.SHOW_ERRORS_DEFAULT) return true;
if (mySettings.showWarnings != DartProblemsViewSettings.SHOW_WARNINGS_DEFAULT) return true;
if (mySettings.showHints != DartProblemsViewSettings.SHOW_HINTS_DEFAULT) return true;
return mySettings.fileFilterMode != DartProblemsViewSettings.FILE_FILTER_MODE_DEFAULT;
return mySettings.fileFilterMode != DartProblemsViewSettings.FILE_FILTER_MODE_DEFAULT;
}

boolean setCurrentFile(@Nullable VirtualFile file) {
Expand Down Expand Up @@ -121,10 +117,6 @@ DartProblemsViewSettings.FileFilterMode getFileFilterMode() {
return mySettings.fileFilterMode;
}

DartProblemsViewSettings.ScopedAnalysisMode getScopedAnalysisMode() {
return mySettings.scopedAnalysisMode;
}

@Nullable VirtualFile getCurrentFile() {
return myCurrentFile;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,14 @@ public void run() {
}

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

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

VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(filePath);
boolean fileOk = vFile != null && (scopedAnalysisMode != DartProblemsViewSettings.ScopedAnalysisMode.All ||
ProjectFileIndex.getInstance(myProject).isInContent(vFile));
boolean fileOk = vFile != null && ProjectFileIndex.getInstance(myProject).isInContent(vFile);
List<DartProblem> dartProblems = fileOk
? ContainerUtil.map(analysisErrors, analysisError -> new DartProblem(myProject, analysisError))
: Collections.emptyList();
Expand All @@ -110,9 +107,7 @@ public void run() {
return filePathToDartProblems;
})
.expireWith(getInstance(myProject))
.finishOnUiThread(ModalityState.nonModal(), filePathToDartProblems -> {
panel.setErrors(filePathToDartProblems);
})
.finishOnUiThread(ModalityState.nonModal(), panel::setErrors)
.submit(AppExecutorUtil.getAppExecutorService());
}
};
Expand Down Expand Up @@ -183,13 +178,6 @@ private void updateIcon() {
return project.getService(DartProblemsView.class);
}

public static DartProblemsViewSettings.ScopedAnalysisMode getScopeAnalysisMode(final @NotNull Project project) {
if (!DartAnalysisServerService.getInstance(project).isServerProcessActive()) {
return DartProblemsViewSettings.SCOPED_ANALYSIS_MODE_DEFAULT;
}
return getInstance(project).myPresentationHelper.getScopedAnalysisMode();
}

public VirtualFile getCurrentFile() {
return myPresentationHelper.getCurrentFile();
}
Expand Down Expand Up @@ -310,10 +298,6 @@ public void setCurrentFile(final @Nullable VirtualFile file) {
myPresentationHelper.getFileFilterMode() != DartProblemsViewSettings.FileFilterMode.All) {
panel.fireGroupingOrFilterChanged();
}

if (myPresentationHelper.getScopedAnalysisMode() == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage) {
DartAnalysisServerService.getInstance(myProject).ensureAnalysisRootsUpToDate();
}
}

public void updateErrorsForFile(final @NotNull String filePath, @NotNull List<? extends AnalysisError> errors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,6 @@ public void filtersResetRequested() {

private void showAnalysisServerSettingsPopup() {
DartAnalysisServerSettingsForm serverSettingsForm = new DartAnalysisServerSettingsForm(myProject);
serverSettingsForm.reset(myPresentationHelper);

serverSettingsForm.addListener(() -> {
myPresentationHelper.updateFromServerSettingsUI(serverSettingsForm);
DartAnalysisServerService.getInstance(myProject).ensureAnalysisRootsUpToDate();
});

createAndShowPopup(DartBundle.message("dart.problems.view.popup.title.analysis.server.settings"), serverSettingsForm.getMainPanel());
}

Expand Down Expand Up @@ -453,8 +446,6 @@ private class AnalysisServerSettingsAction extends DumbAwareAction implements To

@Override
public void update(@NotNull AnActionEvent e) {
boolean asByDefault = myPresentationHelper.getScopedAnalysisMode() == DartProblemsViewSettings.SCOPED_ANALYSIS_MODE_DEFAULT;
Toggleable.setSelected(e.getPresentation(), !asByDefault);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ public class DartProblemsViewSettings {

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

public enum ScopedAnalysisMode {All, DartPackage}

static final boolean AUTO_SCROLL_TO_SOURCE_DEFAULT = false;
static final boolean GROUP_BY_SEVERITY_DEFAULT = true;
static final boolean SHOW_ERRORS_DEFAULT = true;
static final boolean SHOW_WARNINGS_DEFAULT = true;
static final boolean SHOW_HINTS_DEFAULT = true;
static final FileFilterMode FILE_FILTER_MODE_DEFAULT = FileFilterMode.All;
static final ScopedAnalysisMode SCOPED_ANALYSIS_MODE_DEFAULT = ScopedAnalysisMode.All;

@Attribute(value = "auto-scroll-to-source")
public boolean autoScrollToSource = AUTO_SCROLL_TO_SOURCE_DEFAULT;
Expand All @@ -32,7 +29,4 @@ public enum ScopedAnalysisMode {All, DartPackage}
public boolean showWarnings = SHOW_WARNINGS_DEFAULT;
@Attribute(value = "show-hints")
public boolean showHints = SHOW_HINTS_DEFAULT;

@Attribute(value = "scoped-analysis-mode")
public ScopedAnalysisMode scopedAnalysisMode = SCOPED_ANALYSIS_MODE_DEFAULT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public final class DartBuildFileUtil {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
VirtualFile parent = contextFile.isDirectory() ? contextFile : contextFile.getParent();

boolean isPackageScopedAnalysis =
DartProblemsView.getScopeAnalysisMode(project) == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage;

while (parent != null && (isPackageScopedAnalysis || fileIndex.isInContent(parent))) {
while (parent != null && (fileIndex.isInContent(parent))) {
final VirtualFile file = parent.findChild(BUILD_FILE_NAME);
if (file != null && !file.isDirectory()) {
final VirtualFile parent2 = parent.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ public static boolean isPubspecFile(final @NotNull VirtualFile file) {
VirtualFile current = contextFile;
VirtualFile parent = contextFile.isDirectory() ? contextFile : contextFile.getParent();

boolean isPackageScopedAnalysis =
DartProblemsView.getScopeAnalysisMode(project) == DartProblemsViewSettings.ScopedAnalysisMode.DartPackage;

while (parent != null && (LIB_DIR_NAME.equals(current.getName()) || isPackageScopedAnalysis || fileIndex.isInContent(parent))) {
while (parent != null && (LIB_DIR_NAME.equals(current.getName()) || fileIndex.isInContent(parent))) {
current = parent;
final VirtualFile file = parent.findChild(PUBSPEC_YAML);
if (file != null && !file.isDirectory()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ group.by.severity=Group by Severity
group.by.severity.description=Group by severity: errors in the top of the table, then come warnings, and hints in the end
open.dart.plugin.settings=Open Dart plugin settings
analysis.server.settings.diagnostics=View analyzer diagnostics
analysis.server.settings.package.analysis=Scope analysis to the current package
action.DartProblemsViewPanel.open.documentation.text=Open Documentation
action.DartProblemsViewPanel.open.documentation.description=Open detailed problem description in browser
# this text becomes a hyperlink that is added to the red code tooltip right after the error message. Example: "Dead code. (<a href='https://dart.dev/tools/diagnostic-messages#dead_code'>Documentation</a>)"
Expand Down
Loading