Skip to content

Commit

Permalink
dc: add wrapping commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Sep 30, 2023
1 parent 5bd5af0 commit 9bb1a2e
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 11 deletions.
14 changes: 7 additions & 7 deletions packages/DomainCode-Diff/DCMatcher.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ DCMatcher >> fineGrainedMatch2From: src to: dest in: aMapping [
commonAncestorOf: (Array streamContents: [:s | dest allMorphsDo: [:k | (aMapping isDestMapped: k) ifFalse: [s nextPut: k]]])
root: dest.
(topSrc notNil and: [topDest notNil]) ifTrue: [
SBToggledCode
comment: ''
active: 0
do: {[self assert: (aMapping destForSrc: topSrc owner) = topDest owner]}.
DCGreedyBottomUpMatcher new
sizeThreshold: 900000000;
lastChanceMatchFrom: topSrc to: topDest in: aMapping]
"see if we can answer quickly, otherwise we accept a worse diff result"
[
DCGreedyBottomUpMatcher new
sizeThreshold: 900000000;
lastChanceMatchFrom: topSrc to: topDest in: aMapping]
valueWithin: 400 milliSeconds
onTimeout: []]
]

{ #category : #'as yet unclassified' }
Expand Down
84 changes: 80 additions & 4 deletions packages/DomainCode-Parser/DCBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ DCBlock class >> parseBlock: aString language: aLanguage [
yourself]
]

{ #category : #'as yet unclassified' }
DCBlock class >> registerShortcuts: aProvider [

aProvider cmdShortcut: $( do: #wrapInRoundParenthesis.
aProvider cmdShortcut: ${ do: #wrapInCurlyBraces.
aProvider cmdShortcut: $[ do: #wrapInSquareBrackets.
aProvider cmdShortcut: $' do: #wrapInSingleQuotes.
aProvider cmdShortcut: $" do: #wrapInDoubleQuotes.
aProvider cmdShortcut: $` do: #wrapInBackticks
]
{ #category : #'as yet unclassified' }
DCBlock >> absolutePositionOf: aMorph [
Expand Down Expand Up @@ -208,7 +219,7 @@ DCBlock >> deleteBeforeCursor [
do: [:new :edit | apply value: new value: edit value: cursorIndex - 1]]
]
{ #category : #'as yet unclassified' }
{ #category : #'text modify' }
DCBlock >> deleteFrom: aString at: aNumber do: aBlock [
| new |
Expand Down Expand Up @@ -403,7 +414,7 @@ DCBlock >> inputClosestTextMorphTo: cursorPosition [
in: best]
]
{ #category : #'as yet unclassified' }
{ #category : #'text modify' }
DCBlock >> insert: aString in: aContainerString at: aNumber do: aBlock [
| new |
Expand Down Expand Up @@ -556,8 +567,10 @@ DCBlock >> pairMap [
{ #category : #'as yet unclassified' }
DCBlock >> placeCursorIn: newTree at: newIndex [
newIndex ifNil: [^ self].
^ newIndex isNumber ifTrue: [newTree startInputAtSourceIndex: newIndex] ifFalse: [ | target |
target := newTree blockFor: newIndex.
target := (newTree blockFor: newIndex) ifNil: [^ self].
target isTextMorph
ifTrue: [
newTree sandblockEditor
Expand Down Expand Up @@ -707,7 +720,7 @@ DCBlock >> swap: aNumber [
do: {[SBTSRange start: startIndex size: pivot range size]. [startIndex]})]]]
]
{ #category : #'as yet unclassified' }
{ #category : #'text modify' }
DCBlock >> swap: aRange with: anotherRange in: aString do: aBlock [
| first second new |
Expand Down Expand Up @@ -841,6 +854,69 @@ DCBlock >> valid [
^ self type ~= 'ERROR'
]
{ #category : #'text modify' }
DCBlock >> wrap: aRange in: aString open: anotherString close: aThirdString [
self
example: [DCBlock new]
args: [{SBTSRange start: 3 size: 3. 'abcdefghi'. '('. ')'}]
label: 'example'.
^ (aString first: aRange start index), anotherString, (aString copyFrom: aRange start index + 1 to: aRange end index), aThirdString, (aString allButFirst: aRange end index)
]
{ #category : #'action helpers' }
DCBlock >> wrapIn: aString [
^ self tryApplyChange: [:source :textMorph :cursorIndex :apply |
apply
value: (self wrap: self range in: source open: aString close: (self pairMap at: aString))
value: nil
value: self range]
]
{ #category : #actions }
DCBlock >> wrapInBackticks [
<action>
self wrapIn: '`'
]
{ #category : #actions }
DCBlock >> wrapInCurlyBraces [
<action>
self wrapIn: '{'
]
{ #category : #actions }
DCBlock >> wrapInDoubleQuotes [
<action>
self wrapIn: '"'
]
{ #category : #actions }
DCBlock >> wrapInRoundParenthesis [
<action>
self wrapIn: '('
]
{ #category : #actions }
DCBlock >> wrapInSingleQuotes [
<action>
self wrapIn: ''''
]
{ #category : #actions }
DCBlock >> wrapInSquareBrackets [
<action>
self wrapIn: '['
]
{ #category : #'as yet unclassified' }
DCBlock >> writeSourceOn: aStream [
Expand Down

0 comments on commit 9bb1a2e

Please sign in to comment.