Skip to content

Commit 191a7b6

Browse files
authored
Merge pull request #320 from actions/allanguigou/default-case
Remove experimental flag for `case` function
2 parents 448180b + 0410ab8 commit 191a7b6

File tree

5 files changed

+15
-56
lines changed

5 files changed

+15
-56
lines changed

expressions/src/completion.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function complete(
3535
context: Dictionary,
3636
extensionFunctions: FunctionInfo[],
3737
functions?: Map<string, FunctionDefinition>,
38+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3839
featureFlags?: FeatureFlags
3940
): CompletionItem[] {
4041
// Lex
@@ -66,7 +67,7 @@ export function complete(
6667
const result = contextKeys(context);
6768

6869
// Merge with functions
69-
result.push(...functionItems(extensionFunctions, featureFlags));
70+
result.push(...functionItems(extensionFunctions));
7071

7172
return result;
7273
}
@@ -91,15 +92,10 @@ export function complete(
9192
return contextKeys(result);
9293
}
9394

94-
function functionItems(extensionFunctions: FunctionInfo[], featureFlags?: FeatureFlags): CompletionItem[] {
95+
function functionItems(extensionFunctions: FunctionInfo[]): CompletionItem[] {
9596
const result: CompletionItem[] = [];
96-
const flags = featureFlags ?? new FeatureFlags();
9797

9898
for (const fdef of [...Object.values(wellKnownFunctions), ...extensionFunctions]) {
99-
// Filter out case function if feature is disabled
100-
if (fdef.name === "case" && !flags.isEnabled("allowCaseFunction")) {
101-
continue;
102-
}
10399
result.push({
104100
label: fdef.name,
105101
description: fdef.description,

expressions/src/features.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ describe("FeatureFlags", () => {
5151

5252
it("returns all features when all is enabled", () => {
5353
const flags = new FeatureFlags({all: true});
54-
expect(flags.getEnabledFeatures()).toEqual([
55-
"missingInputsQuickfix",
56-
"blockScalarChompingWarning",
57-
"allowCaseFunction"
58-
]);
54+
expect(flags.getEnabledFeatures()).toEqual(["missingInputsQuickfix", "blockScalarChompingWarning"]);
5955
});
6056
});
6157
});

expressions/src/features.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ export interface ExperimentalFeatures {
2828
* @default false
2929
*/
3030
blockScalarChompingWarning?: boolean;
31-
32-
/**
33-
* Enable the case() function in expressions.
34-
* @default false
35-
*/
36-
allowCaseFunction?: boolean;
3731
}
3832

3933
/**
@@ -45,11 +39,7 @@ export type ExperimentalFeatureKey = Exclude<keyof ExperimentalFeatures, "all">;
4539
* All known experimental feature keys.
4640
* This list must be kept in sync with the ExperimentalFeatures interface.
4741
*/
48-
const allFeatureKeys: ExperimentalFeatureKey[] = [
49-
"missingInputsQuickfix",
50-
"blockScalarChompingWarning",
51-
"allowCaseFunction"
52-
];
42+
const allFeatureKeys: ExperimentalFeatureKey[] = ["missingInputsQuickfix", "blockScalarChompingWarning"];
5343

5444
export class FeatureFlags {
5545
private readonly features: ExperimentalFeatures;

languageservice/src/complete.expressions.test.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-non-null-assertion */
2-
import {data, DescriptionDictionary, FeatureFlags} from "@actions/expressions";
2+
import {data, DescriptionDictionary} from "@actions/expressions";
33
import {CompletionItem, CompletionItemKind, MarkupContent} from "vscode-languageserver-types";
44
import {complete, getExpressionInput} from "./complete.js";
55
import {ContextProviderConfig} from "./context-providers/config.js";
@@ -69,8 +69,7 @@ describe("expressions", () => {
6969
it("single region", async () => {
7070
const input = "run-name: ${{ | }}";
7171
const result = await complete(...getPositionFromCursor(input), {
72-
contextProviderConfig,
73-
featureFlags: new FeatureFlags({allowCaseFunction: true})
72+
contextProviderConfig
7473
});
7574

7675
expect(result.map(x => x.label)).toEqual([
@@ -113,8 +112,7 @@ describe("expressions", () => {
113112
it("single region with existing input", async () => {
114113
const input = "run-name: ${{ g| }}";
115114
const result = await complete(...getPositionFromCursor(input), {
116-
contextProviderConfig,
117-
featureFlags: new FeatureFlags({allowCaseFunction: true})
115+
contextProviderConfig
118116
});
119117

120118
expect(result.map(x => x.label)).toEqual([
@@ -135,8 +133,7 @@ describe("expressions", () => {
135133
it("single region with existing condition", async () => {
136134
const input = "run-name: ${{ g| == 'test' }}";
137135
const result = await complete(...getPositionFromCursor(input), {
138-
contextProviderConfig,
139-
featureFlags: new FeatureFlags({allowCaseFunction: true})
136+
contextProviderConfig
140137
});
141138

142139
expect(result.map(x => x.label)).toEqual([
@@ -157,8 +154,7 @@ describe("expressions", () => {
157154
it("multiple regions with partial function", async () => {
158155
const input = "run-name: Run a ${{ inputs.test }} one-line script ${{ from|('test') == inputs.name }}";
159156
const result = await complete(...getPositionFromCursor(input), {
160-
contextProviderConfig,
161-
featureFlags: new FeatureFlags({allowCaseFunction: true})
157+
contextProviderConfig
162158
});
163159

164160
expect(result.map(x => x.label)).toEqual([
@@ -179,8 +175,7 @@ describe("expressions", () => {
179175
it("multiple regions - first region", async () => {
180176
const input = "run-name: test-${{ git| == 1 }}-${{ github.event }}";
181177
const result = await complete(...getPositionFromCursor(input), {
182-
contextProviderConfig,
183-
featureFlags: new FeatureFlags({allowCaseFunction: true})
178+
contextProviderConfig
184179
});
185180

186181
expect(result.map(x => x.label)).toEqual([
@@ -201,8 +196,7 @@ describe("expressions", () => {
201196
it("multiple regions", async () => {
202197
const input = "run-name: test-${{ github }}-${{ | }}";
203198
const result = await complete(...getPositionFromCursor(input), {
204-
contextProviderConfig,
205-
featureFlags: new FeatureFlags({allowCaseFunction: true})
199+
contextProviderConfig
206200
});
207201

208202
expect(result.map(x => x.label)).toEqual([
@@ -1181,8 +1175,7 @@ jobs:
11811175
`;
11821176

11831177
const result = await complete(...getPositionFromCursor(input), {
1184-
contextProviderConfig,
1185-
featureFlags: new FeatureFlags({allowCaseFunction: true})
1178+
contextProviderConfig
11861179
});
11871180
expect(result.map(x => x.label)).toEqual([
11881181
"env",

languageservice/src/complete.test.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {getPositionFromCursor} from "./test-utils/cursor-position.js";
66
import {TestLogger} from "./test-utils/logger.js";
77
import {clearCache} from "./utils/workflow-cache.js";
88
import {ValueProviderConfig, ValueProviderKind} from "./value-providers/config.js";
9-
import {FeatureFlags} from "@actions/expressions/features";
109

1110
registerLogger(new TestLogger());
1211

@@ -898,30 +897,15 @@ jobs:
898897
});
899898

900899
describe("expression completions", () => {
901-
it("include case function when enabled", async () => {
900+
it("includes case function", async () => {
902901
const input = "on: push\njobs:\n build:\n runs-on: ${{ c|";
903-
const result = await complete(...getPositionFromCursor(input), {
904-
featureFlags: new FeatureFlags({allowCaseFunction: true})
905-
});
902+
const result = await complete(...getPositionFromCursor(input));
906903

907904
expect(result).not.toBeUndefined();
908905
// Expression completions starting with 'c': case, contains
909906
const labels = result.map(x => x.label);
910907
expect(labels).toContain("case");
911908
expect(labels).toContain("contains");
912909
});
913-
914-
it("exclude case function when disabled", async () => {
915-
const input = "on: push\njobs:\n build:\n runs-on: ${{ c|";
916-
const result = await complete(...getPositionFromCursor(input), {
917-
featureFlags: new FeatureFlags({allowCaseFunction: false})
918-
});
919-
920-
expect(result).not.toBeUndefined();
921-
// Expression completions starting with 'c': contains
922-
const labels = result.map(x => x.label);
923-
expect(labels).not.toContain("case");
924-
expect(labels).toContain("contains");
925-
});
926910
});
927911
});

0 commit comments

Comments
 (0)