31
31
import com .github ._1c_syntax .utils .Lazy ;
32
32
import lombok .RequiredArgsConstructor ;
33
33
import lombok .Setter ;
34
- import lombok .SneakyThrows ;
35
34
import lombok .extern .slf4j .Slf4j ;
36
35
import org .apache .commons .io .FileUtils ;
37
36
import org .springframework .beans .factory .ObjectProvider ;
@@ -183,15 +182,31 @@ public void clear() {
183
182
configurationMetadata .clear ();
184
183
}
185
184
185
+ /**
186
+ * Помечает документ как открытый и перестраивает его содержимое
187
+ * <p/>
188
+ * Документы, помеченные как открытые, не будут удаляться из контекста сервера при вызове {@link #removeDocument(URI)},
189
+ * а так же не будут очищаться при вызове {@link #tryClearDocument(DocumentContext)}.
190
+ * <p/>
191
+ * Если вспомогательные данные документа был в "замороженном" состоянии, то перед перестроением документа
192
+ * они будут разморожены.
193
+ *
194
+ * @param documentContext документ, который необходимо открыть.
195
+ * @param content новое содержимое документа.
196
+ * @param version версия документа.
197
+ */
186
198
public void openDocument (DocumentContext documentContext , String content , Integer version ) {
187
199
openedDocuments .add (documentContext );
188
- rebuildDocument (documentContext , content , version );
189
-
190
- // under control?
191
200
documentContext .unfreezeComputedData ();
201
+ rebuildDocument (documentContext , content , version );
192
202
}
193
203
194
- @ SneakyThrows
204
+ /**
205
+ * Перестроить документ. В качестве содержимого будут использоваться данные,
206
+ * прочитанные из файла, с которым связан документ.
207
+ *
208
+ * @param documentContext документ, который необходимо перестроить.
209
+ */
195
210
public void rebuildDocument (DocumentContext documentContext ) {
196
211
if (states .get (documentContext ) == State .WITH_CONTENT ) {
197
212
return ;
@@ -200,24 +215,41 @@ public void rebuildDocument(DocumentContext documentContext) {
200
215
documentContext .rebuild ();
201
216
states .put (documentContext , State .WITH_CONTENT );
202
217
}
218
+
219
+ /**
220
+ * Перестроить документ, используя новое содержимое.
221
+ *
222
+ * @param documentContext документ, который необходимо перестроить.
223
+ * @param content новое содержимое документа.
224
+ * @param version версия документа.
225
+ */
203
226
public void rebuildDocument (DocumentContext documentContext , String content , Integer version ) {
204
227
documentContext .rebuild (content , version );
205
228
states .put (documentContext , State .WITH_CONTENT );
206
229
}
207
230
231
+ /**
232
+ * Попытаться очистить документ, если он не открыт.
233
+ *
234
+ * @param documentContext документ, который необходимо попытаться закрыть.
235
+ */
208
236
public void tryClearDocument (DocumentContext documentContext ) {
209
237
if (openedDocuments .contains (documentContext )) {
210
238
return ;
211
239
}
212
240
213
- states .put (documentContext , State .CREATED );
241
+ states .put (documentContext , State .WITHOUT_CONTENT );
214
242
documentContext .clearSecondaryData ();
215
243
}
216
244
245
+ /**
246
+ * Закрыть документ и очистить его содержимое.
247
+ *
248
+ * @param documentContext документ, который необходимо закрыть.
249
+ */
217
250
public void closeDocument (DocumentContext documentContext ) {
218
251
openedDocuments .remove (documentContext );
219
- states .put (documentContext , State .CREATED );
220
- documentContext .unfreezeComputedData ();
252
+ states .put (documentContext , State .WITHOUT_CONTENT );
221
253
documentContext .clearSecondaryData ();
222
254
}
223
255
@@ -292,9 +324,17 @@ private String getMessage(String key) {
292
324
return Resources .getResourceString (languageServerConfiguration .getLanguage (), getClass (), key );
293
325
}
294
326
327
+ /**
328
+ * Состояние документа в контексте.
329
+ */
295
330
private enum State {
296
- CREATED ,
297
- FROZEN ,
331
+ /**
332
+ * В документе отсутствует контент или он был очищен.
333
+ */
334
+ WITHOUT_CONTENT ,
335
+ /**
336
+ * В документе присутствует контент.
337
+ */
298
338
WITH_CONTENT
299
339
}
300
340
0 commit comments