diff options
| author | David Schulz <[email protected]> | 2021-02-26 08:29:15 +0100 |
|---|---|---|
| committer | David Schulz <[email protected]> | 2021-03-02 12:51:47 +0000 |
| commit | d17277b5466ced5c39e615efcc7820be47d770f4 (patch) | |
| tree | facc44eac9e00c61145a89c5b37fbb78b9053042 /src/libs/languageserverprotocol/textsynchronization.cpp | |
| parent | 687597152e67bd662805bf01ae1202db3ca2db2e (diff) | |
LSP: reduce error handling complexity
Instead of checking recursively every possible object just check the
required keys for an object and validate it on construction or
assignment from json.
This will reduce the implementation effort for protocol extensions and
also reduce the false positives we might get if the protocol gets
updated.
Change-Id: I3df24e62430d2c7575d26c1581e6a9606e7da4c1
Reviewed-by: hjk <[email protected]>
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/libs/languageserverprotocol/textsynchronization.cpp')
| -rw-r--r-- | src/libs/languageserverprotocol/textsynchronization.cpp | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/src/libs/languageserverprotocol/textsynchronization.cpp b/src/libs/languageserverprotocol/textsynchronization.cpp index ec8ec0963f0..f18548f8205 100644 --- a/src/libs/languageserverprotocol/textsynchronization.cpp +++ b/src/libs/languageserverprotocol/textsynchronization.cpp @@ -74,12 +74,6 @@ DidChangeTextDocumentParams::DidChangeTextDocumentParams( setContentChanges({TextDocumentContentChangeEvent(text)}); } -bool DidChangeTextDocumentParams::isValid(ErrorHierarchy *error) const -{ - return check<VersionedTextDocumentIdentifier>(error, textDocumentKey) - && checkArray<TextDocumentContentChangeEvent>(error, contentChangesKey); -} - DidOpenTextDocumentParams::DidOpenTextDocumentParams(const TextDocumentItem &document) { setTextDocument(document); @@ -96,24 +90,11 @@ DidChangeTextDocumentParams::TextDocumentContentChangeEvent::TextDocumentContent setText(text); } -bool DidChangeTextDocumentParams::TextDocumentContentChangeEvent::isValid(ErrorHierarchy *error) const -{ - return checkOptional<Range>(error, rangeKey) - && checkOptional<int>(error, rangeLengthKey) - && check<QString>(error, textKey); -} - DidSaveTextDocumentParams::DidSaveTextDocumentParams(const TextDocumentIdentifier &document) { setTextDocument(document); } -bool DidSaveTextDocumentParams::isValid(ErrorHierarchy *error) const -{ - return check<TextDocumentIdentifier>(error, textDocumentKey) - && checkOptional<QString>(error, textKey); -} - WillSaveTextDocumentParams::WillSaveTextDocumentParams( const TextDocumentIdentifier &document, const WillSaveTextDocumentParams::TextDocumentSaveReason &reason) @@ -122,16 +103,4 @@ WillSaveTextDocumentParams::WillSaveTextDocumentParams( setReason(reason); } -bool WillSaveTextDocumentParams::isValid(ErrorHierarchy *error) const -{ - return check<TextDocumentIdentifier>(error, textDocumentKey) - && check<int>(error, reasonKey); -} - -bool TextDocumentSaveRegistrationOptions::isValid(ErrorHierarchy *error) const -{ - return TextDocumentRegistrationOptions::isValid(error) - && checkOptional<bool>(error, includeTextKey); -} - } // namespace LanguageServerProtocol |
