@@ -40,6 +40,32 @@ export function formatSnapshot(
40
40
const out : string [ ] = [ ] ;
41
41
const symbolTable = getSymbolTable ( doc ) ;
42
42
43
+ const formatOptionsPrefix = '# format-options:' ;
44
+ const formatOptions = {
45
+ showDocs : false ,
46
+ showRanges : false ,
47
+ } ;
48
+
49
+ for ( let line of input . lines ) {
50
+ if ( ! line . startsWith ( formatOptionsPrefix ) ) {
51
+ continue ;
52
+ }
53
+
54
+ const options = line . slice ( formatOptionsPrefix . length ) . trim ( ) . split ( ',' ) ;
55
+
56
+ for ( let option of options ) {
57
+ const optionName = option . trim ( ) ;
58
+
59
+ if ( ! ( optionName in formatOptions ) ) {
60
+ throw new Error ( `Invalid format option: ${ optionName } ` ) ;
61
+ }
62
+
63
+ formatOptions [ optionName as keyof typeof formatOptions ] = true ;
64
+ }
65
+
66
+ break ;
67
+ }
68
+
43
69
const externalSymbolTable : Map < string , scip . SymbolInformation > = new Map ( ) ;
44
70
for ( let externalSymbol of externalSymbols ) {
45
71
externalSymbolTable . set ( externalSymbol . symbol , externalSymbol ) ;
@@ -75,6 +101,10 @@ export function formatSnapshot(
75
101
}
76
102
77
103
const pushOneDoc = ( docs : string [ ] , external : boolean ) => {
104
+ if ( ! formatOptions . showDocs ) {
105
+ return ;
106
+ }
107
+
78
108
for ( const documentation of docs ) {
79
109
for ( const [ idx , line ] of documentation . split ( '\n' ) . entries ( ) ) {
80
110
out . push ( prefix ) ;
@@ -189,9 +219,6 @@ export function formatSnapshot(
189
219
const isDefinition = ( occurrence . symbol_roles & scip . SymbolRole . Definition ) > 0 ;
190
220
out . push ( isDefinition ? 'definition' : 'reference' ) ;
191
221
out . push ( ' ' ) ;
192
- if ( occurrence . enclosing_range . length ) {
193
- out . push ( '<enclosing ' + occurrence . enclosing_range . join ( ', ' ) + '>' ) ;
194
- }
195
222
const symbol = occurrence . symbol . startsWith ( packageName )
196
223
? occurrence . symbol . slice ( packageName . length )
197
224
: occurrence . symbol ;
0 commit comments