@@ -65,11 +65,14 @@ public virtual void CompleteCode(ComponentItem component, bool bindingAble)
65
65
{
66
66
foreach ( var item in component . viewItems )
67
67
{
68
+ GenCodeUtil . CompleteKeyField ( item . bindingSource , classNode ) ;
68
69
BindingMemberInvocations ( component . name , item ) ;
69
70
}
70
71
71
72
foreach ( var item in component . eventItems )
72
73
{
74
+ GenCodeUtil . CompleteKeyField ( item . bindingSource , classNode ) ;
75
+
73
76
switch ( item . type )
74
77
{
75
78
case BindingType . NoBinding :
@@ -104,7 +107,7 @@ protected virtual void BindingMemberInvocations(string name, BindingShow binding
104
107
//UnityEngine.Debug.Log(bindingInfo.bindingTarget);
105
108
//UnityEngine.Debug.Log(bindingInfo.bindingTargetType.type);
106
109
107
- var arg1 = string . Format ( " \" {0} \" " , bindingInfo . bindingSource ) ;
110
+ var arg1 = GenCodeUtil . GetSourceKeyWord ( bindingInfo . bindingSource ) ;
108
111
var invocation = invocations . Where (
109
112
x => x . Target . ToString ( ) . Contains ( "Binder" ) &&
110
113
x . Arguments . Count > 0 &&
@@ -136,7 +139,7 @@ protected virtual void BindingMemberInvocations(string name, BindingShow binding
136
139
invocation = new InvocationExpression ( ) ;
137
140
invocation . Target = new MemberReferenceExpression ( new IdentifierExpression ( "Binder" ) , methodName , new AstType [ 0 ] ) ;
138
141
invocation . Arguments . Add ( new IdentifierExpression ( arg0 ) ) ;
139
- invocation . Arguments . Add ( new PrimitiveExpression ( bindingInfo . bindingSource ) ) ;
142
+ invocation . Arguments . Add ( new IdentifierExpression ( GenCodeUtil . GetSourceKeyWord ( bindingInfo . bindingSource ) ) ) ;
140
143
PropBindingsNode . Body . Add ( invocation ) ;
141
144
}
142
145
@@ -153,7 +156,7 @@ protected virtual void BindingEventInvocations(string name, Type componentType,
153
156
{
154
157
var invocations = PropBindingsNode . Body . Descendants . OfType < InvocationExpression > ( ) ;
155
158
var arg0_name = "m_" + name + "." + bindingInfo . bindingTarget ; //绑定目标
156
- var arg1_name = string . Format ( " \" {0} \" " , bindingInfo . bindingSource ) ; //绑定源
159
+ var arg1_name = GenCodeUtil . GetSourceKeyWord ( bindingInfo . bindingSource ) ; //绑定源
157
160
158
161
var may_invocations = invocations . Where (
159
162
x => x . Target . ToString ( ) . Contains ( "Binder" ) &&
@@ -195,7 +198,7 @@ protected virtual void BindingEventInvocations(string name, Type componentType,
195
198
invocation = new InvocationExpression ( ) ;
196
199
invocation . Target = new MemberReferenceExpression ( new IdentifierExpression ( "Binder" ) , methodName , new AstType [ 0 ] ) ;
197
200
invocation . Arguments . Add ( new IdentifierExpression ( arg0_name ) ) ;
198
- invocation . Arguments . Add ( new PrimitiveExpression ( bindingInfo . bindingSource ) ) ;
201
+ invocation . Arguments . Add ( new IdentifierExpression ( GenCodeUtil . GetSourceKeyWord ( bindingInfo . bindingSource ) ) ) ;
199
202
if ( bindingInfo . type == BindingType . WithTarget )
200
203
{
201
204
invocation . Arguments . Add ( new IdentifierExpression ( "m_" + name ) ) ;
@@ -217,7 +220,7 @@ protected virtual void LocalEventInvocations(string name, BindingEvent bindingIn
217
220
var targetName = "m_" + name ;
218
221
var invocation = invocations . Where ( x =>
219
222
x . Target . ToString ( ) . Contains ( targetName ) &&
220
- x . Arguments . FirstOrDefault ( ) . ToString ( ) == bindingInfo . bindingSource ) . FirstOrDefault ( ) ;
223
+ x . Arguments . FirstOrDefault ( ) . ToString ( ) == GenCodeUtil . GetSourceKeyWord ( bindingInfo . bindingSource ) ) . FirstOrDefault ( ) ;
221
224
222
225
var eventName = bindingInfo . bindingTarget ; //如onClick
223
226
if ( invocation == null && ! string . IsNullOrEmpty ( eventName ) && ! string . IsNullOrEmpty ( bindingInfo . bindingSource ) )
@@ -345,7 +348,7 @@ protected virtual void AnalysisLoaclInvocation(InvocationExpression invocation,
345
348
var component = components . Find ( x => invocation . Target . ToString ( ) . Contains ( "m_" + x . name ) ) ;
346
349
if ( component != null )
347
350
{
348
- string bindingSource = invocation . Arguments . First ( ) . ToString ( ) ;
351
+ string bindingSource = GenCodeUtil . FromSourceKey ( invocation . Arguments . First ( ) . ToString ( ) ) ;
349
352
var info = component . eventItems . Find ( x => invocation . Target . ToString ( ) . Contains ( "m_" + component . name + "." + x . bindingTarget ) && x . type == BindingType . NoBinding && x . bindingSource == bindingSource ) ;
350
353
351
354
if ( info == null )
@@ -372,23 +375,23 @@ protected virtual void AnalysisBindingMembers(InvocationExpression invocation, L
372
375
var component = components . Find ( x => invocation . Arguments . Count > 1 && invocation . Arguments . First ( ) . ToString ( ) . Contains ( string . Format ( "m_{0}." , x . name ) ) ) ;
373
376
if ( component != null )
374
377
{
375
- var source = invocation . Arguments . ToArray ( ) [ 1 ] . ToString ( ) . Replace ( " \" " , "" ) ;
376
- var info = component . viewItems . Find ( x => x . bindingSource == source ) ;
378
+ var sourceName = GenCodeUtil . FromSourceKey ( invocation . Arguments . ToArray ( ) [ 1 ] . ToString ( ) ) ;
379
+ var info = component . viewItems . Find ( x => x . bindingSource == sourceName ) ;
377
380
var isMethod = false ;
378
381
var targetName = AnalysisTargetFromLamdaArgument ( invocation . Arguments . First ( ) . ToString ( ) , out isMethod ) ;
379
- UnityEngine . Debug . Log ( "解析出字段:" + targetName ) ;
382
+ // UnityEngine.Debug.Log("解析出字段:" + targetName);
380
383
381
384
if ( string . IsNullOrEmpty ( targetName ) )
382
385
{
383
386
UnityEngine . Debug . Assert ( ! string . IsNullOrEmpty ( targetName ) , "annalysis err:" + invocation . Arguments . First ( ) . ToString ( ) ) ;
384
387
return ;
385
388
}
386
389
var type = GetTypeClamp ( component . componentType , targetName ) ;
387
- UnityEngine . Debug . Log ( "解析出类型:" + type ) ;
390
+ // UnityEngine.Debug.Log("解析出类型:" + type);
388
391
if ( info == null )
389
392
{
390
393
info = new BindingShow ( ) ;
391
- info . bindingSource = source ;
394
+ info . bindingSource = sourceName ;
392
395
info . bindingTarget = targetName ;
393
396
info . isMethod = isMethod ;
394
397
component . viewItems . Add ( info ) ;
@@ -420,7 +423,7 @@ private string AnalysisTargetFromLamdaArgument(string arg, out bool isMethod)
420
423
else
421
424
{
422
425
var value = arg ;
423
- if ( arg . Contains ( "\" " ) )
426
+ if ( arg . Contains ( "\" " ) )
424
427
{
425
428
value = arg . Replace ( "\" " , "" ) ;
426
429
isMethod = false ;
@@ -429,9 +432,10 @@ private string AnalysisTargetFromLamdaArgument(string arg, out bool isMethod)
429
432
{
430
433
isMethod = true ;
431
434
}
432
- UnityEngine . Debug . Log ( isMethod ) ;
435
+ // UnityEngine.Debug.Log(isMethod);
433
436
434
- if ( value . Contains ( "." ) ) {
437
+ if ( value . Contains ( "." ) )
438
+ {
435
439
value = value . Substring ( value . IndexOf ( '.' ) + 1 ) ;
436
440
}
437
441
return value ;
@@ -450,16 +454,16 @@ protected virtual void AnalysisBindingEvents(InvocationExpression invocation, Li
450
454
451
455
if ( component != null )
452
456
{
453
- var source = invocation . Arguments . ToArray ( ) [ 1 ] . ToString ( ) . Replace ( " \" " , "" ) ;
454
- var info = component . eventItems . Find ( x => x . bindingSource == source ) ;
457
+ var sourceName = GenCodeUtil . FromSourceKey ( invocation . Arguments . ToArray ( ) [ 1 ] . ToString ( ) ) ;
458
+ var info = component . eventItems . Find ( x => x . bindingSource == sourceName ) ;
455
459
var arg0 = invocation . Arguments . First ( ) . ToString ( ) ;
456
460
var targetName = arg0 . Substring ( arg0 . IndexOf ( "." ) + 1 ) ;
457
461
Type infoType = GetTypeClamp ( component . componentType , targetName ) ;
458
462
459
463
if ( info == null )
460
464
{
461
465
info = new BindingEvent ( ) ;
462
- info . bindingSource = source ;
466
+ info . bindingSource = sourceName ;
463
467
info . bindingTarget = targetName ;
464
468
info . bindingTargetType . Update ( infoType ) ;
465
469
component . eventItems . Add ( info ) ;
0 commit comments