More flexible API to let language plugins when and how quickly to re-parse documents

Review Request #128290 - Created June 26, 2016 and submitted

Sven Brauch

This replaces the whitespaceSensitivity() API which allowed languages to decide whether they are sensitive to whitespace changes, and instead introduces a function

virtual int suggestedReparseDelayForChange(KTextEditor::Document* doc, const KTextEditor::Range& changedRange,
                                           const QString& changedText, bool removal) const;

in ILanguageSupport which can be overriden. Languages can choose that the signalled change does not require an update at all (white-space in some languages), that an update should happen with the default delay, or give a custom delay in ms. The default implementation indicates an update with the default delay if the change was not whitespace-only or was whitespace but adjacent to a word.

In kdev-clang, this enables us to do something like

int ClangSupport::suggestedReparseDelayForChange(KTextEditor::Document* /*doc*/, const KTextEditor::Range& /*changedRange*/,
                                                 const QString& changedText, bool /*removal*/) const
    if ( changedText.contains(QLatin1Char('\n')) || changedText.contains(QLatin1Char(';')) ) {
        return ILanguageSupport::DefaultDelay;
    return 3000;

(will submit separately), which makes completion feel much more snappy (Kevin knows ;)). I actually think I will do something similar in kdev-python, namely recommend an instant re-parse when a newline is added.



  • 0
  • 3
  • 0
  • 3
Description From Last Updated
Milian Wolff
Milian Wolff
Sven Brauch
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit 64c4abb1a2f938ef34c16d42356a6e4cba8b6136 by Sven Brauch to branch 5.0.