Parameter Info

Good day!

Is there any way to provide a parameter info (ctrl + P) messages for a custom language?

thanks

8 comments
Comment actions Permalink


I've found and implemented ParameterInfoHandler but i can't get it show a
tooltip - methods get called but no tooltip

any help or maybe javadoc?

Good day!

Is there any way to provide a parameter info (ctrl + P) messages for a custom language?

thanks

0
Comment actions Permalink

Perhabs showHint is missed from the parameter info implementation.
Yet another reason is empty parameters

__jay wrote:


I've found and implemented ParameterInfoHandler but i can't get it show
a tooltip - methods get called but no tooltip

any help or maybe javadoc?

>> Good day!
>>
>> Is there any way to provide a parameter info (ctrl + P) messages for a
>> custom language?
>>
>> thanks


--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink


I think the problem is somewhere with the offsets, not with the showHint.

My impl:

public boolean couldShowInLookup() {
return true;
}

public Object[] getParametersForLookup(LookupItem lookupItem,
ParameterInfoContext parameterInfoContext) {
return new Object[0];
}

public Object[] getParametersForDocumentation(Object o, return new Object[0];
}

public Object findElementForParameterInfo(CreateParameterInfoContext context) {
ParserCallingReference callingReference =
ParameterInfoUtils.findParentOfType(context.getFile(), context.getOffset(),
ParserCallingReference.class);
if (callingReference != null) {
ParserMethodReference methodReference = callingReference.getReferenceMethod();
if (methodReference != null) {
PsiElement psiElement = methodReference.getReference().resolve();
if (psiElement == null)
return null;
String name = ((PsiNamedElement) psiElement).getName();
Object[] variants = methodReference.getReference().getVariants();
List list = new ArrayList]]>();
for (Object variant : variants) {
if (variant instanceof ParserSmartLookupItem)
variant = ((ParserSmartLookupItem)variant).getElement();
if (variant instanceof ParserMethod && ((ParserMethod)
variant).getName().equals(name)) {
list.add((PsiElement) variant);
}
}
context.setItemsToShow(list.toArray(new Object[0])); // if i get it right
here i add my methods which are then passed to updateUI
}
}
return callingReference;
}

public void showParameterInfo(@NotNull Object o, CreateParameterInfoContext
context) {
showParameterInfo((ParserCallingReference) o, context);
}

public void showParameterInfo(@NotNull ParserCallingReference callingReference,
CreateParameterInfoContext context) {
if (callingReference.getReferenceMethod() != null)
context.showHint(callingReference,
context.getEditor().getCaretModel().getOffset(), this); // i think the problem
is in this offset or maybe in the offset of my callingReference class
}

public Object findElementForUpdatingParameterInfo(UpdateParameterInfoContext
context) {
return null;
}

public void updateParameterInfo(@NotNull Object o, UpdateParameterInfoContext
context) {
}

public String getParameterCloseChars() {
return ";";
}

public boolean tracksParameterIndex() {
return true;
}

public void updateUI(Object o, ParameterInfoUIContext parameterInfoUIContext) {
updateUI((ParserMethod)o, parameterInfoUIContext);

}

public void updateUI(ParserMethod method, ParameterInfoUIContext context) {
String params = method.getParameterList().getText();
String toShow = params.substring(1, params.length() - 1);
System.out.println(toShow); // LOOK: this is printed correctly
context.setUIComponentEnabled(false);
context.setupUIComponentPresentation(toShow, 0, 0, false, false, false,
context.getDefaultParameterColor());
}

Thank you for quick answer

0
Comment actions Permalink

If findElementForUpdatingParameterInfo returns null then hint is removed


__jay wrote:


I think the problem is somewhere with the offsets, not with the showHint.

My impl:

public boolean couldShowInLookup() {
return true;
}

public Object[] getParametersForLookup(LookupItem lookupItem,
ParameterInfoContext parameterInfoContext) {
return new Object[0];
}

public Object[] getParametersForDocumentation(Object o,
return new Object[0];
}

public Object findElementForParameterInfo(CreateParameterInfoContext
context) {
ParserCallingReference callingReference =
ParameterInfoUtils.findParentOfType(context.getFile(),
context.getOffset(), ParserCallingReference.class);
if (callingReference != null) {
ParserMethodReference methodReference =
callingReference.getReferenceMethod();
if (methodReference != null) {
PsiElement psiElement =
methodReference.getReference().resolve();
if (psiElement == null)
return null;
String name = ((PsiNamedElement) psiElement).getName();
Object[] variants =
methodReference.getReference().getVariants();
List<PsiElement> list = new ArrayList<PsiElement>();
for (Object variant : variants) {
if (variant instanceof ParserSmartLookupItem)
variant =
((ParserSmartLookupItem)variant).getElement();
if (variant instanceof ParserMethod &&
((ParserMethod) variant).getName().equals(name)) {
list.add((PsiElement) variant);
}
}
context.setItemsToShow(list.toArray(new Object[0])); //
if i get it right here i add my methods which are then passed to updateUI
}
}
return callingReference;
}

public void showParameterInfo(@NotNull Object o,
CreateParameterInfoContext context) {
showParameterInfo((ParserCallingReference) o, context);
}

public void showParameterInfo(@NotNull ParserCallingReference
callingReference, CreateParameterInfoContext context) {
if (callingReference.getReferenceMethod() != null)
context.showHint(callingReference,
context.getEditor().getCaretModel().getOffset(), this); // i think the
problem is in this offset or maybe in the offset of my callingReference
class
}

public Object
findElementForUpdatingParameterInfo(UpdateParameterInfoContext context) {
return null;
}

public void updateParameterInfo(@NotNull Object o,
UpdateParameterInfoContext context) {
}

public String getParameterCloseChars() {
return ";";
}

public boolean tracksParameterIndex() {
return true;
}

public void updateUI(Object o, ParameterInfoUIContext
parameterInfoUIContext) {
updateUI((ParserMethod)o, parameterInfoUIContext);

}

public void updateUI(ParserMethod method, ParameterInfoUIContext
context) {
String params = method.getParameterList().getText();
String toShow = params.substring(1, params.length() - 1);
System.out.println(toShow); // LOOK: this is printed correctly
context.setUIComponentEnabled(false);
context.setupUIComponentPresentation(toShow, 0, 0, false, false,
false, context.getDefaultParameterColor());
}

Thank you for quick answer



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Thank you much!
It works

0
Comment actions Permalink

Hi Jay,
where did you register your custom implementation of ParameterInfoHandler?
Can you give me some hints on that?
Thanks,
Dan

0
Comment actions Permalink

Hi Dan!

Check this method ShowParameterInfoHandler.register()

0
Comment actions Permalink

Cool! Thanks a lot!

0

Please sign in to leave a comment.