Search in sources :

Example 6 with MockCreateParameterInfoContext

use of com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext in project intellij-community by JetBrains.

the class ParameterInfoTest method testAfterGenericsInsideCall.

public void testAfterGenericsInsideCall() {
    myFixture.configureByFile(getTestName(false) + ".java");
    MethodParameterInfoHandler handler = new MethodParameterInfoHandler();
    CreateParameterInfoContext context = new MockCreateParameterInfoContext(getEditor(), getFile());
    PsiExpressionList list = handler.findElementForParameterInfo(context);
    assertNotNull(list);
    Object[] itemsToShow = context.getItemsToShow();
    assertNotNull(itemsToShow);
    assertEquals(2, itemsToShow.length);
    assertTrue(itemsToShow[0] instanceof MethodCandidateInfo);
    PsiMethod method = ((MethodCandidateInfo) itemsToShow[0]).getElement();
    ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, getEditor(), handler, 1);
    parameterContext.setUIComponentEnabled(true);
    PsiSubstitutor substitutor = ((MethodCandidateInfo) itemsToShow[0]).getSubstitutor();
    String presentation = MethodParameterInfoHandler.updateMethodPresentation(method, substitutor, parameterContext);
    assertEquals("<html>Class&lt;T&gt; type, <b>boolean tags</b></html>", presentation);
}
Also used : CreateParameterInfoContext(com.intellij.lang.parameterInfo.CreateParameterInfoContext) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext) MethodCandidateInfo(com.intellij.psi.infos.MethodCandidateInfo) MethodParameterInfoHandler(com.intellij.codeInsight.hint.api.impls.MethodParameterInfoHandler) ParameterInfoUIContextEx(com.intellij.lang.parameterInfo.ParameterInfoUIContextEx) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)

Example 7 with MockCreateParameterInfoContext

use of com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext in project intellij-community by JetBrains.

the class ParameterInfoTest method doTest.

private void doTest(String paramsList) {
    myFixture.configureByFile(getTestName(false) + ".java");
    MethodParameterInfoHandler handler = new MethodParameterInfoHandler();
    CreateParameterInfoContext context = new MockCreateParameterInfoContext(getEditor(), getFile());
    PsiExpressionList list = handler.findElementForParameterInfo(context);
    assertNotNull(list);
    Object[] itemsToShow = context.getItemsToShow();
    assertNotNull(itemsToShow);
    assertTrue(itemsToShow.length > 0);
    Object[] params = handler.getParametersForDocumentation(itemsToShow[0], context);
    assertNotNull(params);
    String joined = StringUtil.join(params, o -> ((PsiParameter) o).getName(), ",");
    assertEquals(paramsList, joined);
}
Also used : CreateParameterInfoContext(com.intellij.lang.parameterInfo.CreateParameterInfoContext) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext) MethodParameterInfoHandler(com.intellij.codeInsight.hint.api.impls.MethodParameterInfoHandler) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)

Example 8 with MockCreateParameterInfoContext

use of com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext in project intellij-plugins by JetBrains.

the class CfmlParameterInfoTest method defaultTest.

private void defaultTest(String s) throws /*, int highlightedParameterIndex*/
Exception {
    myFixture.configureByFile(getTestName(false) + ".cfml");
    CfmlParameterInfoHandler parameterInfoHandler = new CfmlParameterInfoHandler();
    MockCreateParameterInfoContext createContext = new MockCreateParameterInfoContext(myFixture.getEditor(), myFixture.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((CfmlFunctionDescription) items[0], context);
    assertEquals(s, parameterInfoHandler.getText());
    // index check
    MockUpdateParameterInfoContext updateContext = new MockUpdateParameterInfoContext(myFixture.getEditor(), myFixture.getFile());
    final PsiElement element = parameterInfoHandler.findElementForUpdatingParameterInfo(updateContext);
    parameterInfoHandler.updateParameterInfo(element, updateContext);
// assertEquals(highlightedParameterIndex, updateContext.getCurrentParameter());
}
Also used : MockUpdateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockUpdateParameterInfoContext) MockParameterInfoUIContext(com.intellij.testFramework.utils.parameterInfo.MockParameterInfoUIContext) CfmlParameterInfoHandler(com.intellij.coldFusion.UI.editorActions.CfmlParameterInfoHandler) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext) PsiElement(com.intellij.psi.PsiElement)

Example 9 with MockCreateParameterInfoContext

use of com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext 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

MockCreateParameterInfoContext (com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)9 CreateParameterInfoContext (com.intellij.lang.parameterInfo.CreateParameterInfoContext)7 MethodParameterInfoHandler (com.intellij.codeInsight.hint.api.impls.MethodParameterInfoHandler)4 MockParameterInfoUIContext (com.intellij.testFramework.utils.parameterInfo.MockParameterInfoUIContext)3 MockUpdateParameterInfoContext (com.intellij.testFramework.utils.parameterInfo.MockUpdateParameterInfoContext)3 ParameterInfoUIContextEx (com.intellij.lang.parameterInfo.ParameterInfoUIContextEx)2 PsiElement (com.intellij.psi.PsiElement)2 MethodCandidateInfo (com.intellij.psi.infos.MethodCandidateInfo)2 GoArgumentList (com.goide.psi.GoArgumentList)1 AnnotationParameterInfoHandler (com.intellij.codeInsight.hint.api.impls.AnnotationParameterInfoHandler)1 CfmlParameterInfoHandler (com.intellij.coldFusion.UI.editorActions.CfmlParameterInfoHandler)1 DartParameterInfoHandler (com.jetbrains.lang.dart.ide.info.DartParameterInfoHandler)1