Skip to content

Commit

Permalink
Merge pull request #36 from PraneshASP/staging
Browse files Browse the repository at this point in the history
✨ v1.2.1
  • Loading branch information
PraneshASP authored Dec 16, 2023
2 parents 242358c + 532eb66 commit b121e30
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-solidity-inspector",
"displayName": "Solidity Inspector",
"description": "A vscode extension used to inspect Solidity files",
"version": "1.2.0",
"version": "1.2.1",
"engines": {
"vscode": "^1.72.0"
},
Expand Down
10 changes: 6 additions & 4 deletions src/commands/highlight-unused-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ async function unusedImportsActiveFile(editor) {
const solhintRuleString = "solhint-disable no-unused-import"
if (text.includes(solhintRuleString)) return;

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

for (const importStatement of imports) {
const imports = extractImports(importStatement);
for (const item of imports) {
const regex = new RegExp(item, 'g');
const regex = new RegExp(`\\b${item}\\b`, 'g');
const itemOccurrencesInImportStatement = (importStatement.replace(/\.sol\b/g, '').match(regex) || []).length;
const totalOccurrencesOfItem = (text.match(new RegExp(`\\b${item}\\b`, 'gi')) || []).length;
if (totalOccurrencesOfItem == itemOccurrencesInImportStatement) {
Expand Down
9 changes: 0 additions & 9 deletions src/commands/parse-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ const treeFilesCodeActionProvider = vscode.languages.registerCodeActionsProvider

document.getText().split('\n').forEach((lineText, lineNumber) => {
lineText = lineText.trim();
if (lineNumber == 0 && !lineText.endsWith('.t.sol')) {
const diagnostic = new vscode.Diagnostic(
new vscode.Range(0, 0, 0, lineText.length),
`Should be a valid test name (ending with .t.sol)`,
vscode.DiagnosticSeverity.Error
);

diagnostics.push(diagnostic);
}
if (/^(||)/.test(lineText)) {
const allowedPrefixes = ['it', 'when', 'given'];
lineText = lineText.replace(/^[^a-zA-Z0-9]+/, '');
Expand Down
2 changes: 1 addition & 1 deletion src/syntaxes/tree-syntax.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"include": "#tree-characters"
},
{
"match": "\\b[a-zA-Z0-9_.-]+\\.t\\.sol\\b",
"match": "\\b[a-zA-Z0-9_.-]*?(Test[a-zA-Z0-9_.-]*|\\.t\\.sol)\\b",
"name": "constant.filename"
},
{
Expand Down

0 comments on commit b121e30

Please sign in to comment.