Skip to content

Commit e5cc66c

Browse files
committed
[Dart] Require Dart 2.12 or later
1 parent a429fff commit e5cc66c

30 files changed

+120
-573
lines changed

Dart/resources/messages/DartBundle.properties

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ runner.web.app.configuration.name=Dart Web App
109109
command.line.run.config.label.dart.file=Dart &file:
110110
command.line.run.config.label.vm.options=&VM options:
111111
command.line.run.config.checkbox.enable.asserts=E&nable asserts
112-
command.line.run.config.checkbox.checked.mode=Checked mode
113112
command.line.run.config.label.program.arguments=Program a&rguments:
114113
command.line.run.config.label.working.directory=&Working directory:
115114

@@ -125,7 +124,6 @@ webdev.debug.configuration.description=Start Dart web application using the webd
125124
web.run.config.label.html.file=HTML &file:
126125
web.run.config.label.webdev.port=Webdev &port:
127126
choose.html.main.file=Choose HTML File
128-
old.dart.sdk.for.webdev=Dart SDK {0}+ is required for debugging a Dart web app using webdev, current version: {1}
129127

130128
dart.project.description=Create project for use with the Dart programming language
131129
project.template.not.selected=Project template is not selected
@@ -144,7 +142,6 @@ working.dir.0=Working dir: {0}
144142
dart.pub.get.title=Pub Get
145143
dart.pub.upgrade.title=Pub Upgrade
146144
dart.pub.outdated.title=Pub Outdated
147-
dart.pub.build.title=Pub Build
148145
dart.webdev.build.title=Webdev Build
149146
dart.pub.cache.repair.title=Pub Repair Cache
150147
dart.pub.cache.repair.message=<html>The <a href='https://dart.dev/tools/pub/cmd/pub-cache'>pub cache repair</a> command performs a clean reinstall<br/>of all hosted and git packages in the system cache.<br/><br/>Start cache repair?</html>
@@ -347,8 +344,6 @@ action.Dart.stop.dart.webdev.server.description=Stop Dart Webdev Server
347344
action.DartCopyDtdUriAction.text=Dart: Copy DTD URI to Clipboard
348345
action.DartCopyDtdUriAction.description=Copy Dart Tooling Daemon URI to clipboard
349346

350-
action.description.run.pub.build=Run 'pub build'
351-
action.text.pub.build=Pub Build\u2026
352347
action.text.webdev.build=Webdev Build\u2026
353348
action.description.run.webdev.build=Run 'webdev build'
354349
border.breaking.policy=Breaking Policy
@@ -396,7 +391,6 @@ filetype.dart.description=Dart
396391
validation.info.input.and.output.folders.must.be.different=Input and output folders must be different
397392
validation.info.output.folder.not.specified=Output folder not specified
398393
validation.info.input.folder.not.specified=Input folder not specified
399-
validation.info.build.mode.not.specified=Build mode not specified
400394
button.browse.dialog.title.output.folder=Output Folder
401395
button.text.build2=Build
402396
action.title.dart.rename.refactoring=Dart Rename Refactoring

Dart/src/com/jetbrains/lang/dart/DartFileListener.java

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

@@ -68,10 +68,8 @@ public final class DartFileListener implements AsyncFileListener {
6868

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

@@ -82,8 +80,7 @@ public final class DartFileListener implements AsyncFileListener {
8280
}
8381
}
8482
else {
85-
if (DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(PathUtil.getFileName(event.getPath())) ||
86-
DotPackagesFileUtil.DOT_PACKAGES.equals(PathUtil.getFileName(event.getPath()))) {
83+
if (PackageConfigFileUtil.PACKAGE_CONFIG_JSON.equals(PathUtil.getFileName(event.getPath()))) {
8784
packagesFileEvents.add(event);
8885
}
8986

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

139136
Map<String, String> packagesMap = null;
140-
VirtualFile packagesFile = DotPackagesFileUtil.findPackageConfigJsonFile(pubspecFile.getParent());
137+
VirtualFile packagesFile = PackageConfigFileUtil.findPackageConfigJsonFile(pubspecFile.getParent());
141138
if (packagesFile != null) {
142-
packagesMap = DotPackagesFileUtil.getPackagesMapFromPackageConfigJsonFile(packagesFile);
143-
}
144-
else {
145-
packagesFile = DotPackagesFileUtil.findDotPackagesFile(pubspecFile.getParent());
146-
if (packagesFile != null) {
147-
packagesMap = DotPackagesFileUtil.getPackagesMap(packagesFile);
148-
}
139+
packagesMap = PackageConfigFileUtil.getPackagesMapFromPackageConfigJsonFile(packagesFile);
149140
}
150141

151142
if (packagesMap != null) {
@@ -358,7 +349,7 @@ public void afterVfsChange() {
358349
if (file == null) continue;
359350

360351
VirtualFile dartRoot = file.getParent();
361-
if (dartRoot != null && file.getName().equals(DotPackagesFileUtil.PACKAGE_CONFIG_JSON)) {
352+
if (dartRoot != null && file.getName().equals(PackageConfigFileUtil.PACKAGE_CONFIG_JSON)) {
362353
dartRoot = dartRoot.getParent();
363354
}
364355
VirtualFile pubspec = dartRoot == null ? null : dartRoot.findChild(PUBSPEC_YAML);

Dart/src/com/jetbrains/lang/dart/analyzer/DartAnalysisServerService.java

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

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

89-
// 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
90-
// supported.
91-
// https://github.com/dart-lang/webdev/blob/master/webdev/pubspec.yaml#L11
92-
public static final String MIN_WEBDEV_SDK_VERSION = "2.6.0";
93-
94-
// As of the Dart SDK version 2.8.0, the file .dart_tool/package_config.json is preferred over the .packages file.
95-
// https://github.com/dart-lang/sdk/issues/48272
96-
public static final String MIN_PACKAGE_CONFIG_JSON_SDK_VERSION = "2.8.0";
97-
9888
// The dart cli command provides a language server command, `dart language-server`, which
9989
// should be used going forward instead of `dart .../analysis_server.dart.snapshot`.
10090
public static final String MIN_DART_LANG_SERVER_SDK_VERSION = "2.16.0";
@@ -489,18 +479,6 @@ public static boolean isDartSdkVersionSufficient(final @NotNull DartSdk sdk) {
489479
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_SDK_VERSION) >= 0;
490480
}
491481

492-
public static boolean isDartSdkVersionSufficientForMoveFileRefactoring(final @NotNull DartSdk sdk) {
493-
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_MOVE_FILE_SDK_VERSION) >= 0;
494-
}
495-
496-
public static boolean isDartSdkVersionSufficientForWebdev(final @NotNull DartSdk sdk) {
497-
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_WEBDEV_SDK_VERSION) >= 0;
498-
}
499-
500-
public static boolean isDartSdkVersionSufficientForPackageConfigJson(final @NotNull DartSdk sdk) {
501-
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_PACKAGE_CONFIG_JSON_SDK_VERSION) >= 0;
502-
}
503-
504482
public static boolean isDartSdkVersionSufficientForDartLangServer(final @NotNull DartSdk sdk) {
505483
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_DART_LANG_SERVER_SDK_VERSION) >= 0;
506484
}
@@ -1243,10 +1221,6 @@ public void isPostfixCompletionApplicable(Boolean value) {
12431221
return null;
12441222
}
12451223

1246-
if (StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) {
1247-
return PostfixTemplateDescriptor.EMPTY_ARRAY;
1248-
}
1249-
12501224
final Ref<PostfixTemplateDescriptor[]> resultRef = Ref.create();
12511225
final CountDownLatch latch = new CountDownLatch(1);
12521226
server.edit_listPostfixCompletionTemplates(new ListPostfixCompletionTemplatesConsumer() {
@@ -1734,7 +1708,7 @@ public void onError(final RequestError error) {
17341708
final int _selectionOffset,
17351709
final int _selectionLength) {
17361710
final AnalysisServer server = myServer;
1737-
if (server == null || StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) {
1711+
if (server == null) {
17381712
return null;
17391713
}
17401714

@@ -1773,7 +1747,7 @@ public void onError(final RequestError error) {
17731747
final @NotNull List<ImportedElements> importedElements,
17741748
final int _offset) {
17751749
final AnalysisServer server = myServer;
1776-
if (server == null || StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) {
1750+
if (server == null) {
17771751
return null;
17781752
}
17791753

@@ -1938,12 +1912,8 @@ private void analysis_setSubscriptions() {
19381912
subscriptions.put(AnalysisService.NAVIGATION, myVisibleFileUris);
19391913
subscriptions.put(AnalysisService.OVERRIDES, myVisibleFileUris);
19401914
subscriptions.put(AnalysisService.OUTLINE, myVisibleFileUris);
1941-
if (StringUtil.compareVersionNumbers(mySdkVersion, "1.13") >= 0) {
1942-
subscriptions.put(AnalysisService.IMPLEMENTED, myVisibleFileUris);
1943-
}
1944-
if (StringUtil.compareVersionNumbers(mySdkVersion, "1.25.0") >= 0) {
1945-
subscriptions.put(AnalysisService.CLOSING_LABELS, myVisibleFileUris);
1946-
}
1915+
subscriptions.put(AnalysisService.IMPLEMENTED, myVisibleFileUris);
1916+
subscriptions.put(AnalysisService.CLOSING_LABELS, myVisibleFileUris);
19471917

19481918
if (LOG.isDebugEnabled()) {
19491919
LOG.debug("analysis_setSubscriptions, subscriptions:\n" + subscriptions);
@@ -2199,15 +2169,7 @@ else if (!useDartLangServerCall && !dasSnapshotFile.canRead()) {
21992169
vmArgsRaw = "";
22002170
}
22012171

2202-
@NonNls String serverArgsRaw;
2203-
if (useDartLangServerCall) {
2204-
serverArgsRaw = "--protocol=analyzer";
2205-
}
2206-
else {
2207-
// Note that as of Dart 2.12.0 the '--useAnalysisHighlight2' flag is ignored (and is the
2208-
// default highlighting mode). We still want to pass it in for earlier SDKs.
2209-
serverArgsRaw = "--useAnalysisHighlight2";
2210-
}
2172+
@NonNls String serverArgsRaw = useDartLangServerCall ? "--protocol=analyzer" : "";
22112173

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

Dart/src/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");

Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubActionBase.kt

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import com.intellij.openapi.util.Disposer
3636
import com.intellij.openapi.util.Key
3737
import com.intellij.openapi.util.NlsContexts
3838
import com.intellij.openapi.util.io.FileUtil
39-
import com.intellij.openapi.util.text.StringUtil
4039
import com.intellij.openapi.vfs.VfsUtil
4140
import com.intellij.openapi.vfs.VirtualFile
4241
import com.intellij.openapi.wm.ToolWindowId
@@ -105,8 +104,7 @@ abstract class DartPubActionBase : AnAction(), DumbAware {
105104

106105
if (sdk == null) return
107106

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

111109
if (!exeFile.isFile) {
112110
if (allowModalDialogs) {
@@ -186,25 +184,12 @@ abstract class DartPubActionBase : AnAction(), DumbAware {
186184
private const val GROUP_DISPLAY_ID: @NonNls String = "Dart Pub Tool"
187185
private val PUB_TOOL_WINDOW_CONTENT_INFO_KEY = Key.create<PubToolWindowContentInfo>("PUB_TOOL_WINDOW_CONTENT_INFO_KEY")
188186

189-
private const val DART_PUB_MIN_SDK_VERSION = "2.10"
190-
private const val DART_RUN_TEST_MIN_SDK_VERSION = "2.11"
191-
192187
private val ourInProgress = AtomicBoolean(false)
193188

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

210195
@JvmStatic

Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildAction.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,15 @@ 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+
e.getPresentation().setText(DartBundle.message("action.text.webdev.build"));
21+
e.getPresentation().setDescription(DartBundle.message("action.description.run.webdev.build"));
2922
}
3023

3124
@Override
3225
protected @NotNull @NlsContexts.DialogTitle String getTitle(final @NotNull Project project, final @NotNull VirtualFile pubspecYamlFile) {
3326
final String projectName = PubspecYamlUtil.getDartProjectName(pubspecYamlFile);
3427
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");
28+
return prefix + DartBundle.message("dart.webdev.build.title");
3729
}
3830

3931
@Override
@@ -47,12 +39,8 @@ public void update(@NotNull AnActionEvent e) {
4739
final DartSdk sdk = DartSdk.getDartSdk(project);
4840
if (sdk == null) return null; // can't happen, already checked
4941

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-
}
42+
if (!DartWebdev.INSTANCE.ensureWebdevActivated(project)) return null;
5543

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

0 commit comments

Comments
 (0)