• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moosetechnology / MooseIDE / 17410679653

02 Sep 2025 05:05PM UTC coverage: 66.699% (-0.07%) from 66.768%
17410679653

Pull #1399

github

web-flow
Merge 99110d600 into 8305229ab
Pull Request #1399: Adding language keywords highlighting

32 of 54 new or added lines in 4 files covered. (59.26%)

13 existing lines in 2 files now uncovered.

19869 of 29789 relevant lines covered (66.7%)

1.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.15
/src/MooseIDE-Famix/MiSourceTextBrowserModel.class.st
1
"
2
I am a model for the SourceTextBrowser
3

4
I take care of getting the source code for an entity and ""formatting"" it (actually finding where to apply formats: the highlights)
5

6
I also keep the displayedEntity and the selectedEntity (in the source code) if any
7
"
8
Class {
9
        #name : 'MiSourceTextBrowserModel',
10
        #superclass : 'MiAbstractModel',
11
        #instVars : [
12
                'displayedText',
13
                'selectedEntity',
14
                'highlights',
15
                'settings'
16
        ],
17
        #category : 'MooseIDE-Famix-SourceText',
18
        #package : 'MooseIDE-Famix',
19
        #tag : 'SourceText'
20
}
21

22
{ #category : 'accessing' }
23
MiSourceTextBrowserModel >> addHighlight: aSourceTextHighlight [
2✔
24
        highlights add: aSourceTextHighlight
2✔
25
]
2✔
26

27
{ #category : 'highlights' }
28
MiSourceTextBrowserModel >> commentHighlightFor: aComment [
2✔
29

2✔
30
        self addHighlight: (MiSourceTextCommentHighlight new
2✔
31
                highlightedEntity: aComment ;
2✔
32
                yourself)
2✔
33

2✔
34
]
2✔
35

36
{ #category : 'highlights' }
37
MiSourceTextBrowserModel >> createHighlightsFor: anEntity [
2✔
38

2✔
39
        (anEntity class usesFamixTrait: FamixTComment)
2✔
40
        ifTrue: [
2✔
41
                self commentHighlightFor: anEntity.
2✔
42
                ^self
2✔
43
        ].
2✔
44

2✔
45
        (anEntity class usesFamixTrait: FamixTNamedEntity)
2✔
46
        ifTrue: [
2✔
47
                self identifierHighlightFor: anEntity
2✔
48
        ].
2✔
49

2✔
50
        anEntity children do: [ :childChild |
2✔
51
                self createHighlightsFor: childChild ].
2✔
52

2✔
53
        (anEntity tags size = 1) ifTrue: [
2✔
54
                self tagHighlight: anEntity tags anyOne for: anEntity ].
2✔
55

2✔
56
        "aChildEntity queryAllOutgoing do: [:mseAssoc |
2✔
57
                mseAssoc allTargets do: [ :target |         self addHighlight: (self dependencyHighlightFor: mseAssoc) ]
2✔
58
        ]."
2✔
59
]
2✔
60

61
{ #category : 'highlights' }
62
MiSourceTextBrowserModel >> createKeywordHighlights [
2✔
63
        "search for all sourceLanguage keywords in the displayedText and highlight them
2✔
64
        There are several guard conditions because this feature is work in progress and
2✔
65
        not all language implement it"
2✔
66

2✔
67
        self selectedEntity mooseModel
2✔
68
        ifNotNil: [ :mooseModel |
2✔
69
                mooseModel sourceLanguage
2✔
70
                ifNotNil: [ :sourceLanguage |
2✔
71
                        sourceLanguage languageKeyWords do: [ :kw || matcher |
2✔
72
                                matcher := RxMatcher forString: ('\W' , kw , '\W').
2✔
73
                                (matcher matchingRangesIn: self displayedText) do: [ :range |
2✔
74
                                        self keywordHighlightInterval: (range first + 1 to: range last - 1)
2✔
75
                                ]
2✔
76
                        ]
2✔
77
                ]
2✔
78
        ]
2✔
79
]
2✔
80

81
{ #category : 'accessing' }
82
MiSourceTextBrowserModel >> displayedEntity: anEntity [
2✔
83

2✔
84
        self selectedEntity: anEntity.
2✔
85

2✔
86
        self resetHighlights.
2✔
87
        self prepareFormating.
2✔
88
        browser renderTextFor: anEntity
2✔
89
]
2✔
90

91
{ #category : 'accessing' }
92
MiSourceTextBrowserModel >> displayedText [
2✔
93
        ^displayedText
2✔
94
]
2✔
95

96
{ #category : 'accessing' }
97
MiSourceTextBrowserModel >> entities [
2✔
98
        ^selectedEntity
2✔
99
                ifNil: [ #() ]
2✔
100
                ifNotNil: [ { selectedEntity } ]
2✔
101
]
2✔
102

103
{ #category : 'highlights' }
104
MiSourceTextBrowserModel >> errorHighlightInterval: anInterval [
2✔
105

2✔
106
        self addHighlight: (MiSourceTextErrorHighlight new
2✔
107
                highlightInterval: anInterval ;
2✔
108
                yourself)
2✔
109

2✔
110
]
2✔
111

112
{ #category : 'actions' }
113
MiSourceTextBrowserModel >> event: aMouseEvent selectedEntity: anEntity [
×
114

×
115
        self selectedEntity: anEntity.
×
116

×
117
        aMouseEvent controlKeyPressed
×
118
                ifTrue: [ anEntity inspect ]
×
119
]
×
120

121
{ #category : 'accessing' }
122
MiSourceTextBrowserModel >> highlights [
2✔
123
        ^highlights
2✔
124
]
2✔
125

126
{ #category : 'highlights' }
127
MiSourceTextBrowserModel >> identifierHighlightFor: aChildEntity [
2✔
128
        
2✔
129
        self addHighlight: (MiSourceTextIdentifierHighlight new
2✔
130
                highlightedEntity: aChildEntity ;
2✔
131
                yourself)
2✔
132

2✔
133
]
2✔
134

135
{ #category : 'initialization' }
136
MiSourceTextBrowserModel >> initialize [
2✔
137
        super initialize.
2✔
138
        
2✔
139
        self resetHighlights
2✔
140
]
2✔
141

142
{ #category : 'settings' }
143
MiSourceTextBrowserModel >> initializeSettings [
2✔
144

2✔
145
        settings := super initializeSettings
2✔
146
                addItem: self itemWithHighlight named: #withHighlight ;
2✔
147
                yourself
2✔
148
]
2✔
149

150
{ #category : 'settings' }
151
MiSourceTextBrowserModel >> itemWithHighlight [
2✔
152

2✔
153
        ^ MiAbstractSettingItem checkboxSetting
2✔
154
                  setValue: true ;
2✔
155
                  label: 'Highlight children in text?';
2✔
156
                  help:
2✔
157
                          'If checked the entity''s children are highlighted';
2✔
158
                  yourself
2✔
159
]
2✔
160

161
{ #category : 'highlights' }
NEW
162
MiSourceTextBrowserModel >> keywordHighlightInterval: anInterval [
×
NEW
163

×
NEW
164
        self addHighlight: (MiSourceTextKeywordHighlight new
×
NEW
165
                highlightInterval: anInterval ;
×
NEW
166
                yourself)
×
NEW
167

×
NEW
168
]
×
169

170
{ #category : 'accessing' }
171
MiSourceTextBrowserModel >> miSelectedItem [
×
172

×
173
        ^self entities
×
174
]
×
175

176
{ #category : 'formatting' }
177
MiSourceTextBrowserModel >> noSourceCodeFor: anEntity [
2✔
178
        displayedText := ('There is no source code to show for {1}'
2✔
179
                format: { anEntity name }).
2✔
180

2✔
181
        self errorHighlightInterval: (Interval from: 37 to: displayedText size)
2✔
182
]
2✔
183

184
{ #category : 'highlights' }
185
MiSourceTextBrowserModel >> nullHighlightFor: aChildEntity [
×
186

×
187
]
×
188

189
{ #category : 'formatting' }
190
MiSourceTextBrowserModel >> prepareFormating [
2✔
191
        selectedEntity sourceText
2✔
192
                ifEmpty: [ self noSourceCodeFor: selectedEntity ]
2✔
193
                ifNotEmpty: [ :code | self prepareFormating: code ]
2✔
194

2✔
195
]
2✔
196

197
{ #category : 'formatting' }
198
MiSourceTextBrowserModel >> prepareFormating: aString [
2✔
199

2✔
200
        displayedText := aString.
2✔
201
        self withHighlight
2✔
202
                ifFalse: [self resetHighlights ]
2✔
203
                ifTrue: [
2✔
204
                        self createHighlightsFor: self selectedEntity.
2✔
205
                        self createKeywordHighlights ]
2✔
206
]
2✔
207

208
{ #category : 'highlights' }
209
MiSourceTextBrowserModel >> resetHighlights [
2✔
210

2✔
211
        highlights := OrderedCollection new
2✔
212
]
2✔
213

214
{ #category : 'accessing' }
215
MiSourceTextBrowserModel >> selectedEntity [
2✔
216
        ^selectedEntity
2✔
217
]
2✔
218

219
{ #category : 'accessing' }
220
MiSourceTextBrowserModel >> selectedEntity: anEntity [
2✔
221

2✔
222
        selectedEntity := anEntity.
2✔
223
        browser updateToolbar
2✔
224
]
2✔
225

226
{ #category : 'settings' }
227
MiSourceTextBrowserModel >> settings [
2✔
228
        ^settings
2✔
229
]
2✔
230

231
{ #category : 'settings' }
232
MiSourceTextBrowserModel >> settingsChanged: aBoolean [
2✔
233

2✔
234
        aBoolean ifFalse: [ ^self ].
2✔
235

2✔
236
        displayedText ifNotNil: [
2✔
237
                "nil when running some of the tests"
2✔
238
                self prepareFormating.
2✔
239
                self browser reRenderText
2✔
240
        ]
2✔
241
]
2✔
242

243
{ #category : 'highlights' }
244
MiSourceTextBrowserModel >> tagHighlight: aTag for: anEntity [
×
245

×
246
        self addHighlight: (MiSourceTextTagHighlight new
×
247
                highlightedEntity: anEntity ;
×
248
                tag: aTag ;
×
249
                yourself)
×
250

×
251
]
×
252

253
{ #category : 'settings' }
254
MiSourceTextBrowserModel >> withHighlight [
2✔
255

2✔
256
        ^settings getItemValue: #withHighlight
2✔
257
]
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc