Skip to content

Commit add0903

Browse files
committed
Require Dart 2.12 or later
1 parent c936e9c commit add0903

28 files changed

+96
-551
lines changed

third_party/src/main/java/com/jetbrains/lang/dart/DartFileListener.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import com.jetbrains.lang.dart.sdk.DartPackagesLibraryType;
4040
import com.jetbrains.lang.dart.sdk.DartSdk;
4141
import com.jetbrains.lang.dart.sdk.DartSdkLibUtil;
42-
import com.jetbrains.lang.dart.util.DotPackagesFileUtil;
42+
import com.jetbrains.lang.dart.util.PackageConfigFileUtil;
4343
import org.jetbrains.annotations.NotNull;
4444
import org.jetbrains.annotations.Nullable;
4545

@@ -69,10 +69,8 @@ public final class DartFileListener implements AsyncFileListener {
6969

7070
if (event instanceof VFilePropertyChangeEvent) {
7171
if (((VFilePropertyChangeEvent)event).isRename()) {
72-
if (DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getOldValue()) ||
73-
DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getNewValue()) ||
74-
DotPackagesFileUtil.DOT_PACKAGES.equals(((VFilePropertyChangeEvent)event).getOldValue()) ||
75-
DotPackagesFileUtil.DOT_PACKAGES.equals(((VFilePropertyChangeEvent)event).getNewValue())) {
72+
if (PackageConfigFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getOldValue()) ||
73+
PackageConfigFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getNewValue())) {
7674
packagesFileEvents.add(event);
7775
}
7876

@@ -83,8 +81,7 @@ public final class DartFileListener implements AsyncFileListener {
8381
}
8482
}
8583
else {
86-
if (DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(PathUtil.getFileName(event.getPath())) ||
87-
DotPackagesFileUtil.DOT_PACKAGES.equals(PathUtil.getFileName(event.getPath()))) {
84+
if (PackageConfigFileUtil.PACKAGE_CONFIG_JSON.equals(PathUtil.getFileName(event.getPath()))) {
8885
packagesFileEvents.add(event);
8986
}
9087

@@ -138,15 +135,9 @@ public static void scheduleDartPackageRootsUpdate(final @NotNull Project project
138135
if (module == null || !DartSdkLibUtil.isDartSdkEnabled(module)) continue;
139136

140137
Map<String, String> packagesMap = null;
141-
VirtualFile packagesFile = DotPackagesFileUtil.findPackageConfigJsonFile(pubspecFile.getParent());
138+
VirtualFile packagesFile = PackageConfigFileUtil.findPackageConfigJsonFile(pubspecFile.getParent());
142139
if (packagesFile != null) {
143-
packagesMap = DotPackagesFileUtil.getPackagesMapFromPackageConfigJsonFile(packagesFile);
144-
}
145-
else {
146-
packagesFile = DotPackagesFileUtil.findDotPackagesFile(pubspecFile.getParent());
147-
if (packagesFile != null) {
148-
packagesMap = DotPackagesFileUtil.getPackagesMap(packagesFile);
149-
}
140+
packagesMap = PackageConfigFileUtil.getPackagesMapFromPackageConfigJsonFile(packagesFile);
150141
}
151142

152143
if (packagesMap != null) {
@@ -359,7 +350,7 @@ public void afterVfsChange() {
359350
if (file == null) continue;
360351

361352
VirtualFile dartRoot = file.getParent();
362-
if (dartRoot != null && file.getName().equals(DotPackagesFileUtil.PACKAGE_CONFIG_JSON)) {
353+
if (dartRoot != null && file.getName().equals(PackageConfigFileUtil.PACKAGE_CONFIG_JSON)) {
363354
dartRoot = dartRoot.getParent();
364355
}
365356
VirtualFile pubspec = dartRoot == null ? null : dartRoot.findChild(PUBSPEC_YAML);

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

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,9 @@
8181
import java.util.concurrent.TimeUnit;
8282

8383
public final class DartAnalysisServerService implements Disposable {
84-
public static final String MIN_SDK_VERSION = "1.12";
85-
private static final String MIN_MOVE_FILE_SDK_VERSION = "2.3.2";
84+
public static final String MIN_SDK_VERSION = "2.12";
8685
private static final String COMPLETION_2_SERVER_VERSION = "1.33";
8786

88-
// Webdev works going back to 2.6.0, future minimum version listed in the pubspec.yaml, link below, won't mean that 2.6.0 aren't
89-
// supported.
90-
// https://github.com/dart-lang/webdev/blob/master/webdev/pubspec.yaml#L11
91-
public static final String MIN_WEBDEV_SDK_VERSION = "2.6.0";
92-
93-
// As of the Dart SDK version 2.8.0, the file .dart_tool/package_config.json is preferred over the .packages file.
94-
// https://github.com/dart-lang/sdk/issues/48272
95-
public static final String MIN_PACKAGE_CONFIG_JSON_SDK_VERSION = "2.8.0";
96-
9787
// The dart cli command provides a language server command, `dart language-server`, which
9888
// should be used going forward instead of `dart .../analysis_server.dart.snapshot`.
9989
public static final String MIN_DART_LANG_SERVER_SDK_VERSION = "2.16.0";
@@ -488,18 +478,6 @@ public static boolean isDartSdkVersionSufficient(final @NotNull DartSdk sdk) {
488478
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_SDK_VERSION) >= 0;
489479
}
490480

491-
public static boolean isDartSdkVersionSufficientForMoveFileRefactoring(final @NotNull DartSdk sdk) {
492-
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_MOVE_FILE_SDK_VERSION) >= 0;
493-
}
494-
495-
public static boolean isDartSdkVersionSufficientForWebdev(final @NotNull DartSdk sdk) {
496-
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_WEBDEV_SDK_VERSION) >= 0;
497-
}
498-
499-
public static boolean isDartSdkVersionSufficientForPackageConfigJson(final @NotNull DartSdk sdk) {
500-
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_PACKAGE_CONFIG_JSON_SDK_VERSION) >= 0;
501-
}
502-
503481
public static boolean isDartSdkVersionSufficientForDartLangServer(final @NotNull DartSdk sdk) {
504482
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_DART_LANG_SERVER_SDK_VERSION) >= 0;
505483
}
@@ -1239,10 +1217,6 @@ public boolean edit_isPostfixCompletionApplicable(VirtualFile file, int _offset,
12391217
return null;
12401218
}
12411219

1242-
if (StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) {
1243-
return PostfixTemplateDescriptor.EMPTY_ARRAY;
1244-
}
1245-
12461220
final Ref<PostfixTemplateDescriptor[]> resultRef = Ref.create();
12471221
final CountDownLatch latch = new CountDownLatch(1);
12481222
server.edit_listPostfixCompletionTemplates(new ListPostfixCompletionTemplatesConsumer() {
@@ -1730,7 +1704,7 @@ public void onError(final RequestError error) {
17301704
final int _selectionOffset,
17311705
final int _selectionLength) {
17321706
final AnalysisServer server = myServer;
1733-
if (server == null || StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) {
1707+
if (server == null) {
17341708
return null;
17351709
}
17361710

@@ -1769,7 +1743,7 @@ public void onError(final RequestError error) {
17691743
final @NotNull List<ImportedElements> importedElements,
17701744
final int _offset) {
17711745
final AnalysisServer server = myServer;
1772-
if (server == null || StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) {
1746+
if (server == null) {
17731747
return null;
17741748
}
17751749

@@ -1934,12 +1908,8 @@ private void analysis_setSubscriptions() {
19341908
subscriptions.put(AnalysisService.NAVIGATION, myVisibleFileUris);
19351909
subscriptions.put(AnalysisService.OVERRIDES, myVisibleFileUris);
19361910
subscriptions.put(AnalysisService.OUTLINE, myVisibleFileUris);
1937-
if (StringUtil.compareVersionNumbers(mySdkVersion, "1.13") >= 0) {
1938-
subscriptions.put(AnalysisService.IMPLEMENTED, myVisibleFileUris);
1939-
}
1940-
if (StringUtil.compareVersionNumbers(mySdkVersion, "1.25.0") >= 0) {
1941-
subscriptions.put(AnalysisService.CLOSING_LABELS, myVisibleFileUris);
1942-
}
1911+
subscriptions.put(AnalysisService.IMPLEMENTED, myVisibleFileUris);
1912+
subscriptions.put(AnalysisService.CLOSING_LABELS, myVisibleFileUris);
19431913

19441914
if (LOG.isDebugEnabled()) {
19451915
LOG.debug("analysis_setSubscriptions, subscriptions:\n" + subscriptions);
@@ -2187,15 +2157,7 @@ else if (!useDartLangServerCall && !dasSnapshotFile.canRead()) {
21872157
vmArgsRaw = "";
21882158
}
21892159

2190-
@NonNls String serverArgsRaw;
2191-
if (useDartLangServerCall) {
2192-
serverArgsRaw = "--protocol=analyzer";
2193-
}
2194-
else {
2195-
// Note that as of Dart 2.12.0 the '--useAnalysisHighlight2' flag is ignored (and is the
2196-
// default highlighting mode). We still want to pass it in for earlier SDKs.
2197-
serverArgsRaw = "--useAnalysisHighlight2";
2198-
}
2160+
String serverArgsRaw = useDartLangServerCall ? "--protocol=analyzer" : "";
21992161

22002162
try {
22012163
serverArgsRaw += " " + Registry.stringValue("dart.server.additional.arguments");

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import com.intellij.openapi.module.ModuleUtilCore;
1515
import com.intellij.openapi.project.Project;
1616
import com.intellij.openapi.util.NlsContexts;
17-
import com.intellij.openapi.util.text.StringUtil;
1817
import com.intellij.openapi.vfs.VirtualFile;
1918
import com.intellij.psi.PsiFile;
2019
import com.intellij.psi.PsiManager;
@@ -53,7 +52,7 @@ public final class DartEditorNotificationsProvider implements EditorNotification
5352

5453
final DartSdk sdk = DartSdk.getDartSdk(project);
5554
if (sdk != null && DartSdkLibUtil.isDartSdkEnabled(module)) {
56-
return fileEditor -> new PubActionsPanel(fileEditor, sdk);
55+
return fileEditor -> new PubActionsPanel(fileEditor);
5756
}
5857
}
5958

@@ -116,14 +115,11 @@ public final class DartEditorNotificationsProvider implements EditorNotification
116115
}
117116

118117
private static final class PubActionsPanel extends EditorNotificationPanel {
119-
private PubActionsPanel(@NotNull FileEditor fileEditor, @NotNull DartSdk sdk) {
118+
private PubActionsPanel(@NotNull FileEditor fileEditor) {
120119
super(fileEditor, null, EditorColors.GUTTER_BACKGROUND, Status.Info);
121120
createActionLabel(DartBundle.message("pub.get"), "Dart.pub.get");
122121
createActionLabel(DartBundle.message("pub.upgrade"), "Dart.pub.upgrade");
123-
124-
if (StringUtil.compareVersionNumbers(sdk.getVersion(), DartPubOutdatedAction.MIN_SDK_VERSION) >= 0) {
125-
createActionLabel(DartBundle.message("pub.outdated"), "Dart.pub.outdated");
126-
}
122+
createActionLabel(DartBundle.message("pub.outdated"), "Dart.pub.outdated");
127123

128124
myLinksPanel.add(new JSeparator(SwingConstants.VERTICAL));
129125
createActionLabel(DartBundle.message("webdev.build"), "Dart.build");

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ abstract class DartPubActionBase : AnAction(), DumbAware {
104104

105105
if (sdk == null) return
106106

107-
val useDartPub = StringUtil.compareVersionNumbers(sdk.version, DART_PUB_MIN_SDK_VERSION) >= 0
108-
val exeFile = if (useDartPub) File(DartSdkUtil.getDartExePath(sdk)) else File(DartSdkUtil.getPubPath(sdk))
107+
val exeFile = File(DartSdkUtil.getDartExePath(sdk))
109108

110109
if (!exeFile.isFile) {
111110
if (allowModalDialogs) {
@@ -185,25 +184,12 @@ abstract class DartPubActionBase : AnAction(), DumbAware {
185184
private const val GROUP_DISPLAY_ID: @NonNls String = "Dart Pub Tool"
186185
private val PUB_TOOL_WINDOW_CONTENT_INFO_KEY = Key.create<PubToolWindowContentInfo>("PUB_TOOL_WINDOW_CONTENT_INFO_KEY")
187186

188-
private const val DART_PUB_MIN_SDK_VERSION = "2.10"
189-
private const val DART_RUN_TEST_MIN_SDK_VERSION = "2.11"
190-
191187
private val ourInProgress = AtomicBoolean(false)
192188

193-
@JvmStatic
194-
fun isUseDartRunTestInsteadOfPubRunTest(dartSdk: DartSdk): Boolean =
195-
StringUtil.compareVersionNumbers(dartSdk.version, DART_RUN_TEST_MIN_SDK_VERSION) >= 0
196-
197189
@JvmStatic
198190
fun setupPubExePath(commandLine: GeneralCommandLine, dartSdk: DartSdk) {
199-
val useDartPub = StringUtil.compareVersionNumbers(dartSdk.version, DART_PUB_MIN_SDK_VERSION) >= 0
200-
if (useDartPub) {
201-
commandLine.withExePath(FileUtil.toSystemDependentName(DartSdkUtil.getDartExePath(dartSdk)))
202-
commandLine.addParameter("pub")
203-
}
204-
else {
205-
commandLine.withExePath(FileUtil.toSystemDependentName(DartSdkUtil.getPubPath(dartSdk)))
206-
}
191+
commandLine.withExePath(FileUtil.toSystemDependentName(DartSdkUtil.getDartExePath(dartSdk)))
192+
commandLine.addParameter("pub")
207193
}
208194

209195
@JvmStatic

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

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,16 @@ public class DartPubBuildAction extends DartPubActionBase {
1717
@Override
1818
public void update(@NotNull AnActionEvent e) {
1919
super.update(e);
20-
final Project project = e.getProject();
21-
if (project != null && DartWebdev.INSTANCE.useWebdev(DartSdk.getDartSdk(project))) {
22-
e.getPresentation().setText(DartBundle.message("action.text.webdev.build"));
23-
e.getPresentation().setDescription(DartBundle.message("action.description.run.webdev.build"));
24-
}
25-
else {
26-
e.getPresentation().setText(DartBundle.message("action.text.pub.build"));
27-
e.getPresentation().setDescription(DartBundle.message("action.description.run.pub.build"));
28-
}
20+
21+
e.getPresentation().setText(DartBundle.message("action.text.webdev.build"));
22+
e.getPresentation().setDescription(DartBundle.message("action.description.run.webdev.build"));
2923
}
3024

3125
@Override
3226
protected @NotNull @NlsContexts.DialogTitle String getTitle(final @NotNull Project project, final @NotNull VirtualFile pubspecYamlFile) {
3327
final String projectName = PubspecYamlUtil.getDartProjectName(pubspecYamlFile);
3428
final String prefix = projectName == null ? "" : ("[" + projectName + "] ");
35-
return prefix + DartBundle
36-
.message(DartWebdev.INSTANCE.useWebdev(DartSdk.getDartSdk(project)) ? "dart.webdev.build.title" : "dart.pub.build.title");
29+
return prefix + DartBundle.message("dart.webdev.build.title");
3730
}
3831

3932
@Override
@@ -47,12 +40,8 @@ public void update(@NotNull AnActionEvent e) {
4740
final DartSdk sdk = DartSdk.getDartSdk(project);
4841
if (sdk == null) return null; // can't happen, already checked
4942

50-
if (DartWebdev.INSTANCE.useWebdev(sdk)) {
51-
if (!DartWebdev.INSTANCE.ensureWebdevActivated(project)) return null;
52-
53-
return new String[]{"global", "run", "webdev", "build", "--output=" + dialog.getInputFolder() + ":" + dialog.getOutputFolder()};
54-
}
43+
if (!DartWebdev.INSTANCE.ensureWebdevActivated(project)) return null;
5544

56-
return new String[]{"build", "--mode=" + dialog.getPubBuildMode(), "--output=" + dialog.getOutputFolder()};
45+
return new String[]{"global", "run", "webdev", "build", "--output=" + dialog.getInputFolder() + ":" + dialog.getOutputFolder()};
5746
}
5847
}

0 commit comments

Comments
 (0)