Skip to content

Better completions in incomplete constructs#2396

Merged
DanielRosenwasser merged 23 commits into
masterfrom
completionsInIncompleteConstructs
Mar 18, 2015
Merged

Better completions in incomplete constructs#2396
DanielRosenwasser merged 23 commits into
masterfrom
completionsInIncompleteConstructs

Conversation

@DanielRosenwasser
Copy link
Copy Markdown
Member

This PR uses a different mechanism for getting the scope of completion by looking at the context token (here called the previousToken). We then climb up the AST through parent references from that token and find a node that "embraces"/"encompasses" the current position. The logic is shared (i.e. ripped out of) the smart indenter and augmented to be more complete.

Fixes #1410, #1429, #1674, and #2292.

Comment thread src/services/services.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

love it :D

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Mar 17, 2015

Can we add a few tests on the end of a node, e.g

// no a or b
function f (a, b) {}/*here*/
// should see a and b
foo((a, b)=>a,/*here*/
// no "i"
for (let i =0; i < 10; i++) i;/*here*/ 
// no a or b
/*here*/function f (a, b) {} 
 // no a or b
/*here*/(a, b)=> {}  

Comment thread src/harness/fourslash.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why we no longer need to check if completions.entries is defined?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

My understanding is completions can be undefined but entries is non-optional. Can @mhegazy weigh in on the accuracy of this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This seems to be the case.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Mar 18, 2015

👍

DanielRosenwasser added a commit that referenced this pull request Mar 18, 2015
…ucts

Better completions in incomplete constructs
@DanielRosenwasser DanielRosenwasser merged commit 355dcd1 into master Mar 18, 2015
@DanielRosenwasser DanielRosenwasser deleted the completionsInIncompleteConstructs branch March 18, 2015 21:11
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
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.

Arrow function parameters do not show in completion list when in an unclosed call site

4 participants