import * as path from 'path' ; import * as vscode from 'vscode' ; import { channelService } from './sfdx' ; import { telemetryService } from './telemetry' ; export function getDocumentName ( document ) { const documentPath = document . uri . fsPath ; return path . basename ( documentPath ) || '' ; } function hasRootWorkspace ( ws = vscode . workspace ) { return ws && ws . workspaceFolders && ws . workspaceFolders . length > 0 ; } function getRootWorkspace ( ) { return hasRootWorkspace ( ) ? ( vscode . workspace . workspaceFolders as vscode . WorkspaceFolder [ ] ) [ 0 ] : ( { } as vscode . WorkspaceFolder ) ; } export function getRootWorkspacePath ( ) { return getRootWorkspace ( ) . uri ? getRootWorkspace ( ) . uri . fsPath : '' ; } export async function trackErrorWithTelemetry ( problemId , error ) { try { telemetryService . sendException ( `soql_error_${ problemId . toLocaleLowerCase ( ) }` , error ) ; } catch ( err ) { channelService . appendLine ( `soql_error_telemetry:  ${ error . toString ( ) }` ) ; } }