Remove classes and inheritance where they are not needed#868
Open
Gold856 wants to merge 10 commits into
Open
Conversation
a3e42fa to
baad1c4
Compare
…se of undefined in some types
There was a problem hiding this comment.
Pull request overview
Refactors the VS Code WPILib extension to reduce unnecessary class wrappers/inheritance and simplify boolean/undefined checks, while keeping the same feature set (updates, vendor deps, templates/examples, and RioLog UI).
Changes:
- Converted several “registration/utility” classes (updates, templates/examples/commands, build/deploy/debug) into exported functions.
- Extracted commonly used UtilitiesAPI helpers into module-level functions and updated call sites to use them directly.
- Simplified many
undefined/boolean checks and optional property typings across the codebase.
Reviewed changes
Copilot reviewed 51 out of 51 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vscode-wpilib/src/wpilibupdates.ts | Refactor WPILib update logic from class to functions. |
| vscode-wpilib/src/webviews/webviewbase.ts | Simplify optional webview handling. |
| vscode-wpilib/src/webviews/projectcreator.ts | Simplify dialog result check. |
| vscode-wpilib/src/webviews/localeloader.ts | Remove redundant boolean cast. |
| vscode-wpilib/src/webviews/gradle2025import.ts | Simplify selection/dialog checks. |
| vscode-wpilib/src/vscommands.ts | Update command handlers for new update/utilities exports and simplify guards. |
| vscode-wpilib/src/versions.ts | Use optional property syntax for version parsing. |
| vscode-wpilib/src/vendorlibraries.ts | Remove base-class inheritance and use shared helper functions. |
| vscode-wpilib/src/utilities.ts | Simplify javaHome and selection checks. |
| vscode-wpilib/src/toolapi.ts | Simplify result/workspace checks. |
| vscode-wpilib/src/shared/vendorlibrariesbase.ts | Convert base class to standalone helper functions. |
| vscode-wpilib/src/shared/vendorexamples.ts | Remove utilities/vendorlibs parameters; use shared helpers directly. |
| vscode-wpilib/src/shared/utilitiesapi.ts | Add module-level getWPILibYear/getWPILibHomeDir helpers; delegate class methods. |
| vscode-wpilib/src/shared/templates.ts | Convert Templates class into registerProjectTemplates function. |
| vscode-wpilib/src/shared/promisecondition.ts | Simplify boolean/optional callback checks. |
| vscode-wpilib/src/shared/examples.ts | Convert Examples class into registerExamples function. |
| vscode-wpilib/src/riolog/vscodeimpl.ts | Refactor RioLog webview HTML/view creation into functions. |
| vscode-wpilib/src/riolog/shared/sharedscript.ts | Simplify boolean checks in DOM rendering helpers. |
| vscode-wpilib/src/riolog/shared/interfaces.ts | Remove unused window/provider interfaces; keep console/disposable types. |
| vscode-wpilib/src/riolog/riologwindow.ts | Rewire RioLogWindow to use VS Code webview panel directly + new helper functions. |
| vscode-wpilib/src/riolog/promisecond.ts | Simplify boolean/optional callback checks. |
| vscode-wpilib/src/projectinfo.ts | Remove dependency on updater class; use exported version helper. |
| vscode-wpilib/src/preferencesapi.ts | Simplify workspace selection logic. |
| vscode-wpilib/src/preferences.ts | Simplify config retrieval/defaulting. |
| vscode-wpilib/src/logger.ts | Remove ILogger interface; export concrete logger instance. |
| vscode-wpilib/src/java/simulate.ts | Simplify environment guard. |
| vscode-wpilib/src/java/java.ts | Use new register* functions for build/deploy/commands/examples/templates. |
| vscode-wpilib/src/java/deploydebug.ts | Convert DeployDebug class into registration function. |
| vscode-wpilib/src/java/commands.ts | Convert Commands class into registration function. |
| vscode-wpilib/src/java/buildtest.ts | Convert BuildTest class into registration function. |
| vscode-wpilib/src/fetchhelpers.ts | Remove redundant response === undefined check. |
| vscode-wpilib/src/extension.ts | Update activation to use new register/check functions; simplify wiring. |
| vscode-wpilib/src/executor.ts | Simplify shell options guard. |
| vscode-wpilib/src/docsapi.ts | Minor cleanup + optional chaining for disposable disposal. |
| vscode-wpilib/src/deploydebugapi.ts | Remove async factory; construct RioLogWindow directly. |
| vscode-wpilib/src/dependencyView.ts | Use shared vendor helpers; simplify sorts and refresh flow. |
| vscode-wpilib/src/cppprovider/vscommands.ts | Simplify workspace guards. |
| vscode-wpilib/src/cppprovider/jsonformats.ts | Remove unused IBinaryMap interface. |
| vscode-wpilib/src/cppprovider/headertreeprovider.ts | Tighten FileStat boolean getters; simplify checks. |
| vscode-wpilib/src/cppprovider/cppprovider.ts | Simplify workspace guards. |
| vscode-wpilib/src/cppprovider/apiprovider.ts | Simplify optional params/guards; reduce branching. |
| vscode-wpilib/src/cpp/simulatewindows.ts | Simplify environment/config boolean checks. |
| vscode-wpilib/src/cpp/simulateunix.ts | Simplify environment guard. |
| vscode-wpilib/src/cpp/deploydebug.ts | Convert DeployDebug class into registration function. |
| vscode-wpilib/src/cpp/cpp.ts | Use new register* functions for build/deploy/commands/examples/templates. |
| vscode-wpilib/src/cpp/commands.ts | Convert Commands class into registration function. |
| vscode-wpilib/src/cpp/buildtest.ts | Convert BuildTest class into registration function. |
| vscode-wpilib/src/commandapi.ts | Simplify quick pick guards and language selection flow. |
| vscode-wpilib/src/builtintools.ts | Convert BuiltinTools class into registerBuiltinTools function. |
| vscode-wpilib/src/buildtestapi.ts | Simplify quick pick guard. |
| vscode-wpilib/resources/live.html | Remove unused RioLog HTML template file (now generated in TS). |
Comments suppressed due to low confidence (2)
vscode-wpilib/src/wpilibupdates.ts:138
- Because
gradleRioRegexis defined with the globalgflag and reused, calls togradleRioRegex.exec(...)will advancelastIndexand subsequent calls can returnnullunexpectedly. Either remove thegflag forexecusage, resetgradleRioRegex.lastIndex = 0before eachexec, or create a fresh RegExp per call.
vscode-wpilib/src/wpilibupdates.ts:168 setGradleRIOVersionuses a replacement string$1${version}$3, but the currentgradleRioRegexonly defines one capture group. This will produce an incorrectbuild.gradlereplacement (e.g., concatenating old+new versions and/or dropping surrounding text). Update the regex to include the required groups or change the replacement string to match the actual capture groups.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
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.
Depends on #867.