Skip to content

Commit 57f5fae

Browse files
committed
Handle valueof
1 parent ce5e03e commit 57f5fae

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/context/semantic/LogicalIdReferenceFinder.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ function findYamlIntrinsicReferences(text: string, logicalIds: Set<string>): voi
9898
if (text.includes('Condition')) {
9999
extractMatches(text, YamlCondition, logicalIds);
100100
}
101+
if (text.includes('!ValueOf')) {
102+
extractMatches(text, YamlValueOfShort, logicalIds);
103+
}
101104
if (text.includes('Fn::ValueOf')) {
102105
extractMatches(text, YamlValueOf, logicalIds);
103106
}
@@ -215,6 +218,7 @@ const YamlSingleDep = /(?<![A-Za-z])['"]?DependsOn['"]?\s*:\s*['"]?([A-Za-z][A-Z
215218
const YamlInlineDeps = /(?<![A-Za-z])['"]?DependsOn['"]?\s*:\s*\[([^\]]+)]/g; // Matches DependsOn: [Id1, Id2] with optional quotes
216219
const YamlListItem = /-\s*([A-Za-z][A-Za-z0-9]*)/g; // Matches - LogicalId in YAML list format
217220
const YamlInlineItemPattern = /([A-Za-z][A-Za-z0-9]*)/g; // Matches LogicalId within the inline array
221+
const YamlValueOfShort = /!ValueOf\s+\[\s*['"]?([A-Za-z][A-Za-z0-9]*)['"]?/g; // Matches !ValueOf [ParamName, Attr] - YAML short form
218222
const YamlValueOf = /['"]?Fn::ValueOf['"]?\s*:\s*\[\s*['"]?([A-Za-z][A-Za-z0-9]*)['"]?/g; // Matches Fn::ValueOf: [ParamName, Attr] with optional quotes
219223

220224
// Shared pattern for ${} variables - used by both JSON and YAML

tst/unit/context/semantic/IntrinsicsCoverage.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ describe('Intrinsic Function Coverage', () => {
293293
expect(result).toEqual(new Set(['MyParam']));
294294
});
295295

296+
it('!ValueOf short form', () => {
297+
const result = referencedLogicalIds('!ValueOf [MyParam, Attr]', '', DocumentType.YAML);
298+
expect(result).toEqual(new Set(['MyParam']));
299+
});
300+
296301
it('Fn::RefAll with nested !If', () => {
297302
// Fn::RefAll takes a parameter type, but can be nested in conditions
298303
const result = referencedLogicalIds(

0 commit comments

Comments
 (0)