VsCodeHelper class
Helper class for VS Code API operations in scripts
All methods are static and require VSCode instance initialization.
Example usage:
void main() {
// Initialize with adapter
VsCodeHelper.initialize(adapter);
// Use helper methods
VsCodeHelper.showInfo('Hello from script!');
}
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
addDependency(
String name, {String? version, int timeoutSeconds = 180}) → Future< bool> - Add a dependency to pubspec.yaml
-
appendOutput(
String channel, String text, {int timeoutSeconds = 60}) → Future< void> - Append to output channel
-
applyWorkspaceEdit(
List< Map< edits, {int timeoutSeconds = 180}) → Future<String, dynamic> >bool> - Apply workspace edit
-
askCopilot(
String prompt, {String? context, int timeoutSeconds = 300}) → Future< String> - Ask GitHub Copilot a question (D4rt-safe version)
-
askCopilotChat(
String prompt, {String? requestId, int pollIntervalSeconds = 10, int timeoutSeconds = 7200, bool customResponseInstructions = false}) → Future< Map< String, dynamic> > - Ask Copilot Chat a question and wait for the response
-
askModel(
String modelId, String prompt, {String? context, String vendor = 'copilot', int timeoutSeconds = 300}) → Future< String> - Ask a specific language model a question by model ID
-
copyToClipboard(
String text, {int timeoutSeconds = 10}) → Future< void> - Copy to clipboard
-
createFile(
String path, {String content = '', int timeoutSeconds = 60}) → Future< bool> - Create a new file with content (alias for writeFile)
-
createOutput(
String name, {String? initialContent, int timeoutSeconds = 60}) → Future< String> - Create and show output channel
-
deleteFile(
String path, {int timeoutSeconds = 60}) → Future< bool> - Delete file
-
executeCommand(
String command, {List? args, int timeoutSeconds = 120}) → Future - Execute VS Code command
-
explainCode(
String code, {int timeoutSeconds = 300}) → Future< String> - Get code explanation from Copilot
-
fileExists(
String path, {int timeoutSeconds = 30}) → Future< bool> - Check if file exists
-
findFiles(
{required String include, String? exclude, int? maxResults, int timeoutSeconds = 60}) → Future< List< String> > - Find files in workspace
-
fixCode(
String code, String error, {int timeoutSeconds = 300}) → Future< String> - Get fix suggestions from Copilot
-
formatDocument(
String uri, {int timeoutSeconds = 180}) → Future< bool> - Format a Dart document
-
generateTests(
String code, {int timeoutSeconds = 300}) → Future< String> - Generate tests for code using Copilot
-
generateTimestampId(
) → String - Generate a timestamp-based unique ID
-
getActiveTextEditor(
{int timeoutSeconds = 30}) → Future - Get active text editor
-
getBreakpoints(
{int timeoutSeconds = 180}) → Future< List< Map< >String, dynamic> > - Get all breakpoints
-
getConfig(
String section, {String? key, int timeoutSeconds = 60}) → Future - Get configuration value
-
getCopilotModels(
{int timeoutSeconds = 120}) → Future< List< LanguageModelChat> > - Get list of available Copilot models
-
getCopilotSuggestion(
String code, String instruction, {int timeoutSeconds = 300}) → Future< String> - Get code suggestion from Copilot
-
getCursorPosition(
{int timeoutSeconds = 60}) → Future< Position?> - Get cursor position
-
getDiagnostics(
String uri, {int timeoutSeconds = 120}) → Future< List< Map< >String, dynamic> > - Get diagnostics (errors/warnings) for a file
-
getFlutterDevices(
{int timeoutSeconds = 180}) → Future< List< Map< >String, dynamic> > - Get list of Flutter devices
-
getGitRoot(
{int timeoutSeconds = 120}) → Future< String?> - Find git repository root
-
getProjectFiles(
String pattern, {bool excludeTests = true, int timeoutSeconds = 120}) → Future< List< String> > - Get project files matching pattern with smart filtering
-
getProjectType(
{int timeoutSeconds = 120}) → Future< String> - Detect project type (Flutter, Dart, etc.)
-
getSelection(
{int timeoutSeconds = 60}) → Future< Selection?> - Get current selection
-
getTestResults(
{int timeoutSeconds = 240}) → Future< List< Map< >String, dynamic> > - Get test results
-
getVSCode(
) → VSCode - Get the current VSCode API instance This is automatically set when a script executes via the bridge
-
getWindowId(
{int timeoutSeconds = 30}) → Future< String> - Get the VS Code window identifier (sessionId_machineId)
-
getWorkspaceFolders(
{int timeoutSeconds = 30}) → Future< List?> - Get workspace folders
-
getWorkspaceRoot(
{int timeoutSeconds = 30}) → Future< String?> - Get workspace root path
-
hotReload(
{int timeoutSeconds = 180}) → Future< bool> - Trigger Flutter hot reload
-
hotRestart(
{int timeoutSeconds = 240}) → Future< bool> - Trigger Flutter hot restart
-
initialize(
VSCodeAdapter adapter) → void - Initialize VsCodeHelper with adapter This creates the VSCode instance and stores it for use
-
inputBox(
{String? prompt, String? placeholder, String? defaultValue, bool password = false, int timeoutSeconds = 1800, String? fallbackValueOnTimeout, bool failOnTimeout = false}) → Future< String?> - Show input box
-
insertSnippet(
String uri, int line, int character, String snippet, {int timeoutSeconds = 180}) → Future< bool> - Insert a code snippet
-
openFile(
String path, {int timeoutSeconds = 600}) → Future< void> - Open file in editor
-
organizeImports(
String uri, {int timeoutSeconds = 180}) → Future< bool> - Organize imports in a Dart file
-
quickPick(
List< String> items, {String? placeholder, bool canPickMany = false, int timeoutSeconds = 1800, String? fallbackValueOnTimeout, bool failOnTimeout = false}) → Future<String?> - Show quick pick dialog
-
readClipboard(
{int timeoutSeconds = 10}) → Future< String> - Read from clipboard
-
readFile(
String path, {int timeoutSeconds = 60}) → Future< String> - Read file content
-
removeBreakpoint(
String uri, int line, {int timeoutSeconds = 180}) → Future< bool> - Remove breakpoint at line
-
replaceInWorkspace(
String query, String replacement, {String? includePattern, String? excludePattern, bool isRegex = false, int timeoutSeconds = 180}) → Future< bool> - Replace in workspace
-
replaceText(
String uri, int startLine, int startChar, int endLine, int endChar, String text, {int timeoutSeconds = 180}) → Future< bool> - Replace text in a document
-
reviewCode(
String code, {int timeoutSeconds = 300}) → Future< String> - Get code review from Copilot
-
runFlutterApp(
{String? deviceId, int timeoutSeconds = 420}) → Future< bool> - Run Flutter app on specified device
-
runPubGet(
{String? workingDirectory, int timeoutSeconds = 300}) → Future< bool> -
Run
dart pub getin the workspace -
runPubUpgrade(
{String? workingDirectory, int timeoutSeconds = 300}) → Future< bool> -
Run
dart pub upgradein the workspace -
runTests(
{String? uri, int timeoutSeconds = 420}) → Future< Map< String, dynamic> > - Run tests in specified file or workspace
-
runTestsWithCoverage(
{String? uri, int timeoutSeconds = 600}) → Future< Map< String, dynamic> > - Run tests with coverage
-
searchInWorkspace(
String query, {String? includePattern, String? excludePattern, bool isRegex = false, int? maxResults, int timeoutSeconds = 180}) → Future< List< Map< >String, dynamic> > - Search in workspace
-
selectCopilotModel(
{String? family, String? vendor, String? id, int timeoutSeconds = 120}) → Future< LanguageModelChat?> - Select a specific Copilot model
-
setBreakpoint(
String uri, int line, {int timeoutSeconds = 180}) → Future< bool> - Set breakpoint at line
-
setConfig(
String section, String key, dynamic value, {bool global = true, int timeoutSeconds = 60}) → Future< bool> - Set configuration value
-
setSelection(
int startLine, int startChar, int endLine, int endChar, {int timeoutSeconds = 120}) → Future< bool> - Set selection in active editor
-
setStatus(
String message, {int? timeout, int timeoutSeconds = 120}) → Future< void> - Set status bar message
-
setVSCode(
VSCode vscode) → void - Set the VSCode instance (called by bridge)
-
showError(
String message, {List< String> ? choices, int timeoutSeconds = 300}) → Future<String?> - Show error message
-
showInfo(
String message, {List< String> ? choices, int timeoutSeconds = 300}) → Future<String?> - Show information message
-
showWarning(
String message, {List< String> ? choices, int timeoutSeconds = 300}) → Future<String?> - Show warning message
-
startDebugging(
{Map< String, dynamic> ? config, int timeoutSeconds = 300}) → Future<bool> - Start debugging with configuration
-
stopDebugging(
{int timeoutSeconds = 180}) → Future< bool> - Stop current debugging session
-
writeFile(
String path, String content, {int timeoutSeconds = 60}) → Future< bool> - Write file content