Skip to content

Conversation

@kaigouthro
Copy link
Owner

@kaigouthro kaigouthro commented Jun 10, 2025

… done so far and provide feedback for Jules to continue.

Summary by Sourcery

Clean up and streamline the PineTypify and PineParser modules, remove unused code and comments, consolidate configuration, and update tests to support the refactored logic

Enhancements:

  • Refactor PineTypify.parseType and inferTypeFromValue to use static calls, simplify return objects, and consolidate common color constants list
  • Remove obsolete comments and dead code from typifyDocument, unifying the variable-typing logic and insertion logic
  • Add detailed JSDoc comments and improve named-capture-group regex definitions in PineParser for UDTs, fields, functions, and enums
  • Improve PineParser test mocks by stubbing PineRequest and PineDocsManager behaviors
  • Introduce a new skeleton test file for PineTypify to lay groundwork for future tests

… done so far and provide feedback for Jules to continue.
@sourcery-ai
Copy link

sourcery-ai bot commented Jun 10, 2025

Reviewer's Guide

This PR continues the implementation of type parsing and document typification by cleaning up the PineTypify methods (simplifying parseType, streamlining map and document processing) and enhancing PineParser regex patterns with inline documentation, plus updates to test mocks for better coverage.

Sequence Diagram: Streamlined typifyDocument Process in PineTypify

sequenceDiagram
    participant PT as PineTypify
    participant VSL as VSCode.Linter
    participant VSD as VSCode.Document
    participant EU as EditorUtils

    PT->>PT: typifyDocument()
    activate PT
    PT->>PT: makeMap()
    activate PT
    alt Linter available
        PT->>VSL: getLintResponse()
        VSL-->>PT: lintData
    end
    PT-->>PT: typeMap populated
    deactivate PT

    PT->>VSD: getText()
    VSD-->>PT: documentText

    loop for each line in documentText
        PT->>PT: inferTypeFromValue(expression, varName)
        activate PT
        PT-->>PT: inferredType
        deactivate PT
        alt type inferred and valid
            PT->>PT: stringifyParsedType(inferredType)
            activate PT
            PT-->>PT: typeString
            deactivate PT
            PT->>PT: Create TextEdit
        end
    end

    alt edits available
        PT->>EU: applyEditsToDocument(edits)
        EU-->>PT: 
    end
    deactivate PT
Loading

Class Diagram: Changes to PineTypify

classDiagram
    class PineTypify {
        -typeMap: Map<string, ParsedType>
        -mapInitialized: boolean
        +static parseType(typeString: string): ParsedType
        +makeMap(): Promise<void>
        -inferTypeFromValue(valueString: string, variableName: string): ParsedType | null
        +typifyDocument(): Promise<void>
        +static stringifyParsedType(type: ParsedType): string
        -fetchUDTDefinitions(): Promise<string> "removed"
        -parseAndAddUDTs(udtDefinitions: string): void "removed"
    }
Loading

Class Diagram: Updates to PineParser Regular Expressions

classDiagram
    class PineParser {
        +typePattern: RegExp "modified"
        +fieldsPattern: RegExp "modified"
        +enumMemberPattern: RegExp "modified"
        +funcPattern: RegExp "modified"
        +funcArgPattern: RegExp
        +parsedFuncs: any
        +parsedUDTs: any
        +parsedEnums: any
        +parsedLibsUDT: any
    }
Loading

File-Level Changes

Change Details Files
Clean up and refactor parseType implementation
  • Removed redundant inline comments and commented‐out stubs
  • Consolidated all calls to parseType as static
  • Simplified object construction and return paths
src/PineTypify.ts
Streamline typeMap initialization and color constant setup
  • Converted color list to a single inline array
  • Removed commented code around built‐in constants
  • Ensured mapInitialized flag is set once after population
src/PineTypify.ts
Simplify typifyDocument variable typing logic
  • Commented out old Phase 2 loop to avoid conflict
  • Adjusted untyped variable regex and insertion logic
  • Cleaned up processedLines usage and related comments
src/PineTypify.ts
Enhance PineParser regex patterns with JSDoc and named groups
  • Added detailed JSDoc above each RegExp
  • Refactored typePattern, fieldsPattern, funcPattern for clarity
  • Expanded named capture groups and improved lookahead logic
src/PineParser.ts
Improve test mocks for PineParser
  • Explicitly mocked PineDocsManager getter with setParsed stub
  • Refined PineRequest mock to include libList and getScript
src/PineParser.test.ts
Introduce placeholder test file for PineTypify
  • Added new PineTypify.test.ts file (empty stub)
src/PineTypify.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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