Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Changed: Rename useContext parameter to useRelations.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Sep 14, 2018
1 parent 131b2be commit dfa9c6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions src/model/operation/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export function transform( a, b, context = {} ) {
* @param {Array.<module:engine/model/operation/operation~Operation>} operationsB
* @param {Object} options Additional transformation options.
* @param {module:engine/model/document~Document|null} options.document Document which the operations change.
* @param {Boolean} [options.useContext=false] Whether during transformation additional context information should be gathered and used.
* @param {Boolean} [options.useRelations=false] Whether during transformation relations should be used (used during undo for
* better conflict resolution).
* @param {Boolean} [options.padWithNoOps=false] Whether additional {@link module:engine/model/operation/nooperation~NoOperation}s
* should be added to the transformation results to force the same last base version for both transformed sets (in case
* if some operations got broken into multiple operations during transformation).
Expand Down Expand Up @@ -302,7 +303,7 @@ export function transformSets( operationsA, operationsB, options ) {
originalOperationsBCount: operationsB.length
};

const contextFactory = new ContextFactory( options.document, options.useContext );
const contextFactory = new ContextFactory( options.document, options.useRelations );
contextFactory.setOriginalOperations( operationsA );
contextFactory.setOriginalOperations( operationsB );

Expand Down Expand Up @@ -380,13 +381,14 @@ class ContextFactory {
// Creates `ContextFactory` instance.
//
// @param {module:engine/model/document~Document} document Document which the operations change.
// @param {Boolean} useContext Whether during transformation additional context information should be gathered and used.
constructor( document, useContext ) {
// @param {Boolean} useRelations Whether during transformation relations should be used (used during undo for
// better conflict resolution).
constructor( document, useRelations ) {
// `model.History` instance which information about undone operations will be taken from.
this._history = document.history;

// Whether additional context should be used.
this._useContext = useContext;
this._useRelations = useRelations;

// For each operation that is created during transformation process, we keep a reference to the original operation
// which it comes from. The original operation works as a kind of "identifier". Every contextual information
Expand Down Expand Up @@ -512,15 +514,13 @@ class ContextFactory {
aIsStrong,
aWasUndone: this._wasUndone( opA ),
bWasUndone: this._wasUndone( opB ),
abRelation: this._useContext ? this._getRelation( opA, opB ) : null,
baRelation: this._useContext ? this._getRelation( opB, opA ) : null
abRelation: this._useRelations ? this._getRelation( opA, opB ) : null,
baRelation: this._useRelations ? this._getRelation( opB, opA ) : null
};
}

// Returns whether given operation `op` has already been undone.
//
// This is only used when additional context mode is on (options.useContext == true).
//
// Information whether an operation was undone gives more context when making a decision when two operations are in conflict.
//
// @param {module:engine/model/operation/operation~Operation} op
Expand All @@ -538,8 +538,6 @@ class ContextFactory {
// Returns a relation between `opA` and an operation which is undone by `opB`. This can be `String` value if a relation
// was set earlier or `null` if there was no relation between those operations.
//
// This is only used when additional context mode is on (options.useContext == true).
//
// This is a little tricky to understand, so let's compare it to `ContextFactory#_wasUndone`.
//
// When `wasUndone( opB )` is used, we check if the `opB` has already been undone. It is obvious, that the
Expand Down
2 changes: 1 addition & 1 deletion tests/model/operation/transform/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export function syncClients() {

const options = {
document: localClient.document,
useContext: false,
useRelations: false,
padWithNoOps: true
};

Expand Down

0 comments on commit dfa9c6f

Please sign in to comment.