Skip to content

Commit

Permalink
chore(project): remove solidity-parser-antlr dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuuGan committed May 17, 2020
1 parent dba4e51 commit 4155290
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 24 deletions.
1 change: 0 additions & 1 deletion lib/exportsAnalyzer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Debug from 'debug';
import parser from 'solidity-parser-antlr';
import { SolidityExportVisitor } from './antlr/visitors/exportVisitor';
import { ExportType } from './types';

Expand Down
10 changes: 3 additions & 7 deletions lib/importsAnalyzer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import parser from 'solidity-parser-antlr';
import { Utils } from './utils';
import { SolidityImportVisitor } from './antlr/visitors/importVisitor';
import { ImportVisitResult } from './antlr/visitors/types';
Expand Down Expand Up @@ -38,18 +37,13 @@ export class ImportsAnalyzer {
*/
analyzeImports(): ImportsAnalyzerResult[] {
const imports: ImportsAnalyzerResult[] = [];
const ast = Utils.getAstNode(this.contents);

const importDirectives: ImportVisitResult[] = [];
const visitor = new SolidityImportVisitor(this.contents);
visitor.visit((i) => {
importDirectives.push(i);
});

if (!ast) {
return [];
}

for (const importDirective of importDirectives) {
const analyzedImport = this.analyzeImport(importDirective);
imports.push(analyzedImport);
Expand All @@ -65,7 +59,9 @@ export class ImportsAnalyzer {
* 3. Extract filename from import
*
*/
private analyzeImport(importVisitResult: ImportVisitResult): ImportsAnalyzerResult {
private analyzeImport(
importVisitResult: ImportVisitResult,
): ImportsAnalyzerResult {
return {
file: importVisitResult.filename,
globalRenameImport: importVisitResult.globalRename,
Expand Down
10 changes: 0 additions & 10 deletions lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import parser, { ASTNode } from 'solidity-parser-antlr';

export class Utils {
static isRelative(file: string) {
return file.startsWith('.');
}

static getAstNode(contents: string): ASTNode | null {
try {
return parser.parse(contents, { loc: true, range: true });
} catch {
return null;
}
}
}
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"debug": "^4.1.1",
"fs-extra": "^8.0.1",
"glob": "^7.1.2",
"solidity-parser-antlr": "^0.4.11",
"strip-json-comments": "^3.0.1"
},
"pre-commit": [
Expand Down

0 comments on commit 4155290

Please sign in to comment.