This repository was archived by the owner on Jan 5, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +24
-5
lines changed
Expand file tree Collapse file tree 4 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 66import go
77
88/**
9- * Gets the `File` with encoded name `name`.
9+ * Returns the `File` matching the given source file name as encoded by the VS
10+ * Code extension.
1011 */
1112cached
12- File getEncodedFile ( string name ) { result .getAbsolutePath ( ) .replaceAll ( ":" , "_" ) = name }
13+ File getFileBySourceArchiveName ( string name ) {
14+ // The name provided for a file in the source archive by the VS Code extension
15+ // has some differences from the absolute path in the database:
16+ // 1. colons are replaced by underscores
17+ // 2. there's a leading slash, even for Windows paths: "C:/foo/bar" ->
18+ // "/C_/foo/bar"
19+ // 3. double slashes in UNC prefixes are replaced with a single slash
20+ // We can handle 2 and 3 together by unconditionally adding a leading slash
21+ // before replacing double slashes.
22+ name = ( "/" + result .getAbsolutePath ( ) .replaceAll ( ":" , "_" ) ) .replaceAll ( "//" , "/" )
23+ }
Original file line number Diff line number Diff line change @@ -13,5 +13,8 @@ import ideContextual
1313external string selectedSourceFile ( ) ;
1414
1515from Ident def , Ident use , Entity e
16- where use .uses ( e ) and def .declares ( e ) and use .getFile ( ) = getEncodedFile ( selectedSourceFile ( ) )
16+ where
17+ use .uses ( e ) and
18+ def .declares ( e ) and
19+ use .getFile ( ) = getFileBySourceArchiveName ( selectedSourceFile ( ) )
1720select use , def , "V"
Original file line number Diff line number Diff line change @@ -13,5 +13,8 @@ import ideContextual
1313external string selectedSourceFile ( ) ;
1414
1515from Ident def , Ident use , Entity e
16- where use .uses ( e ) and def .declares ( e ) and def .getFile ( ) = getEncodedFile ( selectedSourceFile ( ) )
16+ where
17+ use .uses ( e ) and
18+ def .declares ( e ) and
19+ def .getFile ( ) = getFileBySourceArchiveName ( selectedSourceFile ( ) )
1720select use , def , "V"
Original file line number Diff line number Diff line change @@ -22,7 +22,9 @@ external string selectedSourceFile();
2222class Cfg extends PrintAstConfiguration {
2323 override predicate shouldPrintFunction ( FuncDecl func ) { shouldPrintFile ( func .getFile ( ) ) }
2424
25- override predicate shouldPrintFile ( File file ) { file = getEncodedFile ( selectedSourceFile ( ) ) }
25+ override predicate shouldPrintFile ( File file ) {
26+ file = getFileBySourceArchiveName ( selectedSourceFile ( ) )
27+ }
2628
2729 override predicate shouldPrintComments ( File file ) { none ( ) }
2830}
You can’t perform that action at this time.
0 commit comments