diff --git a/vscode/DscExt/src/extension.ts b/vscode/DscExt/src/extension.ts index fdd469de..d98b1790 100644 --- a/vscode/DscExt/src/extension.ts +++ b/vscode/DscExt/src/extension.ts @@ -33,27 +33,31 @@ export function activate(context: vscode.ExtensionContext) { } const dataArray = JSON.parse(fs.readFileSync(ps_cache_file_path, 'utf-8')); - const all_props_completion = new vscode.CompletionItem(dataArray.ResourceCache[0].Type); - const key_props_completion = new vscode.CompletionItem(dataArray.ResourceCache[0].Type + " [keys only]"); - - let all_props_comp_text: string = ' ' + dataArray.ResourceCache[0].Type; - let key_props_comp_text: string = ' ' + dataArray.ResourceCache[0].Type; - all_props_comp_text += '\nproperties:'; - key_props_comp_text += '\nproperties:'; - dataArray.ResourceCache[0].DscResourceInfo.Properties.forEach(function (value: any) { - all_props_comp_text += '\n ' + value.Name + ':'; - if (value.IsMandatory) - { - key_props_comp_text += '\n ' + value.Name + ':'; - } + var completions:vscode.CompletionItem[] = []; + dataArray.ResourceCache.forEach(function (resouce: any) { + + const all_props_completion = new vscode.CompletionItem(resouce.Type); + const key_props_completion = new vscode.CompletionItem(resouce.Type + " [keys only]"); + + let all_props_comp_text: string = ' ' + resouce.Type; + let key_props_comp_text: string = ' ' + resouce.Type; + all_props_comp_text += '\nproperties:'; + key_props_comp_text += '\nproperties:'; + resouce.DscResourceInfo.Properties.forEach(function (prop: any) { + all_props_comp_text += '\n ' + prop.Name + ': '; + if (prop.IsMandatory) + { + key_props_comp_text += '\n ' + prop.Name + ': '; + } + }); + all_props_completion.insertText = new vscode.SnippetString(all_props_comp_text); + key_props_completion.insertText = new vscode.SnippetString(key_props_comp_text); + + completions.push(all_props_completion); + completions.push(key_props_completion); }); - all_props_completion.insertText = new vscode.SnippetString(all_props_comp_text); - key_props_completion.insertText = new vscode.SnippetString(key_props_comp_text); - return [ - all_props_completion, - key_props_completion - ]; + return completions; } }, ':' // triggered whenever a ':' is being typed