Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

fix: Support auto-import for annotations #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/providers/autoImportActionProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function getImportChoice(missingType, editor, typeRange, languageClient) {
function buildImportSuggestion(autocompleteSuggestion) {
switch (autocompleteSuggestion.type) {
case 'class':
case 'mixin':
const { displayText } = autocompleteSuggestion
const [ typeName, pkgName ] = displayText.split('-').map(s => s.trim())

Expand Down
19 changes: 19 additions & 0 deletions test/autoImportActionProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ describe.only('autoImportActionProvider', () => {
})
})

describe('Suggestion Type: `mixin`', () => {
it('should build the correct import package path', () => {
const suggestion = {
type: 'mixin',
displayText: 'PostMessage - org.springframework.web.bind.annotation'
}

expect(buildImportSuggestion(suggestion)).to.equal('org.springframework.web.bind.annotation.PostMessage')
})

it('should throw error if type or package name is missing', () => {
try {
expect.fail('Should have thrown error')
} catch (error) {
expect(error).not.to.be.null
}
})
})

it('should throw error for unknown suggestion type', () => {
try {
buildImportSuggestion({ type: 'unknown type' })
Expand Down