Skip to content

Commit

Permalink
Proper adding and removal of instance variable probe morphs
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Sep 28, 2023
1 parent 8c847c6 commit 0a4c68a
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -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]

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
as yet unclassified
at: aClassName

^ nameToProbesDict at: aClassName
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
as yet unclassified
removeProbe: aProbe

nameToProbesDict at: aProbe className
nameToProbesDict at: aProbe assignedClassName
ifPresent: [:registeredProbes | registeredProbes remove: aProbe]

Original file line number Diff line number Diff line change
Expand Up @@ -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" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
assignedClassName: aString
assignedClassName := aString
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
assignedClassName
^ assignedClassName

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
variableName: aString

variableName := aString
self enclosedExpressionSource: aString
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
variableName

^ variableName
^ self enclosedExpressionSource
Original file line number Diff line number Diff line change
Expand Up @@ -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" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
],
"commentStamp" : "",
"instvars" : [
"variableName",
"className" ],
"assignedClassName" ],
"name" : "BPInstanceVariableProbe",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -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.



Original file line number Diff line number Diff line change
Expand Up @@ -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" } }
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ private
privateFormat: aText

| parseResult |
self ifNoSelectedMethod: [^ super privateFormat: aText].
self ifNoSelectedMethod: [ ^ self formatNonMethod: aText ].

parseResult := PEGParserBPSmalltalk new
match: aText asString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0a4c68a

Please sign in to comment.