66
77-define (timeout , 30000 ).
88-record (elixir_code_server , {
9- argv = [],
109 loaded = [],
11- at_exit = [],
1210 paths = {[],[]},
1311 mod_pool = {[],0 },
1412 mod_ets = dict :new (),
15- compilation_status = [],
16- compiler_options = [{docs ,true },{debug_info ,true },{warnings_as_errors ,false }],
17- erl_compiler_options = nil
13+ compilation_status = []
1814}).
1915
2016call (Args ) ->
@@ -61,18 +57,6 @@ handle_call({acquire, Path}, From, Config) ->
6157handle_call (loaded , _From , Config ) ->
6258 {reply , [F || {F , true } <- Config # elixir_code_server .loaded ], Config };
6359
64- handle_call (at_exit , _From , Config ) ->
65- {reply , Config # elixir_code_server .at_exit , Config };
66-
67- handle_call (flush_at_exit , _From , Config ) ->
68- {reply , Config # elixir_code_server .at_exit , Config # elixir_code_server {at_exit = []}};
69-
70- handle_call (argv , _From , Config ) ->
71- {reply , Config # elixir_code_server .argv , Config };
72-
73- handle_call (compiler_options , _From , Config ) ->
74- {reply , Config # elixir_code_server .compiler_options , Config };
75-
7660handle_call ({compilation_status , CompilerPid }, _From , Config ) ->
7761 CompilationStatusList = Config # elixir_code_server .compilation_status ,
7862 CompilationStatusListNew = orddict :erase (CompilerPid , CompilationStatusList ),
@@ -88,35 +72,17 @@ handle_call(retrieve_module_name, _From, Config) ->
8872 {reply , module_tuple (Counter ), Config # elixir_code_server {mod_pool = {[],Counter + 1 }}}
8973 end ;
9074
91- handle_call (erl_compiler_options , _From , Config ) ->
92- case Config # elixir_code_server .erl_compiler_options of
93- nil ->
94- Opts = erl_compiler_options (),
95- {reply , Opts , Config # elixir_code_server {erl_compiler_options = Opts }};
96- Opts ->
97- {reply , Opts , Config }
98- end ;
99-
10075handle_call (paths , _From , Config ) ->
10176 {reply , Config # elixir_code_server .paths , Config };
10277
10378handle_call (Request , _From , Config ) ->
10479 {stop , {badcall , Request }, Config }.
10580
106- handle_cast ({at_exit , AtExit }, Config ) ->
107- {noreply , Config # elixir_code_server {at_exit = [AtExit |Config # elixir_code_server .at_exit ]}};
108-
109- handle_cast ({argv , Argv }, Config ) ->
110- {noreply , Config # elixir_code_server {argv = Argv }};
111-
112- handle_cast ({compiler_options , Options }, Config ) ->
113- Final = orddict :merge (fun (_ ,_ ,V ) -> V end , Config # elixir_code_server .compiler_options , Options ),
114- {noreply , Config # elixir_code_server {compiler_options = Final }};
115-
11681handle_cast ({register_warning , CompilerPid }, Config ) ->
11782 CompilationStatusCurrent = Config # elixir_code_server .compilation_status ,
11883 CompilationStatusNew = orddict :store (CompilerPid , error , CompilationStatusCurrent ),
119- case orddict :find (warnings_as_errors , Config # elixir_code_server .compiler_options ) of
84+ CompilerOptions = elixir_config :get (compiler_options ),
85+ case orddict :find (warnings_as_errors , CompilerOptions ) of
12086 {ok , true } -> {noreply , Config # elixir_code_server {compilation_status = CompilationStatusNew }};
12187 _ -> {noreply , Config }
12288 end ;
@@ -183,23 +149,3 @@ undefmodule(Ref, #elixir_code_server{mod_ets=ModEts} = Config) ->
183149 error ->
184150 Config
185151 end .
186-
187- erl_compiler_options () ->
188- Key = " ERL_COMPILER_OPTIONS" ,
189- case os :getenv (Key ) of
190- false -> [];
191- Str when is_list (Str ) ->
192- case erl_scan :string (Str ) of
193- {ok ,Tokens ,_ } ->
194- case erl_parse :parse_term (Tokens ++ [{dot , 1 }]) of
195- {ok ,List } when is_list (List ) -> List ;
196- {ok ,Term } -> [Term ];
197- {error ,_Reason } ->
198- io :format (" Ignoring bad term in ~ts \n " , [Key ]),
199- []
200- end ;
201- {error , {_ ,_ ,_Reason }, _ } ->
202- io :format (" Ignoring bad term in ~ts \n " , [Key ]),
203- []
204- end
205- end .
0 commit comments