Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Show JS parameter hint #4637

Merged
merged 29 commits into from
Aug 18, 2013
Merged

Show JS parameter hint #4637

merged 29 commits into from
Aug 18, 2013

Conversation

dloverin
Copy link

@dloverin dloverin commented Aug 2, 2013

Implements a new command, "Show Parameter Hint".
Shows the parameters of a function and bolds the hint where the cursor is located. Automatically shows a parameter hint when a function is selection from the code hints dialog.

Current limitations:
1. no automatic parameter hint for selected hints that are "guesses".
2. no hint of record type annotations (Tern issue #207)
3. problem with optionals hints (fixed in latest Tern, issue #208)
4. Array. annotation shown as Array. (needs investigation).

dloverin added 21 commits July 22, 2013 14:44
…terHint.

add unittests for HintUtils.formatParameterHint
Clean up unittests.js and change string from "<no arguments>"
to "<no parameters>"
…terHint.

add unittests for HintUtils.formatParameterHint
Clean up unittests.js and change string from "<no arguments>"
to "<no parameters>"
…into fn-param-hints

Conflicts:
	src/extensions/default/JavaScriptCodeHints/ParameterHintManager.js
@dloverin
Copy link
Author

dloverin commented Aug 2, 2013

@RaymondLim Here's the pull request. Please review.

@ghost ghost assigned RaymondLim Aug 2, 2013
$.when(fnTypePromise).done(
function (fnType) {
session.setFnType(fnType);
session.setFunctionCallPos(functionOffset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to use "offset" here instead of "functionOffset" as it can be null.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to use "functionOffset" because "offset" can be relative to a portion of the, not the top of the file. It's a bug for "functionOffset" to be null.

top: 40px;
pointer-events: none;

padding: 1px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need more padding, at least 3px to the left and right of the hint so that text does not touch or too close to the border. Currently, it is harder to see the square brackets that denotes the optional parameter.

* Given a Tern formatted function type string, convert it to an array of Objects, where each object describes
* a parameter.
*
* @param {String} newFnType - Tern formatted function type string.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: primitive type String should be in lowercase.

if (type === "variable-2" || type === "variable" || type === "property") {
nextToken = self.getNextToken(localCursor, true);
if (nextToken && nextToken.string === "(") {
//nextToken = self.getNextToken(localCursor, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this commented code?

dloverin added 2 commits August 15, 2013 22:52
… Infer.expressionType() as suggested by marijn. The problem with this fix is it requires a "full" text update with the parameter hint request. Suggested a possible solution in the issue.

The quality of the hints has been much improved and record type annotations can be hinted correctly.
@RaymondLim
Copy link
Contributor

Merging now. I'll be submitting a new pull request to fix one unit test failure in JS Quick Edit caused by this pull request.

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants