From 3bb38d34b4c22b8d6c2ec64d70f133071bf17f0f Mon Sep 17 00:00:00 2001 From: Tom Beckmann Date: Mon, 2 Oct 2023 22:10:07 +0200 Subject: [PATCH] dc: add support for updating while typing --- packages/DomainCode-Parser/DCBlock.class.st | 25 +++++++++++++------ .../DomainCode-Parser/DCQueryState.class.st | 10 +++++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/packages/DomainCode-Parser/DCBlock.class.st b/packages/DomainCode-Parser/DCBlock.class.st index 4dda76a..ac21075 100644 --- a/packages/DomainCode-Parser/DCBlock.class.st +++ b/packages/DomainCode-Parser/DCBlock.class.st @@ -264,7 +264,7 @@ DCBlock class >> smalltalkMessageSendSelector [ { #category : #smalltalk } DCBlock class >> smalltalkUndeclaredVariable [ - + ^ { [:x | x language = SBTSSmalltalk]. @@ -447,7 +447,8 @@ DCBlock >> deleteAfterCursor [ self deleteFrom: source at: cursorIndex + 1 - do: [:new :edit | apply value: new value: edit value: cursorIndex]] + do: [:new :edit | apply value: new value: edit value: cursorIndex]]. + self batchedChangeStep ] { #category : #'as yet unclassified' } @@ -458,7 +459,8 @@ DCBlock >> deleteBeforeCursor [ self deleteFrom: source at: cursorIndex - do: [:new :edit | apply value: new value: edit value: cursorIndex - 1]] + do: [:new :edit | apply value: new value: edit value: cursorIndex - 1]]. + self batchedChangeStep ] { #category : #'text modify' } @@ -732,7 +734,13 @@ DCBlock >> intoWorld: aWorld [ when: #selectionChanged send: #updateSelectionQueries to: self queryState. - self queryState updateChangeQueries] + self sandblockEditor + when: #batchedChange + send: #updateTypeQueries + to: self queryState. + self queryState + updateTypeQueries; + updateChangeQueries] ] { #category : #'as yet unclassified' } @@ -798,13 +806,14 @@ DCBlock >> keyStroke: anEvent [ insert: text in: source at: cursorIndex + 1 - do: [:new :edit | apply value: new value: edit value: cursorIndex + 1]]]] + do: [:new :edit | apply value: new value: edit value: cursorIndex + 1]]]]. + self batchedChangeStep ] { #category : #'as yet unclassified' } DCBlock >> language [ - ^ language ifNil: [self owner language] + ^ language ifNil: [self owner ifNotNil: #language] ] { #category : #'as yet unclassified' } @@ -895,8 +904,8 @@ DCBlock >> outOfWorld: aWorld [ self isRootBlock ifTrue: [ self sandblockEditor - removeActionsWithReceiver: self queryState - forEvent: #selectionChanged] + removeActionsWithReceiver: self queryState forEvent: #selectionChanged; + removeActionsWithReceiver: self queryState forEvent: #batchedChange] ] { #category : #'as yet unclassified' } diff --git a/packages/DomainCode-Parser/DCQueryState.class.st b/packages/DomainCode-Parser/DCQueryState.class.st index 5db7f99..525d45d 100644 --- a/packages/DomainCode-Parser/DCQueryState.class.st +++ b/packages/DomainCode-Parser/DCQueryState.class.st @@ -31,6 +31,7 @@ DCQueryState >> initialize [ currentDecorators := Dictionary new at: #selection put: WeakKeyDictionary new; at: #change put: WeakKeyDictionary new; + at: #type put: WeakKeyDictionary new; yourself. updateQueued := Dictionary new ] @@ -97,7 +98,8 @@ DCQueryState >> tryShortcut: aSymbol do: aBlock [ { #category : #'as yet unclassified' } DCQueryState >> updateChangeQueries [ - self updateQueriesFor: #change + self updateQueriesFor: #change. + self updateTypeQueries ] { #category : #'as yet unclassified' } @@ -118,3 +120,9 @@ DCQueryState >> updateSelectionQueries [ self updateQueriesFor: #selection ] + +{ #category : #'as yet unclassified' } +DCQueryState >> updateTypeQueries [ + + self updateQueriesFor: #type +]