-
Notifications
You must be signed in to change notification settings - Fork 31
Update IdentifierUtils #394
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
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/powerquery-parser into dev/jobolton/parseMode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the IdentifierUtils
module to improve identifier handling and normalization capabilities, while also fixing a bug in the type utilities.
- Adds new functions
getNormalizedIdentifier
andgetAllowedIdentifiers
for better identifier management - Updates the
getIdentifierKind
function to use an options parameter instead of boolean flags - Fixes a logical error in
isEqualFunctionParameter
that was returning incorrect comparison results
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
src/powerquery-parser/language/identifierUtils.ts | Major refactor adding new identifier utility functions and updating existing APIs |
src/powerquery-parser/language/type/typeUtils/isEqualType.ts | Fixes logical bug in isEqualFunctionParameter function |
src/powerquery-parser/parser/parsers/naiveParseSteps.ts | Updates call to getIdentifierKind to use new options parameter |
src/powerquery-parser/parser/nodeIdMap/nodeIdMapIterator.ts | Updates calls to use new getNormalizedIdentifier function |
src/powerquery-parser/lexer/lexer.ts | Updates call to getIdentifierLength to use new options parameter |
src/test/libraryTest/identifierUtils.test.ts | Comprehensive test updates for new identifier utility functions |
src/test/libraryTest/language/typeUtils/isEqualType.test.ts | Adds test for function type equality |
package.json | Version bump to 0.18.0 |
break; | ||
|
||
case IdentifierRegexpState.RegularIdentifier: | ||
if (text[index] === ".") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you give an example of some of the states here? for example, i don't understand the "2 sequential periods == done" thing
|
||
export function isRegularIdentifier(text: string, allowTrailingPeriod: boolean): boolean { | ||
return getIdentifierLength(text, 0, allowTrailingPeriod) === text.length; | ||
function insertQuotes(text: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we name this function "makeQuoted" or something instead? "insertQuotes" makes it sound like it will insert anywhere.
foo
can also be#"foo"
)Small other fix I was to lazy to split out into another PR: