-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
introducing context awareness to the autocomplete hinter in addition to context aware renaming, jump to definition and other refactoring changes (draft work for review) #3594
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
Draft
kammeows
wants to merge
41
commits into
processing:develop
Choose a base branch
from
kammeows:develop
base: develop
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.
Draft
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
a79c2f1
context-aware hinter code
kammeows 3e84dd5
Merge pull request #1 from kammeows/Branch_Kamakshi
kammeows 5fc1c64
Merge branch 'processing:develop' into develop
kammeows 9c4bc52
context-aware hinter code
kammeows cf71058
parse code with babel and warn when blacklisted function focused
kammeows e8bf752
updated the hinter to suggest class methods
kammeows 819b9cb
Merge pull request #2 from kammeows/Branch_Kamakshi
kammeows 5559967
user-defined context-aware variables, functions & classes suggestion
kammeows 2c132e6
Merge branch 'processing:develop' into develop
kammeows 761657a
Merge pull request #3 from kammeows/Branch_Kamakshi
kammeows b0ec598
added listOfAllFunctions.json
kammeows 87d89a5
Merge pull request #4 from kammeows/Branch_Kamakshi
kammeows d28914a
implement context aware renaming + fixed bug to show inline hint sugg…
kammeows b0a0feb
fixed autocomplete bug
kammeows 5120dce
bug fix: ensure renaming doesnt happen with commented code and keywords
kammeows bdb7d86
minor changes to ensure all features work smoothly
kammeows e3c7f18
fixed a minor bug in autocomplete method suggestions
kammeows 093dccc
Merge pull request #5 from kammeows/Branch_Kamakshi
kammeows ea39d0e
implement jump to definition basic functionality
kammeows a627fde
Merge branch 'Branch_Kamakshi' of https://github.com/kammeows/p5.js-w…
kammeows 990712a
Merge branch 'develop' into Branch_Kamakshi
kammeows b006d5d
Merge pull request #8 from kammeows/Branch_Kamakshi
kammeows f94b2fb
remove console statements
kammeows a7229da
add descriptive names for files & add a readme for new changes
kammeows f30b884
fix autocomplete and renaming behavior for same var and func name
kammeows 01454d0
fix autocomplete suggestions behavior for same function and variable …
kammeows a67e89d
fix renaming behavior with same function name in different contexts
kammeows ce4ae68
fix logic for correct behavior of jump to definition with same functi…
kammeows 2415953
fix renaming behavior
kammeows 1779145
implement screen reader behavior for context aware renaming and jump …
kammeows c50566f
fix local renaming bug
kammeows 88a9c65
Merge branch 'develop' of https://github.com/processing/p5.js-web-edi…
kammeows 9172902
Merge pull request #10 from kammeows/processing-develop
kammeows 0665cc6
add jump to definition from one file to another file
kammeows 293b49e
modify jump to definition to work according to runtime behavior
kammeows 842c46b
renaming logic for classes
kammeows a0569d0
fixes on renaming logic for classes and methods along with other mino…
kammeows fdcd37a
final edits to clean the code
kammeows 26442f4
Merge branch 'develop' into develop
kammeows ca26d11
Merge branch 'develop' of https://github.com/kammeows/p5.js-web-edito…
kammeows 77465e9
update files to ensure consistency and fix test errors
kammeows File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# GSoC 2025: p5.js Autocomplete Hinter & Refactoring System | ||
This readme elaborates on the core components of the context-aware autocomplete hinter, refactoring utilities, and supporting data structures developed as part of Google Summer of Code 2025. The goal is to enable smart context-aware autocompletion, jump-to-definition, and safe variable renaming. | ||
|
||
# Project Overview | ||
|
||
## Autocomplete Hinter Context-Aware Functionality | ||
The following files and modules work together to make the p5.js autocomplete hinter context-aware: | ||
|
||
### p5CodeAstAnalyzer.js | ||
Purpose: Parses user-written p5.js code using Babel and extracts structural information: | ||
|
||
- Maps variable names to p5 class instances | ||
- Tracks declared variables in each function or global scope | ||
- Detects user-defined functions and their parameters | ||
- Collects info about user-defined classes, constructor-assigned properties, and methods | ||
|
||
Key Output Maps: | ||
|
||
- variableToP5ClassMap: Maps variable names (e.g., col) to their p5.js class type (e.g., p5.Color) | ||
- scopeToDeclaredVarsMap: Maps function names or global scope to variables declared in them | ||
- userDefinedFunctionMetadata: Metadata about custom functions (params, type, etc.) | ||
- userDefinedClassMetadata: Metadata for user-defined classes (methods, constructor properties) | ||
|
||
### context-aware-hinter.js | ||
Purpose: Provides code autocompletion hints based on: | ||
|
||
- Current cursor context (draw, setup, etc.) | ||
- p5CodeAstAnalyzer output | ||
- p5 class method definitions | ||
- Variable/function scope and visibility | ||
- Scope-specific blacklist/whitelist logic | ||
|
||
Features: | ||
|
||
- Dot-autocompletion (e.g., col. shows methods of p5.Color) | ||
- Scope-sensitive variable/function suggestions | ||
- Ranks hints by type and scope relevance | ||
|
||
### getContext.js | ||
Purpose: Get the context of the cursor, i.e. inside what function is the cursor in | ||
|
||
## Context-Aware Renaming Functionality | ||
The following files ensure context-aware renaming when a variable or user-defined function is selected and the F2 button is clicked | ||
|
||
### rename-variable.js | ||
Purpose: Safely renames a variable in the user's code editor by: | ||
|
||
- Analyzing AST to find all matching identifiers | ||
- Ensuring replacement only occurs within the same lexical scope | ||
- Performing in-place replacement using CodeMirror APIs | ||
|
||
### showRenameDialog.jsx | ||
Purpose: Opens either a dialog box to get the new variable name or a temporary box to show that the word selected cannot be renamed | ||
|
||
## Jump to Definition | ||
The following file allows user to jump to the definition for variables or parameters when a word is ctrl-clicked. | ||
|
||
### jumptodefinition.js | ||
Purpose: Implements “jump to definition” for variables or parameters in the editor. | ||
|
||
How It Works: | ||
|
||
- Uses AST + scope map to locate the definition site of a variable | ||
- Supports both VariableDeclarator and FunctionDeclaration/params | ||
- Moves the editor cursor to the source location of the definition | ||
|
||
## Supporting Data Files | ||
### p5-instance-methods-and-creators.json | ||
Purpose: Maps p5.js classes to: | ||
|
||
- Methods used to instantiate them (createMethods) | ||
- Methods available on those instances (methods) | ||
|
||
### p5-scope-function-access-map.json | ||
Purpose: Defines which p5.js functions are allowed or disallowed inside functions like setup, draw, preload, etc. | ||
|
||
### p5-reference-functions.json | ||
Purpose: A flat list of all available p5.js functions. | ||
|
||
Used to: | ||
|
||
- Differentiate between built-in and user-defined functions | ||
- Filter out redefinitions or incorrect hints | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,5 @@ render( | |
</Provider>, | ||
document.getElementById('root') | ||
); | ||
|
||
export default store; |
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Let's keep the README as a separate GitHub Gist, and not include it in the final PR to be merged.