1919import java .util .Collection ;
2020import java .util .Collections ;
2121import java .util .HashMap ;
22- import java .util .HashSet ;
2322import java .util .Iterator ;
2423import java .util .Map ;
2524import java .util .Set ;
25+ import java .util .TreeSet ;
2626
2727import org .eclipse .core .resources .IProject ;
2828import org .eclipse .core .runtime .CoreException ;
@@ -66,7 +66,7 @@ protected void execute(IProgressMonitor monitor) throws CoreException, Invocatio
6666 if (packages .isEmpty ()) {
6767 return ;
6868 }
69- Map <String , HashSet <String >> pkgsAndUses = findPackageReferences (packages , monitor );
69+ Map <String , Set <String >> pkgsAndUses = findPackageReferences (packages , monitor );
7070 if (monitor .isCanceled ()) {
7171 return ;
7272 }
@@ -94,9 +94,9 @@ protected Collection<String> getPublicExportedPackages() {
9494 return list ;
9595 }
9696
97- protected Map <String , HashSet <String >> findPackageReferences (Collection <String > packages , IProgressMonitor monitor ) {
97+ protected Map <String , Set <String >> findPackageReferences (Collection <String > packages , IProgressMonitor monitor ) {
9898 IJavaProject jp = JavaCore .create (fProject );
99- HashMap <String , HashSet <String >> pkgsAndUses = new HashMap <>();
99+ Map <String , Set <String >> pkgsAndUses = new HashMap <>();
100100 IPackageFragment [] frags = PDEJavaHelper .getPackageFragments (jp , Collections .emptySet (), false );
101101 SubMonitor subMonitor = SubMonitor .convert (monitor , frags .length * 2 );
102102 for (IPackageFragment fragment : frags ) {
@@ -107,11 +107,11 @@ protected Map<String, HashSet<String>> findPackageReferences(Collection<String>
107107 iterationMonitor .subTask (
108108 NLS .bind (PDEUIMessages .CalculateUsesOperation_calculatingDirective , fragment .getElementName ()));
109109 if (packages .contains (fragment .getElementName ())) {
110- HashSet <String > pkgs = new HashSet <>();
110+ Set <String > pkgs = new TreeSet <>();
111111 pkgsAndUses .put (fragment .getElementName (), pkgs );
112112 try {
113113 findReferences (fragment .getCompilationUnits (), pkgs , iterationMonitor .split (1 ), false );
114- findReferences (fragment .getClassFiles (), pkgs , iterationMonitor .split (1 ), true );
114+ findReferences (fragment .getOrdinaryClassFiles (), pkgs , iterationMonitor .split (1 ), true );
115115 } catch (JavaModelException e ) {
116116 }
117117 }
@@ -205,14 +205,14 @@ protected final void addPackages(String[] typeSignatures, Set<String> pkgs, ITyp
205205 }
206206 }
207207
208- protected void handleSetUsesDirectives (Map <String , HashSet <String >> pkgsAndUses ) {
208+ protected void handleSetUsesDirectives (Map <String , Set <String >> pkgsAndUses ) {
209209 if (pkgsAndUses .isEmpty ()) {
210210 return ;
211211 }
212212 setUsesDirectives (pkgsAndUses );
213213 }
214214
215- protected void setUsesDirectives (Map <String , HashSet <String >> pkgsAndUses ) {
215+ protected void setUsesDirectives (Map <String , Set <String >> pkgsAndUses ) {
216216 IBundle bundle = fModel .getBundleModel ().getBundle ();
217217 IManifestHeader header = bundle .getManifestHeader (Constants .EXPORT_PACKAGE );
218218 // header will not equal null b/c we would not get this far (ie. no exported packages so we would have returned earlier
@@ -226,7 +226,7 @@ protected void setUsesDirectives(Map<String, HashSet<String>> pkgsAndUses) {
226226 }
227227 }
228228
229- protected String getDirectiveValue (String pkgName , Map <String , HashSet <String >> pkgsAndUses ) {
229+ protected String getDirectiveValue (String pkgName , Map <String , Set <String >> pkgsAndUses ) {
230230 Set <String > usesPkgs = pkgsAndUses .get (pkgName );
231231 usesPkgs .remove (pkgName );
232232 StringBuilder buffer = null ;
0 commit comments