16
16
import org .eclipse .core .resources .IFile ;
17
17
import org .eclipse .core .resources .IResource ;
18
18
import org .eclipse .core .runtime .CoreException ;
19
+ import org .eclipse .core .runtime .IPath ;
20
+ import org .eclipse .core .runtime .Path ;
19
21
22
+ import ts .eclipse .ide .core .resources .jsconfig .IDETsconfigJson ;
20
23
import ts .eclipse .ide .core .utils .WorkbenchResourceUtil ;
21
- import ts .resources .jsonconfig .TsconfigJson ;
22
24
import ts .utils .FileUtils ;
23
25
24
26
/**
@@ -29,16 +31,23 @@ public class JsonConfigResourcesManager {
29
31
30
32
private static final JsonConfigResourcesManager INSTANCE = new JsonConfigResourcesManager ();
31
33
34
+ private static final IPath TSCONFIG_JSON_PATH = new Path (FileUtils .TSCONFIG_JSON );
35
+
32
36
public static JsonConfigResourcesManager getInstance () {
33
37
return INSTANCE ;
34
38
}
35
39
36
- private final Map <IFile , TsconfigJson > jsconConfig ;
40
+ private final Map <IFile , IDETsconfigJson > jsconConfig ;
37
41
38
42
public JsonConfigResourcesManager () {
39
- this .jsconConfig = new HashMap <IFile , TsconfigJson >();
43
+ this .jsconConfig = new HashMap <IFile , IDETsconfigJson >();
40
44
}
41
45
46
+ /**
47
+ * Remove the given tsconfig.json from the cache.
48
+ *
49
+ * @param file
50
+ */
42
51
public void remove (IFile file ) {
43
52
synchronized (jsconConfig ) {
44
53
jsconConfig .remove (file );
@@ -53,29 +62,43 @@ public void remove(IFile file) {
53
62
* @return
54
63
* @throws CoreException
55
64
*/
56
- public TsconfigJson findTsconfig (IResource resource ) throws CoreException {
57
- IFile tsconfigFile = WorkbenchResourceUtil .findFileRecursively (resource , FileUtils . TSCONFIG_JSON );
65
+ public IDETsconfigJson findTsconfig (IResource resource ) throws CoreException {
66
+ IFile tsconfigFile = WorkbenchResourceUtil .findFileRecursively (resource , TSCONFIG_JSON_PATH );
58
67
if (tsconfigFile != null ) {
59
68
return getTsconfig (tsconfigFile );
60
69
}
61
70
return null ;
62
71
}
63
72
64
- private TsconfigJson getTsconfig (IFile tsconfigFile ) throws CoreException {
65
- TsconfigJson tsconfig = jsconConfig .get (tsconfigFile );
73
+ /**
74
+ * Returns the Pojo of the given tsconfig.json file.
75
+ *
76
+ * @param tsconfigFile
77
+ * @return the Pojo of the given tsconfig.json file.
78
+ * @throws CoreException
79
+ */
80
+ private IDETsconfigJson getTsconfig (IFile tsconfigFile ) throws CoreException {
81
+ IDETsconfigJson tsconfig = jsconConfig .get (tsconfigFile );
66
82
if (tsconfig == null ) {
67
83
return createTsConfig (tsconfigFile );
68
84
}
69
85
return tsconfig ;
70
86
}
71
87
72
- private synchronized TsconfigJson createTsConfig (IFile tsconfigFile ) throws CoreException {
73
- TsconfigJson tsconfig = jsconConfig .get (tsconfigFile );
88
+ /**
89
+ * Create Pojo instance of the given tsconfig.json file.
90
+ *
91
+ * @param tsconfigFile
92
+ * @return Pojo instance of the given tsconfig.json file.
93
+ * @throws CoreException
94
+ */
95
+ private synchronized IDETsconfigJson createTsConfig (IFile tsconfigFile ) throws CoreException {
96
+ IDETsconfigJson tsconfig = jsconConfig .get (tsconfigFile );
74
97
if (tsconfig != null ) {
75
98
return tsconfig ;
76
99
}
77
100
78
- tsconfig = TsconfigJson .load (tsconfigFile . getContents () );
101
+ tsconfig = IDETsconfigJson .load (tsconfigFile );
79
102
synchronized (jsconConfig ) {
80
103
jsconConfig .put (tsconfigFile , tsconfig );
81
104
}
0 commit comments