Skip to content

Commit b95124a

Browse files
committed
chore: removed duplicated code
1 parent c746534 commit b95124a

File tree

1 file changed

+8
-30
lines changed

1 file changed

+8
-30
lines changed

src/extension.ts

+8-30
Original file line numberDiff line numberDiff line change
@@ -62,36 +62,14 @@ function generateHighlighting() {
6262
}
6363

6464
export function findMatch(editor: vscode.TextEditor, text: string): any {
65-
const regEx = /^\ {0,3}use (?:(?:function|const) )?(.*);/mg;
66-
let match;
67-
let matches: any[] = [];
68-
let isAlias = false;
69-
70-
while (match = regEx.exec(text)) {
71-
let found = 0;
72-
let splitNameSpace = match[1].split('\\');
73-
let className = splitNameSpace[splitNameSpace.length - 1];
74-
75-
if (className.search(/ as /) > -1) {
76-
isAlias = true;
77-
let splitAlias = className.split(' as ');
78-
className = splitAlias[splitAlias.length - 1].trim();
79-
}
80-
81-
const reg = new RegExp('\\b' + className + '\\b', 'g');
82-
83-
const test = text.match(reg);
84-
85-
found = (test || []).length;
86-
87-
extractUnusedImports(text).forEach(element => {
88-
const {match} = element;
89-
const startPos = editor.document.positionAt(match.index);
90-
const endPos = editor.document.positionAt(match.index + match[0].length);
91-
ranges.push(new vscode.Range(startPos, endPos));
92-
matches.push(element.match);
93-
})
94-
}
65+
const matches: any[] = [];
66+
extractUnusedImports(text).forEach(element => {
67+
const {match} = element;
68+
const startPos = editor.document.positionAt(match.index);
69+
const endPos = editor.document.positionAt(match.index + match[0].length);
70+
ranges.push(new vscode.Range(startPos, endPos));
71+
matches.push(element.match);
72+
});
9573

9674
return matches;
9775
}

0 commit comments

Comments
 (0)