Search in sources :

Example 1 with DartParameterInfoHandler

use of com.jetbrains.lang.dart.ide.info.DartParameterInfoHandler in project intellij-plugins by JetBrains.

the class DartParameterInfoTest method doTest.

private void doTest(String infoText, int highlightedParameterIndex, int highlightStart, int highlightEnd) {
    myFixture.configureByFile(getTestName(false) + "." + DartFileType.DEFAULT_EXTENSION);
    // warm up the server
    myFixture.doHighlighting();
    final DartParameterInfoHandler parameterInfoHandler = new DartParameterInfoHandler();
    MockCreateParameterInfoContext createContext = new MockCreateParameterInfoContext(getEditor(), getFile());
    PsiElement elt = parameterInfoHandler.findElementForParameterInfo(createContext);
    assertNotNull(elt);
    parameterInfoHandler.showParameterInfo(elt, createContext);
    Object[] items = createContext.getItemsToShow();
    assertTrue(items != null);
    assertTrue(items.length > 0);
    MockParameterInfoUIContext context = new MockParameterInfoUIContext<>(elt);
    parameterInfoHandler.updateUI((DartFunctionDescription) items[0], context);
    assertEquals(infoText, parameterInfoHandler.getParametersListPresentableText());
    // index check
    MockUpdateParameterInfoContext updateContext = new MockUpdateParameterInfoContext(getEditor(), getFile());
    final PsiElement element = parameterInfoHandler.findElementForUpdatingParameterInfo(updateContext);
    assertNotNull(element);
    parameterInfoHandler.updateParameterInfo(element, updateContext);
    assertEquals(highlightedParameterIndex, updateContext.getCurrentParameter());
    // range check
    if (highlightStart != -1) {
        assertEquals(highlightStart, context.getHighlightStart());
        assertEquals(highlightEnd, context.getHighlightEnd());
    }
}
Also used : DartParameterInfoHandler(com.jetbrains.lang.dart.ide.info.DartParameterInfoHandler) MockUpdateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockUpdateParameterInfoContext) MockParameterInfoUIContext(com.intellij.testFramework.utils.parameterInfo.MockParameterInfoUIContext) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 MockCreateParameterInfoContext (com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)1 MockParameterInfoUIContext (com.intellij.testFramework.utils.parameterInfo.MockParameterInfoUIContext)1 MockUpdateParameterInfoContext (com.intellij.testFramework.utils.parameterInfo.MockUpdateParameterInfoContext)1 DartParameterInfoHandler (com.jetbrains.lang.dart.ide.info.DartParameterInfoHandler)1