Skip to content

Commit 18da85b

Browse files
authored
Remove interfaces related to Lambda Explorer Nodes (#800)
* Remove interface declarations related to Lambda Explorer nodes * Renamed LambdaFunctionGroupNode to LambdaNode to increase clarity and consistency in naming
1 parent 06b0d41 commit 18da85b

File tree

3 files changed

+21
-31
lines changed

3 files changed

+21
-31
lines changed

src/awsexplorer/regionNode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { TreeItemCollapsibleState } from 'vscode'
77
import { CloudFormationNode } from '../lambda/explorer/cloudFormationNodes'
8-
import { DefaultLambdaFunctionGroupNode, LambdaFunctionGroupNode } from '../lambda/explorer/lambdaNodes'
8+
import { LambdaNode } from '../lambda/explorer/lambdaNodes'
99
import { RegionInfo } from '../shared/regions/regionInfo'
1010
import { AWSTreeNodeBase } from '../shared/treeview/nodes/awsTreeNodeBase'
1111
import { toMap, updateInPlace } from '../shared/utilities/collectionUtils'
@@ -18,7 +18,7 @@ import { toMap, updateInPlace } from '../shared/utilities/collectionUtils'
1818
export class RegionNode extends AWSTreeNodeBase {
1919
private info: RegionInfo
2020
private readonly cloudFormationNode: CloudFormationNode
21-
private readonly lambdaFunctionGroupNode: LambdaFunctionGroupNode
21+
private readonly lambdaNode: LambdaNode
2222

2323
public get regionCode(): string {
2424
return this.info.regionCode
@@ -35,11 +35,11 @@ export class RegionNode extends AWSTreeNodeBase {
3535
this.update(info)
3636

3737
this.cloudFormationNode = new CloudFormationNode(this.regionCode)
38-
this.lambdaFunctionGroupNode = new DefaultLambdaFunctionGroupNode(this.regionCode)
38+
this.lambdaNode = new LambdaNode(this.regionCode)
3939
}
4040

4141
public async getChildren(): Promise<AWSTreeNodeBase[]> {
42-
return [this.cloudFormationNode, this.lambdaFunctionGroupNode]
42+
return [this.cloudFormationNode, this.lambdaNode]
4343
}
4444

4545
public update(info: RegionInfo): void {

src/lambda/explorer/lambdaNodes.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ import { toArrayAsync, toMap, updateInPlace } from '../../shared/utilities/colle
1717
import { listLambdaFunctions } from '../utils'
1818
import { FunctionNodeBase } from './functionNode'
1919

20-
export interface LambdaFunctionGroupNode extends AWSTreeErrorHandlerNode {
21-
getChildren(): Thenable<(LambdaFunctionNode | ErrorNode)[]>
22-
23-
updateChildren(): Thenable<void>
24-
}
25-
26-
export class DefaultLambdaFunctionGroupNode extends AWSTreeErrorHandlerNode implements LambdaFunctionGroupNode {
20+
/**
21+
* An AWS Explorer node representing the Lambda Service.
22+
* Contains Lambda Functions for a specific region as child nodes.
23+
*/
24+
export class LambdaNode extends AWSTreeErrorHandlerNode {
2725
private readonly functionNodes: Map<string, LambdaFunctionNode>
2826

2927
public constructor(private readonly regionCode: string) {
@@ -55,16 +53,12 @@ export class DefaultLambdaFunctionGroupNode extends AWSTreeErrorHandlerNode impl
5553
this.functionNodes,
5654
functions.keys(),
5755
key => this.functionNodes.get(key)!.update(functions.get(key)!),
58-
key => new DefaultLambdaFunctionNode(this, this.regionCode, functions.get(key)!)
56+
key => new LambdaFunctionNode(this, this.regionCode, functions.get(key)!)
5957
)
6058
}
6159
}
6260

63-
export interface LambdaFunctionNode extends FunctionNodeBase {
64-
readonly parent: AWSTreeNodeBase
65-
}
66-
67-
export class DefaultLambdaFunctionNode extends FunctionNodeBase implements LambdaFunctionNode {
61+
export class LambdaFunctionNode extends FunctionNodeBase {
6862
public constructor(
6963
public readonly parent: AWSTreeNodeBase,
7064
public readonly regionCode: string,

src/test/lambda/explorer/lambdaNodes.test.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import * as assert from 'assert'
77
import { Lambda } from 'aws-sdk'
88
import * as os from 'os'
9-
import {
10-
DefaultLambdaFunctionGroupNode,
11-
DefaultLambdaFunctionNode,
12-
LambdaFunctionNode
13-
} from '../../../lambda/explorer/lambdaNodes'
9+
import { LambdaFunctionNode, LambdaNode } from '../../../lambda/explorer/lambdaNodes'
1410
import { CloudFormationClient } from '../../../shared/clients/cloudFormationClient'
1511
import { EcsClient } from '../../../shared/clients/ecsClient'
1612
import { LambdaClient } from '../../../shared/clients/lambdaClient'
@@ -26,7 +22,7 @@ async function* asyncGenerator<T>(items: T[]): AsyncIterableIterator<T> {
2622
yield* items
2723
}
2824

29-
describe('DefaultLambdaFunctionNode', () => {
25+
describe('LambdaFunctionNode', () => {
3026
let fakeFunctionConfig: Lambda.FunctionConfiguration
3127

3228
before(async () => {
@@ -78,14 +74,14 @@ describe('DefaultLambdaFunctionNode', () => {
7874
assert.strictEqual(childNodes.length, 0)
7975
})
8076

81-
function generateTestNode(): DefaultLambdaFunctionNode {
77+
function generateTestNode(): LambdaFunctionNode {
8278
const parentNode = new TestAWSTreeNode('test node')
8379

84-
return new DefaultLambdaFunctionNode(parentNode, 'someregioncode', fakeFunctionConfig)
80+
return new LambdaFunctionNode(parentNode, 'someregioncode', fakeFunctionConfig)
8581
}
8682
})
8783

88-
describe('DefaultLambdaFunctionGroupNode', () => {
84+
describe('LambdaNode', () => {
8985
class FunctionNamesMockLambdaClient extends MockLambdaClient {
9086
public constructor(
9187
public readonly functionNames: string[] = [],
@@ -104,7 +100,7 @@ describe('DefaultLambdaFunctionGroupNode', () => {
104100
}
105101
}
106102

107-
class ThrowErrorDefaultLambdaFunctionGroupNode extends DefaultLambdaFunctionGroupNode {
103+
class ThrowErrorLambdaNode extends LambdaNode {
108104
public constructor() {
109105
super('someregioncode')
110106
}
@@ -136,9 +132,9 @@ describe('DefaultLambdaFunctionGroupNode', () => {
136132
}
137133
}
138134

139-
const functionGroupNode = new DefaultLambdaFunctionGroupNode('someregioncode')
135+
const lambdaNode = new LambdaNode('someregioncode')
140136

141-
const children = await functionGroupNode.getChildren()
137+
const children = await lambdaNode.getChildren()
142138

143139
assert.ok(children, 'Expected to get Lambda function nodes as children')
144140
assert.strictEqual(
@@ -157,7 +153,7 @@ describe('DefaultLambdaFunctionGroupNode', () => {
157153
'Child node expected to contain functionName property'
158154
)
159155

160-
const node: DefaultLambdaFunctionNode = actualChildNode as DefaultLambdaFunctionNode
156+
const node = actualChildNode as LambdaFunctionNode
161157
assert.strictEqual(
162158
node.functionName,
163159
expectedNodeText,
@@ -172,7 +168,7 @@ describe('DefaultLambdaFunctionGroupNode', () => {
172168
})
173169

174170
it('handles error', async () => {
175-
const testNode = new ThrowErrorDefaultLambdaFunctionGroupNode()
171+
const testNode = new ThrowErrorLambdaNode()
176172

177173
const childNodes = await testNode.getChildren()
178174
assert(childNodes !== undefined)

0 commit comments

Comments
 (0)