Search in sources :

Example 6 with MethodParameterInfoHandler

use of com.intellij.codeInsight.hint.api.impls.MethodParameterInfoHandler in project intellij-community by JetBrains.

the class ParameterInfoTest method parameterPresentation.

private String parameterPresentation(int lineIndex, int parameterIndex) {
    MethodParameterInfoHandler handler = new MethodParameterInfoHandler();
    CreateParameterInfoContext context = createContext();
    PsiExpressionList list = handler.findElementForParameterInfo(context);
    assertNotNull(list);
    Object[] itemsToShow = context.getItemsToShow();
    assertNotNull(itemsToShow);
    assertTrue(itemsToShow[lineIndex] instanceof MethodCandidateInfo);
    PsiMethod method = ((MethodCandidateInfo) itemsToShow[lineIndex]).getElement();
    ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, getEditor(), handler, parameterIndex);
    PsiSubstitutor substitutor = ((MethodCandidateInfo) itemsToShow[lineIndex]).getSubstitutor();
    return MethodParameterInfoHandler.updateMethodPresentation(method, substitutor, parameterContext);
}
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)

Example 7 with MethodParameterInfoHandler

use of com.intellij.codeInsight.hint.api.impls.MethodParameterInfoHandler 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)

Aggregations

MethodParameterInfoHandler (com.intellij.codeInsight.hint.api.impls.MethodParameterInfoHandler)7 CreateParameterInfoContext (com.intellij.lang.parameterInfo.CreateParameterInfoContext)6 MockCreateParameterInfoContext (com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)6 MethodCandidateInfo (com.intellij.psi.infos.MethodCandidateInfo)3 ParameterInfoUIContextEx (com.intellij.lang.parameterInfo.ParameterInfoUIContextEx)2 ParameterInfoController (com.intellij.codeInsight.hint.ParameterInfoController)1 ShowParameterInfoContext (com.intellij.codeInsight.hint.ShowParameterInfoContext)1 CaretModel (com.intellij.openapi.editor.CaretModel)1 Editor (com.intellij.openapi.editor.Editor)1 Inlay (com.intellij.openapi.editor.Inlay)1 Project (com.intellij.openapi.project.Project)1 MockUpdateParameterInfoContext (com.intellij.testFramework.utils.parameterInfo.MockUpdateParameterInfoContext)1 ArrayList (java.util.ArrayList)1