You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some editors always produce a valid result. It should, therefore, be possible to implement editors whose result property is of type T and not of type Validated<T>. There are two possible solutions:
Easy solution
Create function defaultResult(): Validated<R> in Expander that can be overridden by subclasses to achieve that the result is always Valid. Plugins can then call force() on results when they know that the result is always Valid.
Pro
This could be implemented quite easily and the API-changes would be backward-compatible.
Contra
not the cleanest solution
the fact that an editor always produces a valid result is not captured in the type definitions
this leads to many unnecessary force() calls.
Complete solution
Change the type of result to R instead of Validated<R>. Editors that may have an invalid result can just pass Validated<R> as the type parameter.
There are however some problems with this solution.
There is currently no way to reflectively create editors for a generic type. This means we can not create an editor for result type ´Validated<T>.
use KType instead of KClass for registering editor factories
there is the typeOf function that can be used to get the KType instead of the KClass from a reified generic
should this also be done for EditorView factories?
How do the CommandLine, the SettingsEditor and the argumentPrompt know if the result of an editor is valid?
Add property isValid: ReactiveBoolean to interface Editor
Create editors by asking for an editor of type P and then for an editor of type Validated<P>
A ListEditor doesn't know if its child results can be invalid.
Create abstract function accumulateResults that is implemented by subclasses ValidatedListEditor and SimpleListEditor
The SyntaxErrorInspection only works for Editors with validated results
Use KType instead of KClass for registering inspections and commands
Pro
clean
this would solve fundamental problems such as generic reflective registration
everything is visible in the types
Contra
quite tedious to implement
many major backward-incompatible changes to the API
The text was updated successfully, but these errors were encountered:
Some editors always produce a valid result. It should, therefore, be possible to implement editors whose
result
property is of typeT
and not of typeValidated<T>
. There are two possible solutions:Easy solution
Create function
defaultResult(): Validated<R>
inExpander
that can be overridden by subclasses to achieve that theresult
is alwaysValid
. Plugins can then callforce()
on results when they know that the result is alwaysValid
.Pro
Contra
force()
calls.Complete solution
Change the type of
result
toR
instead ofValidated<R>
. Editors that may have an invalid result can just passValidated<R>
as the type parameter.There are however some problems with this solution.
Validated<T>
.KType
instead ofKClass
for registering editor factoriestypeOf
function that can be used to get theKType
instead of theKClass
from a reified genericEditorView
factories?CommandLine
, theSettingsEditor
and theargumentPrompt
know if the result of an editor is valid?isValid: ReactiveBoolean
to interfaceEditor
P
and then for an editor of typeValidated<P>
ListEditor
doesn't know if its child results can be invalid.accumulateResults
that is implemented by subclassesValidatedListEditor
andSimpleListEditor
SyntaxErrorInspection
only works for Editors with validated resultsKType
instead ofKClass
for registering inspections and commandsPro
Contra
The text was updated successfully, but these errors were encountered: