@@ -206,48 +206,40 @@ class _MethodExecuteVisitor extends RecursiveVisitor<void> {
206
206
207
207
@override
208
208
void visitLibrary (Library library) {
209
- String importUri = library.importUri.toString ();
210
-
211
- bool matches = false ;
212
- int aopItemInfoListLen = _aopItemList.length;
213
- for (int i = 0 ; i < aopItemInfoListLen && ! matches; i++ ) {
214
- MethodItem aopItem = _aopItemList[i];
215
- if ((aopItem.isRegex && RegExp (aopItem.importUri).hasMatch (importUri)) ||
216
- (! aopItem.isRegex && importUri == aopItem.importUri)) {
217
- matches = true ;
218
- break ;
219
- }
220
- }
221
- if (matches) {
222
- library.visitChildren (this );
223
- }
209
+ library.visitChildren (this );
224
210
}
225
211
226
212
@override
227
213
void visitClass (Class node) {
228
214
String clsName = node.name;
229
215
230
216
Library originalLibrary = node.enclosingLibrary;
217
+
231
218
if (node.isAnonymousMixin && node.isEliminatedMixin) {
232
- print (
233
- "[MethodAopTransformer] ${node .name } isAnonymousMixin:${originalLibrary .importUri .toString ()}}" );
219
+ if (node.implementedTypes.isNotEmpty) {
220
+ originalLibrary =
221
+ node.implementedTypes.first.classNode.enclosingLibrary;
222
+ clsName = node.implementedTypes.first.classNode.name;
223
+ }
224
+ //print(
225
+ // "[MethodAopTransformer] visitClass isAnonymousMixin ${node.name} ${originalLibrary.importUri.toString()}}");
234
226
}
235
227
bool matches = false ;
236
228
int aopItemInfoListLen = _aopItemList.length;
237
229
for (int i = 0 ; i < aopItemInfoListLen && ! matches; i++ ) {
238
230
MethodItem aopItem = _aopItemList[i];
239
231
240
- if ((aopItem.isRegex && RegExp (aopItem.clsName).hasMatch (clsName)) ||
241
- (! aopItem.isRegex && clsName == aopItem.clsName) &&
242
- originalLibrary.importUri.toString () == aopItem.importUri) {
232
+ if ((( aopItem.isRegex && RegExp (aopItem.clsName).hasMatch (clsName)) ||
233
+ (! aopItem.isRegex && clsName == aopItem.clsName) ) &&
234
+ originalLibrary.importUri.toString () == aopItem.importUri) {
243
235
matches = true ;
244
236
break ;
245
237
}
246
238
}
247
239
248
240
if (matches) {
249
241
print (
250
- "[MethodAopTransformer] visitClass match ${node . parent . runtimeType . toString () } ${node .name }" );
242
+ "[MethodAopTransformer] visitClass match ${originalLibrary . importUri } ${node .name }" );
251
243
node.visitChildren (this );
252
244
}
253
245
}
@@ -283,7 +275,7 @@ class _MethodExecuteVisitor extends RecursiveVisitor<void> {
283
275
if (node.parent is Class ) {
284
276
needCompareClass = true ;
285
277
originalClass = node.parent as Class ;
286
- originalLibrary = originalClass .enclosingLibrary;
278
+ originalLibrary = node .enclosingLibrary;
287
279
}
288
280
289
281
String ? clsName = null ;
@@ -293,6 +285,20 @@ class _MethodExecuteVisitor extends RecursiveVisitor<void> {
293
285
importUri = originalLibrary? .importUri.toString ();
294
286
}
295
287
288
+ if (needCompareClass &&
289
+ originalClass != null &&
290
+ originalClass.isAnonymousMixin &&
291
+ originalClass.isEliminatedMixin) {
292
+ if (originalClass.implementedTypes.isNotEmpty) {
293
+ clsName = originalClass.implementedTypes.first.classNode.name;
294
+ importUri = originalClass
295
+ .implementedTypes.first.classNode.enclosingLibrary.importUri
296
+ .toString ();
297
+ //print(
298
+ // "[MethodAopTransformer] visitProcedure isAnonymousMixin so transform it clasName[${originalClass.name} to $clsName] importUri[${originalLibrary?.importUri.toString()} to $importUri]");
299
+ }
300
+ }
301
+
296
302
MethodItem ? matchedAopItem = null ;
297
303
int aopItemInfoListLen = _aopItemList.length;
298
304
for (int i = 0 ; i < aopItemInfoListLen && matchedAopItem == null ; i++ ) {
@@ -316,7 +322,17 @@ class _MethodExecuteVisitor extends RecursiveVisitor<void> {
316
322
}
317
323
}
318
324
if (matchedAopItem == null ) {
325
+ if ((originalClass? .isAnonymousMixin ?? false ) &&
326
+ (originalClass? .isEliminatedMixin ?? false )) {
327
+ //print(
328
+ // "[MethodAopTransformer] visitProcedure isAnonymousMixin so transform it clasName[${originalClass?.name} to $clsName] importUri[${originalLibrary?.importUri.toString()} to $importUri]");
329
+ //print(
330
+ // "[MethodAopTransformer] visitProcedure notMatch ${originalLibrary?.importUri.toString()}|${originalClass?.name}|$procedureName");
331
+ }
319
332
return ;
333
+ } else {
334
+ print (
335
+ "[MethodAopTransformer] visitProcedure match ${originalLibrary ?.importUri .toString ()}|${originalClass ?.name }|$procedureName " );
320
336
}
321
337
322
338
try {
@@ -329,20 +345,20 @@ class _MethodExecuteVisitor extends RecursiveVisitor<void> {
329
345
node.parent? .parent as Library , matchedAopItem, node);
330
346
} else {
331
347
print (
332
- "[MethodAopTransformer] error ${node .parent .runtimeType .toString ()} ${node .name .text }" );
348
+ "[MethodAopTransformer] visitProcedure error ${node .parent .runtimeType .toString ()} ${node .name .text }" );
333
349
}
334
350
} else {
335
351
if (node.parent != null ) {
336
352
transformInstanceMethodProcedure (
337
353
node.parent? .parent as Library , matchedAopItem, node);
338
354
} else {
339
355
print (
340
- "[MethodAopTransformer] error node.parent == null ${node .name .text }" );
356
+ "[MethodAopTransformer] visitProcedure error node.parent == null ${node .name .text }" );
341
357
}
342
358
}
343
359
} catch (error, stack) {
344
360
print (
345
- "[MethodAopTransformer] ${error .toString ()} \n ${stack .toString ()}" );
361
+ "[MethodAopTransformer] visitProcedure ${error .toString ()} \n ${stack .toString ()}" );
346
362
}
347
363
}
348
364
0 commit comments