1
1
import { assert } from '@l2beat/backend-tools'
2
- import { parse } from '@solidity-parser/parser'
3
- // eslint-disable-next-line import/no-unresolved
4
- import type * as AST from '@solidity-parser/parser/dist/src/ast-types'
2
+ import type * as AST from '@mradomski/fast-solidity-parser'
3
+ import { parse } from '@mradomski/fast-solidity-parser'
5
4
import * as posix from 'path'
6
5
7
6
import { getASTIdentifiers } from './getASTIdentifiers'
@@ -67,6 +66,7 @@ export interface Remapping {
67
66
}
68
67
69
68
export interface ParsedFile extends FileContent {
69
+ normalizedPath : string
70
70
rootASTNode : ParseResult
71
71
72
72
topLevelDeclarations : TopLevelDeclaration [ ]
@@ -88,13 +88,17 @@ export class ParsedFilesManager {
88
88
const result = new ParsedFilesManager ( )
89
89
const remappings = decodeRemappings ( remappingStrings )
90
90
91
- result . files = files . map ( ( { path, content } ) => ( {
92
- path : resolveRemappings ( path , remappings ) ,
93
- content,
94
- rootASTNode : parse ( content , { range : true } ) ,
95
- topLevelDeclarations : [ ] ,
96
- importDirectives : [ ] ,
97
- } ) )
91
+ result . files = files . map ( ( { path, content } ) => {
92
+ const remappedPath = resolveRemappings ( path , remappings )
93
+ return {
94
+ path : remappedPath ,
95
+ normalizedPath : posix . normalize ( remappedPath ) ,
96
+ content,
97
+ rootASTNode : parse ( content , { range : true } ) ,
98
+ topLevelDeclarations : [ ] ,
99
+ importDirectives : [ ] ,
100
+ }
101
+ } )
98
102
99
103
// Pass 1: Find all contract declarations
100
104
for ( const file of result . files ) {
@@ -402,9 +406,10 @@ export class ParsedFilesManager {
402
406
? posix . join ( posix . dirname ( fromFile . path ) , importPath )
403
407
: importPath
404
408
409
+ const normalizedPath = posix . normalize ( resolvedPath )
405
410
const matchingFile = findOne (
406
411
this . files ,
407
- ( f ) => posix . normalize ( f . path ) === posix . normalize ( resolvedPath ) ,
412
+ ( f ) => f . normalizedPath === normalizedPath ,
408
413
)
409
414
assert (
410
415
matchingFile !== undefined ,
0 commit comments