Search in sources :

Example 1 with TextOperationAction

use of org.eclipse.ui.texteditor.TextOperationAction in project eclipse.platform.text by eclipse.

the class ContextInfoTest method testContextInfo_hide_Bug512251.

@Test
public void testContextInfo_hide_Bug512251() throws Exception {
    cleanFileAndEditor();
    createAndOpenFile("foobar.txt", BarContentAssistProcessor.PROPOSAL);
    final Set<Shell> beforeShells = Arrays.stream(editor.getSite().getShell().getDisplay().getShells()).filter(Shell::isVisible).collect(Collectors.toSet());
    TextOperationAction action = (TextOperationAction) editor.getAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION);
    editor.selectAndReveal(4, 0);
    action.update();
    action.run();
    waitAndDispatch(100);
    this.completionShell = findNewShell(beforeShells);
    editor.selectAndReveal(8, 0);
    action.update();
    action.run();
    waitAndDispatch(100);
    this.completionShell = findNewShell(beforeShells);
    editor.getAction(ITextEditorActionConstants.DELETE_LINE).run();
    SourceViewer sourceViewer = getSourceViewer();
    ContentAssistant assist = (ContentAssistant) new Accessor(sourceViewer, SourceViewer.class).get("fContentAssistant");
    new Accessor(assist, ContentAssistant.class).invoke("hide", new Object[0]);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) SourceViewer(org.eclipse.jface.text.source.SourceViewer) ContentAssistant(org.eclipse.jface.text.contentassist.ContentAssistant) Accessor(org.eclipse.text.tests.Accessor) TextOperationAction(org.eclipse.ui.texteditor.TextOperationAction) Test(org.junit.Test)

Example 2 with TextOperationAction

use of org.eclipse.ui.texteditor.TextOperationAction in project eclipse.platform.text by eclipse.

the class ContextInfoTest method testContextInfo.

@Test
public void testContextInfo() throws Exception {
    cleanFileAndEditor();
    createAndOpenFile("foobar.txt", BarContentAssistProcessor.PROPOSAL);
    final Set<Shell> beforeShells = Arrays.stream(editor.getSite().getShell().getDisplay().getShells()).filter(Shell::isVisible).collect(Collectors.toSet());
    TextOperationAction action = (TextOperationAction) editor.getAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION);
    editor.selectAndReveal(4, 0);
    action.update();
    action.run();
    waitAndDispatch(100);
    this.completionShell = findNewShell(beforeShells);
    assertEquals("idx= 0", getInfoText(this.completionShell));
    editor.selectAndReveal(8, 0);
    action.update();
    action.run();
    waitAndDispatch(100);
    this.completionShell = findNewShell(beforeShells);
    assertEquals("idx= 1", getInfoText(this.completionShell));
}
Also used : Shell(org.eclipse.swt.widgets.Shell) TextOperationAction(org.eclipse.ui.texteditor.TextOperationAction) Test(org.junit.Test)

Aggregations

Shell (org.eclipse.swt.widgets.Shell)2 TextOperationAction (org.eclipse.ui.texteditor.TextOperationAction)2 Test (org.junit.Test)2 ContentAssistant (org.eclipse.jface.text.contentassist.ContentAssistant)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1 Accessor (org.eclipse.text.tests.Accessor)1