Skip to content

Commit b121e30

Browse files
authored
Merge pull request #36 from PraneshASP/staging
✨ v1.2.1
2 parents 242358c + 532eb66 commit b121e30

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-solidity-inspector",
33
"displayName": "Solidity Inspector",
44
"description": "A vscode extension used to inspect Solidity files",
5-
"version": "1.2.0",
5+
"version": "1.2.1",
66
"engines": {
77
"vscode": "^1.72.0"
88
},

src/commands/highlight-unused-imports.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ async function unusedImportsActiveFile(editor) {
4242
const solhintRuleString = "solhint-disable no-unused-import"
4343
if (text.includes(solhintRuleString)) return;
4444

45-
const importRegex = /import\s+((?:\{.+?\}\s+from\s+)?(?:\".*?\"|'.*?'));/g;
46-
const imports = text.match(importRegex) || [];
45+
const importRegex = /(?<!\/\/\/?).*import\s+((?:\{.+?\}\s+from\s+)?(?:\".*?\"|'.*?'));/g;
46+
const importStatements = text.match(importRegex) || [];
4747
const unusedImportDecorations = [];
48+
for (const importStatement of importStatements) {
49+
// skip commented out import statements
50+
if (importStatement.startsWith("//") || importStatement.startsWith("/*")) return;
4851

49-
for (const importStatement of imports) {
5052
const imports = extractImports(importStatement);
5153
for (const item of imports) {
52-
const regex = new RegExp(item, 'g');
54+
const regex = new RegExp(`\\b${item}\\b`, 'g');
5355
const itemOccurrencesInImportStatement = (importStatement.replace(/\.sol\b/g, '').match(regex) || []).length;
5456
const totalOccurrencesOfItem = (text.match(new RegExp(`\\b${item}\\b`, 'gi')) || []).length;
5557
if (totalOccurrencesOfItem == itemOccurrencesInImportStatement) {

src/commands/parse-tree.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ const treeFilesCodeActionProvider = vscode.languages.registerCodeActionsProvider
1010

1111
document.getText().split('\n').forEach((lineText, lineNumber) => {
1212
lineText = lineText.trim();
13-
if (lineNumber == 0 && !lineText.endsWith('.t.sol')) {
14-
const diagnostic = new vscode.Diagnostic(
15-
new vscode.Range(0, 0, 0, lineText.length),
16-
`Should be a valid test name (ending with .t.sol)`,
17-
vscode.DiagnosticSeverity.Error
18-
);
19-
20-
diagnostics.push(diagnostic);
21-
}
2213
if (/^(||)/.test(lineText)) {
2314
const allowedPrefixes = ['it', 'when', 'given'];
2415
lineText = lineText.replace(/^[^a-zA-Z0-9]+/, '');

src/syntaxes/tree-syntax.tmLanguage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"include": "#tree-characters"
1010
},
1111
{
12-
"match": "\\b[a-zA-Z0-9_.-]+\\.t\\.sol\\b",
12+
"match": "\\b[a-zA-Z0-9_.-]*?(Test[a-zA-Z0-9_.-]*|\\.t\\.sol)\\b",
1313
"name": "constant.filename"
1414
},
1515
{

0 commit comments

Comments
 (0)