@@ -20,7 +20,8 @@ import type { Action } from "../actions/types";
2020import type { Record } from "../utils/makeRecord" ;
2121
2222type EmptyLinesType = number [ ] ;
23- export type SymbolsMap = Map < string , SymbolDeclarations > ;
23+ export type Symbols = SymbolDeclarations | { loading : true } ;
24+ export type SymbolsMap = Map < string , Symbols > ;
2425export type EmptyLinesMap = Map < string , EmptyLinesType > ;
2526
2627export type SourceMetaDataType = {
@@ -70,10 +71,12 @@ function update(
7071) : Record < ASTState > {
7172 switch ( action . type ) {
7273 case "SET_SYMBOLS" : {
73- const { source, symbols } = action ;
74- return state . setIn ( [ "symbols" , source . id ] , symbols ) ;
74+ const { source } = action ;
75+ if ( action . status === "start" ) {
76+ return state . setIn ( [ "symbols" , source . id ] , { loading : true } ) ;
77+ }
78+ return state . setIn ( [ "symbols" , source . id ] , action . value ) ;
7579 }
76-
7780 case "SET_EMPTY_LINES" : {
7881 const { source, emptyLines } = action ;
7982 return state . setIn ( [ "emptyLines" , source . id ] , emptyLines ) ;
@@ -131,25 +134,34 @@ function update(
131134// https://github.com/devtools-html/debugger.html/blob/master/src/reducers/sources.js#L179-L185
132135type OuterState = { ast : Record < ASTState > } ;
133136
134- const emptySymbols = { variables : [ ] , functions : [ ] } ;
135137export function getSymbols (
136138 state : OuterState ,
137139 source : Source
138- ) : SymbolDeclarations {
140+ ) : ? SymbolDeclarations {
139141 if ( ! source ) {
140- return emptySymbols ;
142+ return null ;
141143 }
142144
143- const symbols = state . ast . getIn ( [ "symbols" , source . id ] ) ;
144- return symbols || emptySymbols ;
145+ return state . ast . getIn ( [ "symbols" , source . id ] ) || null ;
145146}
146147
147148export function hasSymbols ( state : OuterState , source : Source ) : boolean {
148- if ( ! source ) {
149+ const symbols = getSymbols ( state , source ) ;
150+
151+ if ( ! symbols ) {
152+ return false ;
153+ }
154+
155+ return ! symbols . loading ;
156+ }
157+
158+ export function isSymbolsLoading ( state : OuterState , source : Source ) : boolean {
159+ const symbols = getSymbols ( state , source ) ;
160+ if ( ! symbols ) {
149161 return false ;
150162 }
151163
152- return ! ! state . ast . getIn ( [ " symbols" , source . id ] ) ;
164+ return ! ! symbols . loading ;
153165}
154166
155167export function isEmptyLineInSource (
0 commit comments