Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 211643 Details for
Bug 359724
[organize imports] nested type imports not collapsed to wildcards ('*')
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix for this bug
Bug359724.patch (text/plain), 3.99 KB, created by
Samrat Dhillon
on 2012-02-26 14:23:07 EST
(
hide
)
Description:
Fix for this bug
Filename:
MIME Type:
Creator:
Samrat Dhillon
Created:
2012-02-26 14:23:07 EST
Size:
3.99 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ImportRewriteAnalyzer.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ImportRewriteAnalyzer.java >index 5a43daf..a3f2446 100644 >--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ImportRewriteAnalyzer.java >+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ImportRewriteAnalyzer.java >@@ -758,9 +758,12 @@ > } else if (doStarImport && !currDecl.isOnDemand()) { > String simpleName = currDecl.getTypeQualifiedName(); > if (simpleName.indexOf('.') != -1) { >+ //If there is '.' in a Simple typename it is safe to assume that we are working with a Nested import > String str= getNewImportString(currDecl.getElementName(), isStatic, lineDelim); >- if (stringsToInsert.indexOf(str) == -1) { >- stringsToInsert.add(str); >+ String nextedStarImport = getNestedStarImport( >+ lineDelim, str); >+ if (stringsToInsert.indexOf(nextedStarImport) == -1) { >+ stringsToInsert.add(nextedStarImport); > } > } > } >@@ -770,6 +773,7 @@ > stringsToInsert.clear(); > currPos= offset + region.getLength(); > } else if (doStarImport && !currDecl.isOnDemand()) { >+ //If there is '.' in a Simple typename it is safe to assume that we are working with a Nested import > String simpleName = currDecl.getTypeQualifiedName(); > if (simpleName.indexOf('.') != -1) { > IRegion rangeBefore = currDecl.getPrecedingCommentRange(); >@@ -782,8 +786,10 @@ > trailingComment = buffer.getText(rangeAfter.getOffset(), rangeAfter.getLength()); > } > String str= getNewImportString(currDecl.getElementName(), isStatic, trailingComment, lineDelim); >- if (stringsToInsert.indexOf(str) == -1) { >- stringsToInsert.add(str); >+ String nextedStarImport = getNestedStarImport( >+ lineDelim, str); >+ if (stringsToInsert.indexOf(nextedStarImport) == -1) { >+ stringsToInsert.add(nextedStarImport); > } > } > } >@@ -977,7 +983,7 @@ > for (int i= 0; i < nImports; i++) { > ImportDeclEntry curr= packageEntry.getImportAt(i); > String simpleName = curr.getTypeQualifiedName(); >- if (simpleName.indexOf('.') != -1) { >+ if (simpleName.indexOf('.') != -1 &&!isStarImportAdded) { > // member type imports - we preserve it > IRegion rangeBefore = curr.getPrecedingCommentRange(); > if (rangeBefore != null) { >@@ -988,7 +994,10 @@ > if (rangeAfter != null) { > trailingComment = buffer.getText(rangeAfter.getOffset(), rangeAfter.getLength()); > } >- allImports.add(getNewImportString(curr.getElementName(), isStatic, trailingComment, lineDelim)); >+ String starImportString = getNestedImports(packageEntry.getName(), >+ simpleName); >+ allImports.add(getNewImportString(starImportString, isStatic, trailingComment, lineDelim)); >+ isStarImportAdded=true; > } else if (!isStarImportAdded) { > String starImportString= packageEntry.getName() + ".*"; //$NON-NLS-1$ > allImports.add(getNewImportString(starImportString, isStatic, lineDelim)); >@@ -1016,6 +1025,23 @@ > } > return (String[]) allImports.toArray(new String[allImports.size()]); > } >+ >+ private String getNestedStarImport(String lineDelim, String str) { >+ StringBuffer buff=new StringBuffer(); >+ buff.append(str.substring(0, str.lastIndexOf('.'))); >+ buff.append(".*;"); >+ buff.append(lineDelim); >+ return buff.toString(); >+ } >+ >+ private String getNestedImports(String packageEntry, String simpleName) { >+ StringBuffer starImportString= new StringBuffer(); >+ starImportString.append(packageEntry); >+ starImportString.append("."); >+ starImportString.append(simpleName.substring(0, simpleName.lastIndexOf('.'))); >+ starImportString.append(".*"); //$NON-NLS-1$ >+ return starImportString.toString(); >+ } > > private static int getFirstTypeBeginPos(CompilationUnit root) { > List types= root.types();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 359724
:
211628
|
211642
| 211643