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 211628 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]
Proposed fix for this bug
BUG-359724.patch (text/plain), 3.95 KB, created by
Samrat Dhillon
on 2012-02-25 19:24:14 EST
(
hide
)
Description:
Proposed fix for this bug
Filename:
MIME Type:
Creator:
Samrat Dhillon
Created:
2012-02-25 19:24:14 EST
Size:
3.95 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/internal/core/dom/rewrite/ImportRewriteAnalyzer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ImportRewriteAnalyzer.java,v >retrieving revision 1.26 >diff -u -r1.26 ImportRewriteAnalyzer.java >--- dom/org/eclipse/jdt/internal/core/dom/rewrite/ImportRewriteAnalyzer.java 13 Apr 2010 18:53:21 -0000 1.26 >+++ dom/org/eclipse/jdt/internal/core/dom/rewrite/ImportRewriteAnalyzer.java 26 Feb 2012 00:19:16 -0000 >@@ -634,9 +634,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); > } > } > } >@@ -648,8 +651,11 @@ > } 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) { >+ String nextedStarImport = getNestedStarImport( >+ lineDelim, str); >+ if (stringsToInsert.indexOf(nextedStarImport) == -1) { > stringsToInsert.add(str); > } > } >@@ -675,6 +681,14 @@ > } > } > >+ 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 void removeAndInsertNew(IBuffer buffer, int contentOffset, int contentEnd, ArrayList stringsToInsert, MultiTextEdit resEdit) { > int pos= contentOffset; > for (int i= 0; i < stringsToInsert.size(); i++) { >@@ -812,9 +826,13 @@ > for (int i= 0; i < nImports; i++) { > ImportDeclEntry curr= packageEntry.getImportAt(i); > String simpleName = curr.getTypeQualifiedName(); >- if (simpleName.indexOf('.') != -1) { >- // member type imports - we preserve it >- allImports.add(getNewImportString(curr.getElementName(), isStatic, lineDelim)); >+ if (simpleName.indexOf('.') != -1 &&!isStarImportAdded) { >+ >+ //If there is '.' in a Simple typename it is safe to assume that we are working with a Nested import >+ StringBuffer starImportString = getNestedImports(packageEntry.getName(), >+ simpleName); >+ allImports.add(getNewImportString(starImportString.toString(), isStatic, lineDelim)); >+ isStarImportAdded = true; > } else if (!isStarImportAdded) { > String starImportString= packageEntry.getName() + ".*"; //$NON-NLS-1$ > allImports.add(getNewImportString(starImportString, isStatic, lineDelim)); >@@ -824,6 +842,15 @@ > return (String[]) allImports.toArray(new String[allImports.size()]); > } > >+ private StringBuffer 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; >+ } >+ > private static int getFirstTypeBeginPos(CompilationUnit root) { > List types= root.types(); > if (!types.isEmpty()) {
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