11/*******************************************************************************
2- * Copyright (c) 2008, 2019 IBM Corporation and others.
2+ * Copyright (c) 2008, 2025 IBM Corporation and others.
33 *
44 * This program and the accompanying materials
55 * are made available under the terms of the Eclipse Public License 2.0
4141import org .eclipse .jdt .core .search .SearchParticipant ;
4242import org .eclipse .jdt .core .search .SearchPattern ;
4343import org .eclipse .jdt .core .search .SearchRequestor ;
44+ import org .eclipse .jdt .ui .text .java .IJavaCompletionProposal ;
4445import org .eclipse .jface .operation .IRunnableWithProgress ;
4546import org .eclipse .osgi .service .resolver .BundleDescription ;
4647import org .eclipse .osgi .service .resolver .BundleSpecification ;
5960 */
6061public class FindClassResolutionsOperation implements IRunnableWithProgress {
6162
62- String fClassName = null ;
63- IProject fProject = null ;
64- AbstractClassResolutionCollector fCollector = null ;
63+ private String fClassName = null ;
64+ private IProject fProject = null ;
65+ private AbstractClassResolutionCollector fCollector = null ;
6566 private CompilationUnit fCompilationUnit ;
6667
6768 /**
@@ -78,7 +79,9 @@ public static abstract class AbstractClassResolutionCollector {
7879 * Import-Package. The proposals can be created with the help of the
7980 * JavaResolutionFactory
8081 */
81- abstract public void addResolutionModification (IProject project , ExportPackageDescription desc );
82+ public void addResolutionModification (IProject project , ExportPackageDescription desc ) {
83+ addResolutionModification (project , desc , null , "" ); //$NON-NLS-1$
84+ }
8285
8386 /**
8487 * This method is meant to be sub-classed. The subclass should decide if
@@ -93,11 +96,14 @@ abstract public void addResolutionModification(IProject project, ExportPackageDe
9396 * Adds an export package proposal. Subclasses should implement the
9497 * actual adding to the collection.
9598 */
96- public Object addExportPackageResolutionModification (IPackageFragment aPackage ) {
99+ public IJavaCompletionProposal addExportPackageResolutionModification (IPackageFragment aPackage ) {
97100 if (aPackage .exists ()) {
101+ // TODO: try (and check null inbetween)
102+ // aPackage.getJavaProject().getProject();
98103 IResource packageResource = aPackage .getResource ();
99104 if (packageResource != null ) {
100- return JavaResolutionFactory .createExportPackageProposal (packageResource .getProject (), aPackage , JavaResolutionFactory .TYPE_JAVA_COMPLETION , 100 );
105+ return JavaResolutionFactory .createJavaCompletionProposal (JavaResolutionFactory
106+ .createExportPackageChange (packageResource .getProject (), aPackage ), 100 );
101107 }
102108 }
103109 return null ;
@@ -114,10 +120,15 @@ public Object addRequireBundleModification(IProject project, ExportPackageDescri
114120 * Adds a require bundle proposal. Subclasses should implement the
115121 * actual adding to the collection.
116122 */
117- public Object addRequireBundleModification (IProject project , ExportPackageDescription desc , int relevance ,
118- CompilationUnit cu , String qualifiedTypeToImport ) {
119- return JavaResolutionFactory .createRequireBundleProposal (project , desc ,
120- JavaResolutionFactory .TYPE_JAVA_COMPLETION , relevance , cu , qualifiedTypeToImport );
123+ public IJavaCompletionProposal addRequireBundleModification (IProject project , ExportPackageDescription desc ,
124+ int relevance , CompilationUnit cu , String qualifiedTypeToImport ) {
125+ BundleDescription exporter = desc .getExporter ();
126+ if (exporter == null ) {
127+ return null ;
128+ }
129+ return JavaResolutionFactory .createJavaCompletionProposal (
130+ JavaResolutionFactory .createRequireBundleChange (project , exporter , cu , qualifiedTypeToImport ),
131+ relevance );
121132 }
122133
123134
0 commit comments