Skip to content

Commit

Permalink
Fix a test
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <[email protected]>
  • Loading branch information
robstryker committed Feb 6, 2024
1 parent 395d5e9 commit 59593d4
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 47 deletions.
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ public static void addTypeMismatchInForEachProposals(IInvocationContextCore cont
new TypeMismatchSubProcessor().collectTypeMismatchInForEachProposals(context, problem, proposals);
}

@Override
public void collectTypeMismatchProposals(IInvocationContextCore context, IProblemLocationCore problem, Collection<ProposalKindWrapper> proposals) throws CoreException {
IProblemLocationCore wrapped = new ProblemLocationWrapper(problem) {
@Override
public String[] getProblemArguments() {
// This is a hack to get around superclass restrictions
String[] ret = super.getProblemArguments();
if (ret == null || ret.length == 0) {
return new String[] { "", "" };
}
if (ret.length == 1) {
return new String[] { ret[0], "" };
}
return ret;
}
};
super.collectTypeMismatchProposals(context, wrapped, proposals);
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.text.correction.TypeMismatchBaseSubProcessor#createInsertNullCheckProposal(java.lang.String, org.eclipse.jdt.core.ICompilationUnit, org.eclipse.jdt.core.dom.rewrite.ASTRewrite, int)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,51 +308,4 @@ public ASTNode getCoveringNode(CompilationUnit astRoot) {
};
super.collectTypeProposals(context, wrap, proposals);
}

private 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);
}
}
}

0 comments on commit 59593d4

Please sign in to comment.