<commit_before>import * as fs from "fs";
import * as path from "path";
import { commands, ExtensionContext, window } from "vscode";
import { Analytics } from "../analytics";
import { config } from "../config";
import { PackageMap } from "../debug/package_map";
import { dartPlatformName, flatMap, isWin } from "../debug/utils";
import { FLUTTER_CREATE_PROJECT_TRIGGER_FILE, FLUTTER_STAGEHAND_PROJECT_TRIGGER_FILE, fsPath, getDartWorkspaceFolders, getSdkVersion, openExtensionLogFile, openInBrowser, reloadExtension, resolvePaths, showLogAction, WorkspaceContext } from "../utils";
import { getChildFolders, hasPubspec } from "../utils/fs";
import { log } from "../utils/log";

const dartExecutableName = isWin ? "dart.exe" : "dart";
const pubExecutableName = isWin ? "pub.bat" : "pub";
const flutterExecutableName = isWin ? "flutter.bat" : "flutter";
const androidStudioExecutableName = isWin ? "studio64.exe" : "studio.sh";
export const dartVMPath = "bin/" + dartExecutableName;
export const pubPath = "bin/" + pubExecutableName;
export const pubSnapshotPath = "bin/snapshots/pub.dart.snapshot";
export const analyzerSnapshotPath = "bin/snapshots/analysis_server.dart.snapshot";
export const flutterPath = "bin/" + flutterExecutableName;
export const androidStudioPath = "bin/" + androidStudioExecutableName;
export const DART_DOWNLOAD_URL = "https://www.dartlang.org/install";
export const FLUTTER_DOWNLOAD_URL = "https://flutter.io/setup/";

export function handleMissingSdks(context: ExtensionContext, analytics: Analytics, workspaceContext: WorkspaceContext) {
	// HACK: In order to provide a more useful message if the user was trying to fun flutter.createProject
	// we need to hook the command and force the project type to Flutter to get the correct error message.
	// This can be reverted and improved if Code adds support for providing activation context:
	//     https://github.com/Microsoft/vscode/issues/44711
	let commandToReRun: string;
	let attemptedToUseFlutter: boolean = false;
	// Note: This code only runs if we fail to find the Dart SDK, or fail to find the Flutter SDK
	// and are in a Flutter project. In the case where we fail to find the Flutter SDK but are not
	// in a Flutter project (eg. we ran Flutter Doctor without the extension activated) then
	// this code will not be run as the extension will activate normally, and then the command-handling
	// code for each command will detect the missing Flutter SDK and respond appropriately.
	context.subscriptions.push(commands.registerCommand("flutter.createProject", (_) => {
		attemptedToUseFlutter = true;
		commandToReRun = "flutter.createProject";
	}));
	context.subscriptions.push(commands.registerCommand("flutter.createWebProject", (_) => {
		commandToReRun = "dart.createProject";
	}));
	context.subscriptions.push(commands.registerCommand("dart.createProject", (_) => {<commit_msg>Update Dart SDK download page URL<commit_after>import * as fs from "fs";
import * as path from "path";
import { commands, ExtensionContext, window } from "vscode";
import { Analytics } from "../analytics";
import { config } from "../config";
import { PackageMap } from "../debug/package_map";
import { dartPlatformName, flatMap, isWin } from "../debug/utils";
import { FLUTTER_CREATE_PROJECT_TRIGGER_FILE, FLUTTER_STAGEHAND_PROJECT_TRIGGER_FILE, fsPath, getDartWorkspaceFolders, getSdkVersion, openExtensionLogFile, openInBrowser, reloadExtension, resolvePaths, showLogAction, WorkspaceContext } from "../utils";
import { getChildFolders, hasPubspec } from "../utils/fs";
import { log } from "../utils/log";

const dartExecutableName = isWin ? "dart.exe" : "dart";
const pubExecutableName = isWin ? "pub.bat" : "pub";
const flutterExecutableName = isWin ? "flutter.bat" : "flutter";
const androidStudioExecutableName = isWin ? "studio64.exe" : "studio.sh";
export const dartVMPath = "bin/" + dartExecutableName;
export const pubPath = "bin/" + pubExecutableName;
export const pubSnapshotPath = "bin/snapshots/pub.dart.snapshot";
export const analyzerSnapshotPath = "bin/snapshots/analysis_server.dart.snapshot";
export const flutterPath = "bin/" + flutterExecutableName;
export const androidStudioPath = "bin/" + androidStudioExecutableName;
export const DART_DOWNLOAD_URL = "https://dart.dev/get-dart";
export const FLUTTER_DOWNLOAD_URL = "https://flutter.io/setup/";

export function handleMissingSdks(context: ExtensionContext, analytics: Analytics, workspaceContext: WorkspaceContext) {
	// HACK: In order to provide a more useful message if the user was trying to fun flutter.createProject
	// we need to hook the command and force the project type to Flutter to get the correct error message.
	// This can be reverted and improved if Code adds support for providing activation context:
	//     https://github.com/Microsoft/vscode/issues/44711
	let commandToReRun: string;
	let attemptedToUseFlutter: boolean = false;
	// Note: This code only runs if we fail to find the Dart SDK, or fail to find the Flutter SDK
	// and are in a Flutter project. In the case where we fail to find the Flutter SDK but are not
	// in a Flutter project (eg. we ran Flutter Doctor without the extension activated) then
	// this code will not be run as the extension will activate normally, and then the command-handling
	// code for each command will detect the missing Flutter SDK and respond appropriately.
	context.subscriptions.push(commands.registerCommand("flutter.createProject", (_) => {
		attemptedToUseFlutter = true;
		commandToReRun = "flutter.createProject";
	}));
	context.subscriptions.push(commands.registerCommand("flutter.createWebProject", (_) => {
		commandToReRun = "dart.createProject";
	}));
	context.subscriptions.push(commands.registerCommand("dart.createProject", (_) => {
{'fraction_non_alphanumeric': 0.10498870154701895, 'fraction_numerical': 0.00243351294976534, 'mean_word_length': 5.187096774193549, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '868437', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1645, 'n_words': 547}