Skip to content

Commit 06b0d41

Browse files
authored
Remove interfaces related to CloudFormation Explorer Nodes (#799)
1 parent c71dc4a commit 06b0d41

File tree

3 files changed

+22
-45
lines changed

3 files changed

+22
-45
lines changed

src/awsexplorer/regionNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { TreeItemCollapsibleState } from 'vscode'
7-
import { CloudFormationNode, DefaultCloudFormationNode } from '../lambda/explorer/cloudFormationNodes'
7+
import { CloudFormationNode } from '../lambda/explorer/cloudFormationNodes'
88
import { DefaultLambdaFunctionGroupNode, LambdaFunctionGroupNode } from '../lambda/explorer/lambdaNodes'
99
import { RegionInfo } from '../shared/regions/regionInfo'
1010
import { AWSTreeNodeBase } from '../shared/treeview/nodes/awsTreeNodeBase'
@@ -34,7 +34,7 @@ export class RegionNode extends AWSTreeNodeBase {
3434
this.info = info
3535
this.update(info)
3636

37-
this.cloudFormationNode = new DefaultCloudFormationNode(this.regionCode)
37+
this.cloudFormationNode = new CloudFormationNode(this.regionCode)
3838
this.lambdaFunctionGroupNode = new DefaultLambdaFunctionGroupNode(this.regionCode)
3939
}
4040

src/lambda/explorer/cloudFormationNodes.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@ import { intersection, toArrayAsync, toMap, toMapAsync, updateInPlace } from '..
2020
import { listCloudFormationStacks, listLambdaFunctions } from '../utils'
2121
import { FunctionNodeBase } from './functionNode'
2222

23-
export interface CloudFormationNode extends AWSTreeErrorHandlerNode {
24-
getChildren(): Thenable<(CloudFormationStackNode | ErrorNode)[]>
25-
26-
updateChildren(): Thenable<void>
27-
}
28-
29-
export class DefaultCloudFormationNode extends AWSTreeErrorHandlerNode implements CloudFormationNode {
23+
export class CloudFormationNode extends AWSTreeErrorHandlerNode {
3024
private readonly stackNodes: Map<string, CloudFormationStackNode>
3125

3226
public constructor(private readonly regionCode: string) {
@@ -53,24 +47,12 @@ export class DefaultCloudFormationNode extends AWSTreeErrorHandlerNode implement
5347
this.stackNodes,
5448
stacks.keys(),
5549
key => this.stackNodes.get(key)!.update(stacks.get(key)!),
56-
key => new DefaultCloudFormationStackNode(this, this.regionCode, stacks.get(key)!)
50+
key => new CloudFormationStackNode(this, this.regionCode, stacks.get(key)!)
5751
)
5852
}
5953
}
6054

61-
export interface CloudFormationStackNode extends AWSTreeErrorHandlerNode {
62-
readonly regionCode: string
63-
readonly stackId?: CloudFormation.StackId
64-
readonly stackName: CloudFormation.StackName
65-
66-
readonly parent: AWSTreeNodeBase
67-
68-
getChildren(): Thenable<(CloudFormationFunctionNode | PlaceholderNode)[]>
69-
70-
update(stackSummary: CloudFormation.StackSummary): void
71-
}
72-
73-
export class DefaultCloudFormationStackNode extends AWSTreeErrorHandlerNode implements CloudFormationStackNode {
55+
export class CloudFormationStackNode extends AWSTreeErrorHandlerNode {
7456
private readonly functionNodes: Map<string, CloudFormationFunctionNode>
7557

7658
public constructor(
@@ -137,7 +119,7 @@ export class DefaultCloudFormationStackNode extends AWSTreeErrorHandlerNode impl
137119
this.functionNodes,
138120
intersection(resources, functions.keys()),
139121
key => this.functionNodes.get(key)!.update(functions.get(key)!),
140-
key => new DefaultCloudFormationFunctionNode(this, this.regionCode, functions.get(key)!)
122+
key => new CloudFormationFunctionNode(this, this.regionCode, functions.get(key)!)
141123
)
142124
}
143125

@@ -155,11 +137,7 @@ export class DefaultCloudFormationStackNode extends AWSTreeErrorHandlerNode impl
155137
}
156138
}
157139

158-
export interface CloudFormationFunctionNode extends FunctionNodeBase {
159-
readonly parent: CloudFormationStackNode
160-
}
161-
162-
export class DefaultCloudFormationFunctionNode extends FunctionNodeBase {
140+
export class CloudFormationFunctionNode extends FunctionNodeBase {
163141
public constructor(
164142
public readonly parent: AWSTreeNodeBase,
165143
public readonly regionCode: string,

src/test/lambda/explorer/cloudFormationNodes.test.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import * as assert from 'assert'
77
import { CloudFormation, Lambda } from 'aws-sdk'
88
import * as os from 'os'
99
import {
10-
CloudFormationStackNode,
11-
DefaultCloudFormationFunctionNode,
12-
DefaultCloudFormationNode,
13-
DefaultCloudFormationStackNode
10+
CloudFormationFunctionNode,
11+
CloudFormationNode,
12+
CloudFormationStackNode
1413
} from '../../../lambda/explorer/cloudFormationNodes'
1514
import { CloudFormationClient } from '../../../shared/clients/cloudFormationClient'
1615
import { EcsClient } from '../../../shared/clients/ecsClient'
@@ -27,7 +26,7 @@ async function* asyncGenerator<T>(items: T[]): AsyncIterableIterator<T> {
2726
yield* items
2827
}
2928

30-
describe('DefaultCloudFormationStackNode', () => {
29+
describe('CloudFormationStackNode', () => {
3130
let fakeStackSummary: CloudFormation.StackSummary
3231

3332
before(async () => {
@@ -192,21 +191,21 @@ describe('DefaultCloudFormationStackNode', () => {
192191
assert(childNodes !== undefined)
193192
assert.strictEqual(childNodes.length, 2)
194193

195-
assert(childNodes[0] instanceof DefaultCloudFormationFunctionNode)
196-
assert.strictEqual((childNodes[0] as DefaultCloudFormationFunctionNode).label, lambda1Name)
194+
assert(childNodes[0] instanceof CloudFormationFunctionNode)
195+
assert.strictEqual((childNodes[0] as CloudFormationFunctionNode).label, lambda1Name)
197196

198-
assert(childNodes[1] instanceof DefaultCloudFormationFunctionNode)
199-
assert.strictEqual((childNodes[1] as DefaultCloudFormationFunctionNode).label, lambda3Name)
197+
assert(childNodes[1] instanceof CloudFormationFunctionNode)
198+
assert.strictEqual((childNodes[1] as CloudFormationFunctionNode).label, lambda3Name)
200199
})
201200

202201
function generateTestNode(): CloudFormationStackNode {
203202
const parentNode = new TestAWSTreeNode('test node')
204203

205-
return new DefaultCloudFormationStackNode(parentNode, 'someregioncode', fakeStackSummary)
204+
return new CloudFormationStackNode(parentNode, 'someregioncode', fakeStackSummary)
206205
}
207206
})
208207

209-
describe('DefaultCloudFormationNode', () => {
208+
describe('CloudFormationNode', () => {
210209
class StackNamesMockCloudFormationClient extends MockCloudFormationClient {
211210
public constructor(
212211
public readonly stackNames: string[] = [],
@@ -251,7 +250,7 @@ describe('DefaultCloudFormationNode', () => {
251250
}
252251
}
253252

254-
const cloudFormationNode = new DefaultCloudFormationNode('someregioncode')
253+
const cloudFormationNode = new CloudFormationNode('someregioncode')
255254

256255
const children = await cloudFormationNode.getChildren()
257256

@@ -267,12 +266,12 @@ describe('DefaultCloudFormationNode', () => {
267266
expectedNodeText: string
268267
) {
269268
assert.strictEqual(
270-
actualChildNode instanceof DefaultCloudFormationStackNode,
269+
actualChildNode instanceof CloudFormationStackNode,
271270
true,
272271
'Child node was not a Stack Node'
273272
)
274273

275-
const node: DefaultCloudFormationStackNode = actualChildNode as DefaultCloudFormationStackNode
274+
const node = actualChildNode as CloudFormationStackNode
276275
assert.strictEqual(
277276
node.stackName,
278277
expectedNodeText,
@@ -287,7 +286,7 @@ describe('DefaultCloudFormationNode', () => {
287286
})
288287

289288
it('handles error', async () => {
290-
class ThrowErrorDefaultCloudFormationNode extends DefaultCloudFormationNode {
289+
class ThrowErrorCloudFormationNode extends CloudFormationNode {
291290
public constructor() {
292291
super('someregioncode')
293292
}
@@ -297,7 +296,7 @@ describe('DefaultCloudFormationNode', () => {
297296
}
298297
}
299298

300-
const testNode: ThrowErrorDefaultCloudFormationNode = new ThrowErrorDefaultCloudFormationNode()
299+
const testNode: ThrowErrorCloudFormationNode = new ThrowErrorCloudFormationNode()
301300

302301
const childNodes = await testNode.getChildren()
303302
assert(childNodes !== undefined)

0 commit comments

Comments
 (0)