Skip to content

Commit 720e849

Browse files
Rename prev and next to previousSibling and nextSibling
1 parent 2744e0f commit 720e849

File tree

4 files changed

+150
-150
lines changed

4 files changed

+150
-150
lines changed

lib/SymbolTree.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -107,27 +107,27 @@ class SymbolTree {
107107
*
108108
* `O(1)`
109109
*
110-
* @method prev
110+
* @method previousSibling
111111
* @memberOf module:symbol-tree#
112112
* @param {Object} object
113113
* @return {Object}
114114
*/
115-
prev(object) {
116-
return this._node(object).prev;
115+
previousSibling(object) {
116+
return this._node(object).previousSibling;
117117
}
118118

119119
/**
120-
* Return the next sibling of the given object.
120+
* Return the nextSibling sibling of the given object.
121121
*
122122
* `O(1)`
123123
*
124-
* @method next
124+
* @method nextSibling
125125
* @memberOf module:symbol-tree#
126126
* @param {Object} object
127127
* @return {Object}
128128
*/
129-
next(object) {
130-
return this._node(object).next;
129+
nextSibling(object) {
130+
return this._node(object).nextSibling;
131131
}
132132

133133
/**
@@ -187,10 +187,10 @@ class SymbolTree {
187187
return null;
188188
}
189189

190-
const prev = this._node(object).prev;
190+
const previousSibling = this._node(object).previousSibling;
191191

192-
if (prev) {
193-
return this.lastInclusiveDescendant(prev);
192+
if (previousSibling) {
193+
return this.lastInclusiveDescendant(previousSibling);
194194
}
195195

196196
// if there is no previous sibling return the parent (might be null)
@@ -229,10 +229,10 @@ class SymbolTree {
229229
return null;
230230
}
231231

232-
const next = this._node(object).next;
232+
const nextSibling = this._node(object).nextSibling;
233233

234-
if (next) {
235-
return next;
234+
if (nextSibling) {
235+
return nextSibling;
236236
}
237237

238238
object = this._node(object).parent;
@@ -276,7 +276,7 @@ class SymbolTree {
276276
array.push(object);
277277
}
278278

279-
object = node.next;
279+
object = node.nextSibling;
280280
++index;
281281
}
282282

@@ -387,7 +387,7 @@ class SymbolTree {
387387
return new TreeIterator(
388388
this,
389389
object,
390-
this._node(object).prev,
390+
this._node(object).previousSibling,
391391
TreeIterator.PREV
392392
);
393393
}
@@ -406,7 +406,7 @@ class SymbolTree {
406406
return new TreeIterator(
407407
this,
408408
object,
409-
this._node(object).next,
409+
this._node(object).nextSibling,
410410
TreeIterator.NEXT
411411
);
412412
}
@@ -487,7 +487,7 @@ class SymbolTree {
487487

488488
if (parentNode.childIndexCachedUpTo) {
489489
const cachedUpToNode = this._node(parentNode.childIndexCachedUpTo);
490-
object = cachedUpToNode.next;
490+
object = cachedUpToNode.nextSibling;
491491
index = cachedUpToNode.getCachedIndex(parentNode) + 1;
492492
}
493493

@@ -500,7 +500,7 @@ class SymbolTree {
500500
}
501501

502502
++index;
503-
object = node.next;
503+
object = node.nextSibling;
504504
}
505505

506506
parentNode.childIndexCachedUpTo = child;
@@ -635,30 +635,30 @@ class SymbolTree {
635635
remove(removeObject) {
636636
const removeNode = this._node(removeObject);
637637
const parentNode = this._node(removeNode.parent);
638-
const prevNode = this._node(removeNode.prev);
639-
const nextNode = this._node(removeNode.next);
638+
const prevNode = this._node(removeNode.previousSibling);
639+
const nextNode = this._node(removeNode.nextSibling);
640640

641641
if (parentNode) {
642642
if (parentNode.firstChild === removeObject) {
643-
parentNode.firstChild = removeNode.next;
643+
parentNode.firstChild = removeNode.nextSibling;
644644
}
645645

646646
if (parentNode.lastChild === removeObject) {
647-
parentNode.lastChild = removeNode.prev;
647+
parentNode.lastChild = removeNode.previousSibling;
648648
}
649649
}
650650

651651
if (prevNode) {
652-
prevNode.next = removeNode.next;
652+
prevNode.nextSibling = removeNode.nextSibling;
653653
}
654654

655655
if (nextNode) {
656-
nextNode.prev = removeNode.prev;
656+
nextNode.previousSibling = removeNode.previousSibling;
657657
}
658658

659659
removeNode.parent = null;
660-
removeNode.prev = null;
661-
removeNode.next = null;
660+
removeNode.previousSibling = null;
661+
removeNode.nextSibling = null;
662662

663663
if (parentNode) {
664664
parentNode.childrenChanged();
@@ -682,7 +682,7 @@ class SymbolTree {
682682
*/
683683
insertBefore(newObject, referenceObject) {
684684
const referenceNode = this._node(referenceObject);
685-
const prevNode = this._node(referenceNode.prev);
685+
const prevNode = this._node(referenceNode.previousSibling);
686686
const newNode = this._node(newObject);
687687
const parentNode = this._node(referenceNode.parent);
688688

@@ -691,12 +691,12 @@ class SymbolTree {
691691
}
692692

693693
newNode.parent = referenceNode.parent;
694-
newNode.prev = referenceNode.prev;
695-
newNode.next = referenceObject;
696-
referenceNode.prev = newObject;
694+
newNode.previousSibling = referenceNode.previousSibling;
695+
newNode.nextSibling = referenceObject;
696+
referenceNode.previousSibling = newObject;
697697

698698
if (prevNode) {
699-
prevNode.next = newObject;
699+
prevNode.nextSibling = newObject;
700700
}
701701

702702
if (parentNode && parentNode.firstChild === referenceObject) {
@@ -725,7 +725,7 @@ class SymbolTree {
725725
*/
726726
insertAfter(newObject, referenceObject) {
727727
const referenceNode = this._node(referenceObject);
728-
const nextNode = this._node(referenceNode.next);
728+
const nextNode = this._node(referenceNode.nextSibling);
729729
const newNode = this._node(newObject);
730730
const parentNode = this._node(referenceNode.parent);
731731

@@ -734,12 +734,12 @@ class SymbolTree {
734734
}
735735

736736
newNode.parent = referenceNode.parent;
737-
newNode.prev = referenceObject;
738-
newNode.next = referenceNode.next;
739-
referenceNode.next = newObject;
737+
newNode.previousSibling = referenceObject;
738+
newNode.nextSibling = referenceNode.nextSibling;
739+
referenceNode.nextSibling = newObject;
740740

741741
if (nextNode) {
742-
nextNode.prev = newObject;
742+
nextNode.previousSibling = newObject;
743743
}
744744

745745
if (parentNode && parentNode.lastChild === referenceObject) {

lib/SymbolTreeNode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
module.exports = class SymbolTreeNode {
44
constructor() {
55
this.parent = null;
6-
this.prev = null;
7-
this.next = null;
6+
this.previousSibling = null;
7+
this.nextSibling = null;
88

99
this.firstChild = null;
1010
this.lastChild = null;
@@ -21,7 +21,7 @@ module.exports = class SymbolTreeNode {
2121
}
2222

2323
get isAttached() {
24-
return !!(this.parent || this.prev || this.next);
24+
return !!(this.parent || this.previousSibling || this.nextSibling);
2525
}
2626

2727
get hasChildren() {

lib/TreeIterator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class TreeIterator {
2828
const value = this[NEXT];
2929

3030
if (iterateFunc === 1) {
31-
this[NEXT] = tree._node(value).prev;
31+
this[NEXT] = tree._node(value).previousSibling;
3232
}
3333
else if (iterateFunc === 2) {
34-
this[NEXT] = tree._node(value).next;
34+
this[NEXT] = tree._node(value).nextSibling;
3535
}
3636
else if (iterateFunc === 3) {
3737
this[NEXT] = tree._node(value).parent;

0 commit comments

Comments
 (0)