diff --git a/lib/providers/autoImportActionProvider.js b/lib/providers/autoImportActionProvider.js index a493d05..107263a 100644 --- a/lib/providers/autoImportActionProvider.js +++ b/lib/providers/autoImportActionProvider.js @@ -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()) diff --git a/test/autoImportActionProvider.test.js b/test/autoImportActionProvider.test.js index 6f8576a..e06aeae 100644 --- a/test/autoImportActionProvider.test.js +++ b/test/autoImportActionProvider.test.js @@ -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' })