Skip to content

Commit 5ac4963

Browse files
committed
Adds BPUnannotatedStyler
1 parent 3e3778c commit 5ac4963

File tree

10 files changed

+59
-15
lines changed

10 files changed

+59
-15
lines changed

packages/Babylonian-UI.package/BPBrowser.class/instance/sourceStringUnannotated.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sourceStringUnannotated
1111
sourceString := class ultimateSourceCodeAt: selector ifAbsent: [^'error'].
1212
self validateMessageSource: sourceString forSelector: selector inClass: class.
1313
sourceString := BPUnannotatedStyler new
14-
selectedMethod: class>>selector;
14+
selectedMethod: (MethodReference class: class selector: selector);
15+
classOrMetaClass: class;
1516
styledTextFor: sourceString.
16-
1717
^ sourceString

packages/Babylonian-UI.package/BPBrowser.class/methodProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"showUnannotated:" : "jb 10/29/2021 23:07",
2727
"showingUnannotated" : "jb 10/29/2021 22:58",
2828
"showingUnannotatedSourceString" : "jb 11/1/2021 00:58",
29-
"sourceStringUnannotated" : "jb 11/2/2021 15:03",
29+
"sourceStringUnannotated" : "jb 11/10/2021 23:53",
3030
"toggleUnannotatedSource" : "jb 10/29/2021 23:15",
3131
"toolBuilderModelsMenu:" : "pre 9/28/2021 16:32",
3232
"wantsMessageCategoriesDrop:" : "jb 8/29/2021 22:15" } }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
private
2+
insertAnchorCharacterForAnnotation: annotation from: aText at: startTagStart
3+
4+
| startOfExpressionText expressionText |
5+
6+
startOfExpressionText := aText indexOfSubCollection: annotation enclosedExpressionSource startingAt: startTagStart.
7+
expressionText := aText copyFrom: startOfExpressionText to: startOfExpressionText + annotation enclosedExpressionSource size - 1.
8+
(self isAlreadyAnnotatedExpressionAt: startTagStart in: aText)
9+
ifTrue: [
10+
expressionText := (aText copyFrom: startTagStart - 1 to: startTagStart - 1) , expressionText]
11+
ifFalse: [
12+
expressionText := Character startOfHeader asString asText , expressionText.
13+
expressionText attributesAt: 2 do: [:attr |
14+
expressionText addAttribute: attr from: 1 to: 1]].
15+
16+
^ expressionText
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
private
22
textForAnnotation: annotation from: aText at: startTagStart
3-
4-
| newMorph startOfExpressionText expressionText |
3+
4+
| newMorph expressionText |
55
newMorph := self annotationMorphFor: annotation.
66

77
newMorph ifNil: [
88
"The annotation does not want to be drawn directly"
99
^ '' asText].
1010

11-
startOfExpressionText := aText indexOfSubCollection: annotation enclosedExpressionSource startingAt: startTagStart.
12-
expressionText := aText copyFrom: startOfExpressionText to: startOfExpressionText + annotation enclosedExpressionSource size - 1.
13-
(self isAlreadyAnnotatedExpressionAt: startTagStart in: aText)
14-
ifTrue: [
15-
expressionText := (aText copyFrom: startTagStart - 1 to: startTagStart - 1) , expressionText]
16-
ifFalse: [
17-
expressionText := Character startOfHeader asString asText , expressionText.
18-
expressionText attributesAt: 2 do: [:attr |
19-
expressionText addAttribute: attr from: 1 to: 1]].
11+
expressionText := self insertAnchorCharacterForAnnotation: annotation from: aText at: startTagStart.
2012
expressionText addAttribute: (BPTextAnchor new anchoredMorph: newMorph; yourself).
2113

2214
^ expressionText

packages/Babylonian-UI.package/BPStyler.class/methodProperties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"extractIntervals" : "jb 12/3/2020 22:57",
1515
"hasExamplesMorph:" : "jb 8/21/2021 15:38",
1616
"ifNoSelectedMethod:" : "pre 3/19/2020 11:07",
17+
"insertAnchorCharacterForAnnotation:from:at:" : "jb 11/10/2021 23:27",
1718
"insertExamplesMorph:into:withNewLineStartingFrom:to:" : "jb 8/21/2021 16:29",
1819
"insertExamplesMorphFrom:into:basedOn:" : "jb 8/21/2021 16:31",
1920
"isAlreadyAnnotatedExpressionAt:in:" : "pre 5/29/2019 22:40",
@@ -22,5 +23,5 @@
2223
"reformat:basedOn:" : "jb 12/3/2020 22:58",
2324
"removePotentialEmptyLinesInText:around:" : "pre 8/25/2020 09:47",
2425
"selectedMethod:" : "ct 8/20/2021 06:24",
25-
"textForAnnotation:from:at:" : "pre 11/23/2020 11:57",
26+
"textForAnnotation:from:at:" : "jb 11/10/2021 23:27",
2627
"unstyledTextFrom:" : "lu 6/1/2021 21:39" } }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A BPUnannotatedStyler is styling the same way the BPStyler does with the addition of hiding the generated annotations to make the source code seem unannotated while still being able to maintain the text anchors when edited.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
private
2+
annotationMorphFor: anAnnotation
3+
4+
5+
^ (super annotationMorphFor: anAnnotation)
6+
vResizing: #rigid;
7+
extent: 1@1;
8+
hide;
9+
yourself
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
private
2+
insertExamplesMorphFrom: parseResult into: text basedOn: annotations
3+
4+
"Do nothing"
5+
^ text
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"class" : {
3+
},
4+
"instance" : {
5+
"annotationMorphFor:" : "jb 11/10/2021 23:30",
6+
"insertExamplesMorphFrom:into:basedOn:" : "jb 11/10/2021 23:56" } }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"category" : "Babylonian-UI",
3+
"classinstvars" : [
4+
],
5+
"classvars" : [
6+
],
7+
"commentStamp" : "jb 11/10/2021 23:54",
8+
"instvars" : [
9+
],
10+
"name" : "BPUnannotatedStyler",
11+
"pools" : [
12+
],
13+
"super" : "BPStyler",
14+
"type" : "normal" }

0 commit comments

Comments
 (0)