Skip to content

Commit 05d2062

Browse files
m2decvharris
authored andcommitted
Refactor extensions to reduce code duplication
1 parent 71ba52d commit 05d2062

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

src/extension.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -125,31 +125,26 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
125125
const htmlRegex = /class=["|']([\w- ]*$)/;
126126
const jsxRegex = /className=["|']([\w- ]*$)/;
127127

128-
const html = provideCompletionItemsGenerator('html', htmlRegex);
129-
const razor = provideCompletionItemsGenerator('razor', htmlRegex);
130-
const php = provideCompletionItemsGenerator('php', htmlRegex);
131-
const vue = provideCompletionItemsGenerator('vue', htmlRegex);
132-
const twig = provideCompletionItemsGenerator('twig', htmlRegex);
133-
const md = provideCompletionItemsGenerator('markdown', htmlRegex);
134-
const tsReact = provideCompletionItemsGenerator('typescriptreact', jsxRegex);
135-
const js = provideCompletionItemsGenerator('javascript', jsxRegex)
136-
const jsReact = provideCompletionItemsGenerator('javascriptreact', jsxRegex);
137-
const erb = provideCompletionItemsGenerator('erb', htmlRegex);
138-
const hbs = provideCompletionItemsGenerator('handlebars', htmlRegex);
139-
const ejs = provideCompletionItemsGenerator('ejs', htmlRegex);
140-
141-
context.subscriptions.push(html);
142-
context.subscriptions.push(razor);
143-
context.subscriptions.push(php);
144-
context.subscriptions.push(vue);
145-
context.subscriptions.push(twig);
146-
context.subscriptions.push(md);
147-
context.subscriptions.push(tsReact);
148-
context.subscriptions.push(js);
149-
context.subscriptions.push(jsReact);
150-
context.subscriptions.push(erb);
151-
context.subscriptions.push(hbs);
152-
context.subscriptions.push(ejs);
128+
const extensions = [
129+
'html',
130+
'razor',
131+
'php',
132+
'vue',
133+
'twig',
134+
'markdown',
135+
'typescriptreact',
136+
'javascript',
137+
'javascriptreact',
138+
'erb',
139+
'handlebars',
140+
'ejs'
141+
];
142+
143+
extensions.forEach((extension) => {
144+
context.subscriptions.push(
145+
provideCompletionItemsGenerator(extension, htmlRegex)
146+
);
147+
});
153148

154149
caching = true;
155150
try {

0 commit comments

Comments
 (0)