|
Lines 758-766
Link Here
|
| 758 |
} else if (doStarImport && !currDecl.isOnDemand()) { |
758 |
} else if (doStarImport && !currDecl.isOnDemand()) { |
| 759 |
String simpleName = currDecl.getTypeQualifiedName(); |
759 |
String simpleName = currDecl.getTypeQualifiedName(); |
| 760 |
if (simpleName.indexOf('.') != -1) { |
760 |
if (simpleName.indexOf('.') != -1) { |
|
|
761 |
//If there is '.' in a Simple typename it is safe to assume that we are working with a Nested import |
| 761 |
String str= getNewImportString(currDecl.getElementName(), isStatic, lineDelim); |
762 |
String str= getNewImportString(currDecl.getElementName(), isStatic, lineDelim); |
| 762 |
if (stringsToInsert.indexOf(str) == -1) { |
763 |
String nextedStarImport = getNestedStarImport( |
| 763 |
stringsToInsert.add(str); |
764 |
lineDelim, str); |
|
|
765 |
if (stringsToInsert.indexOf(nextedStarImport) == -1) { |
| 766 |
stringsToInsert.add(nextedStarImport); |
| 764 |
} |
767 |
} |
| 765 |
} |
768 |
} |
| 766 |
} |
769 |
} |
|
Lines 770-775
Link Here
|
| 770 |
stringsToInsert.clear(); |
773 |
stringsToInsert.clear(); |
| 771 |
currPos= offset + region.getLength(); |
774 |
currPos= offset + region.getLength(); |
| 772 |
} else if (doStarImport && !currDecl.isOnDemand()) { |
775 |
} else if (doStarImport && !currDecl.isOnDemand()) { |
|
|
776 |
//If there is '.' in a Simple typename it is safe to assume that we are working with a Nested import |
| 773 |
String simpleName = currDecl.getTypeQualifiedName(); |
777 |
String simpleName = currDecl.getTypeQualifiedName(); |
| 774 |
if (simpleName.indexOf('.') != -1) { |
778 |
if (simpleName.indexOf('.') != -1) { |
| 775 |
IRegion rangeBefore = currDecl.getPrecedingCommentRange(); |
779 |
IRegion rangeBefore = currDecl.getPrecedingCommentRange(); |
|
Lines 782-789
Link Here
|
| 782 |
trailingComment = buffer.getText(rangeAfter.getOffset(), rangeAfter.getLength()); |
786 |
trailingComment = buffer.getText(rangeAfter.getOffset(), rangeAfter.getLength()); |
| 783 |
} |
787 |
} |
| 784 |
String str= getNewImportString(currDecl.getElementName(), isStatic, trailingComment, lineDelim); |
788 |
String str= getNewImportString(currDecl.getElementName(), isStatic, trailingComment, lineDelim); |
| 785 |
if (stringsToInsert.indexOf(str) == -1) { |
789 |
String nextedStarImport = getNestedStarImport( |
| 786 |
stringsToInsert.add(str); |
790 |
lineDelim, str); |
|
|
791 |
if (stringsToInsert.indexOf(nextedStarImport) == -1) { |
| 792 |
stringsToInsert.add(nextedStarImport); |
| 787 |
} |
793 |
} |
| 788 |
} |
794 |
} |
| 789 |
} |
795 |
} |
|
Lines 977-983
Link Here
|
| 977 |
for (int i= 0; i < nImports; i++) { |
983 |
for (int i= 0; i < nImports; i++) { |
| 978 |
ImportDeclEntry curr= packageEntry.getImportAt(i); |
984 |
ImportDeclEntry curr= packageEntry.getImportAt(i); |
| 979 |
String simpleName = curr.getTypeQualifiedName(); |
985 |
String simpleName = curr.getTypeQualifiedName(); |
| 980 |
if (simpleName.indexOf('.') != -1) { |
986 |
if (simpleName.indexOf('.') != -1 &&!isStarImportAdded) { |
| 981 |
// member type imports - we preserve it |
987 |
// member type imports - we preserve it |
| 982 |
IRegion rangeBefore = curr.getPrecedingCommentRange(); |
988 |
IRegion rangeBefore = curr.getPrecedingCommentRange(); |
| 983 |
if (rangeBefore != null) { |
989 |
if (rangeBefore != null) { |
|
Lines 988-994
Link Here
|
| 988 |
if (rangeAfter != null) { |
994 |
if (rangeAfter != null) { |
| 989 |
trailingComment = buffer.getText(rangeAfter.getOffset(), rangeAfter.getLength()); |
995 |
trailingComment = buffer.getText(rangeAfter.getOffset(), rangeAfter.getLength()); |
| 990 |
} |
996 |
} |
| 991 |
allImports.add(getNewImportString(curr.getElementName(), isStatic, trailingComment, lineDelim)); |
997 |
String starImportString = getNestedImports(packageEntry.getName(), |
|
|
998 |
simpleName); |
| 999 |
allImports.add(getNewImportString(starImportString, isStatic, trailingComment, lineDelim)); |
| 1000 |
isStarImportAdded=true; |
| 992 |
} else if (!isStarImportAdded) { |
1001 |
} else if (!isStarImportAdded) { |
| 993 |
String starImportString= packageEntry.getName() + ".*"; //$NON-NLS-1$ |
1002 |
String starImportString= packageEntry.getName() + ".*"; //$NON-NLS-1$ |
| 994 |
allImports.add(getNewImportString(starImportString, isStatic, lineDelim)); |
1003 |
allImports.add(getNewImportString(starImportString, isStatic, lineDelim)); |
|
Lines 1016-1021
Link Here
|
| 1016 |
} |
1025 |
} |
| 1017 |
return (String[]) allImports.toArray(new String[allImports.size()]); |
1026 |
return (String[]) allImports.toArray(new String[allImports.size()]); |
| 1018 |
} |
1027 |
} |
|
|
1028 |
|
| 1029 |
private String getNestedStarImport(String lineDelim, String str) { |
| 1030 |
StringBuffer buff=new StringBuffer(); |
| 1031 |
buff.append(str.substring(0, str.lastIndexOf('.'))); |
| 1032 |
buff.append(".*;"); |
| 1033 |
buff.append(lineDelim); |
| 1034 |
return buff.toString(); |
| 1035 |
} |
| 1036 |
|
| 1037 |
private String getNestedImports(String packageEntry, String simpleName) { |
| 1038 |
StringBuffer starImportString= new StringBuffer(); |
| 1039 |
starImportString.append(packageEntry); |
| 1040 |
starImportString.append("."); |
| 1041 |
starImportString.append(simpleName.substring(0, simpleName.lastIndexOf('.'))); |
| 1042 |
starImportString.append(".*"); //$NON-NLS-1$ |
| 1043 |
return starImportString.toString(); |
| 1044 |
} |
| 1019 |
|
1045 |
|
| 1020 |
private static int getFirstTypeBeginPos(CompilationUnit root) { |
1046 |
private static int getFirstTypeBeginPos(CompilationUnit root) { |
| 1021 |
List types= root.types(); |
1047 |
List types= root.types(); |