Skip to content

Commit

Permalink
Consume jdt.ui interface deletion Part 1
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <[email protected]>
  • Loading branch information
robstryker authored and rgrunber committed Feb 27, 2024
1 parent 522b56b commit 6c16211
Show file tree
Hide file tree
Showing 25 changed files with 262 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.NodeFinder;
import org.eclipse.jdt.internal.core.manipulation.dom.ASTResolving;
import org.eclipse.jdt.internal.ui.text.correction.IInvocationContextCore;
import org.eclipse.jdt.ui.text.java.IInvocationContext;

public class InnovationContext implements IInvocationContextCore {
public class InnovationContext implements IInvocationContext {

private final ICompilationUnit fCompilationUnit;
private CompilationUnit fASTRoot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
import org.eclipse.jdt.internal.core.manipulation.dom.OperatorPrecedence;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder;
import org.eclipse.jdt.internal.ui.text.correction.IInvocationContextCore;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.internal.ui.text.correction.IProposalRelevance;
import org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedCorrectionProposalCore;
import org.eclipse.jdt.ls.core.internal.Messages;
Expand All @@ -84,7 +84,7 @@
public class InvertBooleanUtility {
public static final String INVERT_VARIABLE_COMMAND = "invertVariable";

public static ProposalKindWrapper getInvertVariableProposal(CodeActionParams params, IInvocationContextCore context, ASTNode covering, boolean returnAsCommand) {
public static ProposalKindWrapper getInvertVariableProposal(CodeActionParams params, IInvocationContext context, ASTNode covering, boolean returnAsCommand) {
// cursor should be placed on variable name
if (!(covering instanceof SimpleName)) {
return null;
Expand Down Expand Up @@ -232,13 +232,13 @@ public SimpleName getRenamed(SimpleName simpleName) {
return CodeActionHandler.wrap(proposal, CodeActionKind.Refactor);
}

public static boolean getInverseConditionProposals(CodeActionParams params, IInvocationContextCore context, ASTNode covering, Collection<ProposalKindWrapper> proposals) {
public static boolean getInverseConditionProposals(CodeActionParams params, IInvocationContext context, ASTNode covering, Collection<ProposalKindWrapper> proposals) {
ArrayList<ASTNode> coveredNodes = QuickAssistProcessor.getFullyCoveredNodes(context, covering);
return getInverseConditionProposals(params, context, covering, coveredNodes, proposals);

}

private static boolean getInverseConditionProposals(CodeActionParams params, IInvocationContextCore context, ASTNode covering, ArrayList<ASTNode> coveredNodes, Collection<ProposalKindWrapper> proposals) {
private static boolean getInverseConditionProposals(CodeActionParams params, IInvocationContext context, ASTNode covering, ArrayList<ASTNode> coveredNodes, Collection<ProposalKindWrapper> proposals) {
if (proposals == null) {
return false;
}
Expand Down Expand Up @@ -491,7 +491,7 @@ private static Expression getInversedExpression(ASTRewrite rewrite, Expression e
return prefixExpression;
}

public static boolean getSplitAndConditionProposals(IInvocationContextCore context, ASTNode node, Collection<ProposalKindWrapper> resultingCollections) {
public static boolean getSplitAndConditionProposals(IInvocationContext context, ASTNode node, Collection<ProposalKindWrapper> resultingCollections) {
Operator andOperator = InfixExpression.Operator.CONDITIONAL_AND;
// check that user invokes quick assist on infix expression
if (!(node instanceof InfixExpression)) {
Expand Down Expand Up @@ -561,7 +561,7 @@ public static boolean getSplitAndConditionProposals(IInvocationContextCore conte
return true;
}

public static boolean getSplitOrConditionProposals(IInvocationContextCore context, ASTNode node, Collection<ProposalKindWrapper> resultingCollections) {
public static boolean getSplitOrConditionProposals(IInvocationContext context, ASTNode node, Collection<ProposalKindWrapper> resultingCollections) {
Operator orOperator = InfixExpression.Operator.CONDITIONAL_OR;
// check that user invokes quick assist on infix expression
if (!(node instanceof InfixExpression)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
import org.eclipse.jdt.core.manipulation.CUCorrectionProposalCore;
import org.eclipse.jdt.core.manipulation.ChangeCorrectionProposalCore;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.text.correction.IInvocationContextCore;
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;
Expand All @@ -58,6 +56,8 @@
import org.eclipse.jdt.ls.core.internal.handlers.CodeActionHandler;
import org.eclipse.jdt.ls.core.internal.handlers.OrganizeImportsHandler;
import org.eclipse.jdt.ls.core.internal.text.correction.ModifierCorrectionSubProcessor;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.ui.text.java.IProblemLocation;
import org.eclipse.lsp4j.CodeActionKind;
import org.eclipse.lsp4j.CodeActionParams;

Expand All @@ -80,29 +80,29 @@ private static int moveBack(int offset, int start, String ignoreCharacters, ICom
return start;
}

public List<ProposalKindWrapper> getCorrections(CodeActionParams params, IInvocationContextCore context, IProblemLocationCore[] locations) throws CoreException {
public List<ProposalKindWrapper> getCorrections(CodeActionParams params, IInvocationContext context, IProblemLocation[] locations) throws CoreException {
if (locations == null || locations.length == 0) {
return Collections.emptyList();
}
ArrayList<ProposalKindWrapper> resultingCollections = new ArrayList<>();
Set<Integer> handledProblems = new HashSet<>(locations.length);
for (int i = 0; i < locations.length; i++) {
IProblemLocationCore curr = locations[i];
IProblemLocation curr = locations[i];
if (handledProblems(curr, locations, handledProblems)) {
process(params, context, curr, resultingCollections);
}
}
return resultingCollections;
}

private static boolean handledProblems(IProblemLocationCore location, IProblemLocationCore[] locations, Set<Integer> handledProblems) {
private static boolean handledProblems(IProblemLocation location, IProblemLocation[] locations, Set<Integer> handledProblems) {
int problemId = location.getProblemId();
if (handledProblems.contains(problemId)) {
return false;
}
if (problemId == IProblem.UndefinedName) {
// skip different problems with the same resolution
for (IProblemLocationCore l : locations) {
for (IProblemLocation l : locations) {
if (l.getProblemId() == IProblem.UndefinedType && Arrays.deepEquals(l.getProblemArguments(), location.getProblemArguments())) {
handledProblems.add(problemId);
return false;
Expand All @@ -112,7 +112,7 @@ private static boolean handledProblems(IProblemLocationCore location, IProblemLo
return handledProblems.add(problemId);
}

private void process(CodeActionParams params, IInvocationContextCore context, IProblemLocationCore problem, Collection<ProposalKindWrapper> proposals) throws CoreException {
private void process(CodeActionParams params, IInvocationContext context, IProblemLocation problem, Collection<ProposalKindWrapper> proposals) throws CoreException {
int id = problem.getProblemId();
if (id == 0) { // no proposals for none-problem locations
return;
Expand Down Expand Up @@ -686,7 +686,7 @@ private void process(CodeActionParams params, IInvocationContextCore context, IP
// problem, proposals);
}

public void addAddAllMissingImportsProposal(IInvocationContextCore context, Collection<ProposalKindWrapper> proposals) {
public void addAddAllMissingImportsProposal(IInvocationContext context, Collection<ProposalKindWrapper> proposals) {
if (proposals.size() == 0) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
import org.eclipse.jdt.internal.ui.fix.AbstractCleanUpCore;
import org.eclipse.jdt.internal.ui.fix.LambdaExpressionsCleanUpCore;
import org.eclipse.jdt.internal.ui.fix.MultiFixMessages;
import org.eclipse.jdt.internal.ui.text.correction.IInvocationContextCore;
import org.eclipse.jdt.internal.ui.text.correction.IProblemLocationCore;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.ui.text.java.IProblemLocation;
import org.eclipse.jdt.internal.ui.text.correction.IProposalRelevance;
import org.eclipse.jdt.internal.ui.text.correction.proposals.ASTRewriteRemoveImportsCorrectionProposalCore;
import org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposalCore;
Expand Down Expand Up @@ -125,7 +125,7 @@ public RefactorProcessor(PreferenceManager preferenceManager) {
this.preferenceManager = preferenceManager;
}

public List<ProposalKindWrapper> getProposals(CodeActionParams params, IInvocationContextCore context, IProblemLocationCore[] locations) throws CoreException {
public List<ProposalKindWrapper> getProposals(CodeActionParams params, IInvocationContext context, IProblemLocation[] locations) throws CoreException {
ASTNode coveringNode = context.getCoveringNode();
if (coveringNode != null) {
ArrayList<ProposalKindWrapper> proposals = new ArrayList<>();
Expand Down Expand Up @@ -164,7 +164,7 @@ public List<ProposalKindWrapper> getProposals(CodeActionParams params, IInvocati
return Collections.emptyList();
}

private boolean getIntroduceParameterProposals(CodeActionParams params, IInvocationContextCore context, ASTNode coveringNode, IProblemLocationCore[] locations, ArrayList<ProposalKindWrapper> resultingCollections) throws CoreException {
private boolean getIntroduceParameterProposals(CodeActionParams params, IInvocationContext context, ASTNode coveringNode, IProblemLocation[] locations, ArrayList<ProposalKindWrapper> resultingCollections) throws CoreException {
if (resultingCollections == null) {
return false;
}
Expand All @@ -176,7 +176,7 @@ private boolean getIntroduceParameterProposals(CodeActionParams params, IInvocat
return false;
}

private boolean getInverseLocalVariableProposals(CodeActionParams params, IInvocationContextCore context, ASTNode covering, Collection<ProposalKindWrapper> proposals) {
private boolean getInverseLocalVariableProposals(CodeActionParams params, IInvocationContext context, ASTNode covering, Collection<ProposalKindWrapper> proposals) {
if (proposals == null) {
return false;
}
Expand All @@ -196,7 +196,7 @@ private boolean getInverseLocalVariableProposals(CodeActionParams params, IInvoc
return true;
}

private boolean getMoveRefactoringProposals(CodeActionParams params, IInvocationContextCore context, ASTNode coveringNode, ArrayList<ProposalKindWrapper> resultingCollections) {
private boolean getMoveRefactoringProposals(CodeActionParams params, IInvocationContext context, ASTNode coveringNode, ArrayList<ProposalKindWrapper> resultingCollections) {
if (resultingCollections == null) {
return false;
}
Expand All @@ -213,12 +213,12 @@ private boolean getMoveRefactoringProposals(CodeActionParams params, IInvocation

}

static boolean noErrorsAtLocation(IProblemLocationCore[] locations, ASTNode coveringNode) {
static boolean noErrorsAtLocation(IProblemLocation[] locations, ASTNode coveringNode) {
if (locations != null) {
int start = coveringNode.getStartPosition();
int length = coveringNode.getLength();
for (int i = 0; i < locations.length; i++) {
IProblemLocationCore location = locations[i];
IProblemLocation location = locations[i];
if (location.getOffset() > start + length || (location.getOffset() + location.getLength()) < start) {
continue;
}
Expand All @@ -235,7 +235,7 @@ static boolean noErrorsAtLocation(IProblemLocationCore[] locations, ASTNode cove
}


private boolean getExtractVariableProposal(CodeActionParams params, IInvocationContextCore context, boolean problemsAtLocation, Collection<ProposalKindWrapper> proposals) throws CoreException {
private boolean getExtractVariableProposal(CodeActionParams params, IInvocationContext context, boolean problemsAtLocation, Collection<ProposalKindWrapper> proposals) throws CoreException {
if (proposals == null) {
return false;
}
Expand All @@ -255,7 +255,7 @@ private boolean getExtractVariableProposal(CodeActionParams params, IInvocationC
return true;
}

private boolean getAssignToVariableProposals(IInvocationContextCore context, ASTNode node, IProblemLocationCore[] locations, Collection<ProposalKindWrapper> resultingCollections, CodeActionParams params) {
private boolean getAssignToVariableProposals(IInvocationContext context, ASTNode node, IProblemLocation[] locations, Collection<ProposalKindWrapper> resultingCollections, CodeActionParams params) {
try {
Map formatterOptions = null;
ProposalKindWrapper proposal = RefactorProposalUtility.getAssignVariableProposal(params, context, locations != null && locations.length != 0, formatterOptions,
Expand All @@ -274,7 +274,7 @@ private boolean getAssignToVariableProposals(IInvocationContextCore context, AST
return true;
}

private boolean getExtractMethodProposal(CodeActionParams params, IInvocationContextCore context, ASTNode coveringNode, boolean problemsAtLocation, Collection<ProposalKindWrapper> proposals) throws CoreException {
private boolean getExtractMethodProposal(CodeActionParams params, IInvocationContext context, ASTNode coveringNode, boolean problemsAtLocation, Collection<ProposalKindWrapper> proposals) throws CoreException {
if (proposals == null) {
return false;
}
Expand All @@ -294,7 +294,7 @@ private boolean getExtractMethodProposal(CodeActionParams params, IInvocationCon
return true;
}

private boolean getExtractFieldProposal(CodeActionParams params, IInvocationContextCore context, boolean problemsAtLocation, Collection<ProposalKindWrapper> proposals) throws CoreException {
private boolean getExtractFieldProposal(CodeActionParams params, IInvocationContext context, boolean problemsAtLocation, Collection<ProposalKindWrapper> proposals) throws CoreException {
if (proposals == null) {
return false;
}
Expand All @@ -311,7 +311,7 @@ private boolean getExtractFieldProposal(CodeActionParams params, IInvocationCont
}


private boolean getInlineProposal(IInvocationContextCore context, ASTNode node, Collection<ProposalKindWrapper> resultingCollections) {
private boolean getInlineProposal(IInvocationContext context, ASTNode node, Collection<ProposalKindWrapper> resultingCollections) {
if (resultingCollections == null) {
return false;
}
Expand Down Expand Up @@ -396,7 +396,7 @@ private boolean getInlineProposal(IInvocationContextCore context, ASTNode node,
}


private boolean getConvertAnonymousToNestedProposals(CodeActionParams params, IInvocationContextCore context, ASTNode node, Collection<ProposalKindWrapper> proposals) throws CoreException {
private boolean getConvertAnonymousToNestedProposals(CodeActionParams params, IInvocationContext context, ASTNode node, Collection<ProposalKindWrapper> proposals) throws CoreException {
if (proposals == null) {
return false;
}
Expand All @@ -416,7 +416,7 @@ private boolean getConvertAnonymousToNestedProposals(CodeActionParams params, II
return true;
}

public static ProposalKindWrapper getConvertAnonymousToNestedProposal(CodeActionParams params, IInvocationContextCore context, final ASTNode node, boolean returnAsCommand) throws CoreException {
public static ProposalKindWrapper getConvertAnonymousToNestedProposal(CodeActionParams params, IInvocationContext context, final ASTNode node, boolean returnAsCommand) throws CoreException {
String label = CorrectionMessages.QuickAssistProcessor_convert_anonym_to_nested;
ClassInstanceCreation cic = getClassInstanceCreation(node);
if (cic == null) {
Expand Down Expand Up @@ -478,7 +478,7 @@ private static ClassInstanceCreation getClassInstanceCreation(ASTNode node) {
}
}

private static boolean getConvertAnonymousClassCreationsToLambdaProposals(IInvocationContextCore context, ASTNode covering, Collection<ProposalKindWrapper> resultingCollections) {
private static boolean getConvertAnonymousClassCreationsToLambdaProposals(IInvocationContext context, ASTNode covering, Collection<ProposalKindWrapper> resultingCollections) {
ClassInstanceCreation cic = getClassInstanceCreation(covering);
if (cic == null) {
return false;
Expand All @@ -501,7 +501,7 @@ private static boolean getConvertAnonymousClassCreationsToLambdaProposals(IInvoc
return true;
}

private static boolean getConvertLambdaToAnonymousClassCreationsProposals(IInvocationContextCore context, ASTNode covering, Collection<ProposalKindWrapper> resultingCollections) {
private static boolean getConvertLambdaToAnonymousClassCreationsProposals(IInvocationContext context, ASTNode covering, Collection<ProposalKindWrapper> resultingCollections) {
if (resultingCollections == null) {
return true;
}
Expand Down Expand Up @@ -529,7 +529,7 @@ private static boolean getConvertLambdaToAnonymousClassCreationsProposals(IInvoc
return true;
}

private static boolean getConvertVarTypeToResolvedTypeProposal(IInvocationContextCore context, ASTNode node, Collection<ProposalKindWrapper> proposals) {
private static boolean getConvertVarTypeToResolvedTypeProposal(IInvocationContext context, ASTNode node, Collection<ProposalKindWrapper> proposals) {
CompilationUnit astRoot = context.getASTRoot();
IJavaElement root = astRoot.getJavaElement();
if (root == null) {
Expand Down Expand Up @@ -607,7 +607,7 @@ private static SimpleName getSimpleNameForVariable(ASTNode node) {
return name;
}

private static boolean getConvertResolvedTypeToVarTypeProposal(IInvocationContextCore context, ASTNode node, Collection<ProposalKindWrapper> proposals) {
private static boolean getConvertResolvedTypeToVarTypeProposal(IInvocationContext context, ASTNode node, Collection<ProposalKindWrapper> proposals) {
CompilationUnit astRoot = context.getASTRoot();
IJavaElement root = astRoot.getJavaElement();
if (root == null) {
Expand Down Expand Up @@ -722,7 +722,7 @@ private static boolean getConvertResolvedTypeToVarTypeProposal(IInvocationContex
* @return {@code true} if the operation could or has been performed,
* {@code false otherwise}
*/
private static boolean getAddStaticImportProposals(IInvocationContextCore context, ASTNode node, Collection<ProposalKindWrapper> proposals) {
private static boolean getAddStaticImportProposals(IInvocationContext context, ASTNode node, Collection<ProposalKindWrapper> proposals) {
if (!(node instanceof SimpleName)) {
return false;
}
Expand Down Expand Up @@ -894,7 +894,7 @@ private static boolean isDirectlyAccessible(ASTNode nameNode, ITypeBinding decla
return false;
}

private static boolean getConvertForLoopProposal(IInvocationContextCore context, ASTNode node, Collection<ProposalKindWrapper> resultingCollections) {
private static boolean getConvertForLoopProposal(IInvocationContext context, ASTNode node, Collection<ProposalKindWrapper> resultingCollections) {
ForStatement forStatement = getEnclosingForStatementHeader(node);
if (forStatement == null) {
return false;
Expand Down Expand Up @@ -994,7 +994,7 @@ private static <T extends ASTNode> T getEnclosingHeader(ASTNode node, Class<T> h
return null;
}

private boolean getExtractInterfaceProposal(CodeActionParams params, IInvocationContextCore context, Collection<ProposalKindWrapper> proposals) {
private boolean getExtractInterfaceProposal(CodeActionParams params, IInvocationContext context, Collection<ProposalKindWrapper> proposals) {
if (proposals == null) {
return false;
}
Expand All @@ -1013,7 +1013,7 @@ private boolean getExtractInterfaceProposal(CodeActionParams params, IInvocation
return true;
}

private boolean getChangeSignatureProposal(CodeActionParams params, IInvocationContextCore context, Collection<ProposalKindWrapper> proposals) {
private boolean getChangeSignatureProposal(CodeActionParams params, IInvocationContext context, Collection<ProposalKindWrapper> proposals) {
if (proposals == null) {
return false;
}
Expand All @@ -1028,7 +1028,7 @@ private boolean getChangeSignatureProposal(CodeActionParams params, IInvocationC
return true;
}

private boolean getSurroundWithTryCatchProposal(IInvocationContextCore context, Collection<ProposalKindWrapper> proposals) {
private boolean getSurroundWithTryCatchProposal(IInvocationContext context, Collection<ProposalKindWrapper> proposals) {
if (proposals == null) {
return false;
}
Expand Down
Loading

0 comments on commit 6c16211

Please sign in to comment.