@@ -10,18 +10,17 @@ import {
1010 TextEditorRevealType ,
1111 Selection ,
1212 TextEditor ,
13- TextEditorEdit
14- } from ' vscode' ;
13+ TextEditorEdit ,
14+ } from " vscode" ;
1515
16- import { WorkspaceEdit , TextEdit } from ' vscode-languageclient/node' ;
16+ import { WorkspaceEdit , TextEdit } from " vscode-languageclient/node" ;
1717
18- import { client } from ' ./extension' ;
18+ import { client } from " ./extension" ;
1919
2020/**
2121 * Callback function for the `intersystems.language-server.overrideClassMembers` command.
2222 */
2323export async function overrideClassMembers ( ) {
24-
2524 // Get the open document and check that it's an ObjectScript class
2625 const openDoc = window . activeTextEditor . document ;
2726 if ( openDoc . languageId != "objectscript-class" ) {
@@ -58,7 +57,7 @@ export async function overrideClassMembers() {
5857 if ( cursorvalid ) {
5958 docposvalid = await client . sendRequest ( "intersystems/refactor/validateOverrideCursor" , {
6059 uri : openDoc . uri . toString ( ) ,
61- line : selection . active . line
60+ line : selection . active . line ,
6261 } ) ;
6362 }
6463 if ( ! cursorvalid || ! docposvalid ) {
@@ -68,9 +67,12 @@ export async function overrideClassMembers() {
6867 }
6968
7069 // Ask the user to select the type of member that they want to override
71- const selectedType = await window . showQuickPick ( [ "Method" , "Parameter" , "Projection" , "Property" , "Query" , "Trigger" , "XData" ] , {
72- title : "Pick the type of class member to override"
73- } ) ;
70+ const selectedType = await window . showQuickPick (
71+ [ "Method" , "Parameter" , "Projection" , "Property" , "Query" , "Trigger" , "XData" ] ,
72+ {
73+ title : "Pick the type of class member to override" ,
74+ } ,
75+ ) ;
7476 if ( ! selectedType ) {
7577 // No member type was selected, so exit
7678 return ;
@@ -79,18 +81,16 @@ export async function overrideClassMembers() {
7981 let plural = selectedType + "s" ;
8082 if ( selectedType == "Query" ) {
8183 plural = "Queries" ;
82- }
83- else if ( selectedType == "XData" ) {
84+ } else if ( selectedType == "XData" ) {
8485 plural = "XData blocks" ;
85- }
86- else if ( selectedType == "Property" ) {
86+ } else if ( selectedType == "Property" ) {
8787 plural = "Properties" ;
8888 }
8989
9090 // Ask the server for all overridable members of the selected type
9191 const overridableMembers : QuickPickItem [ ] = await client . sendRequest ( "intersystems/refactor/listOverridableMembers" , {
9292 uri : openDoc . uri . toString ( ) ,
93- memberType : selectedType
93+ memberType : selectedType ,
9494 } ) ;
9595 if ( ! overridableMembers ?. length ) {
9696 // There are no members of this type to override, so tell the user and exit
@@ -103,7 +103,7 @@ export async function overrideClassMembers() {
103103 title : `Pick the ${ plural } to override` ,
104104 matchOnDescription : true ,
105105 matchOnDetail : true ,
106- canPickMany : true
106+ canPickMany : true ,
107107 } ) ;
108108 if ( ! selectedMembers ?. length ) {
109109 // No members were selected, so exit
@@ -115,7 +115,7 @@ export async function overrideClassMembers() {
115115 uri : openDoc . uri . toString ( ) ,
116116 members : selectedMembers ,
117117 cursor : selection . active ,
118- memberType : selectedType
118+ memberType : selectedType ,
119119 } ) ;
120120
121121 // Apply the workspace edit
@@ -133,7 +133,7 @@ export async function selectParameterType(uri: string, parameterRange: Range) {
133133 const selectedParameter = await window . showQuickPick ( allparametertypes , {
134134 title : "Pick the Parameter type" ,
135135 matchOnDescription : true ,
136- canPickMany : false
136+ canPickMany : false ,
137137 } ) ;
138138 if ( ! selectedParameter ) {
139139 // No parameter was selected
@@ -143,12 +143,12 @@ export async function selectParameterType(uri: string, parameterRange: Range) {
143143 // Compute the workspace edit
144144 const change : TextEdit = {
145145 range : parameterRange ,
146- newText : selectedParameter . label
146+ newText : selectedParameter . label ,
147147 } ;
148148 const edit : WorkspaceEdit = {
149149 changes : {
150- [ uri ] : [ change ]
151- }
150+ [ uri ] : [ change ] ,
151+ } ,
152152 } ;
153153
154154 // Apply the workspace edit
@@ -162,7 +162,7 @@ export async function selectImportPackage(uri: string, classname: string) {
162162 // Ask for all import packages
163163 const allimportpackages : QuickPickItem [ ] = await client . sendRequest ( "intersystems/refactor/listImportPackages" , {
164164 uri : uri ,
165- classmame : classname
165+ classmame : classname ,
166166 } ) ;
167167
168168 let selectedPackage : QuickPickItem ;
@@ -177,7 +177,7 @@ export async function selectImportPackage(uri: string, classname: string) {
177177 // Ask the user to select an import package
178178 selectedPackage = await window . showQuickPick ( allimportpackages , {
179179 title : "Pick the package to import" ,
180- canPickMany : false
180+ canPickMany : false ,
181181 } ) ;
182182 if ( ! selectedPackage ) {
183183 // No package was selected
@@ -198,7 +198,13 @@ export async function selectImportPackage(uri: string, classname: string) {
198198/**
199199 * Callback function for the `intersystems.language-server.extractMethod` command.
200200 */
201- export async function extractMethod ( uri : string , lnstart : number , lnend : number , lnmethod : number , newmethodtype : string ) {
201+ export async function extractMethod (
202+ uri : string ,
203+ lnstart : number ,
204+ lnend : number ,
205+ lnmethod : number ,
206+ newmethodtype : string ,
207+ ) {
202208 // Get the list of class member names
203209 const symbols = await commands . executeCommand ( "vscode.executeDocumentSymbolProvider" , Uri . parse ( uri ) ) ;
204210 const clsmembers : string [ ] = [ ] ;
@@ -216,7 +222,6 @@ export async function extractMethod(uri: string, lnstart: number, lnend: number,
216222 let testname : string = newmethodname ;
217223 if (
218224 ( newmethodname . charAt ( 0 ) !== '"' || newmethodname . charAt ( newmethodname . length ) !== '"' ) &&
219- // eslint-disable-next-line no-control-regex
220225 newmethodname . match ( / ( ^ ( [ A - Z a - z ] | % ) $ ) | ( ^ ( [ A - Z a - z ] | % ) ( [ A - Z a - z ] | \d | [ ^ \x00 - \x7F ] ) + $ ) / g) === null
221226 ) {
222227 // Input contains forbidden characters so double exisiting " and add leading and trailing "
@@ -228,15 +233,15 @@ export async function extractMethod(uri: string, lnstart: number, lnend: number,
228233 if ( clsmembers . includes ( testname ) ) {
229234 return "Name already in use" ;
230235 }
231- }
236+ } ,
232237 } ) ;
233238
234239 if ( ! newmethodname ) {
235240 // No name
236241 return ;
237242 }
238- // Format name
239- // eslint-disable-next-line no-control-regex
243+ // Format name
244+
240245 if ( newmethodname . match ( / ( ^ ( [ A - Z a - z ] | % ) $ ) | ( ^ ( [ A - Z a - z ] | % ) ( [ A - Z a - z ] | \d | [ ^ \x00 - \x7F ] ) + $ ) / g) === null ) {
241246 // Add quotes if the name does not start with a letter or %, then followed by letter/number/ascii>128
242247 newmethodname = '"' + newmethodname . replace ( '"' , '""' ) + '"' ;
@@ -249,7 +254,7 @@ export async function extractMethod(uri: string, lnstart: number, lnend: number,
249254 lnstart : lnstart ,
250255 lnend : lnend ,
251256 lnmethod : lnmethod ,
252- newmethodtype : newmethodtype
257+ newmethodtype : newmethodtype ,
253258 } ) ;
254259
255260 // Apply the workspace edit
@@ -272,21 +277,23 @@ export async function extractMethod(uri: string, lnstart: number, lnend: number,
272277 const linesize = lspWorkspaceEdit . changes [ uri ] [ lspWorkspaceEdit . changes [ uri ] . length - 1 ] . newText . length ;
273278 const range2 : Range = new Range (
274279 new Position ( anchor2 . line + methodsize + 1 , anchor2 . character ) ,
275- new Position ( anchor2 . line + methodsize + 1 , anchor2 . character + linesize + 1 )
280+ new Position ( anchor2 . line + methodsize + 1 , anchor2 . character + linesize + 1 ) ,
276281 ) ;
277282
278283 // Scroll to the extracted method
279284 activeEditor . revealRange ( range ) ;
280285
281286 // Highlight extracted method and method call
282- const color : string = "#ffff0020" ; // Transparent yellow
287+ const color : string = "#ffff0020" ; // Transparent yellow
283288 const timeout : number = 2000 ; // Highlight disapears after 2 seconds
284289 const decoration = window . createTextEditorDecorationType ( {
285- backgroundColor : color
290+ backgroundColor : color ,
286291 } ) ;
287292 activeEditor . setDecorations ( decoration , [ range , range2 ] ) ;
288- await new Promise ( r => setTimeout ( r , timeout ) ) ;
289- setTimeout ( function ( ) { decoration . dispose ( ) ; } , 0 ) ;
293+ await new Promise ( ( r ) => setTimeout ( r , timeout ) ) ;
294+ setTimeout ( function ( ) {
295+ decoration . dispose ( ) ;
296+ } , 0 ) ;
290297 }
291298}
292299
@@ -304,7 +311,7 @@ export async function showSymbolInClass(uri: string, memberType: string, memberN
304311 return ;
305312 }
306313 const symbol = symbols [ 0 ] . children . find (
307- ( symbol ) => symbol . detail . toLowerCase ( ) . includes ( memberType . toLowerCase ( ) ) && symbol . name === memberName
314+ ( symbol ) => symbol . detail . toLowerCase ( ) . includes ( memberType . toLowerCase ( ) ) && symbol . name === memberName ,
308315 ) ;
309316 if ( symbol !== undefined ) {
310317 // Show the symbol in the editor
@@ -320,7 +327,14 @@ export async function showSymbolInClass(uri: string, memberType: string, memberN
320327/**
321328 * Callback function for the `intersystems.language-server.setSelection` command.
322329 */
323- export function setSelection ( editor : TextEditor , _edit : TextEditorEdit , startLine : number , startCharacter : number , endLine : number , endCharacter : number ) {
330+ export function setSelection (
331+ editor : TextEditor ,
332+ _edit : TextEditorEdit ,
333+ startLine : number ,
334+ startCharacter : number ,
335+ endLine : number ,
336+ endCharacter : number ,
337+ ) {
324338 const range = new Range ( startLine , startCharacter , endLine , endCharacter ) ;
325339 editor . selection = new Selection ( range . start , range . end ) ;
326340 editor . revealRange ( range , TextEditorRevealType . InCenter ) ;
0 commit comments