This repository was archived by the owner on Jan 5, 2023. It is now read-only.
File tree 4 files changed +24
-5
lines changed
4 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 6
6
import go
7
7
8
8
/**
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.
10
11
*/
11
12
cached
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
13
13
external string selectedSourceFile ( ) ;
14
14
15
15
from 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 ( ) )
17
20
select use , def , "V"
Original file line number Diff line number Diff line change @@ -13,5 +13,8 @@ import ideContextual
13
13
external string selectedSourceFile ( ) ;
14
14
15
15
from 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 ( ) )
17
20
select use , def , "V"
Original file line number Diff line number Diff line change @@ -22,7 +22,9 @@ external string selectedSourceFile();
22
22
class Cfg extends PrintAstConfiguration {
23
23
override predicate shouldPrintFunction ( FuncDecl func ) { shouldPrintFile ( func .getFile ( ) ) }
24
24
25
- override predicate shouldPrintFile ( File file ) { file = getEncodedFile ( selectedSourceFile ( ) ) }
25
+ override predicate shouldPrintFile ( File file ) {
26
+ file = getFileBySourceArchiveName ( selectedSourceFile ( ) )
27
+ }
26
28
27
29
override predicate shouldPrintComments ( File file ) { none ( ) }
28
30
}
You can’t perform that action at this time.
0 commit comments