Skip to content

Commit

Permalink
dc: switch to text-centric editing including whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Oct 9, 2023
1 parent 5bc7646 commit 17116ff
Show file tree
Hide file tree
Showing 21 changed files with 964 additions and 322 deletions.
19 changes: 19 additions & 0 deletions packages/DomainCode-Core/Morph.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ Morph >> allChildrenSelect: aBlock [
^ Array streamContents: [:stream | self allChildrenDo: [:b | (aBlock value: b) ifTrue: [stream nextPut: b]]]
]

{ #category : #'*DomainCode-Core' }
Morph >> allDomainBlocksWithDepthDo: aBlock leafDo: anotherBlock depth: aNumber [

anotherBlock value: self value: aNumber
]

{ #category : #'*DomainCode-Core' }
Morph >> children [

Expand Down Expand Up @@ -70,6 +76,19 @@ Morph >> purpose [
^ nil
]

{ #category : #'*DomainCode-Core' }
Morph >> setBoundsDirect: aRectangle [

| priorBounds box |
priorBounds := self outerBounds.

bounds := aRectangle.
fullBounds := aRectangle.

box := self outerBounds.
box = priorBounds ifFalse: [self invalidRect: (priorBounds quickMerge: box)]
]

{ #category : #'*DomainCode-Core' }
Morph >> treeSize [

Expand Down
28 changes: 23 additions & 5 deletions packages/DomainCode-Diff/DCChawatheScriptGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ DCChawatheScriptGenerator >> alignChildrenSrc: w dest: x srcInOrder: srcInOrder
{ #category : #actions }
DCChawatheScriptGenerator >> delete: aMorph [

aMorph delete
| target |
target := aMorph replacedParent
ifNotNil: [:p | p isReplacement ifTrue: [p] ifFalse: [aMorph]]
ifNil: [aMorph].

aMorph delete.

self logChanges ifTrue: [Transcript showln: {#delete. target}]
]

{ #category : #'as yet unclassified' }
Expand Down Expand Up @@ -87,7 +94,9 @@ DCChawatheScriptGenerator >> generateFrom: src to: dest in: aMapping [
{ #category : #actions }
DCChawatheScriptGenerator >> insert: aMorph at: aNumber in: anOwnerMorph [

anOwnerMorph addMorph: aMorph asElementNumber: aNumber
anOwnerMorph addMorph: aMorph asElementNumber: aNumber.
self maybeAttachFlash: aMorph.
self logChanges ifTrue: [Transcript showln: {#insert. anOwnerMorph. aNumber. aMorph}]
]

{ #category : #'as yet unclassified' }
Expand Down Expand Up @@ -134,14 +143,23 @@ DCChawatheScriptGenerator >> maybeAttachFlash: aMorph [
{ #category : #actions }
DCChawatheScriptGenerator >> move: aMorph to: anOwnerMorph postDeleteDo: aBlock [

| index |
| index target |
target := aMorph replacedParent
ifNotNil: [:p | p isReplacement ifTrue: [p] ifFalse: [aMorph]]
ifNil: [aMorph].

aMorph delete.
index := aBlock value.
anOwnerMorph addMorph: aMorph asElementNumber: index
anOwnerMorph addMorph: aMorph asElementNumber: index.

self maybeAttachFlash: target.
self logChanges ifTrue: [Transcript showln: {#move. anOwnerMorph. index. target}]
]

{ #category : #actions }
DCChawatheScriptGenerator >> update: aMorph with: aString [

aMorph contents: aString
aMorph contents: aString.
self maybeAttachFlash: aMorph.
self logChanges ifTrue: [Transcript showln: {#update. aMorph. aString}]
]
8 changes: 0 additions & 8 deletions packages/DomainCode-Diff/DCCommandScriptGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ DCCommandScriptGenerator >> editor: anEditor [
editor := anEditor
]

{ #category : #'initialize-release' }
DCCommandScriptGenerator >> initialize [

super initialize.

commands := OrderedCollection new
]

{ #category : #actions }
DCCommandScriptGenerator >> insert: aMorph at: aNumber in: anOwnerMorph [

Expand Down
11 changes: 10 additions & 1 deletion packages/DomainCode-Diff/DCMatcher.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DCMatcher >> commonAncestorOf: aCollection root: aTree [
{ #category : #'as yet unclassified' }
DCMatcher >> doCommandForEditsIn: aDest to: aSrc in: anEditor [

SBToggledCode comment: '' active: 2 do: {
SBToggledCode comment: '' active: 1 do: {
[
DCChawatheScriptGenerator new
generateFrom: aSrc
Expand Down Expand Up @@ -98,3 +98,12 @@ DCMatcher >> matchFrom: src to: dest [

^ mappings
]

{ #category : #'as yet unclassified' }
DCMatcher >> performEditsIn: aDest to: aSrc [

DCChawatheScriptGenerator new
generateFrom: aSrc
to: aDest
in: (self matchFrom: aSrc to: aDest)
]
6 changes: 6 additions & 0 deletions packages/DomainCode-Diff/String.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Extension { #name : #String }

{ #category : #'*DomainCode-Diff' }
String >> isolateLineBreaks [

^ (self splitBy: String lf) collect: #yourself separatedBy: String cr
]

{ #category : #'*DomainCode-Diff' }
String >> levenshteinDistanceTo: anotherString [

Expand Down
Loading

0 comments on commit 17116ff

Please sign in to comment.