Skip to content

Commit

Permalink
feat: add new lwc directives as autocomplete options in 242/258 (#565)
Browse files Browse the repository at this point in the history
* feat: add new lwc directives as autocomplete options in 242/258

* chore: wrong descriptions

* chore: fix in README

* test: fixed test
  • Loading branch information
CristiCanizales committed Apr 19, 2023
1 parent cdddc30 commit 93c8794
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ npm run compile
Note: complete the install process before this step, or you may receive errors about "Property ‘objType’ does not exist on type ‘Node’." from the Tern Server. This is due to the node_modules being improperly installed at a level above the lightning-language-server. If this does happen to you, simply remove the extra node_modules directory.

```
cd lightning-language-server
cd ../lightning-language-server
code ./vscode-workspaces/multiroot-simple.code-workspace # or
code ./vscode-workspaces/multiroot-flat.code-workspace
```
Expand Down
34 changes: 32 additions & 2 deletions packages/lwc-language-server/scripts/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const globalAttributes = [
},
{
name: 'if:true',
description: 'Renders the element or template if the expression value is truthy.',
description: 'Renders the element or template if the expression value is truthy. This directive is deprecated and no longer recommended. It may be removed in the future. Use lwc:if, lwc:elseif, and lwc:else instead.',
references: [
{
name: 'Salesforce',
Expand All @@ -94,7 +94,37 @@ const globalAttributes = [
},
{
name: 'if:false',
description: 'Renders the element or template if the expression value is falsy.',
description: 'Renders the element or template if the expression value is falsy. This directive is deprecated and no longer recommended. It may be removed in the future. Use lwc:if, lwc:elseif, and lwc:else instead.',
references: [
{
name: 'Salesforce',
url: 'https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_directives',
},
],
},
{
name: 'lwc:if',
description: 'Renders the element or template if the expression value is truthy.',
references: [
{
name: 'Salesforce',
url: 'https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_directives',
},
],
},
{
name: 'lwc:elseif',
description: 'Renders the element or template if the expression value is truthy.',
references: [
{
name: 'Salesforce',
url: 'https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_directives',
},
],
},
{
name: 'lwc:else',
description: 'Renders the element or template if none of the expressions values of the preceding lwc:if or lwc:elseif are truthy.',
references: [
{
name: 'Salesforce',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ describe('provideAttributes()', () => {
it('should return a set list of attributes for template tag', () => {
const attributes = provider.provideAttributes('template');
expect(attributes).not.toBeEmpty();
expect(attributes).toBeArrayOfSize(6);
expect(attributes).toBeArrayOfSize(9);
expect(attributes[0].name).toEqual('for:each');
expect(attributes[1].name).toEqual('for:item');
expect(attributes[2].name).toEqual('for:index');
expect(attributes[3].name).toEqual('if:true');
expect(attributes[4].name).toEqual('if:false');
expect(attributes[5].name).toEqual('iterator:it');
expect(attributes[5].name).toEqual('lwc:if');
expect(attributes[6].name).toEqual('lwc:elseif');
expect(attributes[7].name).toEqual('lwc:else');
expect(attributes[8].name).toEqual('iterator:it');
});
});
34 changes: 32 additions & 2 deletions packages/lwc-language-server/src/resources/standard-lwc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3679,7 +3679,7 @@
},
{
"name": "if:true",
"description": "Renders the element or template if the expression value is truthy.",
"description": "Renders the element or template if the expression value is truthy. This directive is deprecated and no longer recommended. It may be removed in the future. Use lwc:if, lwc:elseif, and lwc:else instead.",
"references": [
{
"name": "Salesforce",
Expand All @@ -3689,7 +3689,37 @@
},
{
"name": "if:false",
"description": "Renders the element or template if the expression value is falsy.",
"description": "Renders the element or template if the expression value is falsy. This directive is deprecated and no longer recommended. It may be removed in the future. Use lwc:if, lwc:elseif, and lwc:else instead.",
"references": [
{
"name": "Salesforce",
"url": "https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_directives"
}
]
},
{
"name": "lwc:if",
"description": "Renders the element or template if the expression value is truthy.",
"references": [
{
"name": "Salesforce",
"url": "https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_directives"
}
]
},
{
"name": "lwc:elseif",
"description": "Renders the element or template if the expression value is truthy.",
"references": [
{
"name": "Salesforce",
"url": "https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_directives"
}
]
},
{
"name": "lwc:else",
"description": "Renders the element or template if none of the expressions values of the preceding lwc:if or lwc:elseif are truthy.",
"references": [
{
"name": "Salesforce",
Expand Down

0 comments on commit 93c8794

Please sign in to comment.