Skip to content

Commit

Permalink
Replace name "fetch" with "get" for consistency
Browse files Browse the repository at this point in the history
This includes renaming the option so will need noting in release notes.

Fixes Dart-Code#689.
  • Loading branch information
DanTup committed Mar 14, 2018
1 parent 9f4ec5a commit f66cee3
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
- Flutter and Dart debuggers have been merged, you will no longer be asked to choose between Flutter and Dart when running new projects!
- As part of this, the `type` attribute on launch configurations in your `launch.json` will be automatically changed from `dart-cli`/`flutter` to `dart` upon opening the project
- Flutter projects no longer require a `launch.json` file if being launched with default arguments; if you hit F5 in a project without one it will just launch immediately
- If your packages are missing or out of date you will be prompted to run `pub get`/`flutter packages get` upon loading your project (this can be disabled with the new `dart.promptToFetchPackages` setting, which can be set at the folder level)
- If your packages are missing or out of date you will be prompted to run `pub get`/`flutter packages get` upon loading your project (this can be disabled with the new `dart.promptToGetPackages` setting, which can be set at the folder level)
- Snippets have been added for Flutter widgets (`stless`, `stful`, `stanim`) and will show only inside Flutter projects
- Quick Fixes and other code actions that insert code now support tab stops and selections (for example the `Wrap with new widget` assist will now select the text `widget` for you to type over)
- Code completions will no longer insert parentheses/argument placeholders if they are already present
Expand All @@ -44,7 +44,7 @@
- Due to a number of issues with the implementation, external files (SDK, packages) will no longer open read-only (this behaviour may be restored in some form in future)
- Executing package restore commands in a workspace that has no `pubspec.yaml` on Windows will no longer get the extension stuck in a loop
- Saving `pubspec.yaml` in a Dart project will no longer run `flutter packages get` if you have a Flutter project in the same workspace
- Fetching flutter packages will no longer sometimes unexpectedly ask you for the workspace folder to run the command in
- Running `Flutter: Get Packages` will no longer sometimes unexpectedly ask you for the workspace folder to run the command in
- Opening a Dart file outside of a folder will no longer show errors in the developer console
- A new setting (`dart.previewDart2`) has been added which allows you to opt-in to Dart 2 behaviour such as optional `new`/`const` (you must be using an SDK that supports this!)

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The `src/services` folder contains some plumbing code for services, such as a ba
Running Dart Code from source is relatively straight forward. You should:

1. Clone the Dart Code repository (or your own fork)
2. Run `npm install` to fetch dependencies
2. Run `npm install` to install dependencies
3. Open the repository root folder in Visual Studio Code
4. Press F5

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Dart Code can be [installed from the Visual Studio Code Marketplace](https://mar
- `dart.lineLength`: The maximum length of a line of code. This is used by the document formatter. Defaults to `80`.
- `dart.pubAdditionalArgs`: Additional args to pass to `pub get` and `pub upgrade` commands (eg. `--packages-dir`).
- `dart.runPubGetOnPubspecChanges`: Whether to automatically run `pub get` whenever pubspec.yaml is saved. Defaults to `true`.
- `dart.promptToFetchPackages`: Whether to prompt to fetch packages when opening a project with out of date packages. Defaults to `true`.
- `dart.promptToGetPackages`: Whether to prompt to get packages when opening a project with out of date packages. Defaults to `true`.
- `dart.sdkPath`: If the Dart SDK is not automatically found on your machine from your `PATH` you can enter the path to it here.
- `dart.sdkPaths`: If you often switch between multiple Dart SDKs, setting this option to an array of Dart SDK folders or folders that contain multiple Dart SDKs in sub-folders will allow fast switching by clicking the Dart SDK version in the status bar.
- `dart.showLintNames`: Whether to show the names of linter rules in the problems panel to make it easier to `// ignore:`.
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
},
{
"command": "flutter.packages.get",
"title": "Get Flutter Packages",
"title": "Get Packages",
"category": "Flutter",
"icon": {
"light": "./media/commands/pull.svg",
Expand All @@ -130,7 +130,7 @@
},
{
"command": "flutter.packages.upgrade",
"title": "Upgrade Flutter Packages",
"title": "Upgrade Packages",
"category": "Flutter",
"icon": {
"light": "./media/commands/pull.svg",
Expand Down Expand Up @@ -452,10 +452,10 @@
"description": "Automatically runs `pub get` whenever pubspec.yaml is saved.",
"scope": "resource"
},
"dart.promptToFetchPackages": {
"dart.promptToGetPackages": {
"type": "boolean",
"default": true,
"description": "Prompt to fetch packages when opening a project with out of date packages.",
"description": "Prompt to get packages when opening a project with out of date packages.",
"scope": "resource"
},
"dart.showLintNames": {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class SdkCommands {
// SDK commands.
const sdkManager = new SdkManager(sdks);
context.subscriptions.push(vs.commands.registerCommand("dart.changeSdk", () => sdkManager.changeSdk()));
context.subscriptions.push(vs.commands.registerCommand("dart.fetchPackages", (uri) => {
context.subscriptions.push(vs.commands.registerCommand("dart.getPackages", (uri) => {
if (!uri || !(uri instanceof Uri))
return;
if (isFlutterProject(vs.workspace.getWorkspaceFolder(uri)))
Expand Down Expand Up @@ -67,7 +67,7 @@ export class SdkCommands {
// Hook saving pubspec to run pub.get.
context.subscriptions.push(vs.workspace.onDidSaveTextDocument((td) => {
if (config.for(td.uri).runPubGetOnPubspecChanges && path.basename(td.fileName).toLowerCase() === "pubspec.yaml")
vs.commands.executeCommand("dart.fetchPackages", td.uri);
vs.commands.executeCommand("dart.getPackages", td.uri);
}));
}

Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ResourceConfig {
get runPubGetOnPubspecChanges() { return this.getConfig<boolean>("runPubGetOnPubspecChanges"); }
get flutterRunLogFile() { return resolveHomePath(this.getConfig<string>("flutterRunLogFile")); }
get observatoryLogFile() { return resolveHomePath(this.getConfig<string>("observatoryLogFile")); }
get promptToFetchPackages() { return this.getConfig<boolean>("promptToFetchPackages"); }
get promptToGetPackages() { return this.getConfig<boolean>("promptToGetPackages"); }
get vmAdditionalArgs() { return this.getConfig<string[]>("vmAdditionalArgs"); }
}

Expand Down
6 changes: 3 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ export function activate(context: vs.ExtensionContext) {
// Prompt for pub get if required
function checkForPackages() {
const folders = util.getDartWorkspaceFolders();
const foldersRequiringPackageFetch = folders.filter((ws: WorkspaceFolder) => config.for(ws.uri).promptToFetchPackages).filter(isPubGetProbablyRequired);
if (foldersRequiringPackageFetch.length > 0)
promptToRunPubGet(foldersRequiringPackageFetch);
const foldersRequiringPackageGet = folders.filter((ws: WorkspaceFolder) => config.for(ws.uri).promptToGetPackages).filter(isPubGetProbablyRequired);
if (foldersRequiringPackageGet.length > 0)
promptToRunPubGet(foldersRequiringPackageGet);
}
context.subscriptions.push(vs.workspace.onDidChangeWorkspaceFolders((f) => checkForPackages()));
checkForPackages();
Expand Down
12 changes: 6 additions & 6 deletions src/pub/pub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ export function isPubGetProbablyRequired(ws: WorkspaceFolder): boolean {
}

export function promptToRunPubGet(folders: WorkspaceFolder[]) {
const label = "Fetch packages";
window.showInformationMessage("Some packages are missing or out of date, would you like to fetch them now?", label).then((clickedButton) => {
const label = "Get packages";
window.showInformationMessage("Some packages are missing or out of date, would you like to get them now?", label).then((clickedButton) => {
if (clickedButton === label)
fetchPackages(folders);
getPackages(folders);
});
}

function fetchPackages(folders: WorkspaceFolder[]) {
let task = commands.executeCommand("dart.fetchPackages", folders[0].uri);
function getPackages(folders: WorkspaceFolder[]) {
let task = commands.executeCommand("dart.getPackages", folders[0].uri);
for (let i = 1; i < folders.length; i++) {
task = task.then((code) => {
if (code === 0) // Continue with next one only if success
return commands.executeCommand("dart.fetchPackages", folders[i].uri);
return commands.executeCommand("dart.getPackages", folders[i].uri);
});
}
}

0 comments on commit f66cee3

Please sign in to comment.