|
1 |
| -import {ClassIndexer, EnumIndexer, FunctionIndexer, ICachedContent, IClassDeclaration, ICodeAnalyzer, IEnumDeclaration, IExportDeclaration, IFunctionDeclaration, IIdentifierMap, IImportDeclaration, IParameter, IPropDeclaration, IVariableAssignment, ResolvedIIdentifierValueMap, ResolvedSerializedIIdentifierValueMap, VariableIndexer} from "../service/interface/ICodeAnalyzer"; |
| 1 | +import {ClassIndexer, EnumIndexer, FunctionIndexer, ICachedContent, IClassDeclaration, ICodeAnalyzer, IEnumDeclaration, IExportDeclaration, IFunctionDeclaration, IIdentifierMap, IImportDeclaration, IPropDeclaration, IVariableAssignment, ResolvedIIdentifierValueMap, ResolvedSerializedIIdentifierValueMap, VariableIndexer} from "../service/interface/ICodeAnalyzer"; |
2 | 2 | import {ICache} from "./interface/ICache";
|
3 |
| -import {SerializedVersions} from "../serializer/interface/IIdentifierSerializer"; |
4 | 3 |
|
5 | 4 | export class Cache implements ICache {
|
6 | 5 | private cache: Map<string, ICachedContent<{}>> = new Map();
|
7 | 6 |
|
8 | 7 | constructor (private languageService: ICodeAnalyzer) {
|
9 | 8 | }
|
10 | 9 |
|
11 |
| - public getCachedSerializedVariableName (fileName: string, position: number, variableName: string): string { |
12 |
| - return `serializedVariable.${fileName}.${position}.${variableName}`; |
13 |
| - } |
14 |
| - |
15 |
| - public getCachedSerializedParameterName (fileName: string, position: number, parameterName: (string|undefined)[]): string { |
16 |
| - return `serializedParameter.${fileName}.${position}.${parameterName.join(".")}`; |
17 |
| - } |
18 |
| - |
19 |
| - public getCachedSerializedClassName (fileName: string, position: number, className: string): string { |
20 |
| - return `serializedClass.${fileName}.${position}.${className}`; |
21 |
| - } |
22 |
| - |
23 |
| - public getCachedSerializedEnumName (fileName: string, position: number, enumName: string): string { |
24 |
| - return `serializedEnum.${fileName}.${position}.${enumName}`; |
25 |
| - } |
26 |
| - |
27 |
| - public getCachedSerializedFunctionName (fileName: string, position: number, functionName: string): string { |
28 |
| - return `serializedFunction.${fileName}.${position}.${functionName}`; |
29 |
| - } |
30 |
| - |
31 | 10 | public getCachedPropName (fileName: string, className: string, propName: string): string {
|
32 | 11 | return `prop.${fileName}.${className}.${propName}`;
|
33 | 12 | }
|
@@ -89,26 +68,6 @@ export class Cache implements ICache {
|
89 | 68 | return record == null ? null : <ICachedContent<T>>record;
|
90 | 69 | }
|
91 | 70 |
|
92 |
| - public getCachedSerializedVariable (variable: IVariableAssignment): ICachedContent<SerializedVersions>|null { |
93 |
| - return this.getFromCache<SerializedVersions>(this.getCachedSerializedVariableName(variable.filePath, variable.startsAt, variable.name)); |
94 |
| - } |
95 |
| - |
96 |
| - public getCachedSerializedParameter (parameter: IParameter): ICachedContent<SerializedVersions>|null { |
97 |
| - return this.getFromCache<SerializedVersions>(this.getCachedSerializedParameterName(parameter.filePath, parameter.startsAt, parameter.name)); |
98 |
| - } |
99 |
| - |
100 |
| - public getCachedSerializedClass (classDeclaration: IClassDeclaration): ICachedContent<SerializedVersions>|null { |
101 |
| - return this.getFromCache<SerializedVersions>(this.getCachedSerializedClassName(classDeclaration.filePath, classDeclaration.startsAt, classDeclaration.name)); |
102 |
| - } |
103 |
| - |
104 |
| - public getCachedSerializedEnum (enumDeclaration: IEnumDeclaration): ICachedContent<SerializedVersions>|null { |
105 |
| - return this.getFromCache<SerializedVersions>(this.getCachedSerializedEnumName(enumDeclaration.filePath, enumDeclaration.startsAt, enumDeclaration.name)); |
106 |
| - } |
107 |
| - |
108 |
| - public getCachedSerializedFunction (functionDeclaration: IFunctionDeclaration): ICachedContent<SerializedVersions>|null { |
109 |
| - return this.getFromCache<SerializedVersions>(this.getCachedSerializedFunctionName(functionDeclaration.filePath, functionDeclaration.startsAt, functionDeclaration.name)); |
110 |
| - } |
111 |
| - |
112 | 71 | public getCachedVariable (fileName: string, variableName: string): ICachedContent<IVariableAssignment>|null {
|
113 | 72 | return this.getFromCache<IVariableAssignment>(this.getCachedVariableName(fileName, variableName));
|
114 | 73 | }
|
@@ -165,31 +124,6 @@ export class Cache implements ICache {
|
165 | 124 | return this.getFromCache<ResolvedSerializedIIdentifierValueMap>(this.getCachedResolvedSerializedIdentifierValueMapName(fileName));
|
166 | 125 | }
|
167 | 126 |
|
168 |
| - public setCachedSerializedVariable (variable: IVariableAssignment, content: SerializedVersions): void { |
169 |
| - const version = this.languageService.getFileVersion(variable.filePath); |
170 |
| - this.cache.set(this.getCachedSerializedVariableName(variable.filePath, variable.startsAt, variable.name), {content, version}); |
171 |
| - } |
172 |
| - |
173 |
| - public setCachedSerializedParameter (parameter: IParameter, content: SerializedVersions): void { |
174 |
| - const version = this.languageService.getFileVersion(parameter.filePath); |
175 |
| - this.cache.set(this.getCachedSerializedParameterName(parameter.filePath, parameter.startsAt, parameter.name), {content, version}); |
176 |
| - } |
177 |
| - |
178 |
| - public setCachedSerializedClass (classDeclaration: IClassDeclaration, content: SerializedVersions): void { |
179 |
| - const version = this.languageService.getFileVersion(classDeclaration.filePath); |
180 |
| - this.cache.set(this.getCachedSerializedClassName(classDeclaration.filePath, classDeclaration.startsAt, classDeclaration.name), {content, version}); |
181 |
| - } |
182 |
| - |
183 |
| - public setCachedSerializedEnum (enumDeclaration: IEnumDeclaration, content: SerializedVersions): void { |
184 |
| - const version = this.languageService.getFileVersion(enumDeclaration.filePath); |
185 |
| - this.cache.set(this.getCachedSerializedEnumName(enumDeclaration.filePath, enumDeclaration.startsAt, enumDeclaration.name), {content, version}); |
186 |
| - } |
187 |
| - |
188 |
| - public setCachedSerializedFunction (functionDeclaration: IFunctionDeclaration, content: SerializedVersions): void { |
189 |
| - const version = this.languageService.getFileVersion(functionDeclaration.filePath); |
190 |
| - this.cache.set(this.getCachedSerializedFunctionName(functionDeclaration.filePath, functionDeclaration.startsAt, functionDeclaration.name), {content, version}); |
191 |
| - } |
192 |
| - |
193 | 127 | public setCachedVariable (fileName: string, content: IVariableAssignment): void {
|
194 | 128 | const version = this.languageService.getFileVersion(fileName);
|
195 | 129 | this.cache.set(this.getCachedVariableName(fileName, content.name), {content, version});
|
@@ -260,46 +194,6 @@ export class Cache implements ICache {
|
260 | 194 | this.cache.set(this.getCachedVariableIndexerName(fileName), {version, content});
|
261 | 195 | }
|
262 | 196 |
|
263 |
| - public cachedSerializedVariableNeedsUpdate (variable: IVariableAssignment): boolean { |
264 |
| - const cache = this.getCachedSerializedVariable(variable); |
265 |
| - if (cache == null) return true; |
266 |
| - |
267 |
| - const version = this.languageService.getFileVersion(variable.filePath); |
268 |
| - return version > cache.version; |
269 |
| - } |
270 |
| - |
271 |
| - public cachedSerializedParameterNeedsUpdate (parameter: IParameter): boolean { |
272 |
| - const cache = this.getCachedSerializedParameter(parameter); |
273 |
| - if (cache == null) return true; |
274 |
| - |
275 |
| - const version = this.languageService.getFileVersion(parameter.filePath); |
276 |
| - return version > cache.version; |
277 |
| - } |
278 |
| - |
279 |
| - public cachedSerializedClassNeedsUpdate (classDeclaration: IClassDeclaration): boolean { |
280 |
| - const cache = this.getCachedSerializedClass(classDeclaration); |
281 |
| - if (cache == null) return true; |
282 |
| - |
283 |
| - const version = this.languageService.getFileVersion(classDeclaration.filePath); |
284 |
| - return version > cache.version; |
285 |
| - } |
286 |
| - |
287 |
| - public cachedSerializedEnumNeedsUpdate (enumDeclaration: IEnumDeclaration): boolean { |
288 |
| - const cache = this.getCachedSerializedEnum(enumDeclaration); |
289 |
| - if (cache == null) return true; |
290 |
| - |
291 |
| - const version = this.languageService.getFileVersion(enumDeclaration.filePath); |
292 |
| - return version > cache.version; |
293 |
| - } |
294 |
| - |
295 |
| - public cachedSerializedFunctionNeedsUpdate (functionDeclaration: IFunctionDeclaration): boolean { |
296 |
| - const cache = this.getCachedSerializedFunction(functionDeclaration); |
297 |
| - if (cache == null) return true; |
298 |
| - |
299 |
| - const version = this.languageService.getFileVersion(functionDeclaration.filePath); |
300 |
| - return version > cache.version; |
301 |
| - } |
302 |
| - |
303 | 197 | public cachedVariableNeedsUpdate (variable: IVariableAssignment): boolean {
|
304 | 198 | const cache = this.getCachedVariable(variable.filePath, variable.name);
|
305 | 199 | if (cache == null) return true;
|
|
0 commit comments