-
Notifications
You must be signed in to change notification settings - Fork 10
ERRORs super visible now. Updated Completions, Code re-organization, UDT fields, Vars. #26
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
Open
kaigouthro
wants to merge
24
commits into
frizLabz-FFriZz:main
Choose a base branch
from
kaigouthro:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,877
−460
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've implemented comprehensive inline completion and signature help for your user-defined functions, User-Defined Types (UDTs), and enums. Key enhancements include: 1. **User-Defined Functions:** * Accurate parsing of function names, parameters (including types and default values), docstrings (`@function`, `@param`), and export/method keywords. * Correct suggestion of your function names. * Detailed signature help for your functions, displaying parameters, types, defaults, and descriptions from `@param` tags. * Argument completion for your function parameters, including type-appropriate variable suggestions. 2. **User-Defined Types (UDTs):** * Reliable parsing of UDT names, fields (name, type, default value, `const` status), docstrings (`@type`, `@field`), and export keywords. * Completion suggestion for your UDT names. * Suggestion of `.new()` constructor for UDTs. * Detailed signature help for UDT constructors, showing all fields, their types, default values, and descriptions from `@field` tags. * Argument completion for UDT constructor fields. * Instance field completion: When typing `myUdtInstance.`, fields of `myUdtInstance` are suggested with their types, documentation, and default values. 3. **Enums:** * Your user-defined enums (conventionally UDTs with `const` fields) are supported. * Enum member names are suggested with an `EnumMember` kind when accessing them (e.g., `MyEnum.MEMBER_A`). * Built-in constant namespaces (e.g., `color.`) also provide `EnumMember` completions. * Documentation for enum members shows their values. These changes significantly improve your development experience by providing more intelligent and context-aware assistance when working with user-defined code structures in Pine Script.
Co-authored-by: Copilot <[email protected]>
feat: Enhance completions for user-defined constructs
This commit addresses your feedback regarding inline completions for User-Defined Type (UDT) constructors. Specifically, it ensures that field names (e.g., `fieldname =`) are properly suggested inline and that value suggestions are contextually appropriate. Enhancements: - Modified `PineInlineCompletionContext.argumentInlineCompletions` to more intelligently select and prioritize inline suggestions: - Suggests the next available field name (e.g., `fieldname=`) when the argument slot is empty or after a comma. - Offers relevant value suggestions (including type-matched variables and newly added generic literals like `""`, `0`, `na`, `true`, `false`) after a field name and `=` are typed. - Improved `PineInlineCompletionContext.createInlineCompletionItem` to correctly calculate `insertText` and `Range` for a smoother inline completion experience. - Refined `PineCompletionProvider.argumentCompletions` to ensure consistent `CompletionItemKind` for UDT field parameters. - Verified that `PineSignatureHelpProvider` correctly populates `PineSharedCompletionState` to support these refined UDT constructor argument suggestions. - Removed premature clearing of completion state in `PineInlineCompletionContext` to allow you to trigger standard completions if an inline suggestion is ignored. These changes result in a more intuitive and complete suggestion experience when working with UDT constructors, aligning with the behavior of built-in function calls.
Co-authored-by: Copilot <[email protected]>
fix: Refine UDT constructor inline argument suggestions
This commit introduces several improvements to the Pine Script VS Code extension: 1. **Context Menu Refactoring:** - Simplified the editor context menu contributions in `package.json`. - Removed nested submenus for Pine Script commands, directly adding them to the `editor/context` group for a cleaner user experience. - Ensured commands like "Typify Variables" and "Generate Docstring" correctly use `when` clauses for visibility. 2. **"Generate Docstring" Feature Enhancements:** - Added support for generating docstrings for `enum` declarations. - Updated the output format for both `type` (UDT) and `enum` docstrings based on your feedback, including `@type`, `@field`, and `@enum` tags with detailed type information and default values where applicable. 3. **"Typify Variables" Feature Improvements:** - Significantly refactored the type inference logic in `PineTypify.ts`. - Variables can now have their types inferred from their assignment values, including: - String literals (including `str.format()`). - Number literals (int, float, scientific notation). - Color literals and functions (hex, `color.rgb()`, `color.new()`, named colors). - Boolean literals (`true`, `false`). - The `na` value. - Ternary expressions, including those involving `na`. - Improved reliability by checking for already-typed variables to prevent incorrect re-typing. - Enhanced `makeMap` to include built-in constants (`true`, `false`, `na`, common colors) for better type resolution. 4. **Architectural Exploration (Preliminary):** - Investigated refactoring `VSCode.ts` and `PineClass.ts` to reduce custom abstractions and align more closely with native VS Code APIs, paving the way for future developments like a robust linter/formatter. These changes address your feedback to improve the usability and functionality of core editing assistance features.
…provements feat: Enhance Docstring, Typify, and Context Menus
Better completions
This commit addresses several issues: 1. Removes a large block of commented-out code in `src/PineInlineCompletionContext.ts` to improve maintainability. 2. Integrates `PineCompletionService.ts` into `PineCompletionProvider.ts` and `PineSignatureHelpProvider.ts`. These providers now use the service for fetching completion and signature help documentation, centralizing the logic. 3. Consolidates duplicate `onDidChangeTextDocument` listeners in `extension.ts`. This prevents `PineLint.handleDocumentChange` from being triggered twice on document changes, ensuring linting occurs only once per relevant change. The integration of `PineCompletionService` in the providers primarily affects how they retrieve documentation for functions, methods, and UDTs. The core logic for argument completion suggestions within `PineSignatureHelpProvider` (specifically the `sendCompletions` and `extractCompletions` methods) and its usage by `PineCompletionProvider` remains largely unchanged in this refactoring pass to minimize risk, but the foundation for future improvements is now in place.
This commit builds upon the previous refactoring by: 1. Removing Obsolete Code: - Deleted commented-out methods (`determineFunctionType`, `extractMethodString`) in `PineSignatureHelpProvider.ts`. - Removed unused imports in `PineInlineCompletionContext.ts`. 2. Improving Type Safety: - Updated `PineCompletionProvider.ts` to use the `CompletionDoc` interface for parameters and variables handling data from `PineCompletionService`, enhancing type safety in `createCompletionItem`. 3. Implementing Shared `PineCompletionService` Singleton: - Instantiated `PineCompletionService` as a singleton (`Class.pineCompletionService`) in `extension.ts`. - Modified `PineCompletionProvider.ts` and `PineSignatureHelpProvider.ts` to use this shared instance instead of creating their own, reducing redundancy and ensuring consistent state. - Added the `pineCompletionService` static member to `PineClass.ts`. These changes further improve code maintainability, type safety, and resource management within the extension.
…tor-providers Refactor: Consolidate listeners and integrate CompletionService
This commit introduces enhanced visibility for errors and warnings within the Pine Script editor by: - Highlighting the background of lines containing errors or warnings. - Adding distinct gutter icons for error and warning lines. These changes are themeable through new color contributions in `package.json`: - `pine.errorBackground` - `pine.warningBackground` - `pine.errorGutterIcon` (for future use, icons currently use SVG-defined colors) - `pine.warningGutterIcon` (for future use, icons currently use SVG-defined colors) The implementation involves: - Defining new `TextEditorDecorationType`s in `src/extension.ts` for errors and warnings. - Updating `src/PineLint.ts` to apply these decorations based on diagnostic severity. - Adding new SVG icons for the gutter indicators.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
feat: Improve error and warning visibility
Merge this, publish it. k?it's big improved. tested, works very well. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes to the PineScript extension, focusing on improving code completion, refactoring imports, and updating the configuration in
package.json
. The most significant updates include enhancements to completion item handling, new functionality for user-defined types (UDTs), and adjustments to menu configurations.Code Completion Enhancements:
determineCompletionItemKind
method: Added adocDetails
parameter to provide more context when determining completion item kinds, including support for additional types likeEnumMember
andLiteral String
. [1] [2] [3]instanceFieldCompletions
for UDT instance fields andudtConstructorCompletions
for UDT constructors, enhancing the ability to suggest relevant completions for user-defined types. [1] [2]Refactoring and Code Organization:
PineInlineCompletionContext
to a separate file, improving modularity and readability of imports insrc/PineClass.ts
.PineDocString
class: Added a new regex pattern to matchenum
declarations, enabling better parsing of enums.Configuration Updates:
package.json
: Removed thepine.mysubmenu2
submenu and updated related menu configurations to streamline the extension's context menu structure. [1] [2]These changes collectively enhance the extension's functionality, maintainability, and user experience.