Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2019 IBM Corporation and others.
* Copyright (c) 2008, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -41,6 +41,7 @@
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
Expand All @@ -59,9 +60,9 @@
*/
public class FindClassResolutionsOperation implements IRunnableWithProgress {

String fClassName = null;
IProject fProject = null;
AbstractClassResolutionCollector fCollector = null;
private String fClassName = null;
private IProject fProject = null;
private AbstractClassResolutionCollector fCollector = null;
private CompilationUnit fCompilationUnit;

/**
Expand All @@ -78,7 +79,9 @@ public static abstract class AbstractClassResolutionCollector {
* Import-Package. The proposals can be created with the help of the
* JavaResolutionFactory
*/
abstract public void addResolutionModification(IProject project, ExportPackageDescription desc);
public void addResolutionModification(IProject project, ExportPackageDescription desc) {
addResolutionModification(project, desc, null, ""); //$NON-NLS-1$
}

/**
* This method is meant to be sub-classed. The subclass should decide if
Expand All @@ -93,11 +96,15 @@ abstract public void addResolutionModification(IProject project, ExportPackageDe
* Adds an export package proposal. Subclasses should implement the
* actual adding to the collection.
*/
public Object addExportPackageResolutionModification(IPackageFragment aPackage) {
public IJavaCompletionProposal addExportPackageResolutionModification(IPackageFragment aPackage) {
if (aPackage.exists()) {
// TODO: try (and check null inbetween)
// aPackage.getJavaProject().getProject();
IResource packageResource = aPackage.getResource();
if (packageResource != null) {
return JavaResolutionFactory.createExportPackageProposal(packageResource.getProject(), aPackage, JavaResolutionFactory.TYPE_JAVA_COMPLETION, 100);
IProject project = packageResource.getProject();
var change = JavaResolutionFactory.createExportPackageChange(project, aPackage);
return JavaResolutionFactory.createJavaCompletionProposal(change, 100);
}
}
return null;
Expand All @@ -114,13 +121,16 @@ public Object addRequireBundleModification(IProject project, ExportPackageDescri
* Adds a require bundle proposal. Subclasses should implement the
* actual adding to the collection.
*/
public Object addRequireBundleModification(IProject project, ExportPackageDescription desc, int relevance,
CompilationUnit cu, String qualifiedTypeToImport) {
return JavaResolutionFactory.createRequireBundleProposal(project, desc,
JavaResolutionFactory.TYPE_JAVA_COMPLETION, relevance, cu, qualifiedTypeToImport);
public IJavaCompletionProposal addRequireBundleModification(IProject project, ExportPackageDescription desc,
int relevance, CompilationUnit cu, String qualifiedTypeToImport) {
BundleDescription exporter = desc.getExporter();
if (exporter == null) {
return null;
}
var change = JavaResolutionFactory.createRequireBundleChange(project, exporter, cu, qualifiedTypeToImport);
return JavaResolutionFactory.createJavaCompletionProposal(change, relevance);
}


/**
* Adds a search repositories proposal. Subclasses should implement the actual adding to the collection.
*/
Expand Down
Loading
Loading