-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the locate debugger button is placed in the same place as the embedde…
…d debugger [feenkcom/gtoolkit#3735] - add `GtEmbeddedDebuggerTextAttributePositionCalculator`
- Loading branch information
1 parent
31ec0e1
commit 56b8756
Showing
3 changed files
with
128 additions
and
33 deletions.
There are no files selected for viewing
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
107 changes: 107 additions & 0 deletions
107
src/GToolkit-Debugger/GtEmbeddedDebuggerTextAttributePositionCalculator.class.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,107 @@ | ||
Class { | ||
#name : #GtEmbeddedDebuggerTextAttributePositionCalculator, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'sourceString', | ||
'sourceInterval', | ||
'evaluatedCodeInterval', | ||
'targetText', | ||
'sourceEndInText', | ||
'sourceStartInText', | ||
'attributeIndex', | ||
'isSourceFound' | ||
], | ||
#category : #'GToolkit-Debugger-Embedded - Text' | ||
} | ||
|
||
{ #category : #'accessing - computed' } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> attributeIndex [ | ||
<return: #Integer or: nil> | ||
^ attributeIndex | ||
] | ||
|
||
{ #category : #computing } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> compute [ | ||
<return: #Integer or: nil> | ||
isSourceFound := false. | ||
sourceStartInText := targetText finder | ||
caseSensitiveSubstring: sourceString; | ||
startAtPosition: sourceInterval first; | ||
searchClosest. | ||
|
||
"what did we evaluate?" | ||
sourceStartInText isZero ifTrue: [ ^ nil ]. | ||
isSourceFound := true. | ||
sourceEndInText := sourceStartInText + sourceString size - 1 min: targetText size. | ||
|
||
attributeIndex := evaluatedCodeInterval value | ||
ifNil: [ sourceEndInText ] | ||
ifNotNil: [ :aContextInterval | (aContextInterval last + sourceStartInText - 1) min: targetText size ]. | ||
|
||
^ attributeIndex | ||
] | ||
|
||
{ #category : #accessing } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> evaluatedCodeInterval [ | ||
<return: #Interval or: #BlockClosure> | ||
^ evaluatedCodeInterval | ||
] | ||
|
||
{ #category : #accessing } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> evaluatedCodeInterval: anObject [ | ||
evaluatedCodeInterval := anObject | ||
] | ||
|
||
{ #category : #'accessing - computed' } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> isSourceFound [ | ||
^ isSourceFound | ||
] | ||
|
||
{ #category : #'accessing - computed' } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> sourceEndInText [ | ||
<return: #Integer or: nil> | ||
^ sourceEndInText | ||
] | ||
|
||
{ #category : #accessing } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> sourceInterval [ | ||
"Return evaluated source interval" | ||
|
||
<return: #Interval> | ||
^ sourceInterval | ||
] | ||
|
||
{ #category : #accessing } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> sourceInterval: anObject [ | ||
sourceInterval := anObject | ||
] | ||
|
||
{ #category : #'accessing - computed' } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> sourceStartInText [ | ||
<return: #Integer or: nil> | ||
^ sourceStartInText | ||
] | ||
|
||
{ #category : #accessing } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> sourceString [ | ||
"Return evaluated source string" | ||
|
||
<return: #String> | ||
^ sourceString | ||
] | ||
|
||
{ #category : #accessing } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> sourceString: anObject [ | ||
sourceString := anObject | ||
] | ||
|
||
{ #category : #accessing } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> targetText [ | ||
<return: #BlRope> | ||
^ targetText | ||
] | ||
|
||
{ #category : #accessing } | ||
GtEmbeddedDebuggerTextAttributePositionCalculator >> targetText: anObject [ | ||
targetText := anObject | ||
] |