@@ -1155,13 +1155,62 @@ module ts {
1155
1155
getClassificationsForLine ( text : string , lexState : EndOfLineState , classifyKeywordsInGenerics ?: boolean ) : ClassificationResult ;
1156
1156
}
1157
1157
1158
+ /**
1159
+ * The document registry represents a store of SourceFile objects that can be shared between
1160
+ * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
1161
+ * of files in the context.
1162
+ * SourceFile objects account for most of the memory usage by the language service. Sharing
1163
+ * the same DocumentRegistry instance between different instances of LanguageService allow
1164
+ * for more efficient memory utilization since all projects will share at least the library
1165
+ * file (lib.d.ts).
1166
+ *
1167
+ * A more advanced use of the document registry is to serialize sourceFile objects to disk
1168
+ * and re-hydrate them when needed.
1169
+ *
1170
+ * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
1171
+ * to all subsequent createLanguageService calls.
1172
+ */
1158
1173
export interface DocumentRegistry {
1174
+ /**
1175
+ * Request a stored SourceFile with a given filename and compilationSettings.
1176
+ * The first call to acquire will call createLanguageServiceSourceFile to generate
1177
+ * the SourceFile if was not found in the registry.
1178
+ *
1179
+ * @param filename The name of the file requested
1180
+ * @param compilationSettings Some compilation settings like target affects the
1181
+ * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
1182
+ * multiple copies of the same file for different compilation settings.
1183
+ * @parm scriptSnapshot Text of the file. Only used if the file was not found
1184
+ * in the registry and a new one was created.
1185
+ * @parm version Current version of the file. Only used if the file was not found
1186
+ * in the registry and a new one was created.
1187
+ */
1159
1188
acquireDocument (
1160
1189
filename : string ,
1161
1190
compilationSettings : CompilerOptions ,
1162
1191
scriptSnapshot : IScriptSnapshot ,
1163
1192
version : string ) : SourceFile ;
1164
1193
1194
+ /**
1195
+ * Request an updated version of an already existing SourceFile with a given filename
1196
+ * and compilationSettings. The update will intern call updateLanguageServiceSourceFile
1197
+ * to get an updated SourceFile.
1198
+ *
1199
+ * Note: It is not allowed to call update on a SourceFile that was not acquired from this
1200
+ * registry originally.
1201
+ *
1202
+ * @param sourceFile The original sourceFile object to update
1203
+ * @param filename The name of the file requested
1204
+ * @param compilationSettings Some compilation settings like target affects the
1205
+ * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
1206
+ * multiple copies of the same file for different compilation settings.
1207
+ * @parm scriptSnapshot Text of the file. Only used if the file was not found
1208
+ * in the registry and a new one was created.
1209
+ * @parm version Current version of the file. Only used if the file was not found
1210
+ * in the registry and a new one was created.
1211
+ * @parm textChangeRange Change ranges since the last snapshot. Only used if the file
1212
+ * was not found in the registry and a new one was created.
1213
+ */
1165
1214
updateDocument (
1166
1215
sourceFile : SourceFile ,
1167
1216
filename : string ,
@@ -1170,6 +1219,15 @@ module ts {
1170
1219
version : string ,
1171
1220
textChangeRange : TextChangeRange ) : SourceFile ;
1172
1221
1222
+ /**
1223
+ * Informs the DocumentRegistry that a file is not needed any longer.
1224
+ *
1225
+ * Note: It is not allowed to call release on a SourceFile that was not acquired from
1226
+ * this registry originally.
1227
+ *
1228
+ * @param filename The name of the file to be released
1229
+ * @param compilationSettings The compilation settings used to acquire the file
1230
+ */
1173
1231
releaseDocument ( filename : string , compilationSettings : CompilerOptions ) : void
1174
1232
}
1175
1233
0 commit comments