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);
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);
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?
Perhabs showHint is missed from the parameter info implementation.
Yet another reason is empty parameters
__jay wrote:
>> 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!"
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
If findElementForUpdatingParameterInfo returns null then hint is removed
__jay wrote:
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Thank you much!
It works
Hi Jay,
where did you register your custom implementation of ParameterInfoHandler?
Can you give me some hints on that?
Thanks,
Dan
Hi Dan!
Check this method ShowParameterInfoHandler.register()
Cool! Thanks a lot!