Skip to content

make rename\gotoDef work at the end of token#752

Merged
vladima merged 6 commits intomasterfrom
getTokenAtPosition
Oct 1, 2014
Merged

make rename\gotoDef work at the end of token#752
vladima merged 6 commits intomasterfrom
getTokenAtPosition

Conversation

@vladima
Copy link
Copy Markdown
Contributor

@vladima vladima commented Sep 25, 2014

enable scenarios when cursor is positioned at the end of token

… parameter that will determine if token with end === position should be returned
Comment thread src/services/utilities.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.

getTokenAtPosition ?

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Sep 25, 2014

👍

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.

wouldn't we want quick info to support being called at the end of a token?

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

I would model this (the naming and impl) off of Roslyn's GetTouchingToken and GetTouchingWord functions:

http://source.roslyn.codeplex.com/#Microsoft.CodeAnalysis.Workspaces/Shared/Extensions/CommonSyntaxTreeExtensions.cs,cc1428a84e6b2e48
http://source.roslyn.codeplex.com/#Microsoft.CodeAnalysis.Workspaces/Shared/Extensions/CommonSyntaxTreeExtensions.cs,ceb10becddb03c3f

THe difference is that features then use helpers like GetTouchingWord, and that function passes in the appropriate predicate to GetTouchingToken. That way you don't need every feature to have to define an entire set of tokens it cares about.

@vladima
Copy link
Copy Markdown
Contributor Author

vladima commented Sep 26, 2014

  1. I'm ok with renaming getTokenAtPosition to getTouchingToken (though personally I found former option more intuitive).
  2. I don't see why it is bad if feature defines its specific set of tokens given that now this set is feature specific and mostly don't intersect. Since we don't have established definition of word - name getTouchingWord does not tell us what exactly should be returned and people still need to peek to the implementation to discover what was meant by word. One exclusion when predicate is undefined - and we can introduce helper getTouchingTokenExcludingEndPosition for this case (name is can definitely be changed)

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

'Word' is the union of 'Identifier' and 'Keyword'. i.e. all the things that are words in a language like english. This is a distinct concept from things like 'string' or 'number' or 'punctuation' or 'operator'. Effectively 'words' are the alphanumeric string sequences.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

It's not bad per-se for features to identify the list of tokesn they care about. However, i am concerned about things like brittleness, as well as the fact that many features will end up using the same set.

For example, goto-def and quick-info will need the same set. So will highlight-references. This means maintaining several duplicate lists.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

"One exclusion when predicate is undefined - and we can introduce helper getTouchingTokenExcludingEndPosition for this case (name is can definitely be changed)"

Isn't this just FindToken ?

@vladima
Copy link
Copy Markdown
Contributor Author

vladima commented Sep 29, 2014

AFAIR we do support gotoDef on numeric\string literals used in indexers and those ones are not words. Instead of "word" we can use "name" but getTouchingName does not sound like a very descriptive function name (but maybe for a native speaker it makes more sense than getTokenAtPosition)

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

THe right term to use in that case is 'PropertyName'. That matches the name the specs use for Identifiers/NumericLiterals/StringLiterals. So, there would be:

getTouchingToken (most flexible, but reqiures the most work to consume)
getTouchignWord (keywords/identifiers)
getTouchingPropertyName(identifiers/string/numeric-literals).

Thanks!

Comment thread src/services/utilities.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.

Can we remove this entirely. This single guy is now very confusing. i would think getTokenAtPositoin had the same semantics as getTokenContainingPosition. I didn't realize getTokenAtPosition is now just a thin wrapper over getTouchingToken.

@JsonFreeman
Copy link
Copy Markdown
Contributor

👍

vladima added a commit that referenced this pull request Oct 1, 2014
make rename\gotoDef work at the end of token
@vladima vladima merged commit 13f13b8 into master Oct 1, 2014
@vladima vladima deleted the getTokenAtPosition branch October 1, 2014 06:06
@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.

5 participants