Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletion shouldn't fill the full method description #11

Open
fuure opened this issue Mar 22, 2017 · 6 comments
Open

Autocompletion shouldn't fill the full method description #11

fuure opened this issue Mar 22, 2017 · 6 comments

Comments

@fuure
Copy link

fuure commented Mar 22, 2017

For example:

image

Either tabbing, clicking the method or pressing enter provokes this:

image

The expected behavior should be just completing the method name, just before the first parenthesis.

For example VS 2013:
image

@ChuckJonas
Copy link
Owner

While I agree this is the ideal behavior, it relies on having Method Signature Help.

Apex autocomplete currently doesn't have this service and without it, filling in parameters on complex signatures is not very productive.

It potentially could be added by calling by calling completion on the column just before the opening brace (() to get the signature and then decomposing the parameters. However, to get this to work with overloaded signatures will be more complicated.

Example

public void foo(String p1, Boolean p2)

public void foo(Boolean p1, String p2)

Now if I had the following code:

Boolean myParam = true;
foo(myParam, |

Without knowing type of myParam, the "Method Signature Help" wouldn't know which signature we are dealing with.

It might be possible to use the findSymbol method to infer the type and then filter only on signatures that match.

@neowit might have some better ideas on how to make this happen.

@ChuckJonas
Copy link
Owner

ChuckJonas commented Mar 22, 2017

To add to that, this is the model I would need to be able to provide:

	export class SignatureHelp {
		/**
		 * One or more signatures.
		 */
		signatures: SignatureInformation[];

		/**
		 * The active signature.
		 */
		activeSignature: number;

		/**
		 * The active parameter of the active signature.
		 */
		activeParameter: number;
	}

	/**
	 * Represents a parameter of a callable-signature. A parameter can
	 * have a label and a doc-comment.
	 */
	export class ParameterInformation {

		/**
		 * The label of this signature. Will be shown in
		 * the UI.
		 */
		label: string;

		/**
		 * The human-readable doc-comment of this signature. Will be shown
		 * in the UI but can be omitted.
		 */
		documentation: string;

		/**
		 * Creates a new parameter information object.
		 *
		 * @param label A label string.
		 * @param documentation A doc string.
		 */
		constructor(label: string, documentation?: string);
	}

        /**
	 * Represents the signature of something callable. A signature
	 * can have a label, like a function-name, a doc-comment, and
	 * a set of parameters.
	 */
	export class SignatureInformation {

		/**
		 * The label of this signature. Will be shown in
		 * the UI.
		 */
		label: string;

		/**
		 * The human-readable doc-comment of this signature. Will be shown
		 * in the UI but can be omitted.
		 */
		documentation: string;

		/**
		 * The parameters of this signature.
		 */
		parameters: ParameterInformation[];

		/**
		 * Creates a new signature information object.
		 *
		 * @param label A label string.
		 * @param documentation A doc string.
		 */
		constructor(label: string, documentation?: string);
	}

@neowit
Copy link

neowit commented Mar 22, 2017

Hello @ChuckJonas

The expected behavior should be just completing the method name, just before the first parenthesis.

if we are talking about

Schema.describesobje<invoke completion>

resulting in

Schema.describesobjects

then tooling-force.com.jar provides necessary information for this.
Use parameter identity from completion response

RESULT=SUCCESS
{"realIdentity":"describeSObjectsList<String>","signature":"static public List<Schema.DescribeSObjectResult> describeSObjects(List<String> types)","doc":"","identity":"describeSObjects","type":"List<Schema.DescribeSObjectResult>","visibility":"public"}
{"realIdentity":"DescribeSObjectResult","signature":"Schema.DescribeSObjectResult","doc":" ","identity":"DescribeSObjectResult","type":"DescribeSObjectResult","visibility":"public"}

Here is how it works in vim
completion2

@ChuckJonas
Copy link
Owner

@neowit so not quite.

This is to get Method Signature Help after the completion has been evoked. Currently I have the completion write out the signature because I don't support signature help.

Given:

Schema.describesobjects(

I think I can get what I need by calling findSymbol on describesobjects. The only thing it doesn't give me is the description like you see in the listCompletions call. Nice to have but not a deal breaker.

@neowit
Copy link

neowit commented Mar 22, 2017

@ChuckJonas not sure I understand.

If I am reading original post correctly - the issue was that if one calls

Schema.descr<invoke completion>

and select describesobjects from the list

then the end result currently is

Schema.describeSObjects(List<String> types)

while desired behaviour (according to OP) is to end up with

Schema.describeSObjects

Not sure if OP was about getting “Method Signature Help” after completion was done.
Perhaps @fuure could clarify ?

@ChuckJonas
Copy link
Owner

@neowit ya the original post is suggesting that the autocomplete should function as you have outlined above.

However, I'm reluctant to make that change unless I can provide method signature help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants