|
Lines 634-642
Link Here
|
| 634 |
} else if (doStarImport && !currDecl.isOnDemand()) { |
634 |
} else if (doStarImport && !currDecl.isOnDemand()) { |
| 635 |
String simpleName = currDecl.getTypeQualifiedName(); |
635 |
String simpleName = currDecl.getTypeQualifiedName(); |
| 636 |
if (simpleName.indexOf('.') != -1) { |
636 |
if (simpleName.indexOf('.') != -1) { |
|
|
637 |
//If there is '.' in a Simple typename it is safe to assume that we are working with a Nested import |
| 637 |
String str= getNewImportString(currDecl.getElementName(), isStatic, lineDelim); |
638 |
String str= getNewImportString(currDecl.getElementName(), isStatic, lineDelim); |
| 638 |
if (stringsToInsert.indexOf(str) == -1) { |
639 |
String nextedStarImport = getNestedStarImport( |
| 639 |
stringsToInsert.add(str); |
640 |
lineDelim, str); |
|
|
641 |
if (stringsToInsert.indexOf(nextedStarImport) == -1) { |
| 642 |
stringsToInsert.add(nextedStarImport); |
| 640 |
} |
643 |
} |
| 641 |
} |
644 |
} |
| 642 |
} |
645 |
} |
|
Lines 648-655
Link Here
|
| 648 |
} else if (doStarImport && !currDecl.isOnDemand()) { |
651 |
} else if (doStarImport && !currDecl.isOnDemand()) { |
| 649 |
String simpleName = currDecl.getTypeQualifiedName(); |
652 |
String simpleName = currDecl.getTypeQualifiedName(); |
| 650 |
if (simpleName.indexOf('.') != -1) { |
653 |
if (simpleName.indexOf('.') != -1) { |
|
|
654 |
//If there is '.' in a Simple typename it is safe to assume that we are working with a Nested import |
| 651 |
String str= getNewImportString(currDecl.getElementName(), isStatic, lineDelim); |
655 |
String str= getNewImportString(currDecl.getElementName(), isStatic, lineDelim); |
| 652 |
if (stringsToInsert.indexOf(str) == -1) { |
656 |
String nextedStarImport = getNestedStarImport( |
|
|
657 |
lineDelim, str); |
| 658 |
if (stringsToInsert.indexOf(nextedStarImport) == -1) { |
| 653 |
stringsToInsert.add(str); |
659 |
stringsToInsert.add(str); |
| 654 |
} |
660 |
} |
| 655 |
} |
661 |
} |
|
Lines 675-680
Link Here
|
| 675 |
} |
681 |
} |
| 676 |
} |
682 |
} |
| 677 |
|
683 |
|
|
|
684 |
private String getNestedStarImport(String lineDelim, String str) { |
| 685 |
StringBuffer buff=new StringBuffer(); |
| 686 |
buff.append(str.substring(0, str.lastIndexOf('.'))); |
| 687 |
buff.append(".*;"); |
| 688 |
buff.append(lineDelim); |
| 689 |
return buff.toString(); |
| 690 |
} |
| 691 |
|
| 678 |
private void removeAndInsertNew(IBuffer buffer, int contentOffset, int contentEnd, ArrayList stringsToInsert, MultiTextEdit resEdit) { |
692 |
private void removeAndInsertNew(IBuffer buffer, int contentOffset, int contentEnd, ArrayList stringsToInsert, MultiTextEdit resEdit) { |
| 679 |
int pos= contentOffset; |
693 |
int pos= contentOffset; |
| 680 |
for (int i= 0; i < stringsToInsert.size(); i++) { |
694 |
for (int i= 0; i < stringsToInsert.size(); i++) { |
|
Lines 812-820
Link Here
|
| 812 |
for (int i= 0; i < nImports; i++) { |
826 |
for (int i= 0; i < nImports; i++) { |
| 813 |
ImportDeclEntry curr= packageEntry.getImportAt(i); |
827 |
ImportDeclEntry curr= packageEntry.getImportAt(i); |
| 814 |
String simpleName = curr.getTypeQualifiedName(); |
828 |
String simpleName = curr.getTypeQualifiedName(); |
| 815 |
if (simpleName.indexOf('.') != -1) { |
829 |
if (simpleName.indexOf('.') != -1 &&!isStarImportAdded) { |
| 816 |
// member type imports - we preserve it |
830 |
|
| 817 |
allImports.add(getNewImportString(curr.getElementName(), isStatic, lineDelim)); |
831 |
//If there is '.' in a Simple typename it is safe to assume that we are working with a Nested import |
|
|
832 |
StringBuffer starImportString = getNestedImports(packageEntry.getName(), |
| 833 |
simpleName); |
| 834 |
allImports.add(getNewImportString(starImportString.toString(), isStatic, lineDelim)); |
| 835 |
isStarImportAdded = true; |
| 818 |
} else if (!isStarImportAdded) { |
836 |
} else if (!isStarImportAdded) { |
| 819 |
String starImportString= packageEntry.getName() + ".*"; //$NON-NLS-1$ |
837 |
String starImportString= packageEntry.getName() + ".*"; //$NON-NLS-1$ |
| 820 |
allImports.add(getNewImportString(starImportString, isStatic, lineDelim)); |
838 |
allImports.add(getNewImportString(starImportString, isStatic, lineDelim)); |
|
Lines 824-829
Link Here
|
| 824 |
return (String[]) allImports.toArray(new String[allImports.size()]); |
842 |
return (String[]) allImports.toArray(new String[allImports.size()]); |
| 825 |
} |
843 |
} |
| 826 |
|
844 |
|
|
|
845 |
private StringBuffer getNestedImports(String packageEntry, String simpleName) { |
| 846 |
StringBuffer starImportString= new StringBuffer(); |
| 847 |
starImportString.append(packageEntry); |
| 848 |
starImportString.append("."); |
| 849 |
starImportString.append(simpleName.substring(0, simpleName.lastIndexOf('.'))); |
| 850 |
starImportString.append(".*"); //$NON-NLS-1$ |
| 851 |
return starImportString; |
| 852 |
} |
| 853 |
|
| 827 |
private static int getFirstTypeBeginPos(CompilationUnit root) { |
854 |
private static int getFirstTypeBeginPos(CompilationUnit root) { |
| 828 |
List types= root.types(); |
855 |
List types= root.types(); |
| 829 |
if (!types.isEmpty()) { |
856 |
if (!types.isEmpty()) { |