-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from hpi-swa-lab/enhancement/hide-annotations
Adds an unannotated view to the BPBrowser
- Loading branch information
Showing
18 changed files
with
143 additions
and
14 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/Babylonian-Tests.package/BPSearchCollection.class/class/compilerClass.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
as yet unclassified | ||
compiling | ||
compilerClass | ||
|
||
^ BPCompiler |
2 changes: 1 addition & 1 deletion
2
packages/Babylonian-Tests.package/BPSearchCollection.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/Babylonian-UI.package/BPBrowser.class/class/defaultContentsSymbolQuints.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
controls | ||
defaultContentsSymbolQuints | ||
|
||
^ {super defaultContentsSymbolQuints first}, | ||
{{#unannotated | ||
. #toggleUnannotatedSource | ||
. #showingUnannotatedSourceString | ||
. 'unannotated' | ||
. 'the textual source without Babylonian annotations'}}, | ||
super defaultContentsSymbolQuints allButFirst |
25 changes: 25 additions & 0 deletions
25
packages/Babylonian-UI.package/BPBrowser.class/instance/selectedMessage.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
message list | ||
selectedMessage | ||
|
||
"Has to be copied from CodeHolder and get injected to check for unannotated source | ||
before moving on to showingDocumentation" | ||
|
||
| class selector method | | ||
contents == nil ifFalse: [^ contents copy]. | ||
|
||
self showingDecompile ifTrue: | ||
[^ self decompiledSourceIntoContents]. | ||
|
||
class := self selectedClassOrMetaClass. | ||
selector := self selectedMessageName. | ||
method := class compiledMethodAt: selector ifAbsent: [^ '']. "method deleted while in another project" | ||
currentCompiledMethod := method. | ||
|
||
"=== BABYLONIAN CODE START ===" | ||
self showingUnannotated ifTrue: [^ self sourceStringUnannotated]. | ||
"=== BABYLONIAN CODE END ===" | ||
|
||
^ contents := (self showingDocumentation | ||
ifFalse: [ self sourceStringPrettifiedAndDiffed ] | ||
ifTrue: [ self commentContents ]) | ||
copy asText makeSelectorBoldIn: class |
4 changes: 4 additions & 0 deletions
4
packages/Babylonian-UI.package/BPBrowser.class/instance/showUnannotated..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
what to show | ||
showUnannotated: aBoolean | ||
|
||
self contentsSymbol: (aBoolean ifFalse: [#source] ifTrue: [#unannotated]) |
4 changes: 4 additions & 0 deletions
4
packages/Babylonian-UI.package/BPBrowser.class/instance/showingUnannotated.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
what to show | ||
showingUnannotated | ||
|
||
^ self contentsSymbol == #unannotated |
8 changes: 8 additions & 0 deletions
8
packages/Babylonian-UI.package/BPBrowser.class/instance/showingUnannotatedSourceString.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
what to show | ||
showingUnannotatedSourceString | ||
|
||
^ (self showingUnannotated | ||
ifTrue: | ||
['<yes>'] | ||
ifFalse: | ||
['<no>']), 'unannotated' |
17 changes: 17 additions & 0 deletions
17
packages/Babylonian-UI.package/BPBrowser.class/instance/sourceStringUnannotated.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
message list | ||
sourceStringUnannotated | ||
|
||
"Adapt super to deal with actual methods, hence duplicated code" | ||
"Answer a copy of the source code for the selected message, transformed by diffing and pretty-printing exigencies" | ||
|
||
| class selector sourceString | | ||
class := self selectedClassOrMetaClass. | ||
selector := self selectedMessageName. | ||
(class isNil or: [selector isNil]) ifTrue: [^'missing']. | ||
sourceString := class ultimateSourceCodeAt: selector ifAbsent: [^'error']. | ||
self validateMessageSource: sourceString forSelector: selector inClass: class. | ||
sourceString := BPUnannotatedStyler new | ||
selectedMethod: (MethodReference class: class selector: selector); | ||
classOrMetaClass: class; | ||
styledTextFor: sourceString. | ||
^ sourceString |
10 changes: 10 additions & 0 deletions
10
packages/Babylonian-UI.package/BPBrowser.class/instance/toggleUnannotatedSource.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
what to show | ||
toggleUnannotatedSource | ||
|
||
| wasShowing | | ||
self okToChange ifTrue: | ||
[wasShowing := self showingUnannotated. | ||
self restoreTextualCodingPane. | ||
self showUnannotated: wasShowing not. | ||
self setContentsToForceRefetch. | ||
self contentsChanged]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...ylonian-UI.package/BPStyler.class/instance/insertAnchorCharacterForAnnotation.from.at..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
private | ||
insertAnchorCharacterForAnnotation: annotation from: aText at: startTagStart | ||
|
||
| startOfExpressionText expressionText | | ||
|
||
startOfExpressionText := aText indexOfSubCollection: annotation enclosedExpressionSource startingAt: startTagStart. | ||
expressionText := aText copyFrom: startOfExpressionText to: startOfExpressionText + annotation enclosedExpressionSource size - 1. | ||
(self isAlreadyAnnotatedExpressionAt: startTagStart in: aText) | ||
ifTrue: [ | ||
expressionText := (aText copyFrom: startTagStart - 1 to: startTagStart - 1) , expressionText] | ||
ifFalse: [ | ||
expressionText := Character startOfHeader asString asText , expressionText. | ||
expressionText attributesAt: 2 do: [:attr | | ||
expressionText addAttribute: attr from: 1 to: 1]]. | ||
|
||
^ expressionText |
14 changes: 3 additions & 11 deletions
14
packages/Babylonian-UI.package/BPStyler.class/instance/textForAnnotation.from.at..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,14 @@ | ||
private | ||
textForAnnotation: annotation from: aText at: startTagStart | ||
| newMorph startOfExpressionText expressionText | | ||
|
||
| newMorph expressionText | | ||
newMorph := self annotationMorphFor: annotation. | ||
|
||
newMorph ifNil: [ | ||
"The annotation does not want to be drawn directly" | ||
^ '' asText]. | ||
|
||
startOfExpressionText := aText indexOfSubCollection: annotation enclosedExpressionSource startingAt: startTagStart. | ||
expressionText := aText copyFrom: startOfExpressionText to: startOfExpressionText + annotation enclosedExpressionSource size - 1. | ||
(self isAlreadyAnnotatedExpressionAt: startTagStart in: aText) | ||
ifTrue: [ | ||
expressionText := (aText copyFrom: startTagStart - 1 to: startTagStart - 1) , expressionText] | ||
ifFalse: [ | ||
expressionText := Character startOfHeader asString asText , expressionText. | ||
expressionText attributesAt: 2 do: [:attr | | ||
expressionText addAttribute: attr from: 1 to: 1]]. | ||
expressionText := self insertAnchorCharacterForAnnotation: annotation from: aText at: startTagStart. | ||
expressionText addAttribute: (BPTextAnchor new anchoredMorph: newMorph; yourself). | ||
|
||
^ expressionText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/Babylonian-UI.package/BPUnannotatedStyler.class/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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. |
9 changes: 9 additions & 0 deletions
9
packages/Babylonian-UI.package/BPUnannotatedStyler.class/instance/annotationMorphFor..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
private | ||
annotationMorphFor: anAnnotation | ||
|
||
|
||
^ (super annotationMorphFor: anAnnotation) | ||
vResizing: #rigid; | ||
extent: 1@1; | ||
hide; | ||
yourself |
5 changes: 5 additions & 0 deletions
5
...an-UI.package/BPUnannotatedStyler.class/instance/insertExamplesMorphFrom.into.basedOn..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
private | ||
insertExamplesMorphFrom: parseResult into: text basedOn: annotations | ||
|
||
"Do nothing" | ||
^ text |
6 changes: 6 additions & 0 deletions
6
packages/Babylonian-UI.package/BPUnannotatedStyler.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"class" : { | ||
}, | ||
"instance" : { | ||
"annotationMorphFor:" : "jb 11/10/2021 23:30", | ||
"insertExamplesMorphFrom:into:basedOn:" : "jb 11/10/2021 23:56" } } |
14 changes: 14 additions & 0 deletions
14
packages/Babylonian-UI.package/BPUnannotatedStyler.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"category" : "Babylonian-UI", | ||
"classinstvars" : [ | ||
], | ||
"classvars" : [ | ||
], | ||
"commentStamp" : "jb 11/10/2021 23:54", | ||
"instvars" : [ | ||
], | ||
"name" : "BPUnannotatedStyler", | ||
"pools" : [ | ||
], | ||
"super" : "BPStyler", | ||
"type" : "normal" } |