|
Lines 484-490
public class SourceProvider {
Link Here
|
| 484 |
} |
484 |
} |
| 485 |
|
485 |
|
| 486 |
private void updateImplicitReceivers(ASTRewrite rewriter, CallContext context) { |
486 |
private void updateImplicitReceivers(ASTRewrite rewriter, CallContext context) { |
| 487 |
if (context.receiver == null) |
487 |
if (context.receiver == null && !context.methodStaticallyImported) |
| 488 |
return; |
488 |
return; |
| 489 |
List<Expression> implicitReceivers= fAnalyzer.getImplicitReceivers(); |
489 |
List<Expression> implicitReceivers= fAnalyzer.getImplicitReceivers(); |
| 490 |
for (Iterator<Expression> iter= implicitReceivers.iterator(); iter.hasNext();) { |
490 |
for (Iterator<Expression> iter= implicitReceivers.iterator(); iter.hasNext();) { |
|
Lines 554-577
public class SourceProvider {
Link Here
|
| 554 |
} |
554 |
} |
| 555 |
|
555 |
|
| 556 |
private Expression createReceiver(ASTRewrite rewriter, CallContext context, IMethodBinding method, ImportRewriteContext importRewriteContext) { |
556 |
private Expression createReceiver(ASTRewrite rewriter, CallContext context, IMethodBinding method, ImportRewriteContext importRewriteContext) { |
| 557 |
String receiver= getReceiver(context, method.getModifiers(), importRewriteContext); |
557 |
String receiver= getReceiver(context, method, importRewriteContext); |
| 558 |
if (receiver == null) |
558 |
if (receiver == null) |
| 559 |
return null; |
559 |
return null; |
| 560 |
return (Expression)rewriter.createStringPlaceholder(receiver, ASTNode.METHOD_INVOCATION); |
560 |
return (Expression)rewriter.createStringPlaceholder(receiver, ASTNode.METHOD_INVOCATION); |
| 561 |
} |
561 |
} |
| 562 |
|
562 |
|
| 563 |
private Expression createReceiver(ASTRewrite rewriter, CallContext context, IVariableBinding field, ImportRewriteContext importRewriteContext) { |
563 |
private Expression createReceiver(ASTRewrite rewriter, CallContext context, IVariableBinding field, ImportRewriteContext importRewriteContext) { |
| 564 |
String receiver= getReceiver(context, field.getModifiers(), importRewriteContext); |
564 |
String receiver= getReceiver(context, field, importRewriteContext); |
| 565 |
if (receiver == null) |
565 |
if (receiver == null) |
| 566 |
return null; |
566 |
return null; |
| 567 |
return (Expression)rewriter.createStringPlaceholder(receiver, ASTNode.SIMPLE_NAME); |
567 |
return (Expression)rewriter.createStringPlaceholder(receiver, ASTNode.SIMPLE_NAME); |
| 568 |
} |
568 |
} |
| 569 |
|
569 |
|
| 570 |
private String getReceiver(CallContext context, int modifiers, ImportRewriteContext importRewriteContext) { |
570 |
private String getReceiver(CallContext context, IBinding binding, ImportRewriteContext importRewriteContext) { |
|
|
571 |
int modifiers = binding.getModifiers(); |
| 571 |
String receiver= context.receiver; |
572 |
String receiver= context.receiver; |
| 572 |
ITypeBinding invocationType= ASTNodes.getEnclosingType(context.invocation); |
573 |
ITypeBinding invocationType= ASTNodes.getEnclosingType(context.invocation); |
| 573 |
ITypeBinding sourceType= fDeclaration.resolveBinding().getDeclaringClass(); |
574 |
ITypeBinding sourceType= fDeclaration.resolveBinding().getDeclaringClass(); |
| 574 |
if (!context.receiverIsStatic && Modifier.isStatic(modifiers)) { |
575 |
if(context.methodStaticallyImported) { |
|
|
576 |
receiver = context.importer.addStaticImport(binding, new ContextSensitiveImportRewriteContext(context.invocation, context.importer)); |
| 577 |
if(binding.getName().equals(receiver)) |
| 578 |
receiver = null; |
| 579 |
else { |
| 580 |
receiver = receiver.substring(0, receiver.lastIndexOf('.')); |
| 581 |
} |
| 582 |
} |
| 583 |
else if (!context.receiverIsStatic && Modifier.isStatic(modifiers)) { |
| 575 |
if ("this".equals(receiver) && invocationType != null && Bindings.equals(invocationType, sourceType)) { //$NON-NLS-1$ |
584 |
if ("this".equals(receiver) && invocationType != null && Bindings.equals(invocationType, sourceType)) { //$NON-NLS-1$ |
| 576 |
receiver= null; |
585 |
receiver= null; |
| 577 |
} else { |
586 |
} else { |