|
Lines 356-362
Link Here
|
| 356 |
} |
356 |
} |
| 357 |
resolvedImports[index++] = new ImportBinding(compoundName, true, importBinding, importReference); |
357 |
resolvedImports[index++] = new ImportBinding(compoundName, true, importBinding, importReference); |
| 358 |
} else { |
358 |
} else { |
| 359 |
Binding importBinding = findSingleImport(compoundName, importReference.isStatic()); |
359 |
Binding importBinding = findSingleImport(compoundName, Binding.TYPE | Binding.FIELD | Binding.METHOD, importReference.isStatic()); |
| 360 |
if (!importBinding.isValidBinding()) { |
360 |
if (!importBinding.isValidBinding()) { |
| 361 |
if (importBinding.problemId() == ProblemReasons.Ambiguous) { |
361 |
if (importBinding.problemId() == ProblemReasons.Ambiguous) { |
| 362 |
// keep it unless a duplicate can be found below |
362 |
// keep it unless a duplicate can be found below |
|
Lines 442-448
Link Here
|
| 442 |
if(onDemand) { |
442 |
if(onDemand) { |
| 443 |
return findImport(compoundName, compoundName.length); |
443 |
return findImport(compoundName, compoundName.length); |
| 444 |
} else { |
444 |
} else { |
| 445 |
return findSingleImport(compoundName, findStaticImports); |
445 |
return findSingleImport(compoundName, Binding.TYPE | Binding.FIELD | Binding.METHOD, findStaticImports); |
| 446 |
} |
446 |
} |
| 447 |
} |
447 |
} |
| 448 |
private Binding findImport(char[][] compoundName, int length) { |
448 |
private Binding findImport(char[][] compoundName, int length) { |
|
Lines 493-499
Link Here
|
| 493 |
return new ProblemReferenceBinding(compoundName, type, ProblemReasons.NotVisible); |
493 |
return new ProblemReferenceBinding(compoundName, type, ProblemReasons.NotVisible); |
| 494 |
return type; |
494 |
return type; |
| 495 |
} |
495 |
} |
| 496 |
private Binding findSingleImport(char[][] compoundName, boolean findStaticImports) { |
496 |
private Binding findSingleImport(char[][] compoundName, int mask, boolean findStaticImports) { |
| 497 |
if (compoundName.length == 1) { |
497 |
if (compoundName.length == 1) { |
| 498 |
// findType records the reference |
498 |
// findType records the reference |
| 499 |
// the name cannot be a package |
499 |
// the name cannot be a package |
|
Lines 506-515
Link Here
|
| 506 |
} |
506 |
} |
| 507 |
|
507 |
|
| 508 |
if (findStaticImports) |
508 |
if (findStaticImports) |
| 509 |
return findSingleStaticImport(compoundName); |
509 |
return findSingleStaticImport(compoundName, mask); |
| 510 |
return findImport(compoundName, compoundName.length); |
510 |
return findImport(compoundName, compoundName.length); |
| 511 |
} |
511 |
} |
| 512 |
private Binding findSingleStaticImport(char[][] compoundName) { |
512 |
private Binding findSingleStaticImport(char[][] compoundName, int mask) { |
| 513 |
Binding binding = findImport(compoundName, compoundName.length - 1); |
513 |
Binding binding = findImport(compoundName, compoundName.length - 1); |
| 514 |
if (!binding.isValidBinding()) return binding; |
514 |
if (!binding.isValidBinding()) return binding; |
| 515 |
|
515 |
|
|
Lines 523-529
Link Here
|
| 523 |
|
523 |
|
| 524 |
// look to see if its a static field first |
524 |
// look to see if its a static field first |
| 525 |
ReferenceBinding type = (ReferenceBinding) binding; |
525 |
ReferenceBinding type = (ReferenceBinding) binding; |
| 526 |
FieldBinding field = findField(type, name, null, true); |
526 |
FieldBinding field = (mask & Binding.FIELD) != 0 ? findField(type, name, null, true) : null; |
| 527 |
if (field != null) { |
527 |
if (field != null) { |
| 528 |
if (field.problemId() == ProblemReasons.Ambiguous && ((ProblemFieldBinding) field).closestMatch.isStatic()) |
528 |
if (field.problemId() == ProblemReasons.Ambiguous && ((ProblemFieldBinding) field).closestMatch.isStatic()) |
| 529 |
return field; // keep the ambiguous field instead of a possible method match |
529 |
return field; // keep the ambiguous field instead of a possible method match |
|
Lines 532-538
Link Here
|
| 532 |
} |
532 |
} |
| 533 |
|
533 |
|
| 534 |
// look to see if there is a static method with the same selector |
534 |
// look to see if there is a static method with the same selector |
| 535 |
MethodBinding method = findStaticMethod(type, name); |
535 |
MethodBinding method = (mask & Binding.METHOD) != 0 ? findStaticMethod(type, name) : null; |
| 536 |
if (method != null) return method; |
536 |
if (method != null) return method; |
| 537 |
|
537 |
|
| 538 |
type = findMemberType(name, type); |
538 |
type = findMemberType(name, type); |
|
Lines 589-595
Link Here
|
| 589 |
public final Binding getImport(char[][] compoundName, boolean onDemand, boolean isStaticImport) { |
589 |
public final Binding getImport(char[][] compoundName, boolean onDemand, boolean isStaticImport) { |
| 590 |
if (onDemand) |
590 |
if (onDemand) |
| 591 |
return findImport(compoundName, compoundName.length); |
591 |
return findImport(compoundName, compoundName.length); |
| 592 |
return findSingleImport(compoundName, isStaticImport); |
592 |
return findSingleImport(compoundName, Binding.TYPE | Binding.FIELD | Binding.METHOD, isStaticImport); |
| 593 |
} |
593 |
} |
| 594 |
|
594 |
|
| 595 |
public int nextCaptureID() { |
595 |
public int nextCaptureID() { |
|
Lines 708-716
Link Here
|
| 708 |
referencedTypes.add(actualType); |
708 |
referencedTypes.add(actualType); |
| 709 |
} |
709 |
} |
| 710 |
} |
710 |
} |
| 711 |
Binding resolveSingleImport(ImportBinding importBinding) { |
711 |
Binding resolveSingleImport(ImportBinding importBinding, int mask) { |
| 712 |
if (importBinding.resolvedImport == null) { |
712 |
if (importBinding.resolvedImport == null) { |
| 713 |
importBinding.resolvedImport = findSingleImport(importBinding.compoundName, importBinding.isStatic()); |
713 |
importBinding.resolvedImport = findSingleImport(importBinding.compoundName, mask, importBinding.isStatic()); |
| 714 |
if (!importBinding.resolvedImport.isValidBinding() || importBinding.resolvedImport instanceof PackageBinding) { |
714 |
if (!importBinding.resolvedImport.isValidBinding() || importBinding.resolvedImport instanceof PackageBinding) { |
| 715 |
if (importBinding.resolvedImport.problemId() == ProblemReasons.Ambiguous) |
715 |
if (importBinding.resolvedImport.problemId() == ProblemReasons.Ambiguous) |
| 716 |
return importBinding.resolvedImport; |
716 |
return importBinding.resolvedImport; |