Skip to content

Commit

Permalink
AbstractAnnotateAssistTests: more information on NPE #736
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohnstn authored and jukzi committed Jun 19, 2024
1 parent 76cb0af commit 5c73ece
Showing 1 changed file with 14 additions and 4 deletions.
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

0 comments on commit 5c73ece

Please sign in to comment.