mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
Added an extra api call that omits the default result
Signed-off-by: Titouan Vervack <titouan.vervack@sigasi.com>
This commit is contained in:
parent
69e9f07aca
commit
528de63088
2 changed files with 57 additions and 3 deletions
|
@ -50,7 +50,24 @@ public interface IReadAccess<State> {
|
|||
return work.exec(state);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tries to get a read-only copy of the State and execute {@code work} on it.
|
||||
*
|
||||
* @param work Work to execute on the State
|
||||
*
|
||||
* @return The result of executing {@code work}, or
|
||||
* null if the State is null
|
||||
* @since 2.15
|
||||
*/
|
||||
default <Result> Result tryReadOnly(IUnitOfWork<Result, State> work) {
|
||||
return readOnly((state) -> {
|
||||
if (state == null) return null;
|
||||
|
||||
return work.exec(state);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to get a read-only copy of the State and execute {@code work} on it.
|
||||
*
|
||||
|
@ -116,7 +133,27 @@ public interface IReadAccess<State> {
|
|||
return work.exec(state);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tries to get a read-only copy of the State and execute {@code work} on it.
|
||||
* Cancels all cancelable readers before executing the {@link IUnitOfWork}.
|
||||
* For interactive jobs that need fastest possible execution.
|
||||
*
|
||||
* @param work Work to execute on the State
|
||||
*
|
||||
* @return The result of executing {@code work}, or
|
||||
* null if the State is null
|
||||
* @since 2.15
|
||||
* @see CancelableUnitOfWork
|
||||
*/
|
||||
default <Result> Result tryPriorityReadOnly(IUnitOfWork<Result, State> work) {
|
||||
return priorityReadOnly((state) -> {
|
||||
if (state == null) return null;
|
||||
|
||||
return work.exec(state);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to get a read-only copy of the State and execute {@code work} on it.
|
||||
* Cancels all cancelable readers before executing the {@link IUnitOfWork}.
|
||||
|
|
|
@ -49,7 +49,24 @@ public interface IWriteAccess<State> {
|
|||
return work.exec(state);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tries to modify the State by executing {@code work} on it.
|
||||
*
|
||||
* @param work Work that modifies the State
|
||||
*
|
||||
* @return The result of executing {@code work}, or
|
||||
* null if the State is null
|
||||
* @since 2.15
|
||||
*/
|
||||
default <Result> Result tryModify(IUnitOfWork<Result, State> work) {
|
||||
return modify((state) -> {
|
||||
if (state == null) return null;
|
||||
|
||||
return work.exec(state);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to modify the State by executing {@code work} on it.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue