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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions third_party/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 501.0.0

### Removed

- Dropped support for Dart SDK versions older than 2.12.

## 500.0.0

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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;

Expand Down Expand Up @@ -69,10 +69,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);
}

Expand All @@ -83,8 +81,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);
}

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

Map<String, String> 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) {
Expand Down Expand Up @@ -359,7 +350,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,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";
Expand Down Expand Up @@ -488,18 +478,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;
}
Expand Down Expand Up @@ -1239,10 +1217,6 @@ public boolean edit_isPostfixCompletionApplicable(VirtualFile file, int _offset,
return null;
}

if (StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) {
return PostfixTemplateDescriptor.EMPTY_ARRAY;
}

final Ref<PostfixTemplateDescriptor[]> resultRef = Ref.create();
final CountDownLatch latch = new CountDownLatch(1);
server.edit_listPostfixCompletionTemplates(new ListPostfixCompletionTemplatesConsumer() {
Expand Down Expand Up @@ -1730,7 +1704,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;
}

Expand Down Expand Up @@ -1769,7 +1743,7 @@ public void onError(final RequestError error) {
final @NotNull List<ImportedElements> importedElements,
final int _offset) {
final AnalysisServer server = myServer;
if (server == null || StringUtil.compareVersionNumbers(mySdkVersion, "1.25") < 0) {
if (server == null) {
return null;
}

Expand Down Expand Up @@ -1934,12 +1908,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);
Expand Down Expand Up @@ -2187,15 +2157,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";
}
String serverArgsRaw = useDartLangServerCall ? "--protocol=analyzer" : "";

try {
serverArgsRaw += " " + Registry.stringValue("dart.server.additional.arguments");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -77,7 +76,7 @@ abstract class DartPubActionBase : AnAction(), DumbAware {
e.presentation.isEnabled = visible && !isInProgress
}

protected abstract fun getTitle(project: Project, pubspecYamlFile: VirtualFile): String
protected abstract fun getTitle(pubspecYamlFile: VirtualFile): String

protected abstract fun calculatePubParameters(project: Project, pubspecYamlFile: VirtualFile): Array<String>?

Expand All @@ -92,7 +91,7 @@ abstract class DartPubActionBase : AnAction(), DumbAware {
if (sdk == null && allowModalDialogs) {
val answer = Messages.showDialog(module.project,
DartBundle.message("dart.sdk.is.not.configured"),
getTitle(module.project, pubspecYamlFile),
getTitle(pubspecYamlFile),
arrayOf(DartBundle.message("setup.dart.sdk"), CommonBundle.getCancelButtonText()),
Messages.OK,
Messages.getErrorIcon())
Expand All @@ -104,14 +103,13 @@ 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) {
val answer = Messages.showDialog(module.project,
DartBundle.message("dart.sdk.bad.dartpub.path", exeFile.path),
getTitle(module.project, pubspecYamlFile),
getTitle(pubspecYamlFile),
arrayOf(DartBundle.message("setup.dart.sdk"), CommonBundle.getCancelButtonText()),
Messages.OK,
Messages.getErrorIcon())
Expand All @@ -135,7 +133,7 @@ abstract class DartPubActionBase : AnAction(), DumbAware {
setupPubExePath(command, sdk)
command.addParameters(*pubParameters)

doPerformPubAction(module, pubspecYamlFile, command, getTitle(module.project, pubspecYamlFile))
doPerformPubAction(module, pubspecYamlFile, command, getTitle(pubspecYamlFile))
}
}

Expand Down Expand Up @@ -185,25 +183,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<PubToolWindowContentInfo>("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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,16 @@ 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) {
protected @NotNull @NlsContexts.DialogTitle String getTitle(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
Expand All @@ -47,12 +40,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()};
}
}
Loading
Loading