-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(server) - Add support for Ref in hover and autocomplete (#248)
* Support Ref functions for hover/autocomplete
- Loading branch information
Showing
8 changed files
with
537 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
client/src/test/suite/fixtures/completion/completion2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
Parameters: | ||
Vpc: | ||
Type: AWS::EC2::VPC::Id | ||
Resources: | ||
Subnet1: | ||
Type: AWS::EC2::Subnet | ||
Properties: | ||
VpcId: !Ref Vpc | ||
Subnet2: | ||
Type: AWS::EC2::Subnet | ||
Properties: | ||
VpcId: | ||
Ref: V | ||
RouteTable1: | ||
Type: AWS::EC2::RouteTable | ||
Properties: | ||
VpcId: !Ref V | ||
Subnet1RouteTable1: | ||
Type: AWS::EC2::SubnetRouteTableAssociation | ||
Properties: | ||
RouteTableId: !R | ||
SubnetId: !Ref Subnet1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
Parameters: | ||
Vpc: | ||
Type: AWS::EC2::VPC::Id | ||
Resources: | ||
Subnet1: | ||
Type: AWS::EC2::Subnet | ||
Properties: | ||
VpcId: !Ref Vpc | ||
Subnet2: | ||
Type: AWS::EC2::Subnet | ||
Properties: | ||
VpcId: | ||
Ref: Vpc | ||
RouteTable1: | ||
Type: AWS::EC2::RouteTable | ||
Properties: | ||
VpcId: !Ref Vpc | ||
Subnet1RouteTable1: | ||
Type: AWS::EC2::SubnetRouteTableAssociation | ||
Properties: | ||
RouteTableId: !Ref RouteTable1 | ||
SubnetId: | ||
Ref: Subnet1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import * as vscode from "vscode"; | ||
import assert = require("assert"); | ||
import { getDocUri, activate } from "./helper"; | ||
|
||
suite("Should hover", () => { | ||
test("Hover on !Ref to parameter", async () => { | ||
const docUri = getDocUri("hover", "hover.yaml"); | ||
await activate(docUri); | ||
|
||
await testHover( | ||
docUri, | ||
new vscode.Position(17, 20), | ||
"\n```\n(Parameter) Vpc: AWS::EC2::VPC::Id\n```\n" | ||
); | ||
}); | ||
test("Hover on !Ref to resource", async () => { | ||
const docUri = getDocUri("hover", "hover.yaml"); | ||
await activate(docUri); | ||
|
||
await testHover( | ||
docUri, | ||
new vscode.Position(21, 31), | ||
"\n```\n(Resource) RouteTable1: AWS::EC2::RouteTable\n```\n" | ||
); | ||
}); | ||
test("Hover on Ref: to resource", async () => { | ||
const docUri = getDocUri("hover", "hover.yaml"); | ||
await activate(docUri); | ||
|
||
await testHover( | ||
docUri, | ||
new vscode.Position(23, 17), | ||
"\n```\n(Resource) Subnet1: AWS::EC2::Subnet\n```\n" | ||
); | ||
}); | ||
test("Hover on Ref: to parameter", async () => { | ||
const docUri = getDocUri("hover", "hover.yaml"); | ||
await activate(docUri); | ||
|
||
await testHover( | ||
docUri, | ||
new vscode.Position(13, 15), | ||
"\n```\n(Parameter) Vpc: AWS::EC2::VPC::Id\n```\n" | ||
); | ||
}); | ||
}); | ||
|
||
export async function testHover( | ||
docUri: vscode.Uri, | ||
position: vscode.Position, | ||
expectedHover: string | ||
): Promise<void> { | ||
// Executing the command `vscode.executeHoverProvider` to simulate triggering hover | ||
const actualHovers = (await vscode.commands.executeCommand( | ||
"vscode.executeHoverProvider", | ||
docUri, | ||
position | ||
)) as vscode.Hover[]; | ||
|
||
const actualHover = actualHovers[0]; | ||
const gotMessage = (<vscode.MarkdownString>actualHover.contents[0]).value; | ||
assert.equal(expectedHover, gotMessage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.