From 038fe3774cafbdaeda6b6877e1bff21deeb8619d Mon Sep 17 00:00:00 2001 From: Razvan Stoenescu Date: Thu, 9 Aug 2018 21:52:31 +0300 Subject: [PATCH 1/2] feat: Add support for Quasar Framework --- .../tagProviders/externalTagProviders.ts | 18 +++++++++++++++ .../src/modes/template/tagProviders/index.ts | 23 +++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/server/src/modes/template/tagProviders/externalTagProviders.ts b/server/src/modes/template/tagProviders/externalTagProviders.ts index 7caa7d6b7d..3dfc6e0725 100644 --- a/server/src/modes/template/tagProviders/externalTagProviders.ts +++ b/server/src/modes/template/tagProviders/externalTagProviders.ts @@ -1,3 +1,7 @@ +import * as ts from 'typescript'; +import * as fs from 'fs'; +import { join } from 'path'; + import { IHTMLTagProvider, Priority } from './common'; import * as elementTags from 'element-helper-json/element-tags.json'; @@ -21,6 +25,20 @@ export const bootstrapTagProvider = getExternalTagProvider('bootstrap', bootstra export const buefyTagProvider = getExternalTagProvider('buefy', buefyTags, buefyAttributes); export const vuetifyTagProvider = getExternalTagProvider('vuetify', vuetifyTags, vuetifyAttributes); +export function getQuasarTagProvider(workspacePath: string, pkg: any): IHTMLTagProvider | null { + const base = 'node_modules/quasar-framework'; + const tagsPath = ts.findConfigFile(workspacePath, ts.sys.fileExists, join(base, pkg.vetur.tags)); + const attrsPath = ts.findConfigFile(workspacePath, ts.sys.fileExists, join(base, pkg.vetur.attributes)); + + return tagsPath && attrsPath + ? getExternalTagProvider( + 'quasar', + JSON.parse(fs.readFileSync(tagsPath, 'utf-8')), + JSON.parse(fs.readFileSync(attrsPath, 'utf-8')) + ) + : null; +} + export function getExternalTagProvider(id: string, tags: any, attributes: any): IHTMLTagProvider { function findAttributeDetail(tag: string, attr: string) { return attributes[attr] || attributes[tag + '/' + attr]; diff --git a/server/src/modes/template/tagProviders/index.ts b/server/src/modes/template/tagProviders/index.ts index 3144fa5045..6f3641a673 100644 --- a/server/src/modes/template/tagProviders/index.ts +++ b/server/src/modes/template/tagProviders/index.ts @@ -7,13 +7,15 @@ import { onsenTagProvider, bootstrapTagProvider, buefyTagProvider, - vuetifyTagProvider + vuetifyTagProvider, + getQuasarTagProvider } from './externalTagProviders'; export { getComponentTags } from './componentTags'; export { IHTMLTagProvider } from './common'; import * as ts from 'typescript'; import * as fs from 'fs'; +import { join } from 'path'; export let allTagProviders: IHTMLTagProvider[] = [ getHTML5TagProvider(), @@ -39,7 +41,8 @@ export function getTagProviderSettings(workspacePath: string | null | undefined) onsen: false, bootstrap: false, buefy: false, - vuetify: false + vuetify: false, + quasar: false }; if (!workspacePath) { return settings; @@ -68,6 +71,22 @@ export function getTagProviderSettings(workspacePath: string | null | undefined) if (packageJson.dependencies['vuetify']) { settings['vuetify'] = true; } + + const quasarPath = ts.findConfigFile( + workspacePath, + ts.sys.fileExists, + join('node_modules', 'quasar-framework', 'package.json') + ); + if (quasarPath) { + const quasarPkg = JSON.parse(fs.readFileSync(quasarPath, 'utf-8')); + if (quasarPkg.vetur) { + const provider = getQuasarTagProvider(workspacePath, quasarPkg); + if (provider !== null) { + allTagProviders.push(provider); + settings['quasar'] = true; + } + } + } } catch (e) {} return settings; } From 704a63e1844e2d8122443605f9c300c633d7f851 Mon Sep 17 00:00:00 2001 From: Razvan Stoenescu Date: Thu, 9 Aug 2018 23:06:59 +0300 Subject: [PATCH 2/2] chore: Add Quasar unit-tests --- test/fixture/client/completion/template/Quasar.vue | 4 ++++ test/fixture/package.json | 1 + test/fixture/yarn.lock | 4 ++++ test/lsp/completion/template.test.ts | 12 +++++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/fixture/client/completion/template/Quasar.vue diff --git a/test/fixture/client/completion/template/Quasar.vue b/test/fixture/client/completion/template/Quasar.vue new file mode 100644 index 0000000000..c95712bc42 --- /dev/null +++ b/test/fixture/client/completion/template/Quasar.vue @@ -0,0 +1,4 @@ +