-
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.
Adds Instance Probe class and interval determination for it
- Loading branch information
Showing
17 changed files
with
133 additions
and
44 deletions.
There are no files selected for viewing
Empty file.
4 changes: 4 additions & 0 deletions
4
packages/Babylonian-Core.package/BPInstanceVariableProbe.class/instance/canBeAnnotatedTo.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 @@ | ||
ui | ||
canBeAnnotatedTo | ||
|
||
^ #(stringLiteral) |
4 changes: 4 additions & 0 deletions
4
...Babylonian-Core.package/BPInstanceVariableProbe.class/instance/isInstanceVariableProbe.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 @@ | ||
testing | ||
isInstanceVariableProbe | ||
|
||
^ true |
4 changes: 4 additions & 0 deletions
4
...abylonian-Core.package/BPInstanceVariableProbe.class/instance/wantsMetaClassIndication.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 @@ | ||
accessing | ||
wantsMetaClassIndication | ||
|
||
^ false |
7 changes: 7 additions & 0 deletions
7
packages/Babylonian-Core.package/BPInstanceVariableProbe.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,7 @@ | ||
{ | ||
"class" : { | ||
}, | ||
"instance" : { | ||
"canBeAnnotatedTo" : "joabe 9/21/2023 21:08", | ||
"isInstanceVariableProbe" : "joabe 9/21/2023 21:18", | ||
"wantsMetaClassIndication" : "joabe 9/21/2023 21:08" } } |
14 changes: 14 additions & 0 deletions
14
packages/Babylonian-Core.package/BPInstanceVariableProbe.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-Core-Annotations", | ||
"classinstvars" : [ | ||
], | ||
"classvars" : [ | ||
], | ||
"commentStamp" : "", | ||
"instvars" : [ | ||
], | ||
"name" : "BPInstanceVariableProbe", | ||
"pools" : [ | ||
], | ||
"super" : "BPProbe", | ||
"type" : "normal" } |
4 changes: 4 additions & 0 deletions
4
packages/Babylonian-Core.package/BPProbe.class/instance/isInstanceVariableProbe.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 @@ | ||
testing | ||
isInstanceVariableProbe | ||
|
||
^ false |
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
4 changes: 3 additions & 1 deletion
4
packages/Babylonian-UI.package/CodeHolder.extension/instance/addProbeToSelection.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,5 +1,7 @@ | ||
*Babylonian-UI-annotations | ||
addProbeToSelection | ||
|
||
self addAnnotationAtSelection: BPProbe new. | ||
self editSelection == #editClass | ||
ifTrue: [self addAnnotationAtSelection: BPInstanceVariableProbe new] | ||
ifFalse: [self addAnnotationAtSelection: BPProbe new] | ||
|
28 changes: 28 additions & 0 deletions
28
....package/CodeHolder.extension/instance/allAndLowestUsefulAncestorFor.canBeAnnotatedTo..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,28 @@ | ||
*Babylonian-UI-private | ||
allAndLowestUsefulAncestorFor: aListOfNodes canBeAnnotatedTo: aListOfKeywords | ||
|
||
"This is necessary as we do only assume that the last node is the lowest one, not that | ||
the rest of the nodes is necessarily ordered according to the tree" | ||
| ancestors lowestCommonAncestorIndex parents | | ||
parents := aListOfNodes collect: [:allNodes | {allNodes last} , allNodes last allParents]. | ||
|
||
"This is a naiive approach but is fine as the trees are not that deep." | ||
lowestCommonAncestorIndex := parents first findFirst: [:n | parents second includes: n]. | ||
lowestCommonAncestorIndex = 0 ifTrue: [self error: 'broken tree, no common root found']. | ||
|
||
ancestors := parents first | ||
copyFrom: lowestCommonAncestorIndex | ||
to: parents first size. | ||
|
||
"This is not enough yet, we have the list of AST nodes covering the selected interval | ||
and their full ranges, but these nodes could be nonsensical to annotate." | ||
^ {ancestors. ancestors | ||
detect: [:n | aListOfKeywords includes: n ruleName] | ||
ifNone: ["This can happen if users selected more than one statement, | ||
we now have to search for the first statement below the current index" | ||
(parents first first: lowestCommonAncestorIndex) reverse | ||
detect: [:n | aListOfKeywords includes: n ruleName] | ||
ifNone: ["Try it again for the end of the interval" | ||
(parents second copyUpTo: (parents first at: lowestCommonAncestorIndex)) reverse | ||
detect: [:n | aListOfKeywords includes: n ruleName] | ||
ifNone: [nil "There really is nothing to annotate"]]]}. |
11 changes: 11 additions & 0 deletions
11
packages/Babylonian-UI.package/CodeHolder.extension/instance/bpClassDeclarationSourceMap.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,11 @@ | ||
*Babylonian-UI-private | ||
bpClassDeclarationSourceMap | ||
|
||
| result map | | ||
result := BPSmalltalkGrammar | ||
match: self contents | ||
startingFrom: #KeywordMessageSend. | ||
result succeeded ifFalse: [self haltOnce. ^ #()]. | ||
map := (BPSmalltalkGrammar semanticAction: BPSourceMapping new) | ||
createSourceMapFor: result cst. | ||
^ map |
20 changes: 20 additions & 0 deletions
20
...ian-UI.package/CodeHolder.extension/instance/determineIntervalOfVariableNameIn.having..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,20 @@ | ||
*Babylonian-UI-private | ||
determineIntervalOfVariableNameIn: anInterval having: aTopologicalCollectionOfAncestors | ||
|
||
| lowestKeywordMessageSegment selectedText | | ||
|
||
lowestKeywordMessageSegment := aTopologicalCollectionOfAncestors | ||
detect: [:n | n ruleName = #KeywordMessageSegment] | ||
ifNone: [^ nil]. | ||
|
||
((self contents atAll: lowestKeywordMessageSegment children first interval) ~= 'instanceVariableNames:') ifTrue: [^ nil]. | ||
|
||
selectedText := (self contents atAll: anInterval) withBlanksTrimmed. | ||
|
||
^ self selectedClassOrMetaClass instVarNames | ||
detect: [:aVariable | aVariable = selectedText] | ||
ifFound: [:matchingVariable | | start | | ||
start := self contents findString: matchingVariable. | ||
^ Interval from: start to: start + matchingVariable size] | ||
|
||
|
37 changes: 0 additions & 37 deletions
37
...nian-UI.package/CodeHolder.extension/instance/determineIntervalToAnnotateFor.forNodes..st
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...Babylonian-UI.package/CodeHolder.extension/instance/determineIntervalToAnnotateFor.in..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,24 @@ | ||
*Babylonian-UI-private | ||
determineIntervalToAnnotateFor: anAnnotation in: anInterval | ||
|
||
| result sourceMap | | ||
"This determines the interval to annotate for a selected interval. | ||
The selected interval can also be a 0 width selection. | ||
If there is not valid interval this method will return nil." | ||
|
||
self bpEnsureContentsAndSelectedMessage. | ||
self halt. | ||
sourceMap := currentCompiledMethod ifNotNil: [currentCompiledMethod bpSourceMap] ifNil: [self bpClassDeclarationSourceMap]. | ||
result := self | ||
allAndLowestUsefulAncestorFor: (sourceMap atAll: anInterval) | ||
canBeAnnotatedTo: anAnnotation canBeAnnotatedTo. | ||
result second ifNil: [^ nil]. | ||
|
||
anAnnotation isInstanceVariableProbe ifFalse: [^ result second interval]. | ||
|
||
(self editSelection == #editClass and: [self metaClassIndicated == anAnnotation wantsMetaClassIndication]) ifFalse: [^ nil]. | ||
|
||
^ self | ||
determineIntervalOfVariableNameIn: anInterval | ||
having: result first. | ||
|
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
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
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