Skip to content

Commit

Permalink
Migrate ReorgCorrections, TypeMismatch, UnresolvedElements sub proces…
Browse files Browse the repository at this point in the history
…sors.

Signed-off-by: Rob Stryker <rob@oxbeef.net>
  • Loading branch information
robstryker committed Feb 16, 2024
1 parent 29c8799 commit 0591774
Show file tree
Hide file tree
Showing 9 changed files with 539 additions and 2,253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
import org.eclipse.jdt.internal.ui.text.correction.IProblemLocationCore;
import org.eclipse.jdt.internal.ui.text.correction.IProposalRelevance;
import org.eclipse.jdt.internal.ui.text.correction.UnInitializedFinalFieldBaseSubProcessor;
import org.eclipse.jdt.internal.ui.text.correction.proposals.AddImportCorrectionProposalCore;
import org.eclipse.jdt.internal.ui.text.correction.proposals.ReplaceCorrectionProposalCore;
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
import org.eclipse.jdt.ls.core.internal.corrections.proposals.AddImportCorrectionProposal;
import org.eclipse.jdt.ls.core.internal.corrections.proposals.GetterSetterCorrectionSubProcessor;
import org.eclipse.jdt.ls.core.internal.corrections.proposals.GradleCompatibilityProcessor;
import org.eclipse.jdt.ls.core.internal.corrections.proposals.JavadocTagsSubProcessor;
Expand Down Expand Up @@ -691,7 +691,7 @@ public void addAddAllMissingImportsProposal(IInvocationContextCore context, Coll
return;
}

Optional<Integer> minRelevance = proposals.stream().filter(w -> w.getProposal() instanceof AddImportCorrectionProposal).map((w) -> w.getProposal().getRelevance()).min(Comparator.naturalOrder());
Optional<Integer> minRelevance = proposals.stream().filter(w -> w.getProposal() instanceof AddImportCorrectionProposalCore).map((w) -> w.getProposal().getRelevance()).min(Comparator.naturalOrder());
if (minRelevance.isPresent()) {
CUCorrectionProposalCore proposal = OrganizeImportsHandler.getOrganizeImportsProposal(CorrectionMessages.UnresolvedElementsSubProcessor_add_allMissing_imports_description, context.getCompilationUnit(),
minRelevance.get() - 1, context.getASTRoot(), JavaLanguageServerPlugin.getPreferencesManager().getClientPreferences().isAdvancedOrganizeImportsSupported(), true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*******************************************************************************
* Copyright (c) 2024 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal.corrections.proposals;

import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.ui.text.correction.IProblemLocationCore;

public class ProblemLocationWrapper implements IProblemLocationCore {
private IProblemLocationCore delegate;

public ProblemLocationWrapper(IProblemLocationCore del) {
this.delegate = del;
}

@Override
public int getOffset() {
return this.delegate.getOffset();
}

@Override
public int getLength() {
return this.delegate.getLength();
}

@Override
public String getMarkerType() {
return this.delegate.getMarkerType();
}

@Override
public int getProblemId() {
return this.delegate.getProblemId();
}

@Override
public String[] getProblemArguments() {
return this.delegate.getProblemArguments();
}

@Override
public boolean isError() {
return this.delegate.isError();
}

@Override
public ASTNode getCoveringNode(CompilationUnit astRoot) {
return this.delegate.getCoveringNode(astRoot);
}
@Override
public ASTNode getCoveredNode(CompilationUnit astRoot) {
return this.delegate.getCoveredNode(astRoot);
}
}

Large diffs are not rendered by default.

Loading

0 comments on commit 0591774

Please sign in to comment.