4
4
using System . Reflection ;
5
5
using System . Collections . Generic ;
6
6
using OpenIDE . Core . Config ;
7
+ using OpenIDE . Core . Logging ;
7
8
8
9
namespace OpenIDE . Core . Configs
9
10
{
@@ -13,14 +14,10 @@ public class Interpreters
13
14
private Dictionary < string , string > _interpreters = new Dictionary < string , string > ( ) ;
14
15
15
16
public Interpreters ( string token ) {
17
+ Logger . Write ( "Initializing interpreters" ) ;
16
18
_token = token ;
17
- var local = new Configuration ( _token , false ) ;
18
- var global =
19
- new Configuration (
20
- Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location )
21
- , false ) ;
22
- readInterpreters ( local ) ;
23
- readInterpreters ( global ) ;
19
+ var reader = new ConfigReader ( _token ) ;
20
+ readInterpreters ( reader ) ;
24
21
}
25
22
26
23
public string GetInterpreterFor ( string extension ) {
@@ -30,9 +27,9 @@ public string GetInterpreterFor(string extension) {
30
27
return null ;
31
28
}
32
29
33
- private void readInterpreters ( Configuration config ) {
30
+ private void readInterpreters ( ConfigReader config ) {
34
31
var prefix = "interpreter." ;
35
- foreach ( var interpreter in config . GetSettingsStartingWith ( prefix ) ) {
32
+ foreach ( var interpreter in config . GetStartingWith ( prefix ) ) {
36
33
if ( interpreter . Key . Length <= prefix . Length )
37
34
continue ;
38
35
@@ -51,17 +48,19 @@ private void readInterpreters(Configuration config) {
51
48
path . Replace ( "/" , "\\ " ) ;
52
49
}
53
50
if ( ! File . Exists ( path ) ) {
54
- path =
51
+ var modifiedPath =
55
52
System . IO . Path . Combine (
56
53
System . IO . Path . GetDirectoryName (
57
54
Assembly . GetExecutingAssembly ( ) . Location ) ,
58
55
path ) ;
59
- if ( ! File . Exists ( path ) )
60
- continue ;
56
+ if ( File . Exists ( path ) )
57
+ path = modifiedPath ;
61
58
}
62
- if ( ! _interpreters . ContainsKey ( extension ) )
59
+ if ( ! _interpreters . ContainsKey ( extension ) ) {
60
+ Logger . Write ( "Adding interpreter: " + path + " for " + extension ) ;
63
61
_interpreters . Add ( extension , path ) ;
62
+ }
64
63
}
65
64
}
66
65
}
67
- }
66
+ }
0 commit comments