@@ -31,22 +31,18 @@ function getSymbolTable(doc: scip.Document): Map<string, scip.SymbolInformation>
31
31
32
32
const packageName = 'scip-python python' ;
33
33
const commentSyntax = '#' ;
34
+ const formatOptionsPrefix = '# format-options:' ;
34
35
35
- export function formatSnapshot (
36
- input : Input ,
37
- doc : scip . Document ,
38
- externalSymbols : scip . SymbolInformation [ ] = [ ]
39
- ) : string {
40
- const out : string [ ] = [ ] ;
41
- const symbolTable = getSymbolTable ( doc ) ;
42
-
43
- const formatOptionsPrefix = '# format-options:' ;
36
+ function parseOptions ( lines : string [ ] ) : {
37
+ showDocs : boolean ;
38
+ showRanges : boolean ;
39
+ } {
44
40
const formatOptions = {
45
41
showDocs : false ,
46
42
showRanges : false ,
47
43
} ;
48
44
49
- for ( let line of input . lines ) {
45
+ for ( let line of lines ) {
50
46
if ( ! line . startsWith ( formatOptionsPrefix ) ) {
51
47
continue ;
52
48
}
@@ -66,6 +62,17 @@ export function formatSnapshot(
66
62
break ;
67
63
}
68
64
65
+ return formatOptions ;
66
+ }
67
+
68
+ export function formatSnapshot (
69
+ input : Input ,
70
+ doc : scip . Document ,
71
+ externalSymbols : scip . SymbolInformation [ ] = [ ]
72
+ ) : string {
73
+ const out : string [ ] = [ ] ;
74
+ const symbolTable = getSymbolTable ( doc ) ;
75
+
69
76
const externalSymbolTable : Map < string , scip . SymbolInformation > = new Map ( ) ;
70
77
for ( let externalSymbol of externalSymbols ) {
71
78
externalSymbolTable . set ( externalSymbol . symbol , externalSymbol ) ;
@@ -74,6 +81,8 @@ export function formatSnapshot(
74
81
const enclosingRanges : { range : Range ; symbol : string } [ ] = [ ] ;
75
82
const symbolsWithDefinitions : Set < string > = new Set ( ) ;
76
83
84
+ const formatOptions = parseOptions ( input . lines ) ;
85
+
77
86
for ( let occurrence of doc . occurrences ) {
78
87
const isDefinition = ( occurrence . symbol_roles & scip . SymbolRole . Definition ) > 0 ;
79
88
if ( isDefinition ) {
0 commit comments