Skip to content

Conversation

JordanBoltonMN
Copy link
Contributor

  1. adds getNormalizedPath which attempts to normalize a string representing an identifier
  2. adds getAllowedIdentifiers which is used to generate alternative names for the identifier (e.g. foo can also be #"foo")
  3. removed export on most other identifierUtils functions

Small other fix I was to lazy to split out into another PR:

  1. fixed typeUtils.isEqualFunctionParameter

Copy link
Contributor

@Copilot Copilot AI left a 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 and getAllowedIdentifiers 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] === ".") {
Copy link

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 {
Copy link

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.

@JordanBoltonMN JordanBoltonMN merged commit 8ca8947 into master Aug 12, 2025
5 checks passed
@JordanBoltonMN JordanBoltonMN deleted the dev/jobolton/identifierUtilsOptions branch August 12, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants