Skip to content

Commit

Permalink
AnnotateAssistTest1d8 test failed
Browse files Browse the repository at this point in the history
addresses the ClassCastException

fixes eclipse-jdt#736
  • Loading branch information
stephan-herrmann committed Jun 26, 2024
1 parent 690340f commit 841bbc0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;

import org.eclipse.jface.preference.IPreferenceStore;

import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
Expand All @@ -53,6 +55,7 @@
import org.eclipse.jdt.internal.core.ClasspathEntry;
import org.eclipse.jdt.internal.core.manipulation.util.Strings;

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

import org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor;
Expand All @@ -67,6 +70,17 @@ public abstract class AbstractAnnotateAssistTests extends QuickFixTest {

protected IJavaProject fJProject1;

// to be called from setUp/tearDown:
protected void setDefaultClassFileEditor(boolean set) {
@SuppressWarnings("restriction")
IPreferenceStore preferenceStore= org.eclipse.ui.internal.WorkbenchPlugin.getDefault().getPreferenceStore();
if (set) {
preferenceStore.setValue("defaultEditorForContentType_org.eclipse.jdt.core.javaClass", JavaUI.ID_CF_EDITOR);
} else {
preferenceStore.setToDefault("defaultEditorForContentType_org.eclipse.jdt.core.javaClass");
}
}

protected void ensureExists(IContainer parent) throws CoreException {
if (parent.exists()) return;
if (parent.getParent() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ public void setUp() throws Exception {
fJProject1= projectSetup.getProject();
fJProject1.getProject().getFolder(ANNOTATION_PATH).create(true, true, null);
fJProject1.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
setDefaultClassFileEditor(true);
}

@After
public void tearDown() throws Exception {
JavaProjectHelper.clear(fJProject1, projectSetup.getDefaultClasspath());
setDefaultClassFileEditor(false);
}

// === Tests ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,13 @@ public void setUp() throws Exception {
fJProject1= projectSetup.getProject();
fJProject1.getProject().getFolder(ANNOTATION_PATH).create(true, true, null);
fJProject1.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
setDefaultClassFileEditor(true);
}

@After
public void tearDown() throws Exception {
JavaProjectHelper.clear(fJProject1, projectSetup.getDefaultClasspath());
setDefaultClassFileEditor(false);
}

/**
Expand Down

0 comments on commit 841bbc0

Please sign in to comment.