How to use parameter assistance?

Questions on using RSyntaxTextArea should go here.

Moderator: robert

How to use parameter assistance?

Postby as3boyan » Fri Sep 20, 2013 2:03 pm

I trying to use parameter assistance, to show help for function arguments. But it seems like I run into some problems, I don't know how to specify parameters for each function. Maybe using new FunctionCompletion().addParameters()?

Code: Select all
provider = createCompletionProvider();
provider.setAutoActivationRules(true, ".");
provider.setParameterChoicesProvider(new HaxeParameterChoicesProvider());
provider.setParameterizedCompletionParams('(', ",", ')');
     
ac = new AutoCompletion(provider);
ac.setShowDescWindow(true);
ac.setAutoActivationDelay(100);
ac.setAutoActivationEnabled(true);
ac.setParameterAssistanceEnabled(true);


I am using FunctionCompletion for functions and BasicCompletion for properties.

I want to show function arguments in description window.

I don't know maybe I should subclass ParameterizedCompletion...

HaxeParameterChoicesProvider basically just empty class that implements ParameterChoicesProvider, implemented getParameterChoices:

java code:

@Override
public List<Completion> getParameterChoices(JTextComponent tc, ParameterizedCompletion.Parameter param) {
System.out.println(param);
return null;
}


I have used TemplateCompletion instead FunctionCompletion to place cursor between round brackets. Maybe I should override some method in FunctionCompletion.

When I press enter(insert new line) after comment:
// this;
|

I want to change implementation of tabbing
tab_count = (count("{") - count("}"))

To make this:
// this
|
as3boyan
 
Posts: 19
Joined: Mon Sep 16, 2013 8:21 pm

Re: How to use parameter assistance?

Postby as3boyan » Fri Sep 20, 2013 3:55 pm

Seems like

java code:

FunctionCompletion completion = new FunctionCompletion(name, returnType);
completion.setParams();


works pretty well!

I just want to insert only required parameters, and don't insert optional:

Currently, it inserts something like this:

as3 code:

this.addEventListener(type : String , listener : (Dynamic -> Void) , ?useCapture : Bool , ?priority : Int , ?useWeakReference : Bool )


As you can see parameters which starts from "?" character should be considered as optional.

I need something like this:

as3 code:

this.addEventListener(type : String , listener : (Dynamic -> Void) )


But I want to show parameter assistance for optional parameters too.
as3boyan
 
Posts: 19
Joined: Mon Sep 16, 2013 8:21 pm

Re: How to use parameter assistance?

Postby as3boyan » Fri Sep 20, 2013 5:13 pm

I was able to do that modifying FunctionCompletion class:

java code:

for (int i = 0; i < paramCount; i++) {
Parameter param = getParam(i);

if (param.getName().startsWith("?")) {
continue;
}

String paramText = getParamText(param);
if (i == 0) {
firstParamLen = paramText.length();
}
sb.append(paramText);
int end = start + paramText.length();
info.addReplacementLocation(start, end);
// Patch for param. list separators with length > 2 -
// thanks to Matthew Adereth!
if (!(i + 1 < paramCount && getParam(i + 1).getName().startsWith("?"))) {

String sep = getProvider().getParameterListSeparator();
if (i < paramCount - 1 && sep != null) {
sb.append(sep);
start = end + sep.length();
}
}
}


Next thing is good to have is to show parameterized completion for this case:

as3 code:

this.addEventListener(|);
Event
MouseEvent
as3boyan
 
Posts: 19
Joined: Mon Sep 16, 2013 8:21 pm

Re: How to use parameter assistance?

Postby as3boyan » Fri Sep 20, 2013 5:41 pm

If I will be able to change tabulation behavior, then would like to make an Format action(set tabulation for every line), I am just wonder, maybe RSyntaxTextArea already has something like this?
as3boyan
 
Posts: 19
Joined: Mon Sep 16, 2013 8:21 pm

Re: How to use parameter assistance?

Postby as3boyan » Fri Sep 20, 2013 6:24 pm

My solution for inserting only required function parameters works, but it seems like it doesn't highlight current function parameter correctly.

I mean it shows all function parameters in description(tooltip), but when I add new comma(where optional parameters can be placed, Tooltip still shows second parameter as bold.

as3 code:

this.addEventListener(type : String,listener : (Dynamic -> Void), |)
as3boyan
 
Posts: 19
Joined: Mon Sep 16, 2013 8:21 pm

Re: How to use parameter assistance?

Postby as3boyan » Fri Sep 20, 2013 7:16 pm

Parameterized completion shows exactly what I need:

as3 code:

this.addEventListener(|);
flash.events.


I made it by modifying FunctionCompletion
by changing this function
public ParameterizedCompletionInsertionInfo getInsertionInfo(

But then I press Tab to switch between function parameters, I got same completion, even If I press Enter:

as3 code:

this.addEventListener(flash.events. , |);
flash.events.


But I need to show this completion only for first parameter, maybe show something else for second parameter.

Is there are way to show function parameters tooltip for some function, when I just move caret between (|)? To show help.
as3boyan
 
Posts: 19
Joined: Mon Sep 16, 2013 8:21 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 5 guests