diff --git a/Dart/resources/messages/DartBundle.properties b/Dart/resources/messages/DartBundle.properties index bf2c593b03b..ed5557095b3 100644 --- a/Dart/resources/messages/DartBundle.properties +++ b/Dart/resources/messages/DartBundle.properties @@ -109,7 +109,6 @@ runner.web.app.configuration.name=Dart Web App command.line.run.config.label.dart.file=Dart &file: command.line.run.config.label.vm.options=&VM options: command.line.run.config.checkbox.enable.asserts=E&nable asserts -command.line.run.config.checkbox.checked.mode=Checked mode command.line.run.config.label.program.arguments=Program a&rguments: command.line.run.config.label.working.directory=&Working directory: @@ -125,7 +124,6 @@ webdev.debug.configuration.description=Start Dart web application using the webd web.run.config.label.html.file=HTML &file: web.run.config.label.webdev.port=Webdev &port: choose.html.main.file=Choose HTML File -old.dart.sdk.for.webdev=Dart SDK {0}+ is required for debugging a Dart web app using webdev, current version: {1} dart.project.description=Create project for use with the Dart programming language project.template.not.selected=Project template is not selected @@ -144,7 +142,6 @@ working.dir.0=Working dir: {0} dart.pub.get.title=Pub Get dart.pub.upgrade.title=Pub Upgrade dart.pub.outdated.title=Pub Outdated -dart.pub.build.title=Pub Build dart.webdev.build.title=Webdev Build dart.pub.cache.repair.title=Pub Repair Cache dart.pub.cache.repair.message=The pub cache repair command performs a clean reinstall
of all hosted and git packages in the system cache.

Start cache repair? @@ -347,8 +344,6 @@ action.Dart.stop.dart.webdev.server.description=Stop Dart Webdev Server action.DartCopyDtdUriAction.text=Dart: Copy DTD URI to Clipboard action.DartCopyDtdUriAction.description=Copy Dart Tooling Daemon URI to clipboard -action.description.run.pub.build=Run 'pub build' -action.text.pub.build=Pub Build\u2026 action.text.webdev.build=Webdev Build\u2026 action.description.run.webdev.build=Run 'webdev build' border.breaking.policy=Breaking Policy @@ -396,7 +391,6 @@ filetype.dart.description=Dart validation.info.input.and.output.folders.must.be.different=Input and output folders must be different validation.info.output.folder.not.specified=Output folder not specified validation.info.input.folder.not.specified=Input folder not specified -validation.info.build.mode.not.specified=Build mode not specified button.browse.dialog.title.output.folder=Output Folder button.text.build2=Build action.title.dart.rename.refactoring=Dart Rename Refactoring diff --git a/Dart/src/com/jetbrains/lang/dart/DartFileListener.java b/Dart/src/com/jetbrains/lang/dart/DartFileListener.java index 5df3e29e461..c15c5f7ae18 100644 --- a/Dart/src/com/jetbrains/lang/dart/DartFileListener.java +++ b/Dart/src/com/jetbrains/lang/dart/DartFileListener.java @@ -38,7 +38,7 @@ import com.jetbrains.lang.dart.sdk.DartPackagesLibraryType; import com.jetbrains.lang.dart.sdk.DartSdk; import com.jetbrains.lang.dart.sdk.DartSdkLibUtil; -import com.jetbrains.lang.dart.util.DotPackagesFileUtil; +import com.jetbrains.lang.dart.util.PackageConfigFileUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -68,10 +68,8 @@ public final class DartFileListener implements AsyncFileListener { if (event instanceof VFilePropertyChangeEvent) { if (((VFilePropertyChangeEvent)event).isRename()) { - if (DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getOldValue()) || - DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getNewValue()) || - DotPackagesFileUtil.DOT_PACKAGES.equals(((VFilePropertyChangeEvent)event).getOldValue()) || - DotPackagesFileUtil.DOT_PACKAGES.equals(((VFilePropertyChangeEvent)event).getNewValue())) { + if (PackageConfigFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getOldValue()) || + PackageConfigFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getNewValue())) { packagesFileEvents.add(event); } @@ -82,8 +80,7 @@ public final class DartFileListener implements AsyncFileListener { } } else { - if (DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(PathUtil.getFileName(event.getPath())) || - DotPackagesFileUtil.DOT_PACKAGES.equals(PathUtil.getFileName(event.getPath()))) { + if (PackageConfigFileUtil.PACKAGE_CONFIG_JSON.equals(PathUtil.getFileName(event.getPath()))) { packagesFileEvents.add(event); } @@ -137,15 +134,9 @@ public static void scheduleDartPackageRootsUpdate(final @NotNull Project project if (module == null || !DartSdkLibUtil.isDartSdkEnabled(module)) continue; Map packagesMap = null; - VirtualFile packagesFile = DotPackagesFileUtil.findPackageConfigJsonFile(pubspecFile.getParent()); + VirtualFile packagesFile = PackageConfigFileUtil.findPackageConfigJsonFile(pubspecFile.getParent()); if (packagesFile != null) { - packagesMap = DotPackagesFileUtil.getPackagesMapFromPackageConfigJsonFile(packagesFile); - } - else { - packagesFile = DotPackagesFileUtil.findDotPackagesFile(pubspecFile.getParent()); - if (packagesFile != null) { - packagesMap = DotPackagesFileUtil.getPackagesMap(packagesFile); - } + packagesMap = PackageConfigFileUtil.getPackagesMapFromPackageConfigJsonFile(packagesFile); } if (packagesMap != null) { @@ -358,7 +349,7 @@ public void afterVfsChange() { if (file == null) continue; VirtualFile dartRoot = file.getParent(); - if (dartRoot != null && file.getName().equals(DotPackagesFileUtil.PACKAGE_CONFIG_JSON)) { + if (dartRoot != null && file.getName().equals(PackageConfigFileUtil.PACKAGE_CONFIG_JSON)) { dartRoot = dartRoot.getParent(); } VirtualFile pubspec = dartRoot == null ? null : dartRoot.findChild(PUBSPEC_YAML); diff --git a/Dart/src/com/jetbrains/lang/dart/analyzer/DartAnalysisServerService.java b/Dart/src/com/jetbrains/lang/dart/analyzer/DartAnalysisServerService.java index 96eaee37c47..b5038180a15 100644 --- a/Dart/src/com/jetbrains/lang/dart/analyzer/DartAnalysisServerService.java +++ b/Dart/src/com/jetbrains/lang/dart/analyzer/DartAnalysisServerService.java @@ -82,19 +82,9 @@ import java.util.concurrent.TimeUnit; public final class DartAnalysisServerService implements Disposable { - public static final String MIN_SDK_VERSION = "1.12"; - private static final String MIN_MOVE_FILE_SDK_VERSION = "2.3.2"; + public static final String MIN_SDK_VERSION = "2.12"; private static final String COMPLETION_2_SERVER_VERSION = "1.33"; - // 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 - // supported. - // https://github.com/dart-lang/webdev/blob/master/webdev/pubspec.yaml#L11 - public static final String MIN_WEBDEV_SDK_VERSION = "2.6.0"; - - // As of the Dart SDK version 2.8.0, the file .dart_tool/package_config.json is preferred over the .packages file. - // https://github.com/dart-lang/sdk/issues/48272 - public static final String MIN_PACKAGE_CONFIG_JSON_SDK_VERSION = "2.8.0"; - // The dart cli command provides a language server command, `dart language-server`, which // should be used going forward instead of `dart .../analysis_server.dart.snapshot`. 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) { return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_SDK_VERSION) >= 0; } - public static boolean isDartSdkVersionSufficientForMoveFileRefactoring(final @NotNull DartSdk sdk) { - return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_MOVE_FILE_SDK_VERSION) >= 0; - } - - public static boolean isDartSdkVersionSufficientForWebdev(final @NotNull DartSdk sdk) { - return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_WEBDEV_SDK_VERSION) >= 0; - } - - public static boolean isDartSdkVersionSufficientForPackageConfigJson(final @NotNull DartSdk sdk) { - return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_PACKAGE_CONFIG_JSON_SDK_VERSION) >= 0; - } - public static boolean isDartSdkVersionSufficientForDartLangServer(final @NotNull DartSdk sdk) { return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_DART_LANG_SERVER_SDK_VERSION) >= 0; } @@ -1243,10 +1221,6 @@ public void isPostfixCompletionApplicable(Boolean value) { return null; } - if (StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) { - return PostfixTemplateDescriptor.EMPTY_ARRAY; - } - final Ref resultRef = Ref.create(); final CountDownLatch latch = new CountDownLatch(1); server.edit_listPostfixCompletionTemplates(new ListPostfixCompletionTemplatesConsumer() { @@ -1734,7 +1708,7 @@ public void onError(final RequestError error) { final int _selectionOffset, final int _selectionLength) { final AnalysisServer server = myServer; - if (server == null || StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) { + if (server == null) { return null; } @@ -1773,7 +1747,7 @@ public void onError(final RequestError error) { final @NotNull List importedElements, final int _offset) { final AnalysisServer server = myServer; - if (server == null || StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) { + if (server == null) { return null; } @@ -1938,12 +1912,8 @@ private void analysis_setSubscriptions() { subscriptions.put(AnalysisService.NAVIGATION, myVisibleFileUris); subscriptions.put(AnalysisService.OVERRIDES, myVisibleFileUris); subscriptions.put(AnalysisService.OUTLINE, myVisibleFileUris); - if (StringUtil.compareVersionNumbers(mySdkVersion, "1.13") >= 0) { - subscriptions.put(AnalysisService.IMPLEMENTED, myVisibleFileUris); - } - if (StringUtil.compareVersionNumbers(mySdkVersion, "1.25.0") >= 0) { - subscriptions.put(AnalysisService.CLOSING_LABELS, myVisibleFileUris); - } + subscriptions.put(AnalysisService.IMPLEMENTED, myVisibleFileUris); + subscriptions.put(AnalysisService.CLOSING_LABELS, myVisibleFileUris); if (LOG.isDebugEnabled()) { LOG.debug("analysis_setSubscriptions, subscriptions:\n" + subscriptions); @@ -2199,15 +2169,7 @@ else if (!useDartLangServerCall && !dasSnapshotFile.canRead()) { vmArgsRaw = ""; } - @NonNls String serverArgsRaw; - if (useDartLangServerCall) { - serverArgsRaw = "--protocol=analyzer"; - } - else { - // Note that as of Dart 2.12.0 the '--useAnalysisHighlight2' flag is ignored (and is the - // default highlighting mode). We still want to pass it in for earlier SDKs. - serverArgsRaw = "--useAnalysisHighlight2"; - } + @NonNls String serverArgsRaw = useDartLangServerCall ? "--protocol=analyzer" : ""; try { serverArgsRaw += " " + Registry.stringValue("dart.server.additional.arguments"); diff --git a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartEditorNotificationsProvider.java b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartEditorNotificationsProvider.java index 7bd7f9d46fe..859d90fb36f 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartEditorNotificationsProvider.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartEditorNotificationsProvider.java @@ -14,7 +14,6 @@ import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NlsContexts; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; @@ -53,7 +52,7 @@ public final class DartEditorNotificationsProvider implements EditorNotification final DartSdk sdk = DartSdk.getDartSdk(project); if (sdk != null && DartSdkLibUtil.isDartSdkEnabled(module)) { - return fileEditor -> new PubActionsPanel(fileEditor, sdk); + return fileEditor -> new PubActionsPanel(fileEditor); } } @@ -116,14 +115,11 @@ public final class DartEditorNotificationsProvider implements EditorNotification } private static final class PubActionsPanel extends EditorNotificationPanel { - private PubActionsPanel(@NotNull FileEditor fileEditor, @NotNull DartSdk sdk) { + private PubActionsPanel(@NotNull FileEditor fileEditor) { super(fileEditor, null, EditorColors.GUTTER_BACKGROUND, Status.Info); createActionLabel(DartBundle.message("pub.get"), "Dart.pub.get"); createActionLabel(DartBundle.message("pub.upgrade"), "Dart.pub.upgrade"); - - if (StringUtil.compareVersionNumbers(sdk.getVersion(), DartPubOutdatedAction.MIN_SDK_VERSION) >= 0) { - createActionLabel(DartBundle.message("pub.outdated"), "Dart.pub.outdated"); - } + createActionLabel(DartBundle.message("pub.outdated"), "Dart.pub.outdated"); myLinksPanel.add(new JSeparator(SwingConstants.VERTICAL)); createActionLabel(DartBundle.message("webdev.build"), "Dart.build"); diff --git a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubActionBase.kt b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubActionBase.kt index 7311e68b520..dae6eff60d6 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubActionBase.kt +++ b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubActionBase.kt @@ -36,7 +36,6 @@ import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.Key import com.intellij.openapi.util.NlsContexts import com.intellij.openapi.util.io.FileUtil -import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.wm.ToolWindowId @@ -105,8 +104,7 @@ abstract class DartPubActionBase : AnAction(), DumbAware { if (sdk == null) return - val useDartPub = StringUtil.compareVersionNumbers(sdk.version, DART_PUB_MIN_SDK_VERSION) >= 0 - val exeFile = if (useDartPub) File(DartSdkUtil.getDartExePath(sdk)) else File(DartSdkUtil.getPubPath(sdk)) + val exeFile = File(DartSdkUtil.getDartExePath(sdk)) if (!exeFile.isFile) { if (allowModalDialogs) { @@ -186,25 +184,12 @@ abstract class DartPubActionBase : AnAction(), DumbAware { private const val GROUP_DISPLAY_ID: @NonNls String = "Dart Pub Tool" private val PUB_TOOL_WINDOW_CONTENT_INFO_KEY = Key.create("PUB_TOOL_WINDOW_CONTENT_INFO_KEY") - private const val DART_PUB_MIN_SDK_VERSION = "2.10" - private const val DART_RUN_TEST_MIN_SDK_VERSION = "2.11" - private val ourInProgress = AtomicBoolean(false) - @JvmStatic - fun isUseDartRunTestInsteadOfPubRunTest(dartSdk: DartSdk): Boolean = - StringUtil.compareVersionNumbers(dartSdk.version, DART_RUN_TEST_MIN_SDK_VERSION) >= 0 - @JvmStatic fun setupPubExePath(commandLine: GeneralCommandLine, dartSdk: DartSdk) { - val useDartPub = StringUtil.compareVersionNumbers(dartSdk.version, DART_PUB_MIN_SDK_VERSION) >= 0 - if (useDartPub) { - commandLine.withExePath(FileUtil.toSystemDependentName(DartSdkUtil.getDartExePath(dartSdk))) - commandLine.addParameter("pub") - } - else { - commandLine.withExePath(FileUtil.toSystemDependentName(DartSdkUtil.getPubPath(dartSdk))) - } + commandLine.withExePath(FileUtil.toSystemDependentName(DartSdkUtil.getDartExePath(dartSdk))) + commandLine.addParameter("pub") } @JvmStatic diff --git a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildAction.java b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildAction.java index 55dd43de767..1d8e076f331 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildAction.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildAction.java @@ -17,23 +17,15 @@ public class DartPubBuildAction extends DartPubActionBase { @Override public void update(@NotNull AnActionEvent e) { super.update(e); - final Project project = e.getProject(); - if (project != null && DartWebdev.INSTANCE.useWebdev(DartSdk.getDartSdk(project))) { - e.getPresentation().setText(DartBundle.message("action.text.webdev.build")); - e.getPresentation().setDescription(DartBundle.message("action.description.run.webdev.build")); - } - else { - e.getPresentation().setText(DartBundle.message("action.text.pub.build")); - e.getPresentation().setDescription(DartBundle.message("action.description.run.pub.build")); - } + e.getPresentation().setText(DartBundle.message("action.text.webdev.build")); + e.getPresentation().setDescription(DartBundle.message("action.description.run.webdev.build")); } @Override protected @NotNull @NlsContexts.DialogTitle String getTitle(final @NotNull Project project, final @NotNull VirtualFile pubspecYamlFile) { final String projectName = PubspecYamlUtil.getDartProjectName(pubspecYamlFile); final String prefix = projectName == null ? "" : ("[" + projectName + "] "); - return prefix + DartBundle - .message(DartWebdev.INSTANCE.useWebdev(DartSdk.getDartSdk(project)) ? "dart.webdev.build.title" : "dart.pub.build.title"); + return prefix + DartBundle.message("dart.webdev.build.title"); } @Override @@ -47,12 +39,8 @@ public void update(@NotNull AnActionEvent e) { final DartSdk sdk = DartSdk.getDartSdk(project); if (sdk == null) return null; // can't happen, already checked - if (DartWebdev.INSTANCE.useWebdev(sdk)) { - if (!DartWebdev.INSTANCE.ensureWebdevActivated(project)) return null; - - return new String[]{"global", "run", "webdev", "build", "--output=" + dialog.getInputFolder() + ":" + dialog.getOutputFolder()}; - } + if (!DartWebdev.INSTANCE.ensureWebdevActivated(project)) return null; - return new String[]{"build", "--mode=" + dialog.getPubBuildMode(), "--output=" + dialog.getOutputFolder()}; + return new String[]{"global", "run", "webdev", "build", "--output=" + dialog.getInputFolder() + ":" + dialog.getOutputFolder()}; } } diff --git a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildDialog.form b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildDialog.form index 69cf7ee48b9..9b551f78f31 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildDialog.form +++ b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildDialog.form @@ -1,21 +1,21 @@
- + - + - + - + @@ -24,79 +24,19 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildDialog.java b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildDialog.java index d2a44972231..c38c8c4cf11 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildDialog.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubBuildDialog.java @@ -12,65 +12,34 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.wm.IdeFocusManager; -import com.intellij.ui.components.JBRadioButton; import com.jetbrains.lang.dart.DartBundle; -import com.jetbrains.lang.dart.pubServer.DartWebdev; -import com.jetbrains.lang.dart.sdk.DartSdk; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.awt.event.ActionListener; public class DartPubBuildDialog extends DialogWrapper { - private static final String DART_PUB_BUILD_MODE_KEY = "DART_PUB_BUILD_MODE"; - private static final String DART_PUB_CUSTOM_BUILD_MODE_KEY = "DART_PUB_CUSTOM_BUILD_MODE"; - - private static final String RELEASE_MODE = "release"; - private static final String DEBUG_MODE = "debug"; - private static final String OTHER_MODE = "other"; - private static final String DEFAULT_MODE = RELEASE_MODE; - private static final String DART_BUILD_INPUT_KEY = "DART_BUILD_INPUT_KEY"; private static final String DEFAULT_INPUT_FOLDER = "web"; private static final String DART_BUILD_OUTPUT_KEY = "DART_PUB_BUILD_OUTPUT_KEY"; // _PUB_ - for compatibility private static final String DEFAULT_OUTPUT_FOLDER = "build"; private JPanel myMainPanel; - private JPanel myBuildModePanel; - private JBRadioButton myReleaseRadioButton; - private JBRadioButton myDebugRadioButton; - private JBRadioButton myOtherRadioButton; - private JTextField myOtherModeTextField; - private JPanel myInputFolderPanel; private JTextField myInputFolderTextField; private TextFieldWithBrowseButton myOutputFolderField; private final @NotNull Project myProject; - private final boolean myUseWebdev; public DartPubBuildDialog(final @NotNull Project project, final @NotNull VirtualFile packageDir) { super(project); myProject = project; - myUseWebdev = DartWebdev.INSTANCE.useWebdev(DartSdk.getDartSdk(project)); - setTitle(DartBundle.message(myUseWebdev ? "dart.webdev.build.title" : "dart.pub.build.title")); + setTitle(DartBundle.message("dart.webdev.build.title")); setOKButtonText(DartBundle.message("button.text.build2")); - final ActionListener listener = e -> updateControls(); - myReleaseRadioButton.addActionListener(listener); - myDebugRadioButton.addActionListener(listener); - myOtherRadioButton.addActionListener(listener); - myOtherRadioButton.addActionListener(e -> { - if (myOtherRadioButton.isSelected()) { - IdeFocusManager.getInstance(myProject).requestFocus(myOtherModeTextField, true); - } - }); - var packagePathSlash = FileUtil.toSystemDependentName(packageDir.getPath() + "/"); myOutputFolderField.addBrowseFolderListener( myProject, @@ -103,34 +72,8 @@ public void setText(JTextField component, @NotNull String text) { private void reset() { final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject); - if (myUseWebdev) { - myBuildModePanel.setVisible(false); - myInputFolderTextField.setText(propertiesComponent.getValue(DART_BUILD_INPUT_KEY, DEFAULT_INPUT_FOLDER)); - } - else { - myInputFolderPanel.setVisible(false); - - final String mode = propertiesComponent.getValue(DART_PUB_BUILD_MODE_KEY, DEFAULT_MODE); - if (mode.equals(RELEASE_MODE)) { - myReleaseRadioButton.setSelected(true); - } - else if (mode.equals(DEBUG_MODE)) { - myDebugRadioButton.setSelected(true); - } - else { - myOtherRadioButton.setSelected(true); - } - - myOtherModeTextField.setText(propertiesComponent.getValue(DART_PUB_CUSTOM_BUILD_MODE_KEY, "")); - } - + myInputFolderTextField.setText(propertiesComponent.getValue(DART_BUILD_INPUT_KEY, DEFAULT_INPUT_FOLDER)); myOutputFolderField.setText(propertiesComponent.getValue(DART_BUILD_OUTPUT_KEY, DEFAULT_OUTPUT_FOLDER)); - - updateControls(); - } - - private void updateControls() { - myOtherModeTextField.setEnabled(myOtherRadioButton.isSelected()); } @Override @@ -138,19 +81,9 @@ private void updateControls() { return myMainPanel; } - @Override - public @Nullable JComponent getPreferredFocusedComponent() { - if (myOtherRadioButton.isSelected()) return myOtherModeTextField; - return null; - } - @Override protected @Nullable ValidationInfo doValidate() { - if (!myUseWebdev && myOtherRadioButton.isSelected() && StringUtil.isEmptyOrSpaces(myOtherModeTextField.getText())) { - return new ValidationInfo(DartBundle.message("validation.info.build.mode.not.specified")); - } - - if (myUseWebdev && myInputFolderTextField.getText().trim().isEmpty()) { + if (myInputFolderTextField.getText().trim().isEmpty()) { return new ValidationInfo(DartBundle.message("validation.info.input.folder.not.specified")); } @@ -158,7 +91,7 @@ private void updateControls() { return new ValidationInfo(DartBundle.message("validation.info.output.folder.not.specified")); } - if (myUseWebdev && myInputFolderTextField.getText().trim().equals(myOutputFolderField.getText().trim())) { + if (myInputFolderTextField.getText().trim().equals(myOutputFolderField.getText().trim())) { return new ValidationInfo(DartBundle.message("validation.info.input.and.output.folders.must.be.different")); } @@ -174,31 +107,13 @@ protected void doOKAction() { private void saveDialogState() { final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject); - if (myUseWebdev) { - final String inputPath = StringUtil.nullize(myInputFolderTextField.getText().trim()); - propertiesComponent.setValue(DART_BUILD_INPUT_KEY, inputPath, DEFAULT_INPUT_FOLDER); - } - else { - final String mode = myReleaseRadioButton.isSelected() ? RELEASE_MODE - : myDebugRadioButton.isSelected() ? DEBUG_MODE - : OTHER_MODE; - propertiesComponent.setValue(DART_PUB_BUILD_MODE_KEY, mode, DEFAULT_MODE); - - if (myOtherRadioButton.isSelected()) { - propertiesComponent.setValue(DART_PUB_CUSTOM_BUILD_MODE_KEY, myOtherModeTextField.getText().trim()); - } - } + final String inputPath = StringUtil.nullize(myInputFolderTextField.getText().trim()); + propertiesComponent.setValue(DART_BUILD_INPUT_KEY, inputPath, DEFAULT_INPUT_FOLDER); final String outputPath = StringUtil.nullize(myOutputFolderField.getText().trim()); propertiesComponent.setValue(DART_BUILD_OUTPUT_KEY, outputPath, DEFAULT_OUTPUT_FOLDER); } - public @NotNull String getPubBuildMode() { - if (myReleaseRadioButton.isSelected()) return RELEASE_MODE; - if (myDebugRadioButton.isSelected()) return DEBUG_MODE; - return myOtherModeTextField.getText().trim(); - } - public @NotNull String getInputFolder() { String path = myInputFolderTextField.getText().trim(); if (path.isEmpty()) path = DEFAULT_INPUT_FOLDER; diff --git a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubOutdatedAction.java b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubOutdatedAction.java index 0645928b82b..dcda4b92517 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubOutdatedAction.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/actions/DartPubOutdatedAction.java @@ -4,7 +4,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NlsContexts; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.jetbrains.lang.dart.DartBundle; import com.jetbrains.lang.dart.sdk.DartSdk; @@ -13,15 +12,13 @@ import org.jetbrains.annotations.Nullable; public class DartPubOutdatedAction extends DartPubActionBase { - public static final String MIN_SDK_VERSION = "2.8"; - @Override public void update(@NotNull AnActionEvent e) { super.update(e); final Project project = e.getProject(); DartSdk sdk = project != null ? DartSdk.getDartSdk(project) : null; - if (sdk == null || StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_SDK_VERSION) < 0) { + if (sdk == null) { e.getPresentation().setEnabledAndVisible(false); } } diff --git a/Dart/src/com/jetbrains/lang/dart/ide/inspections/DartOutdatedDependenciesInspection.java b/Dart/src/com/jetbrains/lang/dart/ide/inspections/DartOutdatedDependenciesInspection.java index 34d57018b50..7d92e328161 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/inspections/DartOutdatedDependenciesInspection.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/inspections/DartOutdatedDependenciesInspection.java @@ -19,14 +19,13 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.jetbrains.lang.dart.DartBundle; -import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService; import com.jetbrains.lang.dart.flutter.FlutterUtil; import com.jetbrains.lang.dart.ide.actions.DartPubActionBase; import com.jetbrains.lang.dart.psi.DartFile; import com.jetbrains.lang.dart.sdk.DartSdk; import com.jetbrains.lang.dart.sdk.DartSdkLibUtil; import com.jetbrains.lang.dart.util.DartResolveUtil; -import com.jetbrains.lang.dart.util.DotPackagesFileUtil; +import com.jetbrains.lang.dart.util.PackageConfigFileUtil; import com.jetbrains.lang.dart.util.PubspecYamlUtil; import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.NonNls; @@ -69,9 +68,7 @@ public final class DartOutdatedDependenciesInspection extends LocalInspectionToo if (FlutterUtil.isPubspecDeclaringFlutter(pubspecFile)) return null; // 'pub get' will fail anyway - VirtualFile packagesFile = DartAnalysisServerService.isDartSdkVersionSufficientForPackageConfigJson(sdk) - ? DotPackagesFileUtil.getPackageConfigJsonFile(project, pubspecFile) - : pubspecFile.getParent().findChild(DotPackagesFileUtil.DOT_PACKAGES); + VirtualFile packagesFile = PackageConfigFileUtil.getPackageConfigJsonFile(project, pubspecFile); if (packagesFile == null) { return createProblemDescriptors(manager, psiFile, pubspecFile, DartBundle.message("pub.get.never.done")); diff --git a/Dart/src/com/jetbrains/lang/dart/ide/refactoring/introduce/DartServerExtractLocalVariableHandler.java b/Dart/src/com/jetbrains/lang/dart/ide/refactoring/introduce/DartServerExtractLocalVariableHandler.java index fd634a49eef..2c1bf692604 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/refactoring/introduce/DartServerExtractLocalVariableHandler.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/refactoring/introduce/DartServerExtractLocalVariableHandler.java @@ -46,7 +46,7 @@ public void invoke(@NotNull Project project, PsiElement @NotNull [] elements, Da @Override public void invoke(final @NotNull Project project, final Editor editor, PsiFile file, DataContext dataContext) { final DartSdk sdk = DartSdk.getDartSdk(project); - if (sdk == null || StringUtil.compareVersionNumbers(sdk.getVersion(), "1.14") < 0) { + if (sdk == null) { return; } diff --git a/Dart/src/com/jetbrains/lang/dart/ide/refactoring/moveFile/DartServerMoveDartFileHandler.java b/Dart/src/com/jetbrains/lang/dart/ide/refactoring/moveFile/DartServerMoveDartFileHandler.java index a0ee7550064..53db74221e9 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/refactoring/moveFile/DartServerMoveDartFileHandler.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/refactoring/moveFile/DartServerMoveDartFileHandler.java @@ -36,8 +36,7 @@ public boolean canProcessElement(PsiFile psiFile) { return false; } final Project project = psiFile.getProject(); - final DartSdk dartSdk = DartSdk.getDartSdk(project); - if (dartSdk == null || !DartAnalysisServerService.isDartSdkVersionSufficientForMoveFileRefactoring(dartSdk)) { + if (DartSdk.getDartSdk(project) == null) { return false; } return DartAnalysisServerService.getInstance(project).isInIncludedRoots(psiFile.getVirtualFile()); @@ -88,12 +87,16 @@ public void prepareMovedFile(PsiFile psiFile, PsiDirectory moveDestination, Map< } @Override - public @Nullable @Unmodifiable List findUsages(@NotNull PsiFile psiFile, @NotNull PsiDirectory newParent, boolean searchInComments, boolean searchInNonJavaFiles) { + public @Nullable @Unmodifiable List findUsages(@NotNull PsiFile psiFile, + @NotNull PsiDirectory newParent, + boolean searchInComments, + boolean searchInNonJavaFiles) { return null; } @Override - public void retargetUsages(@Unmodifiable @NotNull List usageInfos, @NotNull Map oldToNewMap) { + public void retargetUsages(@Unmodifiable @NotNull List usageInfos, + @NotNull Map oldToNewMap) { } @Override diff --git a/Dart/src/com/jetbrains/lang/dart/ide/runner/server/DartCommandLineRunnerParameters.java b/Dart/src/com/jetbrains/lang/dart/ide/runner/server/DartCommandLineRunnerParameters.java index 4dea720bd79..163c7fea57f 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/runner/server/DartCommandLineRunnerParameters.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/runner/server/DartCommandLineRunnerParameters.java @@ -25,7 +25,7 @@ public class DartCommandLineRunnerParameters implements Cloneable { private @Nullable @NlsSafe String myFilePath = null; private @Nullable @NlsSafe String myVMOptions = null; - private boolean myCheckedModeOrEnableAsserts = true; + private boolean myAssertsEnabled = true; private @Nullable @NlsSafe String myArguments = null; private @Nullable @NlsSafe String myWorkingDirectory = null; private @NotNull Map myEnvs = new LinkedHashMap<>(); @@ -67,19 +67,13 @@ public void setVMOptions(final @Nullable @NlsSafe String vmOptions) { myVMOptions = vmOptions; } - /** - * For Dart 2 it means 'enable asserts' flag; for Dart 1 - 'checked mode' flag - */ @OptionTag("checkedMode") // compatibility - public boolean isCheckedModeOrEnableAsserts() { - return myCheckedModeOrEnableAsserts; + public boolean areAssertsEnabled() { + return myAssertsEnabled; } - /** - * For Dart 2 it means 'enable asserts' flag; for Dart 1 - 'checked mode' flag - */ - public void setCheckedModeOrEnableAsserts(final boolean checkedModeOrEnableAsserts) { - myCheckedModeOrEnableAsserts = checkedModeOrEnableAsserts; + public void setAssertsEnabled(final boolean assertsEnabled) { + myAssertsEnabled = assertsEnabled; } public @Nullable @NlsSafe String getArguments() { diff --git a/Dart/src/com/jetbrains/lang/dart/ide/runner/server/DartCommandLineRunningState.java b/Dart/src/com/jetbrains/lang/dart/ide/runner/server/DartCommandLineRunningState.java index a85c101d8ab..86db2e47cb4 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/runner/server/DartCommandLineRunningState.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/runner/server/DartCommandLineRunningState.java @@ -20,7 +20,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; import com.intellij.util.net.NetUtils; @@ -194,13 +193,8 @@ else if (vmOption.startsWith("--observe:")) { } } - if (myRunnerParameters.isCheckedModeOrEnableAsserts()) { - if (StringUtil.compareVersionNumbers(sdk.getVersion(), "2") < 0) { - addVmOption(sdk, commandLine, "--checked"); - } - else { - addVmOption(sdk, commandLine, "--enable-asserts"); - } + if (myRunnerParameters.areAssertsEnabled()) { + addVmOption(sdk, commandLine, "--enable-asserts"); } if (DefaultDebugExecutor.EXECUTOR_ID.equals(getEnvironment().getExecutor().getId())) { diff --git a/Dart/src/com/jetbrains/lang/dart/ide/runner/server/ui/DartCommandLineConfigurationEditorForm.form b/Dart/src/com/jetbrains/lang/dart/ide/runner/server/ui/DartCommandLineConfigurationEditorForm.form index 30e134f3dc9..838ffd06206 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/runner/server/ui/DartCommandLineConfigurationEditorForm.form +++ b/Dart/src/com/jetbrains/lang/dart/ide/runner/server/ui/DartCommandLineConfigurationEditorForm.form @@ -85,7 +85,7 @@ - + diff --git a/Dart/src/com/jetbrains/lang/dart/ide/runner/server/ui/DartCommandLineConfigurationEditorForm.java b/Dart/src/com/jetbrains/lang/dart/ide/runner/server/ui/DartCommandLineConfigurationEditorForm.java index dec3b948966..7ba3a8607e7 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/runner/server/ui/DartCommandLineConfigurationEditorForm.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/runner/server/ui/DartCommandLineConfigurationEditorForm.java @@ -20,7 +20,6 @@ import com.jetbrains.lang.dart.DartFileType; import com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunConfiguration; import com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunnerParameters; -import com.jetbrains.lang.dart.sdk.DartSdk; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -30,7 +29,7 @@ public class DartCommandLineConfigurationEditorForm extends SettingsEditor DartConfigurable.openDartSettings(project)); } - final String dartSdkVersion = dartSdk.getVersion(); - if (!dartSdkVersion.isEmpty() && - !DartAnalysisServerService.isDartSdkVersionSufficientForWebdev(dartSdk)) { - throw new RuntimeConfigurationError( - DartBundle.message("old.dart.sdk.for.webdev", DartAnalysisServerService.MIN_WEBDEV_SDK_VERSION, dartSdkVersion)); - } // check html file getHtmlFile(); diff --git a/Dart/src/com/jetbrains/lang/dart/ide/runner/test/DartTestRunningState.java b/Dart/src/com/jetbrains/lang/dart/ide/runner/test/DartTestRunningState.java index edc241f29a4..6e12ced368e 100644 --- a/Dart/src/com/jetbrains/lang/dart/ide/runner/test/DartTestRunningState.java +++ b/Dart/src/com/jetbrains/lang/dart/ide/runner/test/DartTestRunningState.java @@ -7,7 +7,6 @@ import com.intellij.execution.Executor; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.configurations.RuntimeConfigurationError; -import com.intellij.execution.executors.DefaultRunExecutor; import com.intellij.execution.filters.UrlFilter; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.runners.ExecutionEnvironment; @@ -29,7 +28,6 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.jetbrains.lang.dart.DartBundle; -import com.jetbrains.lang.dart.ide.actions.DartPubActionBase; import com.jetbrains.lang.dart.ide.runner.DartConsoleFilter; import com.jetbrains.lang.dart.ide.runner.DartRelativePathsConsoleFilter; import com.jetbrains.lang.dart.ide.runner.base.DartRunConfiguration; @@ -46,14 +44,14 @@ public class DartTestRunningState extends DartCommandLineRunningState { private static final String RUN_COMMAND = "run"; private static final String TEST_PACKAGE_SPEC = "test"; private static final String EXPANDED_REPORTER_OPTION = "-r json"; - public static final String DART_VM_OPTIONS_ENV_VAR = "DART_VM_OPTIONS"; public DartTestRunningState(final @NotNull ExecutionEnvironment environment) throws ExecutionException { super(environment); } @Override - public @NotNull ExecutionResult execute(final @NotNull Executor executor, final @NotNull ProgramRunner runner) throws ExecutionException { + public @NotNull ExecutionResult execute(final @NotNull Executor executor, final @NotNull ProgramRunner runner) + throws ExecutionException { final ProcessHandler processHandler = startProcess(); final ConsoleView consoleView = createConsole(getEnvironment()); consoleView.attachToProcess(processHandler); @@ -149,7 +147,7 @@ private static ConsoleView createConsole(@NotNull ExecutionEnvironment env) { } params.setArguments(builder.toString()); - params.setCheckedModeOrEnableAsserts(false); + params.setAssertsEnabled(false); // working directory is not configurable in UI because there's only one valid value that we calculate ourselves params.setWorkingDirectory(params.computeProcessWorkingDirectory(project)); @@ -158,13 +156,7 @@ private static ConsoleView createConsole(@NotNull ExecutionEnvironment env) { @Override protected void setupExePath(@NotNull GeneralCommandLine commandLine, @NotNull DartSdk sdk) { - boolean useDartTest = DartPubActionBase.isUseDartRunTestInsteadOfPubRunTest(sdk); - if (useDartTest) { - commandLine.setExePath(FileUtil.toSystemDependentName(DartSdkUtil.getDartExePath(sdk))); - } - else { - commandLine.setExePath(FileUtil.toSystemDependentName(DartSdkUtil.getPubPath(sdk))); - } + commandLine.setExePath(FileUtil.toSystemDependentName(DartSdkUtil.getDartExePath(sdk))); } @Override @@ -174,31 +166,7 @@ protected void appendParamsAfterVmOptionsBeforeArgs(@NotNull GeneralCommandLine @Override protected void addVmOption(@NotNull DartSdk sdk, @NotNull GeneralCommandLine commandLine, @NotNull String option) { - boolean useDartTest = DartPubActionBase.isUseDartRunTestInsteadOfPubRunTest(sdk); - if (useDartTest) { - super.addVmOption(sdk, commandLine, option); - return; - } - - // SDK 2.9 and older - final String arguments = StringUtil.notNullize(myRunnerParameters.getArguments()); - if (DefaultRunExecutor.EXECUTOR_ID.equals(getEnvironment().getExecutor().getId()) && - option.startsWith("--enable-vm-service:") && - (arguments.startsWith("-p ") || arguments.contains(" -p "))) { - // When we start browser-targeted tests then there are 2 dart processes spawned: parent (pub) and child (tests). - // If we add --enable-vm-service option to the DART_VM_OPTIONS env var then it will apply for both processes and will obviously - // fail for the child process (because the port will be already occupied by the parent one). - // Setting --enable-vm-service option for the parent process doesn't make much sense, so we skip it. - return; - } - - String options = commandLine.getEnvironment().get(DART_VM_OPTIONS_ENV_VAR); - if (StringUtil.isEmpty(options)) { - commandLine.getEnvironment().put(DART_VM_OPTIONS_ENV_VAR, option); - } - else { - commandLine.getEnvironment().put(DART_VM_OPTIONS_ENV_VAR, options + " " + option); - } + super.addVmOption(sdk, commandLine, option); } DartTestRunnerParameters getParameters() { diff --git a/Dart/src/com/jetbrains/lang/dart/projectWizard/DartGeneratorPeer.java b/Dart/src/com/jetbrains/lang/dart/projectWizard/DartGeneratorPeer.java index 89b96fb5be2..52c420f4ed9 100644 --- a/Dart/src/com/jetbrains/lang/dart/projectWizard/DartGeneratorPeer.java +++ b/Dart/src/com/jetbrains/lang/dart/projectWizard/DartGeneratorPeer.java @@ -55,9 +55,7 @@ public class DartGeneratorPeer implements ProjectGeneratorPeer myDartCreateTemplates;// not-null means that it's been already calculated - private List myStagehandTemplates;// not-null means that it's been already calculated public DartGeneratorPeer() { // set initial values before initDartSdkControls() because listeners should not be triggered on initialization @@ -117,42 +115,23 @@ private void onSdkPathChanged() { return; } - boolean useDartCreate = Stagehand.isUseDartCreate(sdkPath); - if (useDartCreate) { - if (myDartCreateCalcStarted) { - if (myDartCreateTemplates != null) { - showTemplates(myDartCreateTemplates); - } - else { - // Calculation in progress, just wait. - myLoadingTemplatesPanel.setVisible(true); - myLoadedTemplatesPanel.setVisible(false); - } + if (myDartCreateCalcStarted) { + if (myDartCreateTemplates != null) { + showTemplates(myDartCreateTemplates); } else { - myDartCreateCalcStarted = true; - startLoadingTemplates(useDartCreate); + // Calculation in progress, just wait. + myLoadingTemplatesPanel.setVisible(true); + myLoadedTemplatesPanel.setVisible(false); } } else { - if (myStagehandCalcStarted) { - if (myStagehandTemplates != null) { - showTemplates(myStagehandTemplates); - } - else { - // Calculation in progress, just wait. - myLoadingTemplatesPanel.setVisible(true); - myLoadedTemplatesPanel.setVisible(false); - } - } - else { - myStagehandCalcStarted = true; - startLoadingTemplates(useDartCreate); - } + myDartCreateCalcStarted = true; + startLoadingTemplates(); } } - private void startLoadingTemplates(boolean useDartCreate) { + private void startLoadingTemplates() { myLoadingTemplatesPanel.setVisible(true); myLoadingTemplatesPanel.setPreferredSize(myLoadedTemplatesPanel.getPreferredSize()); @@ -170,12 +149,7 @@ private void startLoadingTemplates(boolean useDartCreate) { myLoadingTemplatesPanel.remove(asyncProcessIcon); Disposer.dispose(asyncProcessIcon); - if (useDartCreate) { - myDartCreateTemplates = templates; - } - else { - myStagehandTemplates = templates; - } + myDartCreateTemplates = templates; // it's better to call onSdkPathChanged() but not showTemplates() directly as sdk path could have been changed during this long calculation onSdkPathChanged(); diff --git a/Dart/src/com/jetbrains/lang/dart/projectWizard/DartProjectTemplate.java b/Dart/src/com/jetbrains/lang/dart/projectWizard/DartProjectTemplate.java index 260eb881853..e8be4be29e7 100644 --- a/Dart/src/com/jetbrains/lang/dart/projectWizard/DartProjectTemplate.java +++ b/Dart/src/com/jetbrains/lang/dart/projectWizard/DartProjectTemplate.java @@ -30,7 +30,6 @@ public abstract class DartProjectTemplate { private static final Stagehand STAGEHAND = new Stagehand(); - private static List ourStagehandTemplateCache; private static List ourDartCreateTemplateCache; private static final Logger LOG = Logger.getInstance(DartProjectTemplate.class.getName()); @@ -80,36 +79,17 @@ public static void loadTemplatesAsync(@NotNull String sdkRoot, @NotNull Consumer } private static @NotNull List getStagehandTemplates(@NotNull String sdkRoot) { - boolean useDartCreate = Stagehand.isUseDartCreate(sdkRoot); - - if (useDartCreate) { - if (ourDartCreateTemplateCache != null) { - return ourDartCreateTemplateCache; - } - } - else { - if (ourStagehandTemplateCache != null) { - return ourStagehandTemplateCache; - } + if (ourDartCreateTemplateCache != null) { + return ourDartCreateTemplateCache; } - STAGEHAND.install(sdkRoot); final List templates = STAGEHAND.getAvailableTemplates(sdkRoot); - if (useDartCreate) { - ourDartCreateTemplateCache = new ArrayList<>(); - for (StagehandDescriptor template : templates) { - ourDartCreateTemplateCache.add(new StagehandTemplate(STAGEHAND, template)); - } - return ourDartCreateTemplateCache; - } - else { - ourStagehandTemplateCache = new ArrayList<>(); - for (StagehandDescriptor template : templates) { - ourStagehandTemplateCache.add(new StagehandTemplate(STAGEHAND, template)); - } - return ourStagehandTemplateCache; + ourDartCreateTemplateCache = new ArrayList<>(); + for (StagehandDescriptor template : templates) { + ourDartCreateTemplateCache.add(new StagehandTemplate(STAGEHAND, template)); } + return ourDartCreateTemplateCache; } static void createWebRunConfiguration(final @NotNull Module module, final @NotNull VirtualFile htmlFile) { diff --git a/Dart/src/com/jetbrains/lang/dart/projectWizard/Stagehand.java b/Dart/src/com/jetbrains/lang/dart/projectWizard/Stagehand.java index dff3b207426..75fa07de58b 100644 --- a/Dart/src/com/jetbrains/lang/dart/projectWizard/Stagehand.java +++ b/Dart/src/com/jetbrains/lang/dart/projectWizard/Stagehand.java @@ -9,8 +9,6 @@ import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.SystemProperties; -import com.jetbrains.lang.dart.ide.actions.DartPubActionBase; import com.jetbrains.lang.dart.sdk.DartSdkUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -22,15 +20,9 @@ import java.util.ArrayList; import java.util.List; +// TODO: Rename this and related classes away from "stagehand", +// as templates are now retrieved and bootstrapped with `dart create`. public class Stagehand { - - private static final String DART_CREATE_MIN_SDK_VERSION = "2.10"; - - static boolean isUseDartCreate(@NotNull String sdkHomePath) { - String version = DartSdkUtil.getSdkVersion(sdkHomePath); - return version != null && StringUtil.compareVersionNumbers(version, DART_CREATE_MIN_SDK_VERSION) >= 0; - } - public static class StagehandDescriptor { public final @NotNull @NonNls String myId; public final @NotNull @NlsSafe String myLabel; @@ -70,30 +62,11 @@ private static ProcessOutput runDartCreate(@NotNull String sdkRoot, return new CapturingProcessHandler(command).runProcess(timeoutInSeconds * 1000, false); } - private static ProcessOutput runPubGlobal(@NotNull String sdkRoot, - @Nullable String workingDirectory, - int timeoutInSeconds, - @NotNull String pubEnvVarSuffix, - String... pubParameters) throws ExecutionException { - final GeneralCommandLine command = new GeneralCommandLine() - .withExePath(DartSdkUtil.getPubPath(sdkRoot)) - .withWorkDirectory(workingDirectory) - .withEnvironment(DartPubActionBase.PUB_ENV_VAR_NAME, DartPubActionBase.getPubEnvValue() + ".stagehand" + pubEnvVarSuffix); - - command.addParameter("global"); - command.addParameters(pubParameters); - - return new CapturingProcessHandler(command).runProcess(timeoutInSeconds * 1000, false); - } - public void generateInto(final @NotNull String sdkRoot, final @NotNull VirtualFile projectDirectory, final @NotNull String templateId) throws ExecutionException { - ProcessOutput output = isUseDartCreate(sdkRoot) - ? runDartCreate(sdkRoot, projectDirectory.getParent().getPath(), 30, "--force", "--no-pub", "--template", - templateId, projectDirectory.getName()) - : runPubGlobal(sdkRoot, projectDirectory.getPath(), 30, "", "run", "stagehand", "--author", - SystemProperties.getUserName(), templateId); + ProcessOutput output = runDartCreate(sdkRoot, projectDirectory.getParent().getPath(), 30, "--force", "--no-pub", "--template", + templateId, projectDirectory.getName()); if (output.getExitCode() != 0) { throw new ExecutionException(output.getStderr()); @@ -102,9 +75,7 @@ public void generateInto(final @NotNull String sdkRoot, public List getAvailableTemplates(final @NotNull String sdkRoot) { try { - ProcessOutput output = isUseDartCreate(sdkRoot) - ? runDartCreate(sdkRoot, null, 10, "--list-templates") - : runPubGlobal(sdkRoot, null, 10, "", "run", "stagehand", "--machine"); + ProcessOutput output = runDartCreate(sdkRoot, null, 10, "--list-templates"); int exitCode = output.getExitCode(); @@ -126,11 +97,6 @@ public List getAvailableTemplates(final @NotNull String sdk obj.optString("entrypoint"))); } - if (!isUseDartCreate(sdkRoot)) { - // Sort the stagehand templates lexically by name. - result.sort((one, two) -> one.myLabel.compareToIgnoreCase(two.myLabel)); - } - return result; } catch (ExecutionException | JSONException e) { @@ -139,15 +105,4 @@ public List getAvailableTemplates(final @NotNull String sdk return EMPTY; } - - public void install(final @NotNull String sdkRoot) { - if (isUseDartCreate(sdkRoot)) return; - - try { - runPubGlobal(sdkRoot, null, 60, ".activate", "activate", "stagehand"); - } - catch (ExecutionException e) { - LOG.info(e); - } - } } diff --git a/Dart/src/com/jetbrains/lang/dart/psi/DartPackageAwareFileReference.java b/Dart/src/com/jetbrains/lang/dart/psi/DartPackageAwareFileReference.java index 329443f1074..39d4905878e 100644 --- a/Dart/src/com/jetbrains/lang/dart/psi/DartPackageAwareFileReference.java +++ b/Dart/src/com/jetbrains/lang/dart/psi/DartPackageAwareFileReference.java @@ -9,11 +9,10 @@ import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; -import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService; import com.jetbrains.lang.dart.sdk.DartSdk; import com.jetbrains.lang.dart.util.DartResolveUtil; import com.jetbrains.lang.dart.util.DartUrlResolver; -import com.jetbrains.lang.dart.util.DotPackagesFileUtil; +import com.jetbrains.lang.dart.util.PackageConfigFileUtil; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -49,12 +48,7 @@ class DartPackageAwareFileReference extends FileReference { DartSdk sdk = DartSdk.getDartSdk(project); VirtualFile packagesFile; if (sdk != null && pubspecYamlFile != null) { - if (DartAnalysisServerService.isDartSdkVersionSufficientForPackageConfigJson(sdk)) { - packagesFile = DotPackagesFileUtil.getPackageConfigJsonFile(project, pubspecYamlFile); - } - else { - packagesFile = pubspecYamlFile.getParent().findChild(DotPackagesFileUtil.DOT_PACKAGES); - } + packagesFile = PackageConfigFileUtil.getPackageConfigJsonFile(project, pubspecYamlFile); } else { packagesFile = null; diff --git a/Dart/src/com/jetbrains/lang/dart/psi/impl/DartFileReference.java b/Dart/src/com/jetbrains/lang/dart/psi/impl/DartFileReference.java index acba6efad6f..f61e4aafaa6 100644 --- a/Dart/src/com/jetbrains/lang/dart/psi/impl/DartFileReference.java +++ b/Dart/src/com/jetbrains/lang/dart/psi/impl/DartFileReference.java @@ -1,9 +1,7 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.jetbrains.lang.dart.psi.impl; -import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.ResolveCache; @@ -17,9 +15,7 @@ import com.jetbrains.lang.dart.psi.DartImportStatement; import com.jetbrains.lang.dart.psi.DartUriElement; import com.jetbrains.lang.dart.resolve.DartResolver; -import com.jetbrains.lang.dart.sdk.DartSdk; import com.jetbrains.lang.dart.util.DartResolveUtil; -import com.jetbrains.lang.dart.util.DartUrlResolver; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -80,26 +76,6 @@ public PsiElement handleElementRename(final @NotNull String newFileName) throws @Override public PsiElement bindToElement(final @NotNull PsiElement element) throws IncorrectOperationException { - if (element instanceof PsiFile) { - final VirtualFile contextFile = DartResolveUtil.getRealVirtualFile(myUriElement.getContainingFile()); - final VirtualFile targetFile = DartResolveUtil.getRealVirtualFile(((PsiFile)element)); - final Project project = myUriElement.getProject(); - final DartSdk dartSdk = DartSdk.getDartSdk(project); - if (dartSdk != null && !DartAnalysisServerService.isDartSdkVersionSufficientForMoveFileRefactoring(dartSdk)) { - if (contextFile != null && targetFile != null) { - final String newUri = DartUrlResolver.getInstance(myUriElement.getProject(), contextFile).getDartUrlForFile(targetFile); - if (newUri.startsWith(DartUrlResolver.PACKAGE_PREFIX)) { - return updateUri(newUri); - } - else if (newUri.startsWith(DartUrlResolver.FILE_PREFIX)) { - final String relativePath = FileUtil.getRelativePath(contextFile.getParent().getPath(), targetFile.getPath(), '/'); - if (relativePath != null) { - return updateUri(relativePath); - } - } - } - } - } return myUriElement; } diff --git a/Dart/src/com/jetbrains/lang/dart/psi/impl/DartUriElementBase.java b/Dart/src/com/jetbrains/lang/dart/psi/impl/DartUriElementBase.java index 13e50de314d..87a861eb233 100644 --- a/Dart/src/com/jetbrains/lang/dart/psi/impl/DartUriElementBase.java +++ b/Dart/src/com/jetbrains/lang/dart/psi/impl/DartUriElementBase.java @@ -2,13 +2,11 @@ package com.jetbrains.lang.dart.psi.impl; import com.intellij.lang.ASTNode; -import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.jetbrains.lang.dart.DartLanguage; -import com.jetbrains.lang.dart.psi.DartFile; import com.jetbrains.lang.dart.psi.DartImportStatement; import com.jetbrains.lang.dart.psi.DartUriElement; import org.jetbrains.annotations.NotNull; @@ -16,8 +14,6 @@ public abstract class DartUriElementBase extends DartPsiCompositeElementImpl implements DartUriElement { - private static final Condition DART_FILE_OR_DIR_FILTER = item -> item.isDirectory() || item instanceof DartFile; - public DartUriElementBase(final @NotNull ASTNode node) { super(node); } diff --git a/Dart/src/com/jetbrains/lang/dart/pubServer/DartWebdev.kt b/Dart/src/com/jetbrains/lang/dart/pubServer/DartWebdev.kt index 8af583d5bdf..ce549cea265 100644 --- a/Dart/src/com/jetbrains/lang/dart/pubServer/DartWebdev.kt +++ b/Dart/src/com/jetbrains/lang/dart/pubServer/DartWebdev.kt @@ -8,7 +8,6 @@ import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.project.Project import com.intellij.openapi.util.NlsSafe -import com.intellij.openapi.util.text.StringUtil import com.intellij.util.concurrency.ThreadingAssertions import com.jetbrains.lang.dart.DartBundle import com.jetbrains.lang.dart.ide.actions.DartPubActionBase @@ -20,12 +19,6 @@ private val LOG = logger() object DartWebdev { var activated: Boolean = false - fun useWebdev(sdk: DartSdk?): Boolean { - if (sdk == null) return false - val sdkVersion = sdk.version - return StringUtil.compareVersionNumbers(sdkVersion, "2") >= 0 - } - /** * @return `false` only if explicitly cancelled by user */ diff --git a/Dart/src/com/jetbrains/lang/dart/pubServer/PubServerPathHandler.kt b/Dart/src/com/jetbrains/lang/dart/pubServer/PubServerPathHandler.kt index f377d893292..9cc6f8e5d46 100644 --- a/Dart/src/com/jetbrains/lang/dart/pubServer/PubServerPathHandler.kt +++ b/Dart/src/com/jetbrains/lang/dart/pubServer/PubServerPathHandler.kt @@ -32,7 +32,7 @@ private class PubServerPathHandler : WebServerPathHandler { isCustomHost: Boolean, ): Boolean { val sdk = DartSdk.getDartSdk(project) - if (sdk == null || StringUtil.compareVersionNumbers(sdk.version, "1.6") < 0) { + if (sdk == null) { return false } @@ -77,7 +77,9 @@ private fun getServedDirAndPathForPubServer(project: Project, path: String): Pai val parentDir = dir.parent if (parentDir?.findChild(PubspecYamlUtil.PUBSPEC_YAML) != null) { val name = dir.nameSequence - if (StringUtil.equals(name, "build") || StringUtil.equals(name, "lib") || StringUtil.equals(name, DartUrlResolver.PACKAGES_FOLDER_NAME)) { + if (StringUtil.equals(name, "build") || StringUtil.equals(name, "lib") || StringUtil.equals(name, + DartUrlResolver.PACKAGES_FOLDER_NAME) + ) { // contents of "build" folder should be served by the IDE internal web server directly, i.e. without pub serve return null } diff --git a/Dart/src/com/jetbrains/lang/dart/pubServer/PubServerService.java b/Dart/src/com/jetbrains/lang/dart/pubServer/PubServerService.java index 6b9b4886abb..76c03b9f85a 100644 --- a/Dart/src/com/jetbrains/lang/dart/pubServer/PubServerService.java +++ b/Dart/src/com/jetbrains/lang/dart/pubServer/PubServerService.java @@ -185,27 +185,16 @@ public void sendToPubServer(final @NotNull Channel clientChannel, final DartSdk dartSdk = DartSdk.getDartSdk(project); if (dartSdk == null) return null; - if (DartWebdev.INSTANCE.useWebdev(DartSdk.getDartSdk(getProject()))) { - if (!DartWebdev.INSTANCE.getActivated()) { - ApplicationManager.getApplication() - .invokeAndWait(() -> DartWebdev.INSTANCE.ensureWebdevActivated(getProject()), ModalityState.any()); - } + if (!DartWebdev.INSTANCE.getActivated()) { + ApplicationManager.getApplication() + .invokeAndWait(() -> DartWebdev.INSTANCE.ensureWebdevActivated(getProject()), ModalityState.any()); } final GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(firstServedDir.getParent().getPath()); DartPubActionBase.setupPubExePath(commandLine, dartSdk); - commandLine.withEnvironment(DartPubActionBase.PUB_ENV_VAR_NAME, DartPubActionBase.getPubEnvValue()); - - if (DartWebdev.INSTANCE.useWebdev(dartSdk)) { - commandLine.addParameters("global", "run", "webdev", "serve"); - commandLine.addParameter(firstServedDir.getName() + ":" + port); - commandLine.withEnvironment(DartPubActionBase.PUB_ENV_VAR_NAME, DartPubActionBase.getPubEnvValue() + ".webdev"); - } - else { - commandLine.addParameter("serve"); - commandLine.addParameter(firstServedDir.getName()); - commandLine.addParameter("--port=" + port); - } + commandLine.withEnvironment(DartPubActionBase.PUB_ENV_VAR_NAME, DartPubActionBase.getPubEnvValue() + ".webdev"); + commandLine.addParameters("global", "run", "webdev", "serve"); + commandLine.addParameter(firstServedDir.getName() + ":" + port); final OSProcessHandler processHandler = new OSProcessHandler(commandLine); processHandler.addProcessListener(new PubServeOutputListener(project, myServerReadyLock)); @@ -218,15 +207,13 @@ protected void connectToProcess(final @NotNull AsyncPromise pr final int port, final @NotNull OSProcessHandler processHandler, final @NotNull Consumer errorOutputConsumer) { - if (DartWebdev.INSTANCE.useWebdev(DartSdk.getDartSdk(getProject()))) { - synchronized (myServerReadyLock) { - try { - // wait for the Webdev server to start before redirecting, so that Chrome doesn't show error. - //noinspection WaitNotInLoop - myServerReadyLock.wait(15000); - } - catch (InterruptedException e) {/**/} + synchronized (myServerReadyLock) { + try { + // wait for the Webdev server to start before redirecting, so that Chrome doesn't show error. + //noinspection WaitNotInLoop + myServerReadyLock.wait(15000); } + catch (InterruptedException e) {/**/} } if (processHandler.isProcessTerminated()) { @@ -416,13 +403,14 @@ private void showNotificationIfNeeded(final boolean isError) { final String message = DartBundle.message(myNotificationAboutErrors ? "dart.webdev.server.output.contains.errors" : "dart.webdev.server.output.contains.warnings"); - myNotification = NOTIFICATION_GROUP.createNotification(message, NotificationType.WARNING).setListener(new NotificationListener.Adapter() { - @Override - protected void hyperlinkActivated(final @NotNull Notification notification, final @NotNull HyperlinkEvent e) { - notification.expire(); - ToolWindowManager.getInstance(myProject).getToolWindow(DART_WEBDEV).activate(null); - } - }); + myNotification = + NOTIFICATION_GROUP.createNotification(message, NotificationType.WARNING).setListener(new NotificationListener.Adapter() { + @Override + protected void hyperlinkActivated(final @NotNull Notification notification, final @NotNull HyperlinkEvent e) { + notification.expire(); + ToolWindowManager.getInstance(myProject).getToolWindow(DART_WEBDEV).activate(null); + } + }); myNotification.notify(myProject); } diff --git a/Dart/src/com/jetbrains/lang/dart/util/DartUrlResolverImpl.java b/Dart/src/com/jetbrains/lang/dart/util/DartUrlResolverImpl.java index 08a8bcf6317..c36cf14904e 100644 --- a/Dart/src/com/jetbrains/lang/dart/util/DartUrlResolverImpl.java +++ b/Dart/src/com/jetbrains/lang/dart/util/DartUrlResolverImpl.java @@ -19,7 +19,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.ex.temp.TempFileSystem; import com.intellij.util.PairConsumer; -import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService; import com.jetbrains.lang.dart.ide.index.DartLibraryIndex; import com.jetbrains.lang.dart.sdk.DartPackagesLibraryProperties; import com.jetbrains.lang.dart.sdk.DartPackagesLibraryType; @@ -203,15 +202,9 @@ private void initLivePackageNameToDirMap() { final VirtualFile baseDir = myPubspecYamlFile == null ? null : myPubspecYamlFile.getParent(); if (myPubspecYamlFile == null || baseDir == null) return; - Map packagesMap; - if (myDartSdk == null || DartAnalysisServerService.isDartSdkVersionSufficientForPackageConfigJson(myDartSdk)) { - VirtualFile packagesFile = DotPackagesFileUtil.getPackageConfigJsonFile(myProject, myPubspecYamlFile); - packagesMap = packagesFile != null ? DotPackagesFileUtil.getPackagesMapFromPackageConfigJsonFile(packagesFile) : null; - } - else { - VirtualFile packagesFile = baseDir.findChild(DotPackagesFileUtil.DOT_PACKAGES); - packagesMap = packagesFile != null ? DotPackagesFileUtil.getPackagesMap(packagesFile) : null; - } + VirtualFile packagesFile = PackageConfigFileUtil.getPackageConfigJsonFile(myProject, myPubspecYamlFile); + Map packagesMap = + packagesFile != null ? PackageConfigFileUtil.getPackagesMapFromPackageConfigJsonFile(packagesFile) : null; if (packagesMap != null) { for (Map.Entry entry : packagesMap.entrySet()) { diff --git a/Dart/src/com/jetbrains/lang/dart/util/DotPackagesFileUtil.java b/Dart/src/com/jetbrains/lang/dart/util/PackageConfigFileUtil.java similarity index 95% rename from Dart/src/com/jetbrains/lang/dart/util/DotPackagesFileUtil.java rename to Dart/src/com/jetbrains/lang/dart/util/PackageConfigFileUtil.java index da3a9060d8b..c89369ca883 100644 --- a/Dart/src/com/jetbrains/lang/dart/util/DotPackagesFileUtil.java +++ b/Dart/src/com/jetbrains/lang/dart/util/PackageConfigFileUtil.java @@ -26,9 +26,7 @@ import java.util.List; import java.util.Map; -public final class DotPackagesFileUtil { - - public static final String DOT_PACKAGES = ".packages"; +public final class PackageConfigFileUtil { public static final String DART_TOOL_DIR = ".dart_tool"; public static final String PACKAGE_CONFIG_JSON = "package_config.json"; @@ -85,17 +83,6 @@ public final class DotPackagesFileUtil { return null; } - public static @Nullable VirtualFile findDotPackagesFile(@Nullable VirtualFile dir) { - while (dir != null) { - final VirtualFile file = dir.findChild(DOT_PACKAGES); - if (file != null && !file.isDirectory()) { - return file; - } - dir = dir.getParent(); - } - return null; - } - public static @Nullable Map getPackagesMapFromPackageConfigJsonFile(final @NotNull VirtualFile packageConfigJsonFile) { Pair> data = packageConfigJsonFile.getUserData(MOD_STAMP_TO_PACKAGES_MAP); @@ -152,7 +139,7 @@ public final class DotPackagesFileUtil { jsonElement = JsonParser.parseString(fileContentsStr); } catch (Exception e) { - Logger.getInstance(DotPackagesFileUtil.class).info(e); + Logger.getInstance(PackageConfigFileUtil.class).info(e); return null; }