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

moosetechnology / MooseIDE / 19706134381

26 Nov 2025 01:55PM UTC coverage: 65.22%. First build
19706134381

Pull #1542

github

web-flow
Merge e3f63c6a3 into 6a0811939
Pull Request #1542: Dead code pharo rules

210 of 250 new or added lines in 11 files covered. (84.0%)

21389 of 32795 relevant lines covered (65.22%)

1.3 hits per line

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

84.77
/src/MooseIDE-Famix/MiSourceTextRendererModel.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 : 'MiSourceTextRendererModel',
10
        #superclass : 'Object',
11
        #instVars : [
12
                'displayedText',
13
                'highlights',
14
                'shouldHighlightChildren',
15
                'entity',
16
                'renderer'
17
        ],
18
        #category : 'MooseIDE-Famix-SourceText',
19
        #package : 'MooseIDE-Famix',
20
        #tag : 'SourceText'
21
}
22

23
{ #category : 'accessing' }
NEW
24
MiSourceTextRendererModel class >> defaultConfiguration [
×
NEW
25

×
NEW
26
        ^ MiSourceTextSettingsConfiguration new
×
NEW
27
                  shouldHighlightChildren: self defaultShouldHighlightChildren;
×
NEW
28
                  yourself
×
NEW
29
]
×
30

31
{ #category : 'as yet unclassified' }
NEW
32
MiSourceTextRendererModel class >> defaultShouldHighlightChildren [
×
NEW
33

×
NEW
34
        ^ true
×
NEW
35
]
×
36

37
{ #category : 'accessing' }
38
MiSourceTextRendererModel >> addHighlight: aSourceTextHighlight [
2✔
39
        highlights add: aSourceTextHighlight
2✔
40
]
2✔
41

42
{ #category : 'highlights' }
43
MiSourceTextRendererModel >> commentHighlightFor: aComment [
2✔
44

2✔
45
        self addHighlight: (MiSourceTextCommentHighlight new
2✔
46
                highlightedEntity: aComment ;
2✔
47
                yourself)
2✔
48

2✔
49
]
2✔
50

51
{ #category : 'highlights' }
52
MiSourceTextRendererModel >> createHighlightsFor: anEntity [
2✔
53
        "note: checks if anEntity is a comment first
2✔
54
         if so: apply comment formatting, and leave to not add any other one"
2✔
55

2✔
56
        (anEntity class usesFamixTrait: FamixTComment) ifTrue: [
2✔
57
                        self commentHighlightFor: anEntity.
2✔
58
                        ^ self ].
2✔
59

2✔
60
        (anEntity class usesFamixTrait: FamixTNamedEntity) ifTrue: [
2✔
61
                self identifierHighlightFor: anEntity ].
2✔
62

2✔
63
        anEntity containedEntities do: [ :childChild |
2✔
64
                self createHighlightsFor: childChild ].
2✔
65

2✔
66
        anEntity tags size = 1 ifTrue: [
2✔
67
                self tagHighlight: anEntity tags anyOne for: anEntity ]
2✔
68

2✔
69
        "aChildEntity queryAllOutgoing do: [:mseAssoc |
2✔
70
                mseAssoc allTargets do: [ :target |         self addHighlight: (self dependencyHighlightFor: mseAssoc) ]
2✔
71
        ]."
2✔
72
]
2✔
73

74
{ #category : 'highlights' }
75
MiSourceTextRendererModel >> createLanguageKeywordHighlights [
2✔
76
        "search for all sourceLanguage keywords in the displayedText and highlight them
2✔
77
        There are several guard conditions because this feature is work in progress and
2✔
78
        not all language implement it"
2✔
79

2✔
80
        entity mooseModel
2✔
81
        ifNotNil: [ :mooseModel |
2✔
82
                mooseModel sourceLanguage
2✔
83
                ifNotNil: [ :sourceLanguage |
2✔
84
                        sourceLanguage languageKeyWords do: [ :kw || matcher |
2✔
85
                                matcher := RxMatcher forString: ('\W' , kw , '\W').
2✔
86
                                (matcher matchingRangesIn: self displayedText) do: [ :range |
2✔
87
                                        self keywordHighlightInterval: (range first + 1 to: range last - 1)
2✔
88
                                ]
2✔
89
                        ]
2✔
90
                ]
2✔
91
        ]
2✔
92
]
2✔
93

94
{ #category : 'accessing' }
95
MiSourceTextRendererModel >> displayedText [
2✔
96
        ^displayedText
2✔
97
]
2✔
98

99
{ #category : 'accessing' }
NEW
100
MiSourceTextRendererModel >> entity: anEntity [
×
NEW
101
]
×
102

103
{ #category : 'highlights' }
104
MiSourceTextRendererModel >> 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 : 'accessing' }
113
MiSourceTextRendererModel >> highlights [
2✔
114
        ^highlights
2✔
115
]
2✔
116

117
{ #category : 'highlights' }
118
MiSourceTextRendererModel >> identifierHighlightFor: aChildEntity [
2✔
119
        
2✔
120
        self addHighlight: (MiSourceTextIdentifierHighlight new
2✔
121
                highlightedEntity: aChildEntity ;
2✔
122
                yourself)
2✔
123

2✔
124
]
2✔
125

126
{ #category : 'initialization' }
127
MiSourceTextRendererModel >> initialize [
2✔
128
        super initialize.
2✔
129

2✔
130
        shouldHighlightChildren := true
2✔
131
]
2✔
132

133
{ #category : 'highlights' }
134
MiSourceTextRendererModel >> keywordHighlightInterval: anInterval [
2✔
135

2✔
136
        self addHighlight: (MiSourceTextKeywordHighlight new
2✔
137
                highlightInterval: anInterval ;
2✔
138
                yourself)
2✔
139

2✔
140
]
2✔
141

142
{ #category : 'formatting' }
143
MiSourceTextRendererModel >> noSourceCodeFor: anEntity [
2✔
144
        displayedText := ('There is no source code to show for {1}'
2✔
145
                format: { anEntity name }).
2✔
146

2✔
147
        self errorHighlightInterval: (Interval from: 37 to: displayedText size)
2✔
148
]
2✔
149

150
{ #category : 'highlights' }
NEW
151
MiSourceTextRendererModel >> nullHighlightFor: aChildEntity [
×
NEW
152

×
NEW
153
]
×
154

155
{ #category : 'formatting' }
156
MiSourceTextRendererModel >> prepareFormating [
2✔
157
        entity sourceText
2✔
158
                ifEmpty: [ self noSourceCodeFor: entity ]
2✔
159
                ifNotEmpty: [ :code | self prepareFormating: code ]
2✔
160

2✔
161
]
2✔
162

163
{ #category : 'formatting' }
164
MiSourceTextRendererModel >> prepareFormating: aString [
2✔
165

2✔
166
        displayedText := aString.
2✔
167

2✔
168
        self shouldHighlightChildren
2✔
169
                ifTrue: [
2✔
170
                        self createLanguageKeywordHighlights.
2✔
171
                        self createHighlightsFor: entity ]
2✔
172
                ifFalse: [ self resetHighlights ]
2✔
173
]
2✔
174

175
{ #category : 'rendering' }
176
MiSourceTextRendererModel >> renderTextFor: anEntity [
2✔
177

2✔
178
        entity := anEntity.
2✔
179

2✔
180
        self resetHighlights.
2✔
181
        self prepareFormating.
2✔
182

2✔
183
        renderer renderTextFor: entity 
2✔
184
]
2✔
185

186
{ #category : 'accessing' }
187
MiSourceTextRendererModel >> renderer: aUIRenderer [
2✔
188

2✔
189
        renderer := aUIRenderer 
2✔
190
]
2✔
191

192
{ #category : 'highlights' }
193
MiSourceTextRendererModel >> resetHighlights [
2✔
194

2✔
195
        highlights := OrderedCollection new
2✔
196
]
2✔
197

198
{ #category : 'accessing' }
199
MiSourceTextRendererModel >> shouldHighlightChildren [
2✔
200

2✔
201
        ^shouldHighlightChildren
2✔
202
]
2✔
203

204
{ #category : 'accessing' }
205
MiSourceTextRendererModel >> shouldHighlightChildren: aBoolean [
2✔
206

2✔
207
        shouldHighlightChildren := aBoolean 
2✔
208
]
2✔
209

210
{ #category : 'highlights' }
NEW
211
MiSourceTextRendererModel >> tagHighlight: aTag for: anEntity [
×
NEW
212

×
NEW
213
        self addHighlight: (MiSourceTextTagHighlight new
×
NEW
214
                highlightedEntity: anEntity ;
×
NEW
215
                tag: aTag ;
×
NEW
216
                yourself)
×
NEW
217

×
NEW
218
]
×
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