generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 1
Add description to autocomplete #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b9152d8
Adding description to autocomplete suggestion
gemammercado b75a1c9
Add description markdowns on autocomplete for property types and getA…
gemammercado d094e13
Removing extra test in Autocomplete.test.ts
gemammercado 32c684f
Fixed return value for getGetAttCompletions, added unit test for Comp…
gemammercado ed9ca86
fix lint errors, add error logging to empty catch block
gemammercado 2803eb1
Changed jsonPointerPath replaceAll to /. Now descriptions are found f…
gemammercado 02beae1
Add data parameter to createCompletionItem
gemammercado 85bbd99
Merge branch 'main' into documentation-fix
gemammercado 333fa9b
Merge branch 'main' into documentation-fix
gemammercado d9e1afb
Merge branch 'main' into documentation-fix
gemammercado 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,94 @@ | ||
| import { describe, expect, test } from 'vitest'; | ||
| import { CompletionItemKind, MarkupContent, MarkupKind } from 'vscode-languageserver'; | ||
| import { createCompletionItem } from '../../../src/autocomplete/CompletionUtils'; | ||
|
|
||
| describe('CompletionUtils', () => { | ||
| describe('createCompletionItem', () => { | ||
| describe('documentation handling', () => { | ||
| const stringDoc = 'This is a test documentation'; | ||
| const expectedStringResult = 'This is a test documentation\n\nSource: AWS CloudFormation'; | ||
|
|
||
| const markupDoc = { kind: MarkupKind.Markdown, value: '**Bold** documentation' }; | ||
| const expectedMarkupResult = { | ||
| kind: MarkupKind.Markdown, | ||
| value: '**Bold** documentation\n\n**Source:** AWS CloudFormation', | ||
| }; | ||
|
|
||
| const emptyDoc = ''; | ||
| const defaultSource = 'Source: AWS CloudFormation'; | ||
|
|
||
| const markdownDoc = { kind: MarkupKind.Markdown, value: '**Bold** text' }; | ||
| const plainTextDoc = { kind: MarkupKind.PlainText, value: 'Plain text' }; | ||
|
|
||
| const complexMarkdown = { | ||
| kind: MarkupKind.Markdown, | ||
| value: `# S3 Bucket | ||
|
|
||
| Creates an **Amazon S3** bucket with: | ||
| - Versioning enabled | ||
| - Public access *blocked* | ||
| - [Documentation](https://docs.aws.amazon.com)`, | ||
| }; | ||
|
|
||
| const expectedComplexMarkdown = { | ||
| kind: MarkupKind.Markdown, | ||
| value: `# S3 Bucket | ||
|
|
||
| Creates an **Amazon S3** bucket with: | ||
| - Versioning enabled | ||
| - Public access *blocked* | ||
| - [Documentation](https://docs.aws.amazon.com) | ||
|
|
||
| **Source:** AWS CloudFormation`, | ||
| }; | ||
|
|
||
| test('should handle string documentation with source attribution', () => { | ||
| const result = createCompletionItem('Test', CompletionItemKind.Keyword, { | ||
| documentation: stringDoc, | ||
| }); | ||
| expect(result.documentation).toEqual(expectedStringResult); | ||
| }); | ||
|
|
||
| test('should handle MarkupContent documentation with source attribution', () => { | ||
| const result = createCompletionItem('Test', CompletionItemKind.Keyword, { | ||
| documentation: markupDoc, | ||
| }); | ||
| expect(result.documentation).toEqual(expectedMarkupResult); | ||
| }); | ||
|
|
||
| test('should handle undefined documentation with default source', () => { | ||
| const result = createCompletionItem('Test', CompletionItemKind.Keyword); | ||
| expect(result.documentation).toEqual(defaultSource); | ||
| }); | ||
|
|
||
| test('should handle empty string documentation', () => { | ||
| const result = createCompletionItem('Test', CompletionItemKind.Keyword, { | ||
| documentation: emptyDoc, | ||
| }); | ||
| expect(result.documentation).toEqual(defaultSource); | ||
| }); | ||
|
|
||
| test('should preserve MarkupContent kind when adding source attribution', () => { | ||
| const markdownResult = createCompletionItem('Test', CompletionItemKind.Keyword, { | ||
| documentation: markdownDoc, | ||
| }); | ||
| const markdownAsMarkup = markdownResult.documentation as MarkupContent; | ||
| expect(markdownAsMarkup.kind).toEqual(MarkupKind.Markdown); | ||
|
|
||
| const plainTextResult = createCompletionItem('Test', CompletionItemKind.Keyword, { | ||
| documentation: plainTextDoc, | ||
| }); | ||
| const plainTextAsMarkup = plainTextResult.documentation as MarkupContent; | ||
| expect(plainTextAsMarkup.kind).toEqual(MarkupKind.PlainText); | ||
| }); | ||
|
|
||
| test('should handle MarkupContent with existing markdown formatting', () => { | ||
| const result = createCompletionItem('Test', CompletionItemKind.Keyword, { | ||
| documentation: complexMarkdown, | ||
| }); | ||
|
|
||
| expect(result.documentation).toEqual(expectedComplexMarkdown); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.