syncSyntax<State> method

TextSyntaxSnapshot<State> syncSyntax<State>(
  1. TextSyntaxSession<State> session, {
  2. String? language,
  3. bool force = false,
})

Incrementally synchronizes session and updates the dedicated syntax decoration layer without disturbing search or diagnostics.

Implementation

TextSyntaxSnapshot<State> syncSyntax<State>(
  TextSyntaxSession<State> session, {
  String? language,
  bool force = false,
}) {
  if (!force && !workAssessment.allowSynchronousSyntax) {
    return session.snapshot ??
        TextSyntaxSnapshot<State>(
          decorations: decorationsForLayer(textSyntaxDecorationLayerKey),
          language: language ?? session.language,
          document: _document,
        );
  }
  final snapshot = session.syncDocument(
    _document,
    language: language,
    force: force,
    change: _lastDocumentChange,
  );
  setDecorationLayer(
    textSyntaxDecorationLayerKey,
    snapshot.decorations,
    priority: textSyntaxDecorationLayerPriority,
  );
  return snapshot;
}