Skip to content

Conversation

@andjak
Copy link

@andjak andjak commented Apr 23, 2025

autocomplete with type rcognitions based on pinescript version
known issues:

  • variable, const types not displayed; also functions - probably issue that "addAllCompletionItems" is used, ideally only addStandardCompletions and addScannedCompletions should be used (addAllCompletionItems is used as a hack to display namespace subelements in the list)
  • int type detection doesn't work - in assignment it's detected as float and is displayed as unknown
  • "built-in" methods and types are used in places - should rely only on JSON file
  • functions only import first variant at the moment - ideally should import and recognize all variants

andjak added 30 commits April 3, 2025 14:55
… improve token classification for function calls and color constants.
…ing for light and dark themes, enhancing syntax highlighting consistency across different UI settings.
…visual consistency, adjusting function and built-in variable colors to enhance readability.
…ighter to match TradingView's color scheme for improved visual consistency.
…grey for improved visual consistency with TradingView's color scheme.
…, including keywords, built-in variables, namespaces, and function completions. Introduce logging for better debugging and refactor completion logic for improved performance. Update plugin.xml to register additional components for language support and code completion.
…e commenter implementation class for Pine Script support.
…tions for namespace methods and function parameters. Implement logic to handle function calls and improve completion accuracy. Refactor completion methods for better organization and maintainability.
…ompletion suggestions

- Introduced `update_pine_syntax.py` to scrape TradingView's Pine Script reference and generate JSON files for each category.
- Enhanced `PineScriptCompletionContributor` to include context-aware suggestions for function parameters, including specific handling for `strategy.entry` and `strategy.exit`.
- Improved parameter suggestions for various functions to align with Pine Script documentation, enhancing user experience in code completion.
…ing and add new JSON definitions for versions 3 to 6

- Updated `update_pine_syntax.py` to utilize `asyncio` for improved performance during data scraping.
- Added new JSON files for Pine Script versions 3, 4, 5, and 6, including definitions for annotations, constants, functions, keywords, operators, types, and variables.
- Enhanced the structure of the code to support concurrent requests, improving the efficiency of the extraction process.
…rformance

- Updated `update_pine_syntax.py` to enhance the argument and return type extraction methods, transitioning from asynchronous to synchronous functions
- Increased concurrency limit for page loads and maintained a consistent timeout setting.
- Improved HTML parsing logic and added comments for clarity in the extraction process.
- Adjusted the function processing to handle only the first five functions for testing purposes, ensuring efficient data handling.
- Updated `update_pine_syntax.py` to enhance the extraction of function details, including arguments, return types, and descriptions, from dynamically loaded HTML content.
- Introduced a new method `extract_function_details` to streamline the parsing process and improve clarity.
- Adjusted the function processing to utilize the URL fragment for targeted data extraction, ensuring more accurate results.
- Maintained the limit on processing functions for testing purposes, while improving overall data handling efficiency.
…dater

- Updated `update_pine_syntax.py` to allow for optional fragment extraction from the item, improving flexibility in data processing.
- Modified the selector logic to escape dots in the fragment using attribute selectors, ensuring accurate targeting of dynamically loaded HTML elements.
- Adjusted data extraction for function links to include fragment information when applicable, enhancing the overall data structure for function details.
…pdater

- Introduced `extract_variable_details` function to parse variable information from dynamically loaded HTML content, including info, description, type, and remarks.
- Added `process_variable` function to handle the asynchronous processing of variable items, similar to function processing.
- Updated `extract_category` to support both 'Functions' and 'Variables', allowing for flexible data extraction and processing.
- Maintained the limit on processing items for testing purposes, ensuring efficient data handling.
…ater

- Updated `extract_function_details` and `extract_variable_details` functions to use `decode_contents()` for better HTML content handling.
- Enhanced remarks extraction to collect multiple remarks until the next sub-header, improving the detail richness of the extracted data.
- Improved overall clarity and robustness of the extraction logic for descriptions and remarks.
…pdater

- Introduced `process_constant` function to handle the asynchronous processing of constant items, similar to variable and function processing.
- Updated `extract_category` to include 'Constants' in the data extraction logic, allowing for comprehensive handling of constants alongside functions and variables.
- Enhanced error handling for timeouts during constant processing, improving robustness in data scraping operations.
…x extraction logic

- Introduced new JSON files for Pine Script versions 3, 4, 5, and 6, including definitions for annotations, constants, functions, keywords, operators, types, and variables.
- Updated `update_pine_syntax.py` to enhance the extraction logic for constants, functions, and variables, ensuring comprehensive data handling.
- Improved comments in the code for better clarity and maintainability.
- Adjusted item processing limits for testing purposes, allowing for efficient data extraction.
…raction paths

- Added the `org.json:json:20231013` dependency to the Gradle build file for enhanced JSON handling.
- Modified the output directory path in `update_pine_syntax.py` to ensure correct file saving for syntax definitions.
- Expanded function parameter definitions in `PineScriptCompletionContributor.java` to include additional parameters for the `plot` function, improving completion suggestions.
…mpletionContributor

- Improved variable declaration scanning to avoid duplicates by tracking found variables.
- Added support for direct assignment detection, filtering out keywords and built-in variables to refine completion suggestions.
- Enhanced comments for better clarity on the regex patterns used for variable extraction.
- Introduced a caching mechanism for function arguments loaded from JSON definitions, improving completion suggestions.
- Implemented context-aware parameter suggestions based on the current function call, enhancing user experience.
- Added auto-popup functionality for completion triggers on parentheses and commas, streamlining the coding process.
- Improved error handling and logging for loading function arguments, ensuring robustness in data retrieval.
- Added detection for cursor position after parameter equals sign to provide full completions.
- Improved handling of function parentheses and comma triggers for completion popups.
- Enhanced context awareness for function calls, refining parameter-specific completion suggestions.
- Enhanced detection for cursor position after parameter equals sign to provide full completions.
- Improved handling of function call context, ensuring both parameter suggestions and full completions are provided.
- Adjusted priority levels for completion suggestions, ensuring more relevant options are presented to the user.
- Streamlined the addition of standard completions and local variables within function calls.
andjak added 24 commits April 7, 2025 10:50
- Added a method to check if the cursor is inside a string literal, enhancing the completion logic.
- Updated autocompletion behavior to skip suggestions when the cursor is within a string, improving user experience and reducing irrelevant completions.
- Introduced context-aware completion logic for suggestions after '=' and ':=' operators, prioritizing local variables, constants, and functions appropriately.
- Added a specialized method for handling completions after equals signs, ensuring relevant suggestions are presented based on cursor position.
- Adjusted priority levels for local variables and functions to improve user experience and streamline coding efficiency.
…ributor

- Improved detection for cursor position after '=' and ':=' operators, including handling trailing spaces for better suggestion accuracy.
- Added logic to trigger autocomplete when a space follows an equals sign, enhancing user experience and ensuring relevant suggestions are presented.
- Streamlined the completion process to prioritize context-aware suggestions based on cursor position.
- Adjusted priority levels for function, constant, and variable completions to enhance suggestion relevance.
- Updated comments for clarity on the new priority arrangements, ensuring better understanding of completion order.
- Improved overall completion logic to streamline user experience and coding efficiency.
…Contributor

- Enhanced completion suggestions based on cursor position, specifically after equals signs in parameter lists, to improve user experience.
- Adjusted priority levels for parameter, standard, and local variable completions to ensure more relevant suggestions are presented in context.
- Updated logging for better insight into completion behavior, aiding in debugging and user understanding of the completion process.
…ntributor

- Introduced auto-popup completion configuration for Pine Script, improving user experience by providing immediate suggestions.
- Implemented a custom typed handler to manage auto-popup behavior, ensuring relevant completions are triggered based on user input.
- Enhanced logging for better diagnostics during completion processes, aiding in debugging and user understanding of the completion behavior.
- Updated auto-popup completion configuration to utilize CompletionConfidence for improved reliability in suggestions.
- Implemented enhanced logging in PineScriptAutoPopupCompletion to provide detailed context when auto-popup is triggered, aiding in debugging.
- Refined completion handling for dot characters, introducing multiple approaches to ensure completion is triggered effectively.
- Improved logging in PineScriptCompletionContributor for better insights into namespace detection and completion processes.
- Consolidated namespace tracking into a single set to avoid duplication across function, variable, and constant namespaces.
- Updated namespace suggestion logic to use a consistent icon and type text for improved clarity.
- Removed redundant namespace handling code, streamlining the completion process and enhancing user experience.
- Introduced a dedicated namespace icon for better visual distinction in completion suggestions.
…ributor

- Introduced a mechanism to track added members, preventing duplicates across function, variable, and property completions.
- Consolidated the collection of function-like and variable-like members, ensuring consistent handling and improved clarity in completion suggestions.
- Enhanced logging to provide detailed insights into the number of members added and the completion process, aiding in debugging and user understanding.
…theses and position caret correctly

- Modified insert handler logic to insert parentheses instead of a dot when completing members.
- Adjusted caret positioning to place it inside the parentheses for improved user experience.
- Ensured immediate popup for parameters is triggered after insertion, enhancing completion functionality.
…Contributor

- Enhanced detection of cursor position within function calls, particularly after commas and equals signs, to improve suggestion accuracy.
- Adjusted priority levels for parameter and standard completions, ensuring more relevant suggestions are presented based on context.
- Introduced a new method to determine if the cursor is inside a function header, further refining completion behavior.
- Improved logging for better insights into completion processes, aiding in debugging and user understanding.
- Improved tracking of nested function calls by maintaining a list of function start positions, allowing for accurate identification of the innermost function.
- Refined logic for handling parentheses and commas to ensure correct parameter indexing and function name extraction.
- Updated logging to provide clearer insights into the current function context during completion processes, aiding in debugging and user understanding.
…butor

- Introduced improved logic for handling completions after dot characters, ensuring accurate namespace detection and member access.
- Added custom prefix matching for namespace method completions, enhancing suggestion relevance based on user input.
- Enhanced logging throughout the completion process to provide clearer insights into context and decision-making, aiding in debugging and user understanding.
- Improved function parameter completion handling, including fallback mechanisms for missing parameters and enhanced user experience with immediate popups.
…Contributor

- Introduced comprehensive checks for string context to improve accuracy in determining when the cursor is inside a string.
- Added detailed logging for various contexts to aid in debugging and provide insights into the string detection process.
- Enhanced handling of variable declarations, function calls, and assignment contexts to refine completion suggestions.
- Implemented type inference for variable assignments, improving the relevance of completion suggestions based on expected types.
- Streamlined the completion process by consolidating logic for detecting function calls and variable declarations.
…ntributor

- Improved handling of variable assignments and context detection to refine completion suggestions based on expected types.
- Introduced enhanced logging for better insights into variable assignment contexts and type inference processes.
- Streamlined the addition of scanned completions, allowing for type-specific filtering and improved user experience.
- Consolidated logic for handling function calls and parameter completions, ensuring more relevant suggestions based on user input.
- Introduced new maps for storing function return types, variable types, and constant types to enhance completion suggestions.
- Updated loading logic to include type information from JSON definition files for variables, constants, and functions.
- Enhanced completion methods to provide type-aware suggestions based on context, improving user experience and accuracy.
- Improved logging to provide insights into the loading and processing of type information, aiding in debugging and understanding of completion behavior.
…ntributor

- Improved handling of variable declarations by incorporating qualifiers (e.g., var, const) into type inference, allowing for more accurate type suggestions.
- Updated regex patterns to match a wider range of variable declaration formats, enhancing the robustness of type detection.
- Enhanced logging to provide clearer insights into type inference processes and variable handling, aiding in debugging and user understanding.
- Streamlined completion methods to ensure type compatibility checks are performed, improving the relevance of suggestions based on context.
- Improved static initialization logic to handle null DEFAULT_VERSION gracefully, ensuring fallback mechanisms are in place.
- Enhanced logging during the loading of Pine Script definitions to provide clearer insights into the initialization process and potential errors.
- Streamlined the loading of definitions for functions, variables, and constants, ensuring type-specific collections are populated correctly.
- Added comprehensive error handling to prevent failures during initialization, improving overall stability and user experience.
…pletionContributor

- Improved the logic for determining if the cursor is inside a string by counting unescaped quotes, enhancing accuracy in string context detection.
- Streamlined function call context detection, allowing for better handling of parameter indexing and named parameters.
- Enhanced logging to provide clearer insights into the completion process, particularly during function calls and string detection.
- Updated loading logic for type definitions to support both JSON object and array formats, improving robustness in type information handling.
…CompletionContributor

- Updated logic to recognize both '=' and ':=' as assignment operators, improving context detection for variable assignments.
- Enhanced type inference by checking for simple assignments without explicit type declarations, allowing for better type suggestions based on assigned values.
- Improved logging to provide clearer insights into assignment contexts and inferred types, aiding in debugging and user understanding.
…utor

- Simplified the method for determining if the cursor is inside a function call by focusing on parentheses and line context.
- Removed outdated checks for variable declarations and identifier typing, streamlining the detection process.
- Enhanced accuracy in identifying function calls by checking for unclosed parentheses and ensuring proper context handling.
- Improved logging to provide clearer insights into function call detection, aiding in debugging and user understanding.
Enhance string and assignment context detection in PineScriptCompletionContributor

- Improved logic for determining if the cursor is inside a string by implementing unescaped quote counting, enhancing accuracy in string context detection.
- Updated assignment statement detection to recognize both '=' and ':=' operators, refining context handling for variable assignments.
- Introduced new methods for extracting text after assignments and function parameters, streamlining completion logic.
- Enhanced logging to provide clearer insights into string detection, assignment contexts, and function call handling, aiding in debugging and user understanding.
…Contributor

- Improved logic for determining the current line and relative offset, enhancing accuracy in string and comment detection.
- Updated logging to provide clearer insights into cursor position and text context during autocompletion.
- Streamlined the handling of single-line input scenarios, ensuring robust detection of comments and strings.
- Enhanced overall completion logic by refining the conditions for skipping autocompletion based on cursor position.
- Updated the expected type inference to utilize the entire document text instead of just the text before the cursor, improving accuracy in type suggestions during variable assignments.
- Enhanced logging to provide clearer insights into the expected type determination process, aiding in debugging and user understanding.
@kaigouthro
Copy link
Contributor

I'm looking at this..

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