Search in sources :

Example 1 with CreateParameterInfoContext

use of com.intellij.lang.parameterInfo.CreateParameterInfoContext in project intellij-community by JetBrains.

the class ParameterInfoTest method testStopAtAccessibleStaticCorrectCandidate.

public void testStopAtAccessibleStaticCorrectCandidate() {
    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(1, itemsToShow.length);
    assertEquals(0, ((MethodCandidateInfo) itemsToShow[0]).getElement().getParameterList().getParametersCount());
}
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 2 with CreateParameterInfoContext

use of com.intellij.lang.parameterInfo.CreateParameterInfoContext in project intellij-community by JetBrains.

the class ParameterInfoTest method testParameterInfoDoesNotShowInternalJetbrainsAnnotations.

public void testParameterInfoDoesNotShowInternalJetbrainsAnnotations() throws IOException {
    myFixture.configureByText("x.java", "class X { void f(@org.intellij.lang.annotations.Flow int i) { f(<caret>0); }}");
    CreateParameterInfoContext context = new MockCreateParameterInfoContext(getEditor(), getFile());
    PsiMethod method = PsiTreeUtil.getParentOfType(getFile().findElementAt(context.getOffset()), PsiMethod.class);
    assertNotNull(method);
    MockParameterInfoUIContext<PsiMethod> uiContext = new MockParameterInfoUIContext<>(method);
    String list = MethodParameterInfoHandler.updateMethodPresentation(method, PsiSubstitutor.EMPTY, uiContext);
    assertEquals("int i", list);
    PsiAnnotation[] annotations = AnnotationUtil.getAllAnnotations(method.getParameterList().getParameters()[0], false, null);
    assertEquals(1, annotations.length);
}
Also used : CreateParameterInfoContext(com.intellij.lang.parameterInfo.CreateParameterInfoContext) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext) MockParameterInfoUIContext(com.intellij.testFramework.utils.parameterInfo.MockParameterInfoUIContext) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)

Example 3 with CreateParameterInfoContext

use of com.intellij.lang.parameterInfo.CreateParameterInfoContext in project intellij-community by JetBrains.

the class ParameterInfoTest method doTest2CandidatesWithPreselection.

private void doTest2CandidatesWithPreselection() {
    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);
    ParameterInfoComponent.createContext(itemsToShow, getEditor(), handler, -1);
    MockUpdateParameterInfoContext updateParameterInfoContext = updateParameterInfo(handler, list, itemsToShow);
    assertTrue(updateParameterInfoContext.isUIComponentEnabled(0) || updateParameterInfoContext.isUIComponentEnabled(1));
}
Also used : MockUpdateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockUpdateParameterInfoContext) 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) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)

Example 4 with CreateParameterInfoContext

use of com.intellij.lang.parameterInfo.CreateParameterInfoContext in project intellij-community by JetBrains.

the class ParameterInfoTest method annoParameterPresentation.

private String annoParameterPresentation() {
    AnnotationParameterInfoHandler handler = new AnnotationParameterInfoHandler();
    CreateParameterInfoContext context = new MockCreateParameterInfoContext(getEditor(), getFile());
    PsiAnnotationParameterList list = handler.findElementForParameterInfo(context);
    assertNotNull(list);
    Object[] itemsToShow = context.getItemsToShow();
    assertNotNull(itemsToShow);
    assertEquals(1, itemsToShow.length);
    assertTrue(itemsToShow[0] instanceof PsiAnnotationMethod);
    PsiAnnotationMethod method = (PsiAnnotationMethod) itemsToShow[0];
    ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, getEditor(), handler, -1);
    return AnnotationParameterInfoHandler.updateUIText(method, parameterContext);
}
Also used : CreateParameterInfoContext(com.intellij.lang.parameterInfo.CreateParameterInfoContext) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext) AnnotationParameterInfoHandler(com.intellij.codeInsight.hint.api.impls.AnnotationParameterInfoHandler) ParameterInfoUIContextEx(com.intellij.lang.parameterInfo.ParameterInfoUIContextEx) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)

Example 5 with CreateParameterInfoContext

use of com.intellij.lang.parameterInfo.CreateParameterInfoContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoParameterInfoHandlerTest method getItemsToShow.

private Object[] getItemsToShow() {
    CreateParameterInfoContext createCtx = new MockCreateParameterInfoContext(myFixture.getEditor(), myFixture.getFile());
    GoArgumentList psiElement = myParameterInfoHandler.findElementForParameterInfo(createCtx);
    assertNotNull(psiElement);
    myParameterInfoHandler.showParameterInfo(psiElement, createCtx);
    return createCtx.getItemsToShow();
}
Also used : CreateParameterInfoContext(com.intellij.lang.parameterInfo.CreateParameterInfoContext) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext) GoArgumentList(com.goide.psi.GoArgumentList) MockCreateParameterInfoContext(com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)

Aggregations

CreateParameterInfoContext (com.intellij.lang.parameterInfo.CreateParameterInfoContext)9 MockCreateParameterInfoContext (com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext)9 MethodParameterInfoHandler (com.intellij.codeInsight.hint.api.impls.MethodParameterInfoHandler)6 ParameterInfoUIContextEx (com.intellij.lang.parameterInfo.ParameterInfoUIContextEx)3 MethodCandidateInfo (com.intellij.psi.infos.MethodCandidateInfo)3 GoArgumentList (com.goide.psi.GoArgumentList)1 AnnotationParameterInfoHandler (com.intellij.codeInsight.hint.api.impls.AnnotationParameterInfoHandler)1 MockParameterInfoUIContext (com.intellij.testFramework.utils.parameterInfo.MockParameterInfoUIContext)1 MockUpdateParameterInfoContext (com.intellij.testFramework.utils.parameterInfo.MockUpdateParameterInfoContext)1