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 155715 Details for
Bug 252379
Organize imports deletes needed static import.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated patch with regression test
bug_252379.txt (text/plain), 6.21 KB, created by
Jay Arthanareeswaran
on 2010-01-11 03:41:47 EST
(
hide
)
Description:
Updated patch with regression test
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2010-01-11 03:41:47 EST
Size:
6.21 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java,v >retrieving revision 1.17 >diff -u -r1.17 ImportRewrite.java >--- dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java 7 Mar 2009 01:08:09 -0000 1.17 >+++ dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java 11 Jan 2010 07:26:01 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,7 +12,9 @@ > package org.eclipse.jdt.core.dom.rewrite; > > import java.util.ArrayList; >+import java.util.HashMap; > import java.util.List; >+import java.util.Map; > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >@@ -122,6 +124,7 @@ > > private final boolean restoreExistingImports; > private final List existingImports; >+ private final Map importsKindMap; > > private String[] importOrder; > private int importOnDemandThreshold; >@@ -232,6 +235,8 @@ > this.importOrder= CharOperation.NO_STRINGS; > this.importOnDemandThreshold= 99; > this.staticImportOnDemandThreshold= 99; >+ >+ this.importsKindMap = new HashMap(); > } > > >@@ -307,7 +312,7 @@ > this.filterImplicitImports= filterImplicitImports; > } > >- private static int compareImport(char prefix, String qualifier, String name, String curr) { >+ private int compareImport(char prefix, String qualifier, String name, String curr) { > if (curr.charAt(0) != prefix || !curr.endsWith(name)) { > return ImportRewriteContext.RES_NAME_UNKNOWN; > } >@@ -345,7 +350,10 @@ > int res= compareImport(prefix, qualifier, name, curr); > if (res != ImportRewriteContext.RES_NAME_UNKNOWN) { > if (!allowAmbiguity || res == ImportRewriteContext.RES_NAME_FOUND) { >- return res; >+ if (prefix != 's' >+ || (this.importsKindMap.get(curr.substring(1)).equals(this.importsKindMap.get(qualifier + "." + name)))) { >+ return res; >+ } > } > } > } >@@ -839,6 +847,7 @@ > context= this.defaultContext; > } > int kind= isField ? ImportRewriteContext.KIND_STATIC_FIELD : ImportRewriteContext.KIND_STATIC_METHOD; >+ this.importsKindMap.put(declaringTypeName + "." + simpleName, new Integer(kind)); > int res= context.findInContext(declaringTypeName, simpleName, kind); > if (res == ImportRewriteContext.RES_NAME_CONFLICT) { > return declaringTypeName + '.' + simpleName; >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java,v >retrieving revision 1.14 >diff -u -r1.14 ImportRewriteTest.java >--- src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java 16 Nov 2009 15:07:36 -0000 1.14 >+++ src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java 11 Jan 2010 07:26:05 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -922,6 +922,63 @@ > assertEqualString(cu.getSource(), buf.toString()); > } > >+ public void testBug252379() throws CoreException, BackingStoreException, >+ MalformedTreeException, BadLocationException { >+ >+ >+ ICompilationUnit[] units = new ICompilationUnit[3]; >+ >+ IPackageFragment pack1 = this.sourceFolder.createPackageFragment( >+ "bug", false, null); >+ >+ StringBuffer buf = new StringBuffer(); >+ buf.append("package bug;\n"); >+ buf.append("\n"); >+ buf.append("enum CaseType {\n"); >+ buf.append("\tone;\n"); >+ buf.append("\tstatic CaseType[] all(){return null;}\n"); >+ buf.append("}\n"); >+ >+ units[0] = pack1.createCompilationUnit("CaseType.java", buf.toString(), false, null); >+ >+ buf = new StringBuffer(); >+ buf.append("package bug;\n"); >+ buf.append("enum ShareLevel{all})\n"); >+ >+ units[1] = pack1.createCompilationUnit("ShareLevel.java", buf.toString(), false, null); >+ >+ buf = new StringBuffer(); >+ buf.append("package bug;\n"); >+ buf.append("class Bug {\n"); >+ buf.append("public ShareLevel createControl() {\n"); >+ buf.append("for (CaseType cat : all())\n"); >+ buf.append("cat.hashCode();\n"); >+ buf.append("ShareLevel temp = all;\n"); >+ buf.append("return temp;\n"); >+ buf.append("};\n"); >+ buf.append("}\n"); >+ units[2] = pack1.createCompilationUnit("Bug.java", buf.toString(), false, null); >+ >+ ImportRewrite imports = newImportsRewrite(units[2], new String[] {}, 99, 99, false); >+ imports.addStaticImport("bug.CaseType", "all", false); >+ imports.addStaticImport("bug.ShareLevel", "all", true); >+ >+ apply(imports); >+ >+ buf = new StringBuffer(); >+ buf.append("package bug;\n\n"); >+ buf.append("import static bug.CaseType.all;\n"); >+ buf.append("import static bug.ShareLevel.all;\n\n"); >+ buf.append("class Bug {\n"); >+ buf.append("public ShareLevel createControl() {\n"); >+ buf.append("for (CaseType cat : all())\n"); >+ buf.append("cat.hashCode();\n"); >+ buf.append("ShareLevel temp = all;\n"); >+ buf.append("return temp;\n"); >+ buf.append("};\n"); >+ buf.append("}\n"); >+ assertEqualString(units[2].getSource(), buf.toString()); >+ } > > private void assertAddedAndRemoved(ImportRewrite imports, String[] expectedAdded, String[] expectedRemoved, String[] expectedAddedStatic, String[] expectedRemovedStatic) { > assertEqualStringsIgnoreOrder(imports.getAddedImports(), expectedAdded);
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
Flags:
Olivier_Thomann
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 252379
:
155406
| 155715 |
156258