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

Completion list show correct entry for function expression and class expression #3643

Merged
merged 25 commits into from
Jul 10, 2015

Conversation

yuit
Copy link
Contributor

@yuit yuit commented Jun 26, 2015

Fix #3231 and for class expression case

// fo$ <- completion list should contain local name "foo"
// }
// foo$ <- completion list should not contain "foo"
if (displayName === "__function" || displayName === "__class") {
Copy link
Member

Choose a reason for hiding this comment

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

Look into getDeclaredName instead, including the above for the default export

Copy link
Contributor Author

Choose a reason for hiding this comment

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

getDeclaredName doesn't handle function expression correctly. Talk with @mhegazy, the function needed some rewrite and I don't want to have it done in this PR. I will put a TODO here to have it change once getDeclaredName is done

Copy link
Contributor

Choose a reason for hiding this comment

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

@DanielRosenwasser should have a fix for this in a pending review. you should synchronize.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, it's in my PR. Speaking of which, can you guys review it? 😃

#3367

Copy link
Member

Choose a reason for hiding this comment

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

You should be clear to use getDeclaredName

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🌹 yeah
🌵

@@ -1423,6 +1423,9 @@ namespace ts {
// class X {}
export const classElement = "class";

// var x = class X {}
export const localClassElement = "local class";

Copy link
Contributor

Choose a reason for hiding this comment

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

note. you need to handle this on the managed side as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What you mean be handling in the managed side?

Copy link
Member

Choose a reason for hiding this comment

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

Probably best to discuss this in person with someone but I believe the idea is that VS needs to handle styles differently depending on what comes in to the managed side.

Copy link
Contributor

Choose a reason for hiding this comment

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

what do you see in navbar when you do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🌵 file a bug

@DanielRosenwasser
Copy link
Member

@yuit if you pull in from master, there's a fourslash test called renameLocationsForClassExpression01.ts. You'll need to amend it to test correctly in light of the fact that you fixed class expression name resolution.

// The reason we are not using copySymbol for function expression and class expression
// is that copySymbol will not copy a symbol into SymbolTable if the symbol has name prefix
// with "__". Therefore, if class expression or function expression have declared name,
// we will add the symbol into the table using its declared name
Copy link
Member

Choose a reason for hiding this comment

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

Why not change the logic of copySymbol?

Also, the comment for copySymbol says // Returns 'true' if we should stop processing symbols., but it returns void. Can you fix that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🌵

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove the old comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🌵

if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) {
if (length >= 2 &&
name.charCodeAt(0) === name.charCodeAt(length - 1) &&
(name.charCodeAt(0) === CharacterCodes.doubleQuote || name.charCodeAt(0) === CharacterCodes.singleQuote)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, that is cute :)

Yui T added 4 commits July 6, 2015 17:03
if (!(memberFlags & NodeFlags.Static)) {
copySymbols(getSymbolOfNode(location).members, meaning & SymbolFlags.Type);
}
break;
case SyntaxKind.FunctionExpression:
if ((<FunctionExpression>location).name) {
case SyntaxKind.ClassExpression:
Copy link
Contributor

Choose a reason for hiding this comment

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

class expression listed twice

Copy link
Contributor

Choose a reason for hiding this comment

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

Uh oh. It'd be good to have a feature that catches this.

Copy link
Member

Choose a reason for hiding this comment

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

@JsonFreeman it's being tracked in #2854

@mhegazy
Copy link
Contributor

mhegazy commented Jul 9, 2015

👍 just remove the class expression label

@JsonFreeman
Copy link
Contributor

@yuit Do you still need to do all these things now that you fixed the binder?

@yuit
Copy link
Contributor Author

yuit commented Jul 10, 2015

@JsonFreeman I make a change so that the service layer will get name through getDeclaredName which I prefer over using symbol.getName(). This makes completion list more consistent in the case of export default in that we won't show unicode escapes sequence in completion list at all. This will be some what consistent with other feature which show unicode escape sequence in its original declared form.

@JsonFreeman
Copy link
Contributor

Great! Thanks Yui!

@JsonFreeman
Copy link
Contributor

👍

@yuit
Copy link
Contributor Author

yuit commented Jul 10, 2015

@JsonFreeman Thank you for the good discussion we had 😄

yuit added a commit that referenced this pull request Jul 10, 2015
Completion list show correct entry for function expression and class expression
@yuit yuit merged commit e72d0d8 into master Jul 10, 2015
@yuit yuit deleted the completionListWithLocalName branch July 10, 2015 20:02
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
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.

5 participants