This repository has been archived by the owner on Sep 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Add initial custom-element standard snippet #106
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,19 @@ | ||
import {CompletionItemKind, InsertTextFormat} from 'vscode-languageserver'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. License |
||
|
||
export default [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommend giving this a name, as these are specifically snippets for when the user is in a JS file. |
||
{ | ||
label: `custom-element`, | ||
documentation: 'Snippet for definition of a custom-element.', | ||
insertText: | ||
`class $1 extends HTMLElement { | ||
constructor() { | ||
super(); | ||
$0 | ||
} | ||
} | ||
customElements.define('$2', $1)`, | ||
insertTextFormat: InsertTextFormat.Snippet, | ||
kind: CompletionItemKind.Class, | ||
filterText: 'customelement', | ||
} | ||
]; |
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ import {ResolvedUrl} from 'polymer-analyzer/lib/model/url'; | |
import {CompletionItem, CompletionItemKind, CompletionList, InsertTextFormat} from 'vscode-languageserver/lib/main'; | ||
|
||
import {createTestEnvironment} from './util'; | ||
import standardSnippets from '../standard-snippets'; | ||
|
||
const fixtureDir = path.join(__dirname, '..', '..', 'src', 'test', 'static'); | ||
|
||
|
@@ -437,7 +438,7 @@ suite('AutoCompleter', () => { | |
await client.openFile(indexFile, '<script>\n\n</script>\n' + indexContents); | ||
const completions = | ||
await client.getCompletions(indexFile, {line: 1, column: 0}); | ||
assert.deepEqual(completions, {isIncomplete: true, items: []}); | ||
assert.deepEqual(completions, {isIncomplete: false, items: standardSnippets}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the test name |
||
}); | ||
|
||
{ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, should explicitly check for the location being inside of a script section, as we might add other location kinds.
For bonus points it would be cool to do to JS what we did for CSS, and have an entire class of result for locResult.language ===
js
but that might be more than you're interested in doing right now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a TODO, as I tried to make that work, but it required new AST traversal methods in
ast-from-source-position
, which seemed too much for this PR. Should be fixed someday though 😄