Skip to content

Commit d732ec1

Browse files
authored
continue #700: support local overridden by settings (#701)
* continue #700: support local overridden by settings Signed-off-by: Yan Zhang <[email protected]> * tslint Signed-off-by: Yan Zhang <[email protected]>
1 parent e6281cf commit d732ec1

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/extension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { initialize as initUtils } from "./utils";
77
import { initialize as initCommands } from "./commands";
88
import { initialize as initRecommendations } from "./recommendation";
99
import { showReleaseNotesOnStart, HelpViewType } from "./misc";
10-
import { getExpService, initialize as initExp } from "./exp";
10+
import { initialize as initExp } from "./exp";
1111
import { OverviewViewSerializer } from "./overview";
1212
import { JavaRuntimeViewSerializer, validateJavaRuntime } from "./java-runtime";
1313
import { scheduleAction } from "./utils/scheduler";
@@ -19,7 +19,7 @@ import { initFormatterSettingsEditorProvider } from "./formatter-settings";
1919
import { initRemoteProfileProvider } from "./formatter-settings/RemoteProfileProvider";
2020
import { CodeActionProvider } from "./providers/CodeActionProvider";
2121
import { KEY_IS_WELCOME_PAGE_VIEWED, KEY_SHOW_WHEN_USING_JAVA } from "./utils/globalState";
22-
import { TreatmentVariables } from "./exp/TreatmentVariables";
22+
import { isWalkthroughEnabled } from "./utils/walkthrough";
2323

2424
export async function activate(context: vscode.ExtensionContext) {
2525
syncState(context);
@@ -36,7 +36,7 @@ async function initializeExtension(_operationId: string, context: vscode.Extensi
3636
initCommands(context);
3737
initRecommendations(context);
3838

39-
context.subscriptions.push(vscode.languages.registerCodeActionsProvider({scheme: "file", language: "java", pattern: "**/*.java"}, new CodeActionProvider()));
39+
context.subscriptions.push(vscode.languages.registerCodeActionsProvider({ scheme: "file", language: "java", pattern: "**/*.java" }, new CodeActionProvider()));
4040

4141
// webview serializers to restore pages
4242
context.subscriptions.push(vscode.window.registerWebviewPanelSerializer("java.extGuide", new JavaExtGuideViewSerializer()));
@@ -49,7 +49,7 @@ async function initializeExtension(_operationId: string, context: vscode.Extensi
4949
const config = vscode.workspace.getConfiguration("java.help");
5050

5151
// for control group where walkthrough is not enabled, present first view for once.
52-
const walkthroughEnabled = getExpService().getTreatmentVariable<boolean>(TreatmentVariables.VSCodeConfig, TreatmentVariables.JavaWalkthroughEnabled);
52+
const walkthroughEnabled = isWalkthroughEnabled();
5353
if (walkthroughEnabled === false && !context.globalState.get(KEY_IS_WELCOME_PAGE_VIEWED)) {
5454
presentFirstView(context);
5555
context.globalState.update(KEY_IS_WELCOME_PAGE_VIEWED, true)

src/utils/walkthrough.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
import { workspace } from "vscode";
5+
import { getExpService } from "../exp";
6+
import { TreatmentVariables } from "../exp/TreatmentVariables";
7+
8+
export function isWalkthroughEnabled() {
9+
10+
const fromExp = getExpService().getTreatmentVariable<boolean>(TreatmentVariables.VSCodeConfig, TreatmentVariables.JavaWalkthroughEnabled);
11+
// can be overridden by local settings "experiments.override.gettingStarted.overrideCategory.vscjava.vscode-java-pack#javaWelcome.when": "true"
12+
const fromSettings = workspace.getConfiguration("experiments.override.gettingStarted.overrideCategory").get<string>("vscjava.vscode-java-pack#javaWelcome.when") === "true";
13+
14+
return fromExp || fromSettings;
15+
}

src/welcome/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import * as path from "path";
66
import { getExtensionContext, loadTextFromFile } from "../utils";
77
import { instrumentSimpleOperation, sendInfo } from "vscode-extension-telemetry-wrapper";
88
import { KEY_SHOW_WHEN_USING_JAVA, KEY_IS_WELCOME_PAGE_VIEWED } from "../utils/globalState";
9-
import { getExpService } from "../exp";
10-
import { TreatmentVariables } from "../exp/TreatmentVariables";
9+
import { isWalkthroughEnabled } from "../utils/walkthrough";
1110

1211
let welcomeView: vscode.WebviewPanel | undefined;
1312

@@ -88,7 +87,7 @@ const setFirstTimeRun = (context: vscode.ExtensionContext, firstTimeRun: boolean
8887
};
8988

9089
const fetchInitProps = (context: vscode.ExtensionContext) => {
91-
const walkthrough = getExpService().getTreatmentVariable<boolean>(TreatmentVariables.VSCodeConfig, TreatmentVariables.JavaWalkthroughEnabled);
90+
const walkthrough = isWalkthroughEnabled();
9291
welcomeView?.webview.postMessage({
9392
command: "onDidFetchInitProps",
9493
props: {
@@ -101,7 +100,7 @@ const fetchInitProps = (context: vscode.ExtensionContext) => {
101100
};
102101

103102
const showTourPage = (context: vscode.ExtensionContext) => {
104-
const walkthrough = getExpService().getTreatmentVariable<boolean>(TreatmentVariables.VSCodeConfig, TreatmentVariables.JavaWalkthroughEnabled);
103+
const walkthrough = isWalkthroughEnabled();
105104
welcomeView?.webview.postMessage({
106105
command: "onDidFetchInitProps",
107106
props: {

0 commit comments

Comments
 (0)