import * as vscode from 'vscode' ; import { DevToolsExtensionContext } from "../devToolsExtensionContext" ; import { NumberHelper } from '../tools/numberHelper' ; import { StringHelper } from '../tools/stringHelper' ; import { ToolsWorkspaceCommandResponse } from '../langserver/toolsWorkspaceCommandResponse' ; import { WorkspaceCommandSyntaxModifier } from './workspaceCommandSyntaxModifier' ; export class ToolTipModifier extends WorkspaceCommandSyntaxModifier { constructor ( context ) { super ( context , "Add ToolTips" , "addToolTips" ) ; } protected getParameters ( uri ) { let parameters = super . getParameters ( uri ) ; let config = vscode . workspace . getConfiguration ( 'alOutline' , uri ) ; parameters . toolTipField = this . getFieldTooltip ( config ) ; parameters . toolTipFieldComment = this . getFieldTooltipComment ( config ) ; parameters . toolTipAction = this . getActionTooltip ( config ) ; parameters . useFieldDescription = this . getUseFieldDescription ( config ) ; parameters . reuseToolTips = ! config . get < boolean > ( 'doNotReuseToolTipsFromOtherPages' ) ; let toolTipsSource = config . get < string [ ] > ( 'reuseToolTipsFromDependencies' ) ; if ( toolTipsSource ) for ( let i = 0 ; i < toolTipsSource . length ; i ++ ) { let name = "toolTipDependency" + i . toString ( ) ; parameters [ name ] = toolTipsSource [ i ] ; } return parameters ; } protected async confirmRunForWorkspace ( ) { let confirmation = await vscode . window . showInformationMessage ( 'Do you want to add missing tool tips to all files in the current project folder?' , 'Yes' , 'No' ) ; return ( confirmation === 'Yes' ) ; } protected getSuccessWorkspaceMessage ( response ) { return NumberHelper . zeroIfNotDef ( response . parameters . noOfChanges ) . toString ( ) + ' toolTip(s) added to ' + NumberHelper . zeroIfNotDef ( response . parameters . noOfChangedFiles ) . toString ( ) + ' file(s).' ; } protected getSuccessDocumentMessage ( response ) { return response . parameters . noOfChanges . toString ( ) + ' ToolTip(s) added.' ; } protected getActionTooltip ( config ) { let toolTip = StringHelper . emptyIfNotDef ( config . get ( 'pageActionToolTip' ) ) ; if ( toolTip == '' ) { toolTip = 'Executes the action %1' ; } return toolTip ; } protected getFieldTooltip ( config ) { let toolTip = StringHelper . emptyIfNotDef ( config . get ( 'pageFieldToolTip' ) ) ; if ( toolTip == '' ) { toolTip = 'Specifies the value for the field %1' ; } return toolTip ; } protected getFieldTooltipComment ( config ) { let toolTip = StringHelper . emptyIfNotDef ( config . get ( 'pageFieldToolTipComment' ) ) ; if ( toolTip == '' ) { toolTip = '%Caption.Comment%' ; } return toolTip ; } protected getUseFieldDescription ( config ) { let value = ! ! config . get < boolean > ( 'useTableFieldDescriptionAsToolTip' ) ; return value ; } }