File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,13 +20,23 @@ external string selectedSourceFile();
2020 * output of `.getFile()` on locatable entities.
2121 */
2222cached
23- File getEncodedFile ( string name ) { result .getAbsolutePath ( ) .replaceAll ( ":" , "_" ) = name }
23+ File getFileBySourceArchiveName ( string name ) {
24+ // The name provided for a file in the source archive by the VS Code extension
25+ // has some differences from the absolute path in the database:
26+ // 1. colons are replaced by underscores
27+ // 2. there's a leading slash, even for Windows paths: "C:/foo/bar" ->
28+ // "/C_/foo/bar"
29+ // 3. double slashes in UNC prefixes are replaced with a single slash
30+ // We can handle 2 and 3 together by unconditionally adding a leading slash
31+ // before replacing double slashes.
32+ name = ( "/" + result .getAbsolutePath ( ) .replaceAll ( ":" , "_" ) ) .replaceAll ( "//" , "/" )
33+ }
2434
2535/**
2636 * Overrides the configuration to print only nodes in the selected source file.
2737 */
2838class Cfg extends PrintAstConfiguration {
2939 override predicate shouldPrintNode ( AstNode n ) {
30- n .getLocation ( ) .getFile ( ) = getEncodedFile ( selectedSourceFile ( ) )
40+ n .getLocation ( ) .getFile ( ) = getFileBySourceArchiveName ( selectedSourceFile ( ) )
3141 }
3242}
You can’t perform that action at this time.
0 commit comments