Skip to content

When writing class elements show completion with allowed keywords and inheritted properties#15614

Merged
sheetalkamat merged 7 commits into
masterfrom
completionListForClassElementDeclarations
May 12, 2017
Merged

When writing class elements show completion with allowed keywords and inheritted properties#15614
sheetalkamat merged 7 commits into
masterfrom
completionListForClassElementDeclarations

Conversation

@sheetalkamat
Copy link
Copy Markdown
Member

Handles #7158

…vate, readonly

Also when name of the function is location, make sure we are actually looking at the same symbol before using the declaration to get signature to display
Do not show inherited members in completion for when writing private member
Show only static inherited members when writing static member
Comment thread src/harness/fourslash.ts Outdated
"readonly",
"get",
"set",
"constructor"
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.

also async

case SyntaxKind.ConstructorKeyword:
case SyntaxKind.ReadonlyKeyword:
case SyntaxKind.GetKeyword:
case SyntaxKind.SetKeyword:
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.

async

function tryGetClassLikeCompletionContainer(contextToken: Node): ClassLikeDeclaration {
if (contextToken) {
switch (contextToken.kind) {
case SyntaxKind.OpenBraceToken: // class c { |
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.

index signature, and computed property name:

class c {
   |  ["foo"]  // <- i would expect the keywords at least
}

* Relevant symbols are stored in the captured 'symbols' variable.
*
* @returns true if 'symbols' was successfully populated; false otherwise.
*/
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.

this function only returns true, it should be getClassLikeCompletionSymbols

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.

Was just following the pattern, but I will change it

Comment thread src/services/completions.ts Outdated
typeChecker.getTypeOfSymbolAtLocation(baseType.symbol, classLikeDeclaration) :
baseType;

// List of property symbols of base type that are not private
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.

we should filter ones that are already implemented in the current class.

Copy link
Copy Markdown
Member Author

@sheetalkamat sheetalkamat May 10, 2017

Choose a reason for hiding this comment

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

@DanielRosenwasser commented on the issue saying not to do that. Reference

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.

we do filtering in object literal completions, ppl seem to appreciate that.

}

// No member list for private methods
if (!(classElementModifierFlags & ModifierFlags.Private)) {
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.

what about interfaces?

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.

Do we want to show the Implements clause members too? The issue didn't clearly mention it.

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.

well.. probably, do not see why not. like it is likely that it is a member you are implementing or extending..

@sheetalkamat sheetalkamat merged commit 2300a99 into master May 12, 2017
@sheetalkamat sheetalkamat deleted the completionListForClassElementDeclarations branch May 12, 2017 23:10
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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.

3 participants