@@ -44,8 +44,6 @@ public class ASGenerator
44
44
45
45
static List < ICompletionListItem > known ;
46
46
47
- public static List < ICompletionListItem > KnownList => known ;
48
-
49
47
static private bool isHaxe
50
48
{
51
49
get { return ASContext . Context . CurrentModel . haXe ; }
@@ -59,18 +57,18 @@ static public bool HandleGeneratorCompletion(ScintillaControl Sci, bool autoHide
59
57
return false ;
60
58
}
61
59
62
- static public void ContextualGenerator ( ScintillaControl Sci )
60
+ public static List < ICompletionListItem > ContextualGenerator ( ScintillaControl Sci )
63
61
{
64
62
known = new List < ICompletionListItem > ( ) ;
65
63
66
64
if ( ASContext . Context is ASContext ) ( ASContext . Context as ASContext ) . UpdateCurrentFile ( false ) ; // update model
67
- if ( ( ASContext . Context . CurrentClass . Flags & ( FlagType . Enum | FlagType . TypeDef ) ) > 0 ) return ;
65
+ if ( ( ASContext . Context . CurrentClass . Flags & ( FlagType . Enum | FlagType . TypeDef ) ) > 0 ) return known ;
68
66
69
67
lookupPosition = - 1 ;
70
68
int position = Sci . CurrentPos ;
71
69
int style = Sci . BaseStyleAt ( position ) ;
72
70
if ( style == 19 ) // on keyword
73
- return ;
71
+ return known ;
74
72
75
73
bool isNotInterface = ( ASContext . Context . CurrentClass . Flags & FlagType . Interface ) == 0 ;
76
74
int line = Sci . LineFromPosition ( position ) ;
@@ -85,8 +83,8 @@ static public void ContextualGenerator(ScintillaControl Sci)
85
83
{
86
84
if ( style == 4 || style == 6 || style == 7 )
87
85
{
88
- ShowConvertToConst ( found , style ) ;
89
- return ;
86
+ ShowConvertToConst ( found ) ;
87
+ return known ;
90
88
}
91
89
}
92
90
@@ -109,21 +107,21 @@ static public void ContextualGenerator(ScintillaControl Sci)
109
107
{
110
108
contextParam = resolve . Type . Type ;
111
109
ShowImplementInterface ( found ) ;
112
- return ;
110
+ return known ;
113
111
}
114
112
115
113
if ( resolve . Member != null && ! ASContext . Context . CurrentClass . IsVoid ( )
116
114
&& ( resolve . Member . Flags & FlagType . LocalVar ) > 0 ) // promote to class var
117
115
{
118
116
contextMember = resolve . Member ;
119
117
ShowPromoteLocalAndAddParameter ( found ) ;
120
- return ;
118
+ return known ;
121
119
}
122
120
}
123
121
124
122
if ( contextToken != null && resolve . Member == null ) // import declaration
125
123
{
126
- if ( ( resolve . Type == null || resolve . Type . IsVoid ( ) || ! ASContext . Context . IsImported ( resolve . Type , line ) ) && CheckAutoImport ( found ) ) return ;
124
+ if ( ( resolve . Type == null || resolve . Type . IsVoid ( ) || ! ASContext . Context . IsImported ( resolve . Type , line ) ) && CheckAutoImport ( found ) ) return known ;
127
125
if ( resolve . Type == null )
128
126
{
129
127
suggestItemDeclaration = ASComplete . IsTextStyle ( Sci . BaseStyleAt ( position - 1 ) ) ;
@@ -142,10 +140,10 @@ static public void ContextualGenerator(ScintillaControl Sci)
142
140
contextMatch = m ;
143
141
ClassModel type = ASContext . Context . ResolveType ( contextToken , ASContext . Context . CurrentModel ) ;
144
142
if ( type . IsVoid ( ) && CheckAutoImport ( found ) )
145
- return ;
143
+ return known ;
146
144
}
147
145
ShowGetSetList ( found ) ;
148
- return ;
146
+ return known ;
149
147
}
150
148
// inside a function
151
149
else if ( ( found . member . Flags & ( FlagType . Function | FlagType . Getter | FlagType . Setter ) ) > 0
@@ -161,14 +159,14 @@ static public void ContextualGenerator(ScintillaControl Sci)
161
159
contextMatch = m ;
162
160
contextParam = CheckEventType ( m . Groups [ "event" ] . Value ) ;
163
161
ShowEventList ( found ) ;
164
- return ;
162
+ return known ;
165
163
}
166
164
m = Regex . Match ( text , String . Format ( patternAS2Delegate , contextToken ) , RegexOptions . IgnoreCase ) ;
167
165
if ( m . Success )
168
166
{
169
167
contextMatch = m ;
170
168
ShowDelegateList ( found ) ;
171
- return ;
169
+ return known ;
172
170
}
173
171
// suggest delegate
174
172
if ( ASContext . Context . Features . hasDelegates )
@@ -183,7 +181,7 @@ static public void ContextualGenerator(ScintillaControl Sci)
183
181
contextMember = ResolveDelegate ( resolve . Member . Type , resolve . InFile ) ;
184
182
contextMatch = m ;
185
183
ShowDelegateList ( found ) ;
186
- return ;
184
+ return known ;
187
185
}
188
186
}
189
187
}
@@ -202,7 +200,7 @@ static public void ContextualGenerator(ScintillaControl Sci)
202
200
contextParam = CheckEventType ( m . Groups [ "event" ] . Value ) ;
203
201
ShowEventList ( found ) ;
204
202
}
205
- return ;
203
+ return known ;
206
204
}
207
205
208
206
// insert default delegate name, then "generate delegate" suggestion
@@ -226,7 +224,7 @@ static public void ContextualGenerator(ScintillaControl Sci)
226
224
contextMatch = m ;
227
225
ShowDelegateList ( found ) ;
228
226
}
229
- return ;
227
+ return known ;
230
228
}
231
229
}
232
230
}
@@ -241,7 +239,7 @@ static public void ContextualGenerator(ScintillaControl Sci)
241
239
{
242
240
contextMember = resolve . Member ;
243
241
ShowFieldFromParameter ( found ) ;
244
- return ;
242
+ return known ;
245
243
}
246
244
247
245
// "add to interface" suggestion
@@ -279,7 +277,7 @@ static public void ContextualGenerator(ScintillaControl Sci)
279
277
if ( interfaces . Count > 0 )
280
278
{
281
279
ShowAddInterfaceDefList ( found , interfaces ) ;
282
- return ;
280
+ return known ;
283
281
}
284
282
}
285
283
@@ -290,7 +288,7 @@ static public void ContextualGenerator(ScintillaControl Sci)
290
288
&& ln . Length <= Sci . CurrentPos - Sci . PositionFromLine ( curLine ) ) // cursor at end of line
291
289
{
292
290
ShowAssignStatementToVarList ( found ) ;
293
- return ;
291
+ return known ;
294
292
}
295
293
}
296
294
@@ -311,7 +309,7 @@ static public void ContextualGenerator(ScintillaControl Sci)
311
309
if ( ! hasConstructor || ! hasToString )
312
310
{
313
311
ShowConstructorAndToStringList ( found , hasConstructor , hasToString ) ;
314
- return ;
312
+ return known ;
315
313
}
316
314
}
317
315
@@ -338,7 +336,7 @@ static public void ContextualGenerator(ScintillaControl Sci)
338
336
{
339
337
contextParam = eventResolve . Type . QualifiedName ;
340
338
ShowEventMetatagList ( found ) ;
341
- return ;
339
+ return known ;
342
340
}
343
341
aType = aType . Extends ;
344
342
}
@@ -402,7 +400,8 @@ static public void ContextualGenerator(ScintillaControl Sci)
402
400
}
403
401
}
404
402
}
405
- // TODO: Empty line, show generators list?
403
+ // TODO: Empty line, show generators list? yep
404
+ return known ;
406
405
}
407
406
408
407
private static MemberModel ResolveDelegate ( string type , FileModel inFile )
@@ -599,10 +598,10 @@ private static void ShowPromoteLocalAndAddParameter(FoundDeclaration found)
599
598
known . Add ( new GeneratorItem ( labelParam , GeneratorJobType . AddAsParameter , found . member , found . inClass ) ) ;
600
599
}
601
600
602
- private static void ShowConvertToConst ( FoundDeclaration found , int style )
601
+ private static void ShowConvertToConst ( FoundDeclaration found )
603
602
{
604
603
string label = TextHelper . GetString ( "ASCompletion.Label.ConvertToConst" ) ;
605
- known . Add ( new GeneratorItem ( label , GeneratorJobType . ConvertToConst , found . member , found . inClass , style ) ) ;
604
+ known . Add ( new GeneratorItem ( label , GeneratorJobType . ConvertToConst , found . member , found . inClass ) ) ;
606
605
}
607
606
608
607
private static void ShowImplementInterface ( FoundDeclaration found )
@@ -1100,7 +1099,7 @@ static public void GenerateJob(GeneratorJobType job, MemberModel member, ClassMo
1100
1099
Sci . BeginUndoAction ( ) ;
1101
1100
try
1102
1101
{
1103
- ConvertToConst ( inClass , Sci , member , detach , ( int ) data ) ;
1102
+ ConvertToConst ( inClass , Sci , member , detach ) ;
1104
1103
}
1105
1104
finally
1106
1105
{
@@ -1363,7 +1362,7 @@ private static void EventMetatag(ClassModel inClass, ScintillaControl Sci, Membe
1363
1362
InsertCode ( position , template ) ;
1364
1363
}
1365
1364
1366
- private static void ConvertToConst ( ClassModel inClass , ScintillaControl Sci , MemberModel member , bool detach , int style )
1365
+ private static void ConvertToConst ( ClassModel inClass , ScintillaControl Sci , MemberModel member , bool detach )
1367
1366
{
1368
1367
String suggestion = "NEW_CONST" ;
1369
1368
String label = TextHelper . GetString ( "ASCompletion.Label.ConstName" ) ;
@@ -1381,6 +1380,7 @@ private static void ConvertToConst(ClassModel inClass, ScintillaControl Sci, Mem
1381
1380
suggestion = ( string ) info [ "suggestion" ] ;
1382
1381
1383
1382
int position = Sci . CurrentPos ;
1383
+ int style = Sci . BaseStyleAt ( position ) ;
1384
1384
MemberModel latest = null ;
1385
1385
1386
1386
int wordPosEnd = position + 1 ;
@@ -1430,9 +1430,6 @@ private static void ConvertToConst(ClassModel inClass, ScintillaControl Sci, Mem
1430
1430
case 7 :
1431
1431
m . Type = features . stringKey ;
1432
1432
break ;
1433
- default :
1434
- m . Type = features . dynamicKey ?? features . objectKey ;
1435
- break ;
1436
1433
}
1437
1434
1438
1435
m . Value = word ;
@@ -4495,35 +4492,6 @@ public Object Data
4495
4492
}
4496
4493
}
4497
4494
4498
- class RefactorItem : ICompletionListItem
4499
- {
4500
- ToolStripItem value ;
4501
- string label ;
4502
- Bitmap icon ;
4503
-
4504
- public RefactorItem ( ToolStripItem item )
4505
- {
4506
- value = item ;
4507
- label = Regex . Replace ( item . Text , "[&.]" , string . Empty ) ;
4508
- icon = new Bitmap ( item . Image ?? PluginBase . MainForm . FindImage ( "452" ) ) ; //452, 473
4509
- }
4510
-
4511
- public string Description => TextHelper . GetString ( "Info.GeneratorTemplate" ) ;
4512
-
4513
- public Bitmap Icon => icon ;
4514
-
4515
- public string Label => label ;
4516
-
4517
- public string Value
4518
- {
4519
- get
4520
- {
4521
- value . PerformClick ( ) ;
4522
- return null ;
4523
- }
4524
- }
4525
- }
4526
-
4527
4495
class FoundDeclaration
4528
4496
{
4529
4497
public MemberModel member ;
0 commit comments