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 17632 Details for
Bug 84224
Need advice for finding duplicate Types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
the algorithm in code
code.txt (text/plain), 2.57 KB, created by
Martin Aeschlimann
on 2005-02-02 11:31:11 EST
(
hide
)
Description:
the algorithm in code
Filename:
MIME Type:
Creator:
Martin Aeschlimann
Created:
2005-02-02 11:31:11 EST
Size:
2.57 KB
patch
obsolete
>int nPackageEntries= fPackageEntries.size(); >// all type containers to be star imported >final HashSet starImportPackages= new HashSet(nPackageEntries); >// all simple type names referenced in a star-imported package, annottaed with the container >final HashMap typeReferences= new HashMap(); > >// iterate the internal structure of the import rewrite >for (int i= 0; i < nPackageEntries; i++) { > PackageEntry pack= (PackageEntry) fPackageEntries.get(i); > if (!pack.isStatic() && pack.hasStarImport(fImportOnDemandThreshold, null)) { > starImportPackages.add(pack.getName()); > for (int k= 0; k < pack.getNumberOfImports(); k++) { > ImportDeclEntry curr= pack.getImportAt(k); > if (!curr.isOnDemand() && !curr.isComment()) { > typeReferences.put(curr.getSimpleName(), pack.getName()); > } > } > } >} > >if (starImportPackages.isEmpty()) { > return null; >} > >starImportPackages.add(fCompilationUnit.getParent().getElementName()); >starImportPackages.add(JAVA_LANG); > >// resulting simple names that need a explicit import >final HashSet onDemandConflicts= new HashSet(); > >IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { fCompilationUnit.getJavaProject() }); > >ITypeNameRequestor requestor= new ITypeNameRequestor() { > public void acceptClass(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { > processType(packageName, simpleTypeName, enclosingTypeNames); > } > public void acceptInterface(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { > processType(packageName, simpleTypeName, enclosingTypeNames); > } > private String getTypeContainerName(char[] packageName, char[][] enclosingTypeNames) { > StringBuffer buf= new StringBuffer(); > buf.append(packageName); > for (int i= 0; i < enclosingTypeNames.length; i++) { > if (buf.length() > 0) > buf.append('.'); > buf.append(enclosingTypeNames[i]); > } > return buf.toString(); > } > > private void processType(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames) { > String name= new String(simpleTypeName); > String knownContainer= (String) typeReferences.get(name); > if (knownContainer != null) { > String containerName= getTypeContainerName(packageName, enclosingTypeNames); > if (starImportPackages.contains(containerName) && !knownContainer.equals(containerName)) { > onDemandConflicts.add(name); > } > } > } >}; > >new SearchEngine().searchAllTypeNames(null, null, SearchPattern.R_PATTERN_MATCH, IJavaSearchConstants.TYPE, > scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
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 Raw
Actions:
View
Attachments on
bug 84224
: 17632