Skip to content

Commit 0a62232

Browse files
committed
javadoc и чистка
1 parent 7f90596 commit 0a62232

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed

src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import com.github._1c_syntax.utils.Lazy;
3232
import lombok.RequiredArgsConstructor;
3333
import lombok.Setter;
34-
import lombok.SneakyThrows;
3534
import lombok.extern.slf4j.Slf4j;
3635
import org.apache.commons.io.FileUtils;
3736
import org.springframework.beans.factory.ObjectProvider;
@@ -183,15 +182,31 @@ public void clear() {
183182
configurationMetadata.clear();
184183
}
185184

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+
*/
186198
public void openDocument(DocumentContext documentContext, String content, Integer version) {
187199
openedDocuments.add(documentContext);
188-
rebuildDocument(documentContext, content, version);
189-
190-
// under control?
191200
documentContext.unfreezeComputedData();
201+
rebuildDocument(documentContext, content, version);
192202
}
193203

194-
@SneakyThrows
204+
/**
205+
* Перестроить документ. В качестве содержимого будут использоваться данные,
206+
* прочитанные из файла, с которым связан документ.
207+
*
208+
* @param documentContext документ, который необходимо перестроить.
209+
*/
195210
public void rebuildDocument(DocumentContext documentContext) {
196211
if (states.get(documentContext) == State.WITH_CONTENT) {
197212
return;
@@ -200,24 +215,41 @@ public void rebuildDocument(DocumentContext documentContext) {
200215
documentContext.rebuild();
201216
states.put(documentContext, State.WITH_CONTENT);
202217
}
218+
219+
/**
220+
* Перестроить документ, используя новое содержимое.
221+
*
222+
* @param documentContext документ, который необходимо перестроить.
223+
* @param content новое содержимое документа.
224+
* @param version версия документа.
225+
*/
203226
public void rebuildDocument(DocumentContext documentContext, String content, Integer version) {
204227
documentContext.rebuild(content, version);
205228
states.put(documentContext, State.WITH_CONTENT);
206229
}
207230

231+
/**
232+
* Попытаться очистить документ, если он не открыт.
233+
*
234+
* @param documentContext документ, который необходимо попытаться закрыть.
235+
*/
208236
public void tryClearDocument(DocumentContext documentContext) {
209237
if (openedDocuments.contains(documentContext)) {
210238
return;
211239
}
212240

213-
states.put(documentContext, State.CREATED);
241+
states.put(documentContext, State.WITHOUT_CONTENT);
214242
documentContext.clearSecondaryData();
215243
}
216244

245+
/**
246+
* Закрыть документ и очистить его содержимое.
247+
*
248+
* @param documentContext документ, который необходимо закрыть.
249+
*/
217250
public void closeDocument(DocumentContext documentContext) {
218251
openedDocuments.remove(documentContext);
219-
states.put(documentContext, State.CREATED);
220-
documentContext.unfreezeComputedData();
252+
states.put(documentContext, State.WITHOUT_CONTENT);
221253
documentContext.clearSecondaryData();
222254
}
223255

@@ -292,9 +324,17 @@ private String getMessage(String key) {
292324
return Resources.getResourceString(languageServerConfiguration.getLanguage(), getClass(), key);
293325
}
294326

327+
/**
328+
* Состояние документа в контексте.
329+
*/
295330
private enum State {
296-
CREATED,
297-
FROZEN,
331+
/**
332+
* В документе отсутствует контент или он был очищен.
333+
*/
334+
WITHOUT_CONTENT,
335+
/**
336+
* В документе присутствует контент.
337+
*/
298338
WITH_CONTENT
299339
}
300340

0 commit comments

Comments
 (0)