From 542a6a34536212ce54cfe818ec95d356995a47dc Mon Sep 17 00:00:00 2001 From: Stephen Weatherford Date: Wed, 27 Mar 2024 15:21:28 -0700 Subject: [PATCH] Improve filter keywords for snippets --- .github/workflows/update-baselines.yml | 3 + .../baselines/Completions/declarations.json | 107 ++++++++++++++++ .../baselines/Completions/resourceTypes.json | 38 ++++++ .../ResourceTypeSearchKeywordsTests.cs | 117 ++++++++++++++++-- .../Completions/BicepCompletionProvider.cs | 8 +- .../Completions/ResourceTypeSearchKeywords.cs | 54 ++++++-- 6 files changed, 301 insertions(+), 26 deletions(-) diff --git a/.github/workflows/update-baselines.yml b/.github/workflows/update-baselines.yml index 1512c68bfde..e71fa94d7a2 100644 --- a/.github/workflows/update-baselines.yml +++ b/.github/workflows/update-baselines.yml @@ -9,6 +9,9 @@ jobs: main: name: Update Baselines runs-on: ubuntu-latest + permissions: + actions: write + contents: read env: # don't print dotnet logo diff --git a/src/Bicep.Core.Samples/Files/baselines/Completions/declarations.json b/src/Bicep.Core.Samples/Files/baselines/Completions/declarations.json index 8d4a92f7e93..e9a826dc98b 100644 --- a/src/Bicep.Core.Samples/Files/baselines/Completions/declarations.json +++ b/src/Bicep.Core.Samples/Files/baselines/Completions/declarations.json @@ -278,6 +278,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-aks-cluster", + "filterText": "res-aks-cluster,Kubernetes Service Cluster,aks,kubernetes,k8s,cluster,Microsoft.ContainerService/managedClusters", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -308,6 +309,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-api-management-instance", + "filterText": "res-api-management-instance,Api Management Instance,Microsoft.ApiManagement/service", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -338,6 +340,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-app-gateway", + "filterText": "res-app-gateway,Application Gateway,Microsoft.Network/applicationGateways", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -368,6 +371,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-app-gateway-waf", + "filterText": "res-app-gateway-waf,Application Gateway with Web Application Firewall,Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -398,6 +402,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-app-insights", + "filterText": "res-app-insights,Application Insights for Web Apps,Microsoft.Insights/components", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -428,6 +433,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-app-insights-alert-rules", + "filterText": "res-app-insights-alert-rules,Application Insights Alert Rules,Microsoft.Insights/alertrules", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -458,6 +464,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-app-insights-auto-scale-settings", + "filterText": "res-app-insights-auto-scale-settings,Application Insights Auto Scale Settings,Microsoft.Insights/autoscalesettings", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -488,6 +495,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-app-plan", + "filterText": "res-app-plan,Application Service Plan (Server Farm),asp,appserviceplan,hostingplan,Microsoft.Web/serverfarms", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -518,6 +526,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-app-security-group", + "filterText": "res-app-security-group,Application Security Group,Microsoft.Network/applicationSecurityGroups", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -548,6 +557,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-automation-account", + "filterText": "res-automation-account,Automation Account,Microsoft.Automation/automationAccounts", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -578,6 +588,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-automation-cert", + "filterText": "res-automation-cert,Automation Certificate,Microsoft.Automation/automationAccounts,Microsoft.Automation/automationAccounts/certificates", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -608,6 +619,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-automation-cred", + "filterText": "res-automation-cred,Automation Credential,Microsoft.Automation/automationAccounts,Microsoft.Automation/automationAccounts/credentials", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -638,6 +650,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-automation-job-schedule", + "filterText": "res-automation-job-schedule,Automation Job Schedule,Microsoft.Automation/automationAccounts,Microsoft.Automation/automationAccounts/jobSchedules", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -668,6 +681,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-automation-module", + "filterText": "res-automation-module,Automation Module,Microsoft.Automation/automationAccounts,Microsoft.Automation/automationAccounts/modules", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -698,6 +712,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-automation-runbook", + "filterText": "res-automation-runbook,Automation Runbook,Microsoft.Automation/automationAccounts,Microsoft.Automation/automationAccounts/runbooks", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -728,6 +743,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-automation-schedule", + "filterText": "res-automation-schedule,Automation Schedule,Microsoft.Automation/automationAccounts,Microsoft.Automation/automationAccounts/schedules", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -758,6 +774,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-automation-variable", + "filterText": "res-automation-variable,Automation Variable,Microsoft.Automation/automationAccounts,Microsoft.Automation/automationAccounts/variables", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -788,6 +805,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-availability-set", + "filterText": "res-availability-set,Availability Set,Microsoft.Compute/availabilitySets", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -818,6 +836,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-container-group", + "filterText": "res-container-group,Container Group,Microsoft.ContainerInstance/containerGroups", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -848,6 +867,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-container-registry", + "filterText": "res-container-registry,Container Registry,Microsoft.ContainerRegistry/registries", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -878,6 +898,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-cosmos-account", + "filterText": "res-cosmos-account,Cosmos DB Database Account,Microsoft.DocumentDB/databaseAccounts", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -908,6 +929,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-cosmos-cassandra-keyspace", + "filterText": "res-cosmos-cassandra-keyspace,Cosmos DB Cassandra Namespace,Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -938,6 +960,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-cosmos-cassandra-table", + "filterText": "res-cosmos-cassandra-table,Cosmos DB Cassandra Table,Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces,Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces/tables", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -968,6 +991,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-cosmos-gremlin-database", + "filterText": "res-cosmos-gremlin-database,Cosmos DB Gremlin Database,Microsoft.DocumentDB/databaseAccounts/gremlinDatabases", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -998,6 +1022,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-cosmos-gremlin-graph", + "filterText": "res-cosmos-gremlin-graph,Cosmos DB Gremlin Graph,Microsoft.DocumentDB/databaseAccounts/gremlinDatabases,Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1028,6 +1053,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-cosmos-mongo-database", + "filterText": "res-cosmos-mongo-database,Cosmos DB Mongo Database,Microsoft.DocumentDB/databaseAccounts/mongodbDatabases", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1058,6 +1084,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-cosmos-sql-container", + "filterText": "res-cosmos-sql-container,Cosmos DB SQL Container,Microsoft.DocumentDB/databaseAccounts/sqlDatabases,Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1088,6 +1115,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-cosmos-sql-database", + "filterText": "res-cosmos-sql-database,Cosmos DB SQL Database,Microsoft.DocumentDB/databaseAccounts/sqlDatabases", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1118,6 +1146,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-cosmos-tablestorage-table", + "filterText": "res-cosmos-tablestorage-table,Cosmos Table Storage,Microsoft.DocumentDB/databaseAccounts/tables", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1148,6 +1177,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-data-lake", + "filterText": "res-data-lake,Data Lake Store Account,Microsoft.DataLakeStore/accounts", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1178,6 +1208,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-dns-record", + "filterText": "res-dns-record,DNS Record,Microsoft.Network/dnsZones", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1208,6 +1239,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-dns-resolver", + "filterText": "res-dns-resolver,,Microsoft.Network/dnsResolvers", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1238,6 +1270,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-dns-zone", + "filterText": "res-dns-zone,DNS Zone,Microsoft.Network/dnsZones", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1268,6 +1301,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-expressroute-circuit", + "filterText": "res-expressroute-circuit,ExpressRoute Circuit,Microsoft.Network/expressRouteCircuits", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1298,6 +1332,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-expressroute-gateway", + "filterText": "res-expressroute-gateway,ExpressRoute Gateway,Microsoft.Network/expressRouteGateways", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1328,6 +1363,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-firewall-classic-rules", + "filterText": "res-firewall-classic-rules,Azure Firewall using classic rules,Microsoft.Network/azureFirewalls", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1358,6 +1394,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-firewall-policy-standard", + "filterText": "res-firewall-policy-standard,Azure Firewall Policy Standard SKU,Microsoft.Network/firewallPolicies", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1388,6 +1425,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-firewall-standard", + "filterText": "res-firewall-standard,Azure Firewall Standard SKU,Microsoft.Network/azureFirewalls", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1418,6 +1456,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-firewall-standard-vwan", + "filterText": "res-firewall-standard-vwan,Azure Firewall Standard SKU for Virtual WAN Hub,Microsoft.Network/azureFirewalls", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1448,6 +1487,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-function", + "filterText": "res-function,Azure Functions (v2),appservice,webapp,function,Microsoft.Web/sites", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1478,6 +1518,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-ip", + "filterText": "res-ip,Public IP Address,Microsoft.Network/publicIPAddresses", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1508,6 +1549,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-ip-prefix", + "filterText": "res-ip-prefix,Public IP Prefix,Microsoft.Network/publicIPPrefixes", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1538,6 +1580,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-keyvault", + "filterText": "res-keyvault,KeyVault,Microsoft.KeyVault/vaults", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1568,6 +1611,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-keyvault-secret", + "filterText": "res-keyvault-secret,Key Vault Secret,Microsoft.KeyVault/vaults/secrets", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1598,6 +1642,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-loadbalancer-external", + "filterText": "res-loadbalancer-external,External Load Balancer,Microsoft.Network/loadBalancers", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1628,6 +1673,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-loadbalancer-internal", + "filterText": "res-loadbalancer-internal,Internal Load Balancer,Microsoft.Network/loadBalancers", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1658,6 +1704,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-lock", + "filterText": "res-lock,,rbac,Microsoft.Authorization/locks", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1688,6 +1735,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-log-analytics-solution", + "filterText": "res-log-analytics-solution,Log Analytics Solution,Microsoft.OperationsManagement/solutions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1718,6 +1766,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-log-analytics-workspace", + "filterText": "res-log-analytics-workspace,Log Analytics Workspace,loganalytics,Microsoft.OperationalInsights/workspaces", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1748,6 +1797,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-logic-app", + "filterText": "res-logic-app,Logic App,Microsoft.Logic/workflows", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1778,6 +1828,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-logic-app-connector", + "filterText": "res-logic-app-connector,Logic App Connector,Microsoft.Web/connections", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1808,6 +1859,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-logic-app-from-file", + "filterText": "res-logic-app-from-file,Logic App,Microsoft.Logic/workflows", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1838,6 +1890,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-logic-app-integration", + "filterText": "res-logic-app-integration,Logic App Integration Account,Microsoft.Logic/integrationAccounts", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1868,6 +1921,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-managed-identity", + "filterText": "res-managed-identity,Managed Identity (User Assigned),Microsoft.ManagedIdentity/userAssignedIdentities", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1898,6 +1952,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-media", + "filterText": "res-media,Media Services account,Microsoft.Media/mediaServices", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1928,6 +1983,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-mg", + "filterText": "res-mg,Management Group(for tenant scope),Microsoft.Management/managementGroups", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1958,6 +2014,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-mysql", + "filterText": "res-mysql,MySQL Database,Microsoft.DBforMySQL/servers", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -1988,6 +2045,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-nic", + "filterText": "res-nic,Network Interface,Microsoft.Network/networkInterfaces", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2018,6 +2076,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-nsg", + "filterText": "res-nsg,Network Security Group,Microsoft.Network/networkSecurityGroups", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2048,6 +2107,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-nsgrule", + "filterText": "res-nsgrule,Network Security Group Rule,Microsoft.Network/networkSecurityGroups/securityRules", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2078,6 +2138,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-plan", + "filterText": "res-plan,Application Service Plan (Server Farm),asp,appserviceplan,hostingplan,Microsoft.Web/serverfarms", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2108,6 +2169,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policy-assignment", + "filterText": "res-policy-assignment,Policy Assignment,rbac,Microsoft.Authorization/policyAssignments", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2138,6 +2200,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policy-definition-audit-effect", + "filterText": "res-policy-definition-audit-effect,Policy Definition,rbac,Microsoft.Authorization/policyDefinitions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2168,6 +2231,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policy-definition-deploy-effect", + "filterText": "res-policy-definition-deploy-effect,Policy Definition,rbac,Microsoft.Authorization/policyDefinitions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2198,6 +2262,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policy-definition-modify-effect", + "filterText": "res-policy-definition-modify-effect,Policy Definition,rbac,Microsoft.Authorization/policyDefinitions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2228,6 +2293,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policy-exemption", + "filterText": "res-policy-exemption,Policy Exemption,rbac,Microsoft.Authorization/policyExemptions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2258,6 +2324,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policy-guestconfig", + "filterText": "res-policy-guestconfig,Guest configuration assignment for virtual machine,Microsoft.Compute/virtualMachines,Microsoft.GuestConfiguration/guestConfigurationAssignments", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2288,6 +2355,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policy-guestconfig-hybrid", + "filterText": "res-policy-guestconfig-hybrid,Guest configuration assignment for virtual machine,Microsoft.HybridCompute/machines,Microsoft.GuestConfiguration/guestConfigurationAssignments", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2318,6 +2386,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policy-guestconfig-params", + "filterText": "res-policy-guestconfig-params,Guest configuration assignment with parameters, for virtual machine,Microsoft.Compute/virtualMachines,Microsoft.GuestConfiguration/guestConfigurationAssignments", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2348,6 +2417,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policy-remediation", + "filterText": "res-policy-remediation,Policy Remediation,Microsoft.PolicyInsights/remediations", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2378,6 +2448,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-policyset-definition", + "filterText": "res-policyset-definition,PolicySet Definition,rbac,Microsoft.Authorization/policySetDefinitions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2408,6 +2479,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-private-endpoint", + "filterText": "res-private-endpoint,,Microsoft.Network/privateEndpoints", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2438,6 +2510,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-recovery-service-vault", + "filterText": "res-recovery-service-vault,Recovery Service Vault,Microsoft.RecoveryServices/vaults", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2468,6 +2541,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-redis", + "filterText": "res-redis,Redis Cache,Microsoft.Cache/Redis", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2498,6 +2572,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-rg", + "filterText": "res-rg,Resource Group,Microsoft.Resources/resourceGroups", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2528,6 +2603,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-role-assignment", + "filterText": "res-role-assignment,,rbac,Microsoft.Authorization/roleAssignments", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2558,6 +2634,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-route-server", + "filterText": "res-route-server,Route Server,Microsoft.Network/virtualHubs,Microsoft.Network/virtualHubs/ipConfigurations", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2588,6 +2665,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-route-table", + "filterText": "res-route-table,Route Table,Microsoft.Network/routeTables", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2618,6 +2696,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-route-table-route", + "filterText": "res-route-table-route,Azure Route Table Route,Microsoft.Network/routeTables/routes", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2648,6 +2727,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-scoped-lock", + "filterText": "res-scoped-lock,,rbac,Microsoft.Authorization/locks", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2678,6 +2758,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-service-bus", + "filterText": "res-service-bus,Service Bus Namespace,Microsoft.ServiceBus/namespaces", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2708,6 +2789,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-shared-image-gallery", + "filterText": "res-shared-image-gallery,Create Image Gallery,Microsoft.Compute/galleries", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2738,6 +2820,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-sql", + "filterText": "res-sql,SQL Database,Microsoft.Sql/servers,Microsoft.Sql/servers/databases", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2768,6 +2851,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-sql-db-import", + "filterText": "res-sql-db-import,SQL Database Import,Microsoft.Sql/servers/databases,Microsoft.Sql/servers/databases/extensions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2798,6 +2882,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-sql-server-firewall-rules", + "filterText": "res-sql-server-firewall-rules,SQL Server Firewall Rules,Microsoft.Sql/servers,Microsoft.Sql/servers/firewallRules", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2828,6 +2913,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-storage", + "filterText": "res-storage,Storage Account,Microsoft.Storage/storageAccounts", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2858,6 +2944,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-template-spec", + "filterText": "res-template-spec,Template spec,Microsoft.Resources/templateSpecs", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2888,6 +2975,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-traffic-manager", + "filterText": "res-traffic-manager,Traffic Manager Profile,Microsoft.Network/trafficManagerProfiles", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2918,6 +3006,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-virtual-wan", + "filterText": "res-virtual-wan,Virtual WAN,Microsoft.Network/virtualWans", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2948,6 +3037,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vm-dsc", + "filterText": "res-vm-dsc,Desired State Configuration PowerShell script for a Windows Virtual Machine,Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachines/extensions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -2978,6 +3068,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vm-linux-guestconfig-ext", + "filterText": "res-vm-linux-guestconfig-ext,Guest configuration extension for Linux virtual machine,Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachines/extensions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3008,6 +3099,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vm-script-linux", + "filterText": "res-vm-script-linux,Custom script extension for Linux Virtual Machine,Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachines/extensions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3038,6 +3130,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vm-script-windows", + "filterText": "res-vm-script-windows,Custom script extension for a Windows Virtual Machine,Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachines/extensions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3068,6 +3161,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vm-ubuntu", + "filterText": "res-vm-ubuntu,Ubuntu Virtual Machine,Microsoft.Compute/virtualMachines", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3098,6 +3192,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vm-windows", + "filterText": "res-vm-windows,Windows Virtual Machine,Microsoft.Compute/virtualMachines", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3128,6 +3223,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vm-windows-diagnostics", + "filterText": "res-vm-windows-diagnostics,Diagnostics Extension for a Windows Virtual Machine,Microsoft.Compute/virtualMachines/extensions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3158,6 +3254,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vm-windows-guestconfig-ext", + "filterText": "res-vm-windows-guestconfig-ext,Guest configuration assignment for Windows virtual machine,Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachines/extensions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3188,6 +3285,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vnet", + "filterText": "res-vnet,Virtual Network,Microsoft.Network/virtualNetworks", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3218,6 +3316,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vnet-peering", + "filterText": "res-vnet-peering,Virtual Network Peering,Microsoft.Network/virtualNetworks/virtualNetworkPeerings", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3248,6 +3347,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vpn-local-gateway", + "filterText": "res-vpn-local-gateway,VPN Local Network Gateway,Microsoft.Network/localNetworkGateways", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3278,6 +3378,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vpn-vnet-connection", + "filterText": "res-vpn-vnet-connection,VPN Virtual Network Connection,Microsoft.Network/connections", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3308,6 +3409,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-vpn-vnet-gateway", + "filterText": "res-vpn-vnet-gateway,VPN Virtual Network Gateway,Microsoft.Network/virtualNetworkGateways", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3338,6 +3440,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-web-app", + "filterText": "res-web-app,Web Application,appservice,webapp,function,Microsoft.Web/sites", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3368,6 +3471,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-web-app-deploy", + "filterText": "res-web-app-deploy,Web Deploy for a Web Application,appservice,webapp,function,Microsoft.Web/sites,appservice,webapp,function,Microsoft.Web/sites/extensions", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3398,6 +3502,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-wvd-appgroup", + "filterText": "res-wvd-appgroup,WVD AppGroup,Microsoft.DesktopVirtualization/applicationgroups", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3428,6 +3533,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-wvd-hostpool", + "filterText": "res-wvd-hostpool,WVD Host Pool,Microsoft.DesktopVirtualization/hostpools", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -3458,6 +3564,7 @@ "deprecated": false, "preselect": false, "sortText": "2_res-wvd-workspace", + "filterText": "res-wvd-workspace,WVD Workspace,Microsoft.DesktopVirtualization/workspaces", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { diff --git a/src/Bicep.Core.Samples/Files/baselines/Completions/resourceTypes.json b/src/Bicep.Core.Samples/Files/baselines/Completions/resourceTypes.json index 59236731bf2..00350595249 100644 --- a/src/Bicep.Core.Samples/Files/baselines/Completions/resourceTypes.json +++ b/src/Bicep.Core.Samples/Files/baselines/Completions/resourceTypes.json @@ -4826,6 +4826,7 @@ "deprecated": false, "preselect": false, "sortText": "000000d3", + "filterText": "'rbac,Microsoft.Authorization/accessReviewHistoryDefinitions'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -4847,6 +4848,7 @@ "deprecated": false, "preselect": false, "sortText": "000000d4", + "filterText": "'rbac,Microsoft.Authorization/accessReviewScheduleDefinitions'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -4868,6 +4870,7 @@ "deprecated": false, "preselect": false, "sortText": "000000d5", + "filterText": "'rbac,Microsoft.Authorization/accessReviewScheduleDefinitions/instances'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -4889,6 +4892,7 @@ "deprecated": false, "preselect": false, "sortText": "000000d6", + "filterText": "'rbac,Microsoft.Authorization/accessReviewScheduleDefinitions/instances/decisions'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -4910,6 +4914,7 @@ "deprecated": false, "preselect": false, "sortText": "000000d7", + "filterText": "'rbac,Microsoft.Authorization/accessReviewScheduleSettings'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -4931,6 +4936,7 @@ "deprecated": false, "preselect": false, "sortText": "000000d8", + "filterText": "'rbac,Microsoft.Authorization/dataPolicyManifests'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -4952,6 +4958,7 @@ "deprecated": false, "preselect": false, "sortText": "000000d9", + "filterText": "'rbac,Microsoft.Authorization/locks'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -4973,6 +4980,7 @@ "deprecated": false, "preselect": false, "sortText": "000000da", + "filterText": "'rbac,Microsoft.Authorization/policyAssignments'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -4994,6 +5002,7 @@ "deprecated": false, "preselect": false, "sortText": "000000db", + "filterText": "'rbac,Microsoft.Authorization/policyDefinitions'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5015,6 +5024,7 @@ "deprecated": false, "preselect": false, "sortText": "000000dc", + "filterText": "'rbac,Microsoft.Authorization/policyDefinitions/versions'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5036,6 +5046,7 @@ "deprecated": false, "preselect": false, "sortText": "000000dd", + "filterText": "'rbac,Microsoft.Authorization/policyExemptions'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5057,6 +5068,7 @@ "deprecated": false, "preselect": false, "sortText": "000000de", + "filterText": "'rbac,Microsoft.Authorization/policySetDefinitions'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5078,6 +5090,7 @@ "deprecated": false, "preselect": false, "sortText": "000000df", + "filterText": "'rbac,Microsoft.Authorization/policySetDefinitions/versions'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5099,6 +5112,7 @@ "deprecated": false, "preselect": false, "sortText": "000000e0", + "filterText": "'rbac,Microsoft.Authorization/privateLinkAssociations'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5120,6 +5134,7 @@ "deprecated": false, "preselect": false, "sortText": "000000e1", + "filterText": "'rbac,Microsoft.Authorization/resourceManagementPrivateLinks'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5141,6 +5156,7 @@ "deprecated": false, "preselect": false, "sortText": "000000e2", + "filterText": "'rbac,Microsoft.Authorization/roleAssignmentApprovals'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5162,6 +5178,7 @@ "deprecated": false, "preselect": false, "sortText": "000000e3", + "filterText": "'rbac,Microsoft.Authorization/roleAssignmentApprovals/stages'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5183,6 +5200,7 @@ "deprecated": false, "preselect": false, "sortText": "000000e5", + "filterText": "'rbac,Microsoft.Authorization/roleAssignmentScheduleRequests'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5226,6 +5244,7 @@ "deprecated": false, "preselect": false, "sortText": "000000e6", + "filterText": "'rbac,Microsoft.Authorization/roleDefinitions'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5247,6 +5266,7 @@ "deprecated": false, "preselect": false, "sortText": "000000e7", + "filterText": "'rbac,Microsoft.Authorization/roleEligibilityScheduleRequests'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5268,6 +5288,7 @@ "deprecated": false, "preselect": false, "sortText": "000000e8", + "filterText": "'rbac,Microsoft.Authorization/roleManagementPolicyAssignments'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5289,6 +5310,7 @@ "deprecated": false, "preselect": false, "sortText": "000000e9", + "filterText": "'rbac,Microsoft.Authorization/variables'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -5310,6 +5332,7 @@ "deprecated": false, "preselect": false, "sortText": "000000ea", + "filterText": "'rbac,Microsoft.Authorization/variables/values'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -37957,6 +37980,7 @@ "deprecated": false, "preselect": false, "sortText": "0000071a", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -37978,6 +38002,7 @@ "deprecated": false, "preselect": false, "sortText": "0000071b", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/dataCollectorLogs'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -37999,6 +38024,7 @@ "deprecated": false, "preselect": false, "sortText": "0000071c", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/dataExports'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38020,6 +38046,7 @@ "deprecated": false, "preselect": false, "sortText": "0000071d", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/dataSources'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38041,6 +38068,7 @@ "deprecated": false, "preselect": false, "sortText": "0000071e", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/features/clientGroups'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38062,6 +38090,7 @@ "deprecated": false, "preselect": false, "sortText": "0000071f", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/features/machineGroups'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38083,6 +38112,7 @@ "deprecated": false, "preselect": false, "sortText": "00000720", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/features/machines'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38104,6 +38134,7 @@ "deprecated": false, "preselect": false, "sortText": "00000721", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/features/machines/ports'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38125,6 +38156,7 @@ "deprecated": false, "preselect": false, "sortText": "00000722", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/features/machines/processes'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38146,6 +38178,7 @@ "deprecated": false, "preselect": false, "sortText": "00000723", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/features/summaries'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38167,6 +38200,7 @@ "deprecated": false, "preselect": false, "sortText": "00000724", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/linkedServices'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38188,6 +38222,7 @@ "deprecated": false, "preselect": false, "sortText": "00000725", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/linkedStorageAccounts'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38209,6 +38244,7 @@ "deprecated": false, "preselect": false, "sortText": "00000726", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/savedSearches'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38230,6 +38266,7 @@ "deprecated": false, "preselect": false, "sortText": "00000727", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/storageInsightConfigs'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { @@ -38251,6 +38288,7 @@ "deprecated": false, "preselect": false, "sortText": "00000728", + "filterText": "'loganalytics,Microsoft.OperationalInsights/workspaces/tables'", "insertTextFormat": "snippet", "insertTextMode": "adjustIndentation", "textEdit": { diff --git a/src/Bicep.LangServer.UnitTests/Completions/ResourceTypeSearchKeywordsTests.cs b/src/Bicep.LangServer.UnitTests/Completions/ResourceTypeSearchKeywordsTests.cs index e6e02f3410e..95cd7a88c2f 100644 --- a/src/Bicep.LangServer.UnitTests/Completions/ResourceTypeSearchKeywordsTests.cs +++ b/src/Bicep.LangServer.UnitTests/Completions/ResourceTypeSearchKeywordsTests.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Bicep.Core.Resources; using Bicep.LanguageServer.Completions; +using Bicep.LanguageServer.Snippets; using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; using OmniSharp.Extensions.LanguageServer.Protocol.Models; @@ -18,20 +19,19 @@ namespace Bicep.LangServer.UnitTests.Completions [TestClass] public class ResourceTypeSearchKeywordsTests { - [DataRow("Microsoft.Web/sites", "'appservice,webapp,function,Microsoft.Web/sites'")] - [DataRow("microsoft.web/sites", "'appservice,webapp,function,microsoft.web/sites'")] - [DataRow("microsoft.app/abc", "'containerapp,microsoft.app/abc'")] - [DataRow("Microsoft.ContainerService/managedClusters", "'aks,kubernetes,k8s,cluster,Microsoft.ContainerService/managedClusters'")] - [DataRow("toplevel1", "'top level keyword,toplevel1'")] - [DataRow("toplevel1/secondlevel1", "'top level keyword,toplevel1/secondlevel1'")] - [DataRow("toplevel1/secondlevel2", "'top level keyword,toplevel1/secondlevel2'")] - [DataRow("toplevel1/secondlevel1/thirdlevel", "'top level keyword,toplevel1/secondlevel1/thirdlevel'")] + [DataRow("Microsoft.Web/sites", "'Microsoft.Web/sites appservice webapp function'")] + [DataRow("microsoft.web/sites", "'microsoft.web/sites appservice webapp function'")] + [DataRow("microsoft.app/abc", "'microsoft.app/abc containerapp'")] + [DataRow("Microsoft.ContainerService/managedClusters", "'Microsoft.ContainerService/managedClusters aks kubernetes k8s cluster'")] + [DataRow("toplevel1", "'toplevel1 top level keyword'")] + [DataRow("toplevel1/secondlevel1", "'toplevel1/secondlevel1 top level keyword'")] + [DataRow("toplevel1/secondlevel2", "'toplevel1/secondlevel2 top level keyword'")] + [DataRow("toplevel1/secondlevel1/thirdlevel", "'toplevel1/secondlevel1/thirdlevel top level keyword'")] [DataRow("toplevel2", null)] - [DataRow("toplevel2/secondlevel1", "'second level keyword,toplevel2/secondlevel1'")] + [DataRow("toplevel2/secondlevel1", "'toplevel2/secondlevel1 second level keyword'")] [DataRow("toplevel2/secondlevel2", null)] [DataRow("toplevel2/secondlevel2/thirdlevel", null)] - [DataRow("toplevel2/secondlevel1/thirdlevel", "'second level keyword,toplevel2/secondlevel1/thirdlevel'")] - + [DataRow("toplevel2/secondlevel1/thirdlevel", "'toplevel2/secondlevel1/thirdlevel second level keyword'")] [DataTestMethod] public void TryGetResourceTypeFilterText(string resourceType, string? expectedFilter) { @@ -46,7 +46,100 @@ public void TryGetResourceTypeFilterText(string resourceType, string? expectedFi ["toplevel2/secondlevel1"] = ["second level keyword"], }); - var result = sut.TryGetResourceTypeFilterText(new ResourceTypeReference(resourceType, "2020-06-01")); + var result = sut.TryGetResourceTypeFilterText(new ResourceTypeReference(resourceType, "2020-06-01"), surroundWithSingleQuotes: true); + + result.Should().Be(expectedFilter); + } + + [DataRow( + "res-app-plan", + "Application Service Plan (Server Farm)", + """ + no resources + """, + null)] + [DataRow( + "res-app-plan", + "Application Service Plan (Server Farm)", + """ + resource /*${1:appServicePlan}*/appServicePlan 'Microsoft.Web/serverfarms@2020-12-01' = { + name: /*${2:'name'}*/'name' + location: /*${3:location}*/'location' + sku: { + name: 'F1' + capacity: 1 + } + } + """, + "res-app-plan Application Service Plan (Server Farm) Microsoft.Web/serverfarms asp appserviceplan hostingplan")] + [DataRow( + "res-app-plan", + "Application Service Plan (Server Farm)", + """ + resource /*${1:appServicePlan}*/appServicePlan 'Microsoft.Web/serverfarms@2020-12-01' = { + name: /*${2:'name'}*/'name' + location: /*${3:location}*/'location' + sku: { + name: 'F1' + capacity: 1 + } + } + resource /*${1:appServicePlan}*/appServicePlan 'Microsoft.Web/serverfarms@3333-12-01' = { + name: /*${2:'name'}*/'name' + location: /*${3:location}*/'location' + sku: { + name: 'F1' + capacity: 1 + } + } + resource /*${1:appServicePlan}*/appServicePlan 'Microsoft.Web/unknown@2020-12-01-beta' = { + name: /*${2:'name'}*/'name' + location: /*${3:location}*/'location' + sku: { + name: reference + capacity: 1 + } + } + """, + "res-app-plan Application Service Plan (Server Farm) Microsoft.Web/serverfarms asp appserviceplan hostingplan Microsoft.Web/unknown")] + [DataRow( + "res-automation-job-schedule", + "Automation Job Schedule", + """ + resource automationAccount 'Microsoft.Automation/automationAccounts@2019-06-01' = { + name: /*${1:'name'}*/'name' + } + + resource /*${2:automationJobSchedule}*/automationJobSchedule 'Microsoft.Automation/automationAccounts/jobSchedules@2019-06-01' = { + parent: automationAccount + name: /*${3:'name'}*/'name' + properties: { + schedule: { + name: /*${4:'name'}*/'name' + } + runbook: { + name: /*${5:'name'}*/'name' + } + } + } + """, + "res-automation-job-schedule Automation Job Schedule Microsoft.Automation/automationAccounts Microsoft.Automation/automationAccounts/jobSchedules")] + [DataTestMethod] + public void TryGetSnippetFilterText(string prefix, string detail, string text, string? expectedFilter) + { + var sut = new ResourceTypeSearchKeywords(new Dictionary + { + ["Microsoft.Web/sites"] = ["appservice", "webapp", "function"], + ["Microsoft.Web/serverFarms"] = ["asp", "appserviceplan", "hostingplan"], + ["MICROSOFT.APP"] = ["containerapp"], + ["Microsoft.ContainerService"] = ["aks", "kubernetes", "k8s", "cluster"], + ["Microsoft.Authorization/roleAssignments"] = ["rbac"], + ["toplevel1"] = ["top level keyword"], + ["toplevel2/secondlevel1"] = ["second level keyword"], + }); + + var snippet = new Snippet(text, prefix: prefix, detail: detail); + var result = sut.TryGetSnippetFilterText(snippet); result.Should().Be(expectedFilter); } diff --git a/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs b/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs index a9252cab07a..d52d7c101d6 100644 --- a/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs +++ b/src/Bicep.LangServer/Completions/BicepCompletionProvider.cs @@ -185,7 +185,8 @@ private IEnumerable GetDeclarationCompletions(SemanticModel mode resourceSnippet.Text, context.ReplacementRange, command, - resourceSnippet.CompletionPriority); + resourceSnippet.CompletionPriority, + filterText: ResourceTypeSearchKeywords.TryGetSnippetFilterText(resourceSnippet)); } break; @@ -1886,7 +1887,7 @@ private static CompletionItem CreateResourceTypeCompletion(ResourceTypeReference MarkdownHelper.AppendNewline($"Type: `{resourceType.Type}`")) .WithFollowupCompletion("resource type completion") .WithSortText(index.ToString("x8")) - .WithFilterText(ResourceTypeSearchKeywords.TryGetResourceTypeFilterText(resourceType)) + .WithFilterText(ResourceTypeSearchKeywords.TryGetResourceTypeFilterText(resourceType, surroundWithSingleQuotes: true)) .Build(); } } @@ -1943,13 +1944,14 @@ private static CompletionItem CreateContextualSnippetCompletion(string label, st /// /// Creates a completion with a contextual snippet with command option. This will look like a snippet to the user. /// - private static CompletionItem CreateContextualSnippetCompletion(string label, string detail, string snippet, Range replacementRange, Command command, CompletionPriority priority = CompletionPriority.Medium, bool preselect = false) => + private static CompletionItem CreateContextualSnippetCompletion(string label, string detail, string snippet, Range replacementRange, Command command, CompletionPriority priority = CompletionPriority.Medium, bool preselect = false, string? filterText = null) => CompletionItemBuilder.Create(CompletionItemKind.Snippet, label) .WithSnippetEdit(replacementRange, snippet) .WithCommand(command) .WithDetail(detail) .WithDocumentation(MarkdownHelper.CodeBlock(new Snippet(snippet).FormatDocumentation())) .WithSortText(GetSortText(label, priority)) + .WithFilterText(filterText) .Preselect(preselect) .Build(); diff --git a/src/Bicep.LangServer/Completions/ResourceTypeSearchKeywords.cs b/src/Bicep.LangServer/Completions/ResourceTypeSearchKeywords.cs index 9f58b6f7a00..b039df787d0 100644 --- a/src/Bicep.LangServer/Completions/ResourceTypeSearchKeywords.cs +++ b/src/Bicep.LangServer/Completions/ResourceTypeSearchKeywords.cs @@ -6,13 +6,15 @@ using System.Collections.Immutable; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Bicep.Core.Parsing; using Bicep.Core.Resources; +using Bicep.LanguageServer.Snippets; namespace Bicep.LanguageServer.Completions { - public class ResourceTypeSearchKeywords + public partial class ResourceTypeSearchKeywords { private readonly ImmutableDictionary> keywordsMap; @@ -27,6 +29,8 @@ public ResourceTypeSearchKeywords() : this ["Microsoft.ContainerService"] = ["aks", "kubernetes", "k8s", "cluster"], ["Microsoft.Authorization/roleAssignments"] = ["rbac"], ["Microsoft.DocumentDb"] = ["cosmosdb"], + ["Microsoft.Authorization"] = ["rbac"], + ["Microsoft.OperationalInsights/workspaces"] = ["loganalytics"], }) { } @@ -45,30 +49,58 @@ public ResourceTypeSearchKeywords(IDictionary keywordsMap) this.keywordsMap = keywordsMap.ToImmutableDictionary(x => x.Key.ToLowerInvariant(), x => x.Value.ToImmutableArray(), StringComparer.InvariantCultureIgnoreCase); } - public string? TryGetResourceTypeFilterText(ResourceTypeReference resourceType) + public string? TryGetResourceTypeFilterText(ResourceTypeReference resourceType, bool surroundWithSingleQuotes = false) { - var filter = resourceType.Type; + var typeName = resourceType.Type; ImmutableArray keywords; // We want to search using the top-level resource type, including subtypes // Microsoft.web/serverFarms/xxx -> top-level key is Microsoft.web // Microsoft.web/serverFarms/xxx -> second-level key is Microsoft.web/serverFarms - var indexFirstSlash = filter.IndexOf('/'); - var topLevelKey = indexFirstSlash > 0 ? filter[0..indexFirstSlash] : filter; + var indexFirstSlash = typeName.IndexOf('/'); + var topLevelKey = indexFirstSlash > 0 ? typeName[0..indexFirstSlash] : typeName; if (!keywordsMap.TryGetValue(topLevelKey, out keywords)) { if (indexFirstSlash > 0) { - var indexSecondSlash = filter.IndexOf('/', indexFirstSlash + 1); - var secondLevelKey = indexSecondSlash > 0 ? filter[0..indexSecondSlash] : filter; + var indexSecondSlash = typeName.IndexOf('/', indexFirstSlash + 1); + var secondLevelKey = indexSecondSlash > 0 ? typeName[0..indexSecondSlash] : typeName; keywordsMap.TryGetValue(secondLevelKey, out keywords); } } - // The filter text, like the insertText, must include the single quotes that surround the resource type in the resource declaration - return !keywords.IsDefaultOrEmpty ? - StringUtils.EscapeBicepString($"{string.Join(',', keywords)},{filter}") : - null; // null - let vscode use the default (label) + var result = keywords.IsDefaultOrEmpty ? + null : // null - let vscode use the default (label) + string.Join(' ', keywords.Prepend(typeName)); + + return result is string && surroundWithSingleQuotes ? StringUtils.EscapeBicepString(result) : result; + } + + public string? TryGetSnippetFilterText(Snippet snippet) + { + var resourceTypesUsed = GetResourceTypesFromBicepText(snippet.Text); + if (resourceTypesUsed.Length == 0) + { + // Don't provide filter text for non-resource snippets (e.g. param, var, output), just let vscode use label + return null; + } + + // Add the resource type and its keywords for all resourced used in the snippet + var resourceTypeFilters = resourceTypesUsed.Select(rt => TryGetResourceTypeFilterText(new ResourceTypeReference(rt, null)) ?? rt).ToArray(); + return $"{snippet.Prefix} {snippet.Detail} {string.Join(' ', resourceTypeFilters)}"; + } + + // Example match: resource /*${1:appServicePlan}*/appServicePlan 'Microsoft.Web/serverfarms@2020-12-01' = { + // => "Microsoft.Web/serverfarms" + [GeneratedRegex("""'(?[a-z][a-z0-9.]+/[a-z0-9./]+)@[a-z0-9-]+'""", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace)] + private static partial Regex RegexResourceType(); + + private string[] GetResourceTypesFromBicepText(string snippetText) + { + var matches = RegexResourceType().Matches(snippetText); + return matches.Select(m => m.Groups[1].Value) + .Distinct() + .ToArray(); } } }