Helios-Commands-Tools.st 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  1. Smalltalk createPackage: 'Helios-Commands-Tools'!
  2. HLModelCommand subclass: #HLToolCommand
  3. slots: {}
  4. package: 'Helios-Commands-Tools'!
  5. !HLToolCommand methodsFor: 'accessing'!
  6. category
  7. ^ nil
  8. ! !
  9. !HLToolCommand class methodsFor: 'instance creation'!
  10. for: aToolModel
  11. ^ self new
  12. model: aToolModel;
  13. yourself
  14. ! !
  15. !HLToolCommand class methodsFor: 'testing'!
  16. isValidFor: aModel
  17. ^ aModel isToolModel
  18. ! !
  19. HLToolCommand subclass: #HLBrowseMethodCommand
  20. slots: {}
  21. package: 'Helios-Commands-Tools'!
  22. !HLBrowseMethodCommand methodsFor: 'accessing'!
  23. displayLabel
  24. ^ 'browse method'
  25. ! !
  26. !HLBrowseMethodCommand methodsFor: 'executing'!
  27. execute
  28. self model openMethod
  29. ! !
  30. !HLBrowseMethodCommand class methodsFor: 'accessing'!
  31. key
  32. ^ 'b'
  33. !
  34. label
  35. ^ 'browse method'
  36. ! !
  37. !HLBrowseMethodCommand class methodsFor: 'testing'!
  38. isValidFor: aModel
  39. ^ aModel isReferencesModel
  40. ! !
  41. HLToolCommand subclass: #HLCommitPackageCommand
  42. slots: {}
  43. package: 'Helios-Commands-Tools'!
  44. !HLCommitPackageCommand methodsFor: 'accessing'!
  45. category
  46. ^ 'Packages'
  47. ! !
  48. !HLCommitPackageCommand methodsFor: 'error handling'!
  49. onPackageCommitError: anError
  50. (HLPackageCommitErrorHelper on: self model)
  51. showHelp
  52. ! !
  53. !HLCommitPackageCommand methodsFor: 'executing'!
  54. commitPackage
  55. self model
  56. commitPackageOnSuccess: [ self informSuccess ]
  57. onError: [ :error | self onPackageCommitError: error ]
  58. !
  59. execute
  60. self commitPackage
  61. !
  62. informSuccess
  63. HLInformationWidget new
  64. informationString: 'Commit successful!!';
  65. show
  66. ! !
  67. !HLCommitPackageCommand methodsFor: 'testing'!
  68. isActive
  69. ^ true
  70. "self model isPackageDirty"
  71. ! !
  72. !HLCommitPackageCommand class methodsFor: 'accessing'!
  73. key
  74. ^ 'k'
  75. !
  76. label
  77. ^ 'Commit package'
  78. ! !
  79. HLToolCommand subclass: #HLCopyCommand
  80. slots: {}
  81. package: 'Helios-Commands-Tools'!
  82. !HLCopyCommand class methodsFor: 'accessing'!
  83. key
  84. ^ 'c'
  85. !
  86. label
  87. ^ 'Copy'
  88. ! !
  89. HLCopyCommand subclass: #HLCopyClassCommand
  90. slots: {}
  91. package: 'Helios-Commands-Tools'!
  92. !HLCopyClassCommand methodsFor: 'accessing'!
  93. category
  94. ^ 'Classes'
  95. !
  96. displayLabel
  97. ^ 'New class name:'
  98. ! !
  99. !HLCopyClassCommand methodsFor: 'defaults'!
  100. defaultInput
  101. ^ self model selectedClass theNonMetaClass name
  102. ! !
  103. !HLCopyClassCommand methodsFor: 'executing'!
  104. execute
  105. self model copyClassTo: self input
  106. ! !
  107. !HLCopyClassCommand methodsFor: 'testing'!
  108. isActive
  109. ^ self model selectedClass notNil
  110. !
  111. isInputRequired
  112. ^ true
  113. ! !
  114. !HLCopyClassCommand class methodsFor: 'accessing'!
  115. key
  116. ^ 'c'
  117. !
  118. label
  119. ^ 'Copy class'
  120. !
  121. menuLabel
  122. ^ 'Copy class...'
  123. ! !
  124. HLToolCommand subclass: #HLFindCommand
  125. slots: {}
  126. package: 'Helios-Commands-Tools'!
  127. !HLFindCommand class methodsFor: 'accessing'!
  128. key
  129. ^ 'f'
  130. !
  131. label
  132. ^ 'Find'
  133. ! !
  134. HLFindCommand subclass: #HLFindClassCommand
  135. slots: {}
  136. package: 'Helios-Commands-Tools'!
  137. !HLFindClassCommand methodsFor: 'accessing'!
  138. displayLabel
  139. ^ 'select a class'
  140. !
  141. inputCompletion
  142. ^ self model availableClassNames
  143. !
  144. inputLabel
  145. ^ 'Find a class'
  146. ! !
  147. !HLFindClassCommand methodsFor: 'executing'!
  148. execute
  149. self model openClassNamed: self input
  150. ! !
  151. !HLFindClassCommand methodsFor: 'testing'!
  152. isInputRequired
  153. ^ true
  154. ! !
  155. !HLFindClassCommand class methodsFor: 'accessing'!
  156. key
  157. ^ 'c'
  158. !
  159. label
  160. ^ 'Find class'
  161. ! !
  162. HLFindCommand subclass: #HLFindClassReferencesCommand
  163. slots: {}
  164. package: 'Helios-Commands-Tools'!
  165. !HLFindClassReferencesCommand methodsFor: 'accessing'!
  166. category
  167. ^ 'Classes'
  168. ! !
  169. !HLFindClassReferencesCommand methodsFor: 'executing'!
  170. execute
  171. HLReferences new
  172. openAsTab;
  173. search: self model selectedClass theNonMetaClass name
  174. ! !
  175. !HLFindClassReferencesCommand methodsFor: 'testing'!
  176. isActive
  177. ^ self model selectedClass notNil
  178. !
  179. isInputRequired
  180. ^ false
  181. ! !
  182. !HLFindClassReferencesCommand class methodsFor: 'accessing'!
  183. menuLabel
  184. ^ 'Find class references...'
  185. ! !
  186. HLFindCommand subclass: #HLFindMethodReferencesCommand
  187. slots: {}
  188. package: 'Helios-Commands-Tools'!
  189. !HLFindMethodReferencesCommand methodsFor: 'accessing'!
  190. category
  191. ^ 'Methods'
  192. ! !
  193. !HLFindMethodReferencesCommand methodsFor: 'executing'!
  194. execute
  195. HLReferences new
  196. openAsTab;
  197. search: self model selectedMethod selector
  198. ! !
  199. !HLFindMethodReferencesCommand methodsFor: 'testing'!
  200. isActive
  201. ^ self model selectedMethod notNil
  202. !
  203. isInputRequired
  204. ^ false
  205. ! !
  206. !HLFindMethodReferencesCommand class methodsFor: 'accessing'!
  207. menuLabel
  208. ^ 'Find method references...'
  209. ! !
  210. HLFindCommand subclass: #HLFindReferencesCommand
  211. slots: {}
  212. package: 'Helios-Commands-Tools'!
  213. !HLFindReferencesCommand methodsFor: 'accessing'!
  214. displayLabel
  215. ^ 'find references'
  216. !
  217. inputCompletion
  218. ^ self model availableClassNames, self model allSelectors
  219. !
  220. inputLabel
  221. ^ 'Find references of'
  222. ! !
  223. !HLFindReferencesCommand methodsFor: 'defaults'!
  224. defaultInput
  225. ^ self model selectedMethod
  226. ifNil: [
  227. self model selectedClass
  228. ifNil: [ '' ]
  229. ifNotNil: [ :class | class theNonMetaClass name ] ]
  230. ifNotNil: [ :method | method selector ]
  231. ! !
  232. !HLFindReferencesCommand methodsFor: 'executing'!
  233. execute
  234. HLReferences new
  235. openAsTab;
  236. search: self input
  237. ! !
  238. !HLFindReferencesCommand methodsFor: 'testing'!
  239. isInputRequired
  240. ^ true
  241. ! !
  242. !HLFindReferencesCommand class methodsFor: 'accessing'!
  243. key
  244. ^ 'r'
  245. !
  246. label
  247. ^ 'Find references'
  248. ! !
  249. HLToolCommand subclass: #HLMoveToCommand
  250. slots: {}
  251. package: 'Helios-Commands-Tools'!
  252. !HLMoveToCommand class methodsFor: 'accessing'!
  253. key
  254. ^ 'm'
  255. !
  256. label
  257. ^ 'Move'
  258. ! !
  259. HLMoveToCommand subclass: #HLMoveClassToCommand
  260. slots: {}
  261. package: 'Helios-Commands-Tools'!
  262. !HLMoveClassToCommand methodsFor: 'testing'!
  263. isActive
  264. ^ self model selectedClass notNil
  265. ! !
  266. !HLMoveClassToCommand class methodsFor: 'accessing'!
  267. key
  268. ^ 'c'
  269. !
  270. label
  271. ^ 'Move class'
  272. ! !
  273. HLMoveClassToCommand subclass: #HLMoveClassToPackageCommand
  274. slots: {}
  275. package: 'Helios-Commands-Tools'!
  276. !HLMoveClassToPackageCommand methodsFor: 'accessing'!
  277. category
  278. ^ 'Classes'
  279. !
  280. displayLabel
  281. ^ 'select a package'
  282. !
  283. inputCompletion
  284. ^ self model availablePackageNames
  285. !
  286. inputLabel
  287. ^ 'Move class to package:'
  288. ! !
  289. !HLMoveClassToPackageCommand methodsFor: 'executing'!
  290. execute
  291. self model moveClassToPackage: self input
  292. ! !
  293. !HLMoveClassToPackageCommand methodsFor: 'testing'!
  294. isInputRequired
  295. ^ true
  296. ! !
  297. !HLMoveClassToPackageCommand class methodsFor: 'accessing'!
  298. key
  299. ^ 'p'
  300. !
  301. label
  302. ^ 'Move class to package'
  303. !
  304. menuLabel
  305. ^ 'Move to package...'
  306. ! !
  307. HLMoveToCommand subclass: #HLMoveMethodToCommand
  308. slots: {}
  309. package: 'Helios-Commands-Tools'!
  310. !HLMoveMethodToCommand methodsFor: 'accessing'!
  311. category
  312. ^ 'Methods'
  313. ! !
  314. !HLMoveMethodToCommand methodsFor: 'testing'!
  315. isActive
  316. ^ self model selectedMethod notNil
  317. ! !
  318. !HLMoveMethodToCommand class methodsFor: 'accessing'!
  319. key
  320. ^ 'm'
  321. !
  322. label
  323. ^ 'Move method'
  324. ! !
  325. HLMoveMethodToCommand subclass: #HLMoveMethodToClassCommand
  326. slots: {}
  327. package: 'Helios-Commands-Tools'!
  328. !HLMoveMethodToClassCommand methodsFor: 'accessing'!
  329. displayLabel
  330. ^ 'select a class'
  331. !
  332. inputCompletion
  333. ^ self model availableClassNames
  334. !
  335. inputLabel
  336. ^ 'Move method to class:'
  337. ! !
  338. !HLMoveMethodToClassCommand methodsFor: 'executing'!
  339. execute
  340. self model moveMethodToClass: self input
  341. ! !
  342. !HLMoveMethodToClassCommand methodsFor: 'testing'!
  343. isInputRequired
  344. ^ true
  345. ! !
  346. !HLMoveMethodToClassCommand class methodsFor: 'accessing'!
  347. key
  348. ^ 'c'
  349. !
  350. label
  351. ^ 'Move method to class'
  352. !
  353. menuLabel
  354. ^ 'Move to class...'
  355. ! !
  356. HLMoveMethodToCommand subclass: #HLMoveMethodToProtocolCommand
  357. slots: {}
  358. package: 'Helios-Commands-Tools'!
  359. !HLMoveMethodToProtocolCommand methodsFor: 'accessing'!
  360. displayLabel
  361. ^ 'select a protocol'
  362. !
  363. inputCompletion
  364. ^ self model availableProtocols
  365. !
  366. inputLabel
  367. ^ 'Move method to a protocol:'
  368. ! !
  369. !HLMoveMethodToProtocolCommand methodsFor: 'executing'!
  370. execute
  371. self model moveMethodToProtocol: self input
  372. ! !
  373. !HLMoveMethodToProtocolCommand methodsFor: 'testing'!
  374. isInputRequired
  375. ^ true
  376. ! !
  377. !HLMoveMethodToProtocolCommand class methodsFor: 'accessing'!
  378. key
  379. ^ 't'
  380. !
  381. label
  382. ^ 'Move method to protocol'
  383. !
  384. menuLabel
  385. ^ 'Move to protocol...'
  386. ! !
  387. HLToolCommand subclass: #HLRemoveCommand
  388. slots: {}
  389. package: 'Helios-Commands-Tools'!
  390. !HLRemoveCommand class methodsFor: 'accessing'!
  391. key
  392. ^ 'x'
  393. !
  394. label
  395. ^ 'Remove'
  396. ! !
  397. HLRemoveCommand subclass: #HLRemoveClassCommand
  398. slots: {}
  399. package: 'Helios-Commands-Tools'!
  400. !HLRemoveClassCommand methodsFor: 'accessing'!
  401. category
  402. ^ 'Classes'
  403. ! !
  404. !HLRemoveClassCommand methodsFor: 'executing'!
  405. execute
  406. self model removeClass
  407. ! !
  408. !HLRemoveClassCommand methodsFor: 'testing'!
  409. isActive
  410. ^ self model selectedClass notNil
  411. ! !
  412. !HLRemoveClassCommand class methodsFor: 'accessing'!
  413. key
  414. ^ 'c'
  415. !
  416. label
  417. ^ 'Remove class'
  418. !
  419. menuLabel
  420. ^ 'Remove class'
  421. ! !
  422. HLRemoveCommand subclass: #HLRemoveMethodCommand
  423. slots: {}
  424. package: 'Helios-Commands-Tools'!
  425. !HLRemoveMethodCommand methodsFor: 'accessing'!
  426. category
  427. ^ 'Methods'
  428. ! !
  429. !HLRemoveMethodCommand methodsFor: 'executing'!
  430. execute
  431. self model removeMethod
  432. ! !
  433. !HLRemoveMethodCommand methodsFor: 'testing'!
  434. isActive
  435. ^ self model selectedMethod notNil
  436. ! !
  437. !HLRemoveMethodCommand class methodsFor: 'accessing'!
  438. key
  439. ^ 'm'
  440. !
  441. label
  442. ^ 'Remove method'
  443. !
  444. menuLabel
  445. ^ 'Remove method'
  446. ! !
  447. HLRemoveCommand subclass: #HLRemoveProtocolCommand
  448. slots: {}
  449. package: 'Helios-Commands-Tools'!
  450. !HLRemoveProtocolCommand methodsFor: 'accessing'!
  451. category
  452. ^ 'Protocols'
  453. ! !
  454. !HLRemoveProtocolCommand methodsFor: 'executing'!
  455. execute
  456. self model removeProtocol
  457. ! !
  458. !HLRemoveProtocolCommand methodsFor: 'testing'!
  459. isActive
  460. ^ self model selectedProtocol notNil
  461. ! !
  462. !HLRemoveProtocolCommand class methodsFor: 'accessing'!
  463. key
  464. ^ 't'
  465. !
  466. label
  467. ^ 'Remove protocol'
  468. !
  469. menuLabel
  470. ^ 'Remove protocol'
  471. ! !
  472. HLToolCommand subclass: #HLRenameCommand
  473. slots: {}
  474. package: 'Helios-Commands-Tools'!
  475. !HLRenameCommand class methodsFor: 'accessing'!
  476. key
  477. ^ 'r'
  478. !
  479. label
  480. ^ 'Rename'
  481. ! !
  482. HLRenameCommand subclass: #HLRenameClassCommand
  483. slots: {}
  484. package: 'Helios-Commands-Tools'!
  485. !HLRenameClassCommand methodsFor: 'accessing'!
  486. category
  487. ^ 'Classes'
  488. !
  489. displayLabel
  490. ^ 'Rename class to:'
  491. ! !
  492. !HLRenameClassCommand methodsFor: 'defaults'!
  493. defaultInput
  494. ^ self model selectedClass theNonMetaClass name
  495. ! !
  496. !HLRenameClassCommand methodsFor: 'executing'!
  497. execute
  498. self model renameClassTo: self input
  499. ! !
  500. !HLRenameClassCommand methodsFor: 'testing'!
  501. isActive
  502. ^ self model selectedClass notNil
  503. !
  504. isInputRequired
  505. ^ true
  506. ! !
  507. !HLRenameClassCommand class methodsFor: 'accessing'!
  508. key
  509. ^ 'c'
  510. !
  511. label
  512. ^ 'Rename class'
  513. !
  514. menuLabel
  515. ^ 'Rename class...'
  516. ! !
  517. HLRenameCommand subclass: #HLRenamePackageCommand
  518. slots: {}
  519. package: 'Helios-Commands-Tools'!
  520. !HLRenamePackageCommand methodsFor: 'accessing'!
  521. category
  522. ^ 'Packages'
  523. !
  524. displayLabel
  525. ^ 'Rename package to:'
  526. ! !
  527. !HLRenamePackageCommand methodsFor: 'defaults'!
  528. defaultInput
  529. ^ self model selectedPackage name
  530. ! !
  531. !HLRenamePackageCommand methodsFor: 'executing'!
  532. execute
  533. self model renamePackageTo: self input
  534. ! !
  535. !HLRenamePackageCommand methodsFor: 'testing'!
  536. isActive
  537. ^ self model selectedPackage notNil
  538. !
  539. isInputRequired
  540. ^ true
  541. ! !
  542. !HLRenamePackageCommand class methodsFor: 'accessing'!
  543. key
  544. ^ 'p'
  545. !
  546. label
  547. ^ 'Rename package'
  548. !
  549. menuLabel
  550. ^ 'Rename package...'
  551. ! !
  552. HLRenameCommand subclass: #HLRenameProtocolCommand
  553. slots: {}
  554. package: 'Helios-Commands-Tools'!
  555. !HLRenameProtocolCommand methodsFor: 'accessing'!
  556. category
  557. ^ 'Protocols'
  558. !
  559. displayLabel
  560. ^ 'Rename protocol to:'
  561. ! !
  562. !HLRenameProtocolCommand methodsFor: 'defaults'!
  563. defaultInput
  564. ^ self model selectedProtocol
  565. ! !
  566. !HLRenameProtocolCommand methodsFor: 'executing'!
  567. execute
  568. self model renameProtocolTo: self input
  569. ! !
  570. !HLRenameProtocolCommand methodsFor: 'testing'!
  571. isActive
  572. ^ self model selectedProtocol notNil
  573. !
  574. isInputRequired
  575. ^ true
  576. ! !
  577. !HLRenameProtocolCommand class methodsFor: 'accessing'!
  578. key
  579. ^ 't'
  580. !
  581. label
  582. ^ 'Rename protocol'
  583. !
  584. menuLabel
  585. ^ 'Rename protocol...'
  586. ! !