Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractAnnotateAssistTests: more information on NPE #736 #1466

Merged
merged 1 commit into from
Jun 19, 2024
Merged
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
Expand Up @@ -24,6 +24,8 @@
import java.util.List;
import java.util.stream.Collectors;

import org.junit.Assert;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;

Expand All @@ -35,23 +37,26 @@

import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.quickassist.IQuickAssistProcessor;
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;

import org.eclipse.ui.part.FileEditorInput;

import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.WorkingCopyOwner;

import org.eclipse.jdt.internal.core.ClasspathEntry;
import org.eclipse.jdt.internal.core.manipulation.util.Strings;

import org.eclipse.jdt.ui.tests.quickfix.JarUtil.ClassFileFilter;

import org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor;
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
Expand All @@ -76,9 +81,14 @@ public List<ICompletionProposal> collectAnnotateProposals(JavaEditor javaEditor,
viewer.setSelection(new TextSelection(offset, 0));

JavaCorrectionAssistant correctionAssist= new JavaCorrectionAssistant(javaEditor);
IQuickAssistProcessor assistProcessor= new ExternalNullAnnotationQuickAssistProcessor(correctionAssist);
ICompletionProposal[] proposals= assistProcessor.computeQuickAssistProposals(viewer.getQuickAssistInvocationContext());

ExternalNullAnnotationQuickAssistProcessor assistProcessor= new ExternalNullAnnotationQuickAssistProcessor(correctionAssist);
IQuickAssistInvocationContext quickAssistInvocationContext= viewer.getQuickAssistInvocationContext();
ICompletionProposal[] proposals= assistProcessor.computeQuickAssistProposals(quickAssistInvocationContext);
if (proposals==null) {
IClassFile classFile= ((IClassFileEditorInput) javaEditor.getEditorInput()).getClassFile();
ICompilationUnit cu= classFile.getWorkingCopy((WorkingCopyOwner) null, null);
Assert.assertNotNull("cu=" + cu + " source=" + classFile.getSource(), proposals);
}
List<ICompletionProposal> list= Arrays.asList(proposals);
return list;
} else {
Expand Down
Loading