From 0a4c68a816b44c3e8ac0322ae00990ba8f4d33fe Mon Sep 17 00:00:00 2001 From: Joana Be Date: Thu, 28 Sep 2023 15:55:53 +0200 Subject: [PATCH] Proper adding and removal of instance variable probe morphs --- .../instance/addProbe..st | 4 ++-- .../instance/at..st | 4 ++++ .../instance/removeProbe..st | 2 +- .../methodProperties.json | 5 +++-- .../instance/assignedClassName..st | 3 +++ .../instance/assignedClassName.st | 3 +++ .../instance/className..st | 3 --- .../instance/className.st | 3 --- .../instance/variableName..st | 2 +- .../instance/variableName.st | 2 +- .../methodProperties.json | 8 ++++---- .../properties.json | 3 +-- .../instance/removeButtonClicked.st | 5 ++++- .../methodProperties.json | 2 +- .../instance/applyInstanceVariableIn.for..st | 13 +++++++++++++ .../BPStyler.class/instance/formatNonMethod..st | 17 +++++++++++++++++ .../BPStyler.class/instance/privateFormat..st | 2 +- .../BPStyler.class/methodProperties.json | 4 +++- .../doAddInstanceProbeToRegistry.nameIn..st | 4 ++-- .../CodeHolder.extension/methodProperties.json | 2 +- 20 files changed, 65 insertions(+), 26 deletions(-) create mode 100644 packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/at..st create mode 100644 packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/assignedClassName..st create mode 100644 packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/assignedClassName.st delete mode 100644 packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/className..st delete mode 100644 packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/className.st create mode 100644 packages/Babylonian-UI.package/BPStyler.class/instance/applyInstanceVariableIn.for..st create mode 100644 packages/Babylonian-UI.package/BPStyler.class/instance/formatNonMethod..st diff --git a/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/addProbe..st b/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/addProbe..st index e04b5877..0d68c602 100644 --- a/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/addProbe..st +++ b/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/addProbe..st @@ -1,9 +1,9 @@ as yet unclassified addProbe: aProbe - nameToProbesDict at: aProbe className + nameToProbesDict at: aProbe assignedClassName ifPresent: [:registeredProbes | registeredProbes add: aProbe] ifAbsent: [ | k | k := KeyedSet keyBlock: [ :each | each variableName ]. - nameToProbesDict at: aProbe className put: k] + nameToProbesDict at: aProbe assignedClassName put: k] \ No newline at end of file diff --git a/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/at..st b/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/at..st new file mode 100644 index 00000000..d81a8005 --- /dev/null +++ b/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/at..st @@ -0,0 +1,4 @@ +as yet unclassified +at: aClassName + + ^ nameToProbesDict at: aClassName \ No newline at end of file diff --git a/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/removeProbe..st b/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/removeProbe..st index e0484392..9eca447e 100644 --- a/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/removeProbe..st +++ b/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/instance/removeProbe..st @@ -1,6 +1,6 @@ as yet unclassified removeProbe: aProbe - nameToProbesDict at: aProbe className + nameToProbesDict at: aProbe assignedClassName ifPresent: [:registeredProbes | registeredProbes remove: aProbe] \ No newline at end of file diff --git a/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/methodProperties.json b/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/methodProperties.json index 90daebc9..dd4bd954 100644 --- a/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/methodProperties.json +++ b/packages/Babylonian-Core.package/BPClassNameToInstanceProbes.class/methodProperties.json @@ -3,7 +3,8 @@ "clear" : "joabe 9/28/2023 12:59", "default" : "joabe 9/28/2023 12:57" }, "instance" : { - "addProbe:" : "joabe 9/28/2023 13:05", + "addProbe:" : "joabe 9/28/2023 15:50", + "at:" : "joabe 9/28/2023 15:08", "initialize" : "joabe 9/27/2023 16:33", "nameToProbesDict" : "joabe 9/28/2023 12:59", - "removeProbe:" : "joabe 9/27/2023 17:19" } } + "removeProbe:" : "joabe 9/28/2023 15:47" } } diff --git a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/assignedClassName..st b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/assignedClassName..st new file mode 100644 index 00000000..0ba85068 --- /dev/null +++ b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/assignedClassName..st @@ -0,0 +1,3 @@ +accessing +assignedClassName: aString + assignedClassName := aString \ No newline at end of file diff --git a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/assignedClassName.st b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/assignedClassName.st new file mode 100644 index 00000000..bb613fb3 --- /dev/null +++ b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/assignedClassName.st @@ -0,0 +1,3 @@ +accessing +assignedClassName + ^ assignedClassName \ No newline at end of file diff --git a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/className..st b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/className..st deleted file mode 100644 index 19023ac0..00000000 --- a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/className..st +++ /dev/null @@ -1,3 +0,0 @@ -accessing -className: aString - className := aString \ No newline at end of file diff --git a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/className.st b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/className.st deleted file mode 100644 index 08d21063..00000000 --- a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/className.st +++ /dev/null @@ -1,3 +0,0 @@ -accessing -className - ^ className \ No newline at end of file diff --git a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/variableName..st b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/variableName..st index bcffb8c4..a584d519 100644 --- a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/variableName..st +++ b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/variableName..st @@ -1,4 +1,4 @@ accessing variableName: aString - variableName := aString \ No newline at end of file + self enclosedExpressionSource: aString \ No newline at end of file diff --git a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/variableName.st b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/variableName.st index cd8d2993..28a76450 100644 --- a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/variableName.st +++ b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/variableName.st @@ -1,4 +1,4 @@ accessing variableName - ^ variableName \ No newline at end of file + ^ self enclosedExpressionSource \ No newline at end of file diff --git a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/methodProperties.json b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/methodProperties.json index c6954265..41ceb980 100644 --- a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/methodProperties.json +++ b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/methodProperties.json @@ -3,13 +3,13 @@ "annotationTag" : "joabe 9/25/2023 17:30" }, "instance" : { "asMorph" : "joabe 9/21/2023 22:32", + "assignedClassName" : "joabe 9/28/2023 15:45", + "assignedClassName:" : "joabe 9/28/2023 15:46", "canBeAnnotatedTo" : "joabe 9/21/2023 21:08", - "className" : "joabe 9/27/2023 17:16", - "className:" : "joabe 9/27/2023 17:16", "instrumentationCallFor:" : "joabe 9/25/2023 18:43", "isInstanceVariableProbe" : "joabe 9/21/2023 21:18", "probeTypeTag" : "joabe 9/25/2023 17:30", "removeFromMethod:" : "joabe 9/27/2023 16:43", - "variableName" : "joabe 9/27/2023 16:52", - "variableName:" : "joabe 9/27/2023 16:52", + "variableName" : "joabe 9/28/2023 14:47", + "variableName:" : "joabe 9/28/2023 14:47", "wantsMetaClassIndication" : "joabe 9/21/2023 21:08" } } diff --git a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/properties.json b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/properties.json index 3d82397c..acf4ba73 100644 --- a/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/properties.json +++ b/packages/Babylonian-Core.package/BPInstanceVariableProbe.class/properties.json @@ -6,8 +6,7 @@ ], "commentStamp" : "", "instvars" : [ - "variableName", - "className" ], + "assignedClassName" ], "name" : "BPInstanceVariableProbe", "pools" : [ ], diff --git a/packages/Babylonian-UI.package/BPInstanceVariableProbeMorph.class/instance/removeButtonClicked.st b/packages/Babylonian-UI.package/BPInstanceVariableProbeMorph.class/instance/removeButtonClicked.st index 5e9e7b6f..0a8e2a3b 100644 --- a/packages/Babylonian-UI.package/BPInstanceVariableProbeMorph.class/instance/removeButtonClicked.st +++ b/packages/Babylonian-UI.package/BPInstanceVariableProbeMorph.class/instance/removeButtonClicked.st @@ -1,6 +1,9 @@ as yet unclassified removeButtonClicked + "LSP violation here - but otherwise the removal of the morph won't happen... -jb" + BPClassNameToInstanceProbes value removeProbe: self annotation. super removeButtonClicked. - BPClassNameToInstanceProbes value removeProbe: self. + + \ No newline at end of file diff --git a/packages/Babylonian-UI.package/BPInstanceVariableProbeMorph.class/methodProperties.json b/packages/Babylonian-UI.package/BPInstanceVariableProbeMorph.class/methodProperties.json index 0179c284..697b024f 100644 --- a/packages/Babylonian-UI.package/BPInstanceVariableProbeMorph.class/methodProperties.json +++ b/packages/Babylonian-UI.package/BPInstanceVariableProbeMorph.class/methodProperties.json @@ -2,5 +2,5 @@ "class" : { }, "instance" : { - "removeButtonClicked" : "joabe 9/27/2023 17:19", + "removeButtonClicked" : "joabe 9/28/2023 15:54", "step" : "joabe 9/25/2023 18:34" } } diff --git a/packages/Babylonian-UI.package/BPStyler.class/instance/applyInstanceVariableIn.for..st b/packages/Babylonian-UI.package/BPStyler.class/instance/applyInstanceVariableIn.for..st new file mode 100644 index 00000000..28d09f99 --- /dev/null +++ b/packages/Babylonian-UI.package/BPStyler.class/instance/applyInstanceVariableIn.for..st @@ -0,0 +1,13 @@ +private +applyInstanceVariableIn: aPreformmattedText for: anInstanceProbe + + | interval | + interval := (aPreformmattedText string + allRangesOfRegexMatches: '(''| )', anInstanceProbe variableName, '(''| )') first. + + aPreformmattedText + addAttribute: (BPTextDecoration new + anchoredMorph: (self annotationMorphFor: anInstanceProbe); + yourself) + from: interval start + 1 + to: interval stop - 1. \ No newline at end of file diff --git a/packages/Babylonian-UI.package/BPStyler.class/instance/formatNonMethod..st b/packages/Babylonian-UI.package/BPStyler.class/instance/formatNonMethod..st new file mode 100644 index 00000000..9dbbc255 --- /dev/null +++ b/packages/Babylonian-UI.package/BPStyler.class/instance/formatNonMethod..st @@ -0,0 +1,17 @@ +private +formatNonMethod: aText + + | allRangesSubclassRegex className formattedText | + allRangesSubclassRegex := aText string allRangesOfRegexMatches: 'subclass\: #\w+'. + allRangesSubclassRegex ifEmpty: [^ super privateFormat: aText]. + "We are in a class definition and may need to add Text Decorations + for Instance Variable Probes." + className := aText string atAll: (allRangesSubclassRegex first start + ('subclass: #' size) to: + allRangesSubclassRegex first stop ). + formattedText := super privateFormat: aText. + BPClassNameToInstanceProbes value nameToProbesDict at: className + ifPresent: [:probesSet | probesSet do: [:anInstanceProbe | + self + applyInstanceVariableIn: formattedText + for: anInstanceProbe]]. + ^ formattedText \ No newline at end of file diff --git a/packages/Babylonian-UI.package/BPStyler.class/instance/privateFormat..st b/packages/Babylonian-UI.package/BPStyler.class/instance/privateFormat..st index 4641f827..741a9667 100644 --- a/packages/Babylonian-UI.package/BPStyler.class/instance/privateFormat..st +++ b/packages/Babylonian-UI.package/BPStyler.class/instance/privateFormat..st @@ -2,7 +2,7 @@ private privateFormat: aText | parseResult | - self ifNoSelectedMethod: [^ super privateFormat: aText]. + self ifNoSelectedMethod: [ ^ self formatNonMethod: aText ]. parseResult := PEGParserBPSmalltalk new match: aText asString diff --git a/packages/Babylonian-UI.package/BPStyler.class/methodProperties.json b/packages/Babylonian-UI.package/BPStyler.class/methodProperties.json index c713aa8d..adc2318a 100644 --- a/packages/Babylonian-UI.package/BPStyler.class/methodProperties.json +++ b/packages/Babylonian-UI.package/BPStyler.class/methodProperties.json @@ -10,13 +10,15 @@ "annotationCanBePutInSidebar:" : "pre 12/16/2020 19:02", "annotationMorphFor:" : "pre 1/6/2021 17:40", "applyAnnotationsFrom:to:" : "pre 7/20/2022 16:03", + "applyInstanceVariableIn:for:" : "joabe 9/28/2023 15:19", "expressionSourceFor:from:at:" : "pre 7/20/2022 16:58", "extractIntervals" : "jb 12/3/2020 22:57", + "formatNonMethod:" : "joabe 9/28/2023 15:39", "hasExamplesMorph:" : "pre 7/20/2022 09:31", "ifNoSelectedMethod:" : "pre 3/19/2020 11:07", "insertExamplesMorphInto:" : "pre 7/20/2022 10:45", "isAlreadyAnnotatedExpressionAt:in:" : "pre 8/17/2023 08:38", - "privateFormat:" : "jb 12/3/2020 23:35", + "privateFormat:" : "joabe 9/28/2023 15:22", "reformat:basedOn:" : "pre 7/20/2022 16:59", "selectedMethod:" : "ct 8/20/2021 06:24", "textForAnnotation:from:at:" : "pre 7/20/2022 16:58", diff --git a/packages/Babylonian-UI.package/CodeHolder.extension/instance/doAddInstanceProbeToRegistry.nameIn..st b/packages/Babylonian-UI.package/CodeHolder.extension/instance/doAddInstanceProbeToRegistry.nameIn..st index 7b1e5217..1aba3766 100644 --- a/packages/Babylonian-UI.package/CodeHolder.extension/instance/doAddInstanceProbeToRegistry.nameIn..st +++ b/packages/Babylonian-UI.package/CodeHolder.extension/instance/doAddInstanceProbeToRegistry.nameIn..st @@ -2,7 +2,7 @@ doAddInstanceProbeToRegistry: anInstanceVariableProbe nameIn: anInterval anInstanceVariableProbe - variableName: (self codeTextMorph text atAll: {anInterval start. anInterval stop}); - className: (self selectedClass name). + variableName: (self codeTextMorph text atAll: anInterval); + assignedClassName: (self selectedClass name). BPClassNameToInstanceProbes value addProbe: anInstanceVariableProbe \ No newline at end of file diff --git a/packages/Babylonian-UI.package/CodeHolder.extension/methodProperties.json b/packages/Babylonian-UI.package/CodeHolder.extension/methodProperties.json index 3adbe0ca..8735dd17 100644 --- a/packages/Babylonian-UI.package/CodeHolder.extension/methodProperties.json +++ b/packages/Babylonian-UI.package/CodeHolder.extension/methodProperties.json @@ -26,7 +26,7 @@ "determineSelectorOfMessageSend:" : "pre 9/2/2022 14:49", "doAddAnnotation:in:" : "joabe 9/27/2023 17:22", "doAddAnnotationMorphToMethod:in:" : "joabe 9/27/2023 16:21", - "doAddInstanceProbeToRegistry:nameIn:" : "joabe 9/28/2023 13:06", + "doAddInstanceProbeToRegistry:nameIn:" : "joabe 9/28/2023 15:50", "doBrowseActualImplementersFromProbe:andSelector:" : "pre 9/2/2022 15:54", "doItReceiver" : "ct 3/30/2022 16:48", "exampleForEvaluation" : "ct 8/18/2021 23:15",