IDE.st 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391
  1. Smalltalk createPackage: 'IDE'!
  2. Widget subclass: #ClassesList
  3. instanceVariableNames: 'browser ul nodes'
  4. package: 'IDE'!
  5. !ClassesList methodsFor: 'accessing'!
  6. browser
  7. ^ browser
  8. !
  9. browser: aBrowser
  10. browser := aBrowser
  11. !
  12. category
  13. ^ self browser selectedPackage
  14. !
  15. getNodes
  16. | classes children others |
  17. classes := self browser classes.
  18. children := #().
  19. others := #().
  20. classes do: [ :each |
  21. (classes includes: each superclass)
  22. ifFalse: [ children add: each ]
  23. ifTrue: [ others add: each ]].
  24. ^ children collect: [ :each |
  25. ClassesListNode on: each browser: self browser classes: others level: 0 ]
  26. !
  27. nodes
  28. nodes ifNil: [ nodes := self getNodes ].
  29. ^ nodes
  30. !
  31. resetNodes
  32. nodes := nil
  33. ! !
  34. !ClassesList methodsFor: 'rendering'!
  35. renderOn: html
  36. ul := html ul
  37. class: 'amber_column browser classes';
  38. yourself.
  39. self updateNodes
  40. !
  41. updateNodes
  42. ul contents: [ :html |
  43. self nodes do: [ :each |
  44. each renderOn: html ]]
  45. ! !
  46. !ClassesList class methodsFor: 'instance creation'!
  47. on: aBrowser
  48. ^ self new
  49. browser: aBrowser;
  50. yourself
  51. ! !
  52. Widget subclass: #ClassesListNode
  53. instanceVariableNames: 'browser theClass level nodes'
  54. package: 'IDE'!
  55. !ClassesListNode methodsFor: 'accessing'!
  56. browser
  57. ^ browser
  58. !
  59. browser: aBrowser
  60. browser := aBrowser
  61. !
  62. getNodesFrom: aCollection
  63. | children others |
  64. children := #().
  65. others := #().
  66. aCollection do: [ :each |
  67. (each superclass = self theClass)
  68. ifTrue: [ children add: each ]
  69. ifFalse: [ others add: each ]].
  70. nodes:= children collect: [ :each |
  71. ClassesListNode on: each browser: self browser classes: others level: self level + 1 ]
  72. !
  73. label
  74. | str |
  75. str := String new writeStream.
  76. self level timesRepeat: [
  77. str nextPutAll: '    ' ].
  78. str nextPutAll: self theClass name.
  79. ^ str contents
  80. !
  81. level
  82. ^ level
  83. !
  84. level: anInteger
  85. level := anInteger
  86. !
  87. nodes
  88. ^ nodes
  89. !
  90. theClass
  91. ^ theClass
  92. !
  93. theClass: aClass
  94. theClass := aClass
  95. ! !
  96. !ClassesListNode methodsFor: 'rendering'!
  97. renderOn: html
  98. | li cssClass |
  99. cssClass := ''.
  100. li := html li
  101. onClick: [ self browser selectClass: self theClass ].
  102. li asJQuery html: self label.
  103. self browser selectedClass = self theClass ifTrue: [
  104. cssClass := cssClass, ' selected' ].
  105. self theClass comment isEmpty ifFalse: [
  106. cssClass := cssClass, ' commented' ].
  107. li class: cssClass.
  108. self nodes do: [ :each |
  109. each renderOn: html ]
  110. ! !
  111. !ClassesListNode class methodsFor: 'instance creation'!
  112. on: aClass browser: aBrowser classes: aCollection level: anInteger
  113. ^ self new
  114. theClass: aClass;
  115. browser: aBrowser;
  116. level: anInteger;
  117. getNodesFrom: aCollection;
  118. yourself
  119. ! !
  120. Object subclass: #DebugErrorHandler
  121. instanceVariableNames: ''
  122. package: 'IDE'!
  123. !DebugErrorHandler methodsFor: 'error handling'!
  124. handleError: anError
  125. [ Debugger new
  126. error: anError;
  127. open ] on: Error do: [ :error |
  128. ErrorHandler new handleError: error ]
  129. ! !
  130. !DebugErrorHandler class methodsFor: 'initialization'!
  131. initialize
  132. ErrorHandler register: self new
  133. ! !
  134. Widget subclass: #SourceArea
  135. instanceVariableNames: 'editor div receiver onDoIt'
  136. package: 'IDE'!
  137. !SourceArea methodsFor: 'accessing'!
  138. currentLine
  139. ^ editor getLine: (editor getCursor line)
  140. !
  141. currentLineOrSelection
  142. ^ editor somethingSelected
  143. ifFalse: [ self currentLine ]
  144. ifTrue: [ self selection ]
  145. !
  146. editor
  147. ^ editor
  148. !
  149. onDoIt
  150. ^ onDoIt
  151. !
  152. onDoIt: aBlock
  153. onDoIt := aBlock
  154. !
  155. receiver
  156. ^ receiver ifNil: [ DoIt new ]
  157. !
  158. receiver: anObject
  159. receiver := anObject
  160. !
  161. selection
  162. ^ editor getSelection
  163. !
  164. setEditorOn: aTextarea
  165. <self['@editor'] = CodeMirror.fromTextArea(aTextarea, {
  166. theme: 'ide.codeMirrorTheme'._settingValueIfAbsent_('default'),
  167. mode: 'text/x-stsrc',
  168. lineNumbers: true,
  169. enterMode: 'flat',
  170. indentWithTabs: true,
  171. indentUnit: 4,
  172. matchBrackets: true,
  173. electricChars: false
  174. })>
  175. !
  176. val
  177. ^ editor getValue
  178. !
  179. val: aString
  180. editor setValue: aString
  181. ! !
  182. !SourceArea methodsFor: 'actions'!
  183. clear
  184. self val: ''
  185. !
  186. doIt
  187. | result |
  188. result := self eval: self currentLineOrSelection.
  189. self onDoIt ifNotNil: [ self onDoIt value ].
  190. ^ result
  191. !
  192. eval: aString
  193. | compiler |
  194. compiler := Compiler new.
  195. [ compiler parseExpression: aString ] on: Error do: [ :ex |
  196. ^ self alert: ex messageText ].
  197. ^ compiler evaluateExpression: aString on: self receiver
  198. !
  199. fileIn
  200. Importer new import: self currentLineOrSelection readStream
  201. !
  202. focus
  203. self editor focus.
  204. !
  205. handleKeyDown: anEvent
  206. <if(anEvent.ctrlKey) {
  207. if(anEvent.keyCode === 80) { //ctrl+p
  208. self._printIt();
  209. anEvent.preventDefault();
  210. return false;
  211. }
  212. if(anEvent.keyCode === 68) { //ctrl+d
  213. self._doIt();
  214. anEvent.preventDefault();
  215. return false;
  216. }
  217. if(anEvent.keyCode === 73) { //ctrl+i
  218. self._inspectIt();
  219. anEvent.preventDefault();
  220. return false;
  221. }
  222. }>
  223. !
  224. inspectIt
  225. self doIt inspect
  226. !
  227. print: aString
  228. | start stop currentLine |
  229. currentLine := (editor getCursor: false) line.
  230. start := HashedCollection new.
  231. start at: 'line' put: currentLine.
  232. start at: 'ch' put: (editor getCursor: false) ch.
  233. (editor getSelection) ifEmpty: [
  234. "select current line if selection is empty"
  235. start at: 'ch' put: (editor getLine: currentLine) size.
  236. editor setSelection: #{'line' -> currentLine. 'ch' -> 0} end: start.
  237. ].
  238. stop := HashedCollection new.
  239. stop at: 'line' put: currentLine.
  240. stop at: 'ch' put: ((start at: 'ch') + aString size + 2).
  241. editor replaceSelection: (editor getSelection, ' ', aString, ' ').
  242. editor setCursor: (editor getCursor: true).
  243. editor setSelection: stop end: start
  244. !
  245. printIt
  246. self print: self doIt printString.
  247. self focus.
  248. ! !
  249. !SourceArea methodsFor: 'events'!
  250. onKeyDown: aBlock
  251. div onKeyDown: aBlock
  252. !
  253. onKeyUp: aBlock
  254. div onKeyUp: aBlock
  255. ! !
  256. !SourceArea methodsFor: 'rendering'!
  257. renderOn: html
  258. | textarea |
  259. div := html div class: 'source'.
  260. div with: [ textarea := html textarea ].
  261. self setEditorOn: textarea element.
  262. div onKeyDown: [ :e | self handleKeyDown: e ]
  263. ! !
  264. !SourceArea class methodsFor: 'initialization'!
  265. initialize
  266. super initialize.
  267. self setupCodeMirror
  268. !
  269. setupCodeMirror
  270. < CodeMirror.keyMap["default"].fallthrough = ["basic"] >
  271. ! !
  272. Widget subclass: #TabManager
  273. instanceVariableNames: 'selectedTab tabs opened ul input'
  274. package: 'IDE'!
  275. !TabManager methodsFor: 'accessing'!
  276. labelFor: aWidget
  277. | label maxSize |
  278. maxSize := 15.
  279. label := aWidget label copyFrom: 0 to: (aWidget label size min: maxSize).
  280. aWidget label size > maxSize ifTrue: [
  281. label := label, '...' ].
  282. ^ label
  283. !
  284. tabs
  285. ^ tabs ifNil: [ tabs := Array new ]
  286. ! !
  287. !TabManager methodsFor: 'actions'!
  288. close
  289. opened ifTrue: [
  290. '#amber' asJQuery hide.
  291. ul asJQuery hide.
  292. selectedTab hide.
  293. self removeBodyMargin.
  294. 'body' asJQuery removeClass: 'amberBody'.
  295. opened := false ]
  296. !
  297. closeTab: aWidget
  298. self removeTab: aWidget.
  299. self selectTab: self tabs last.
  300. aWidget remove.
  301. self update
  302. !
  303. newBrowserTab
  304. Browser open
  305. !
  306. onResize: aBlock
  307. '#amber' asJQuery resizable: #{
  308. 'handles' -> 'n'.
  309. 'resize' -> aBlock.
  310. 'minHeight' -> 230
  311. }
  312. !
  313. onWindowResize: aBlock
  314. window asJQuery resize: aBlock
  315. !
  316. open
  317. opened ifFalse: [
  318. 'body' asJQuery addClass: 'amberBody'.
  319. '#amber' asJQuery show.
  320. ul asJQuery show.
  321. self updateBodyMargin.
  322. selectedTab show.
  323. opened := true ]
  324. !
  325. removeBodyMargin
  326. self setBodyMargin: 0
  327. !
  328. search: aString
  329. | searchedClass |
  330. searchedClass := Smalltalk globals at: aString.
  331. searchedClass isClass
  332. ifTrue: [ Browser openOn: searchedClass ]
  333. ifFalse: [ ReferencesBrowser search: aString ]
  334. !
  335. selectTab: aWidget
  336. self open.
  337. selectedTab := aWidget.
  338. self tabs do: [ :each |
  339. each hide ].
  340. aWidget show.
  341. self update
  342. !
  343. setBodyMargin: anInteger
  344. '.amberBody' asJQuery css: 'margin-bottom' put: anInteger asString, 'px'
  345. !
  346. updateBodyMargin
  347. self setBodyMargin: '#amber' asJQuery height
  348. !
  349. updatePosition
  350. '#amber' asJQuery
  351. css: 'top' put: '';
  352. css: 'bottom' put: '0px'
  353. ! !
  354. !TabManager methodsFor: 'adding/Removing'!
  355. addTab: aWidget
  356. self tabs add: aWidget.
  357. aWidget appendToJQuery: '#amber' asJQuery.
  358. aWidget hide
  359. !
  360. removeTab: aWidget
  361. self tabs remove: aWidget.
  362. self update
  363. ! !
  364. !TabManager methodsFor: 'initialization'!
  365. initialize
  366. super initialize.
  367. Inspector register: IDEInspector.
  368. opened := true.
  369. [ :html | html div id: 'amber' ] appendToJQuery: 'body' asJQuery.
  370. 'body' asJQuery
  371. addClass: 'amberBody'.
  372. self appendToJQuery: '#amber' asJQuery.
  373. self
  374. addTab: IDETranscript current;
  375. addTab: Workspace new;
  376. addTab: TestRunner new.
  377. self selectTab: self tabs last.
  378. self
  379. onResize: [ self updateBodyMargin; updatePosition ];
  380. onWindowResize: [ self updatePosition ]
  381. ! !
  382. !TabManager methodsFor: 'rendering'!
  383. renderOn: html
  384. html div id: 'logo'.
  385. self renderToolbarOn: html.
  386. ul := html ul
  387. id: 'amberTabs';
  388. yourself.
  389. self renderTabs
  390. !
  391. renderTabFor: aWidget on: html
  392. | li |
  393. li := html li.
  394. selectedTab = aWidget ifTrue: [
  395. li class: 'selected' ].
  396. li with: [
  397. html span class: 'ltab'.
  398. html span
  399. class: 'mtab';
  400. with: [
  401. aWidget canBeClosed ifTrue: [
  402. html span
  403. class: 'close';
  404. with: 'x';
  405. onClick: [ self closeTab: aWidget ]].
  406. html span with: (self labelFor: aWidget) ].
  407. html span class: 'rtab' ];
  408. onClick: [ self selectTab: aWidget ]
  409. !
  410. renderTabs
  411. ul contents: [ :html |
  412. self tabs do: [ :each |
  413. self renderTabFor: each on: html ].
  414. html li
  415. class: 'newtab';
  416. with: [
  417. html span class: 'ltab'.
  418. html span class: 'mtab'; with: ' + '.
  419. html span class: 'rtab' ];
  420. onClick: [ self newBrowserTab ]]
  421. !
  422. renderToolbarOn: html
  423. html div
  424. id: 'amber_toolbar';
  425. with: [
  426. input := html input
  427. class: 'implementors';
  428. yourself.
  429. input onKeyPress: [ :event |
  430. event keyCode = 13 ifTrue: [
  431. self search: input asJQuery val ]].
  432. html div id: 'amber_close'; onClick: [ self close ]]
  433. ! !
  434. !TabManager methodsFor: 'updating'!
  435. update
  436. self renderTabs
  437. ! !
  438. TabManager class instanceVariableNames: 'current'!
  439. !TabManager class methodsFor: 'actions'!
  440. toggleAmberIDE
  441. '#amber' asJQuery length = 0
  442. ifTrue: [ Browser open ]
  443. ifFalse: [
  444. ('#amber' asJQuery is: ':visible')
  445. ifTrue: [ TabManager current close ]
  446. ifFalse: [ TabManager current open ] ]
  447. ! !
  448. !TabManager class methodsFor: 'instance creation'!
  449. current
  450. ^ current ifNil: [ current := super new ]
  451. !
  452. new
  453. self shouldNotImplement
  454. ! !
  455. Widget subclass: #TabWidget
  456. instanceVariableNames: 'div'
  457. package: 'IDE'!
  458. !TabWidget methodsFor: 'accessing'!
  459. label
  460. self subclassResponsibility
  461. ! !
  462. !TabWidget methodsFor: 'actions'!
  463. close
  464. TabManager current closeTab: self
  465. !
  466. hide
  467. div asJQuery hide
  468. !
  469. open
  470. TabManager current addTab: self.
  471. TabManager current selectTab: self
  472. !
  473. remove
  474. div asJQuery remove
  475. !
  476. show
  477. div asJQuery show
  478. ! !
  479. !TabWidget methodsFor: 'rendering'!
  480. renderBoxOn: html
  481. !
  482. renderButtonsOn: html
  483. !
  484. renderOn: html
  485. div := html div
  486. class: 'amberTool';
  487. yourself.
  488. self renderTab
  489. !
  490. renderTab
  491. div contents: [ :html |
  492. html div
  493. class: 'amber_box';
  494. with: [ self renderBoxOn: html ].
  495. html div
  496. class: 'amber_buttons';
  497. with: [ self renderButtonsOn: html ]]
  498. !
  499. update
  500. self renderTab
  501. ! !
  502. !TabWidget methodsFor: 'testing'!
  503. canBeClosed
  504. ^ false
  505. ! !
  506. !TabWidget class methodsFor: 'instance creation'!
  507. open
  508. ^ self new open
  509. ! !
  510. TabWidget subclass: #Browser
  511. instanceVariableNames: 'selectedPackage selectedClass selectedProtocol selectedMethod packagesList classesList protocolsList methodsList sourceArea tabsList selectedTab saveButton classButtons methodButtons unsavedChanges'
  512. package: 'IDE'!
  513. !Browser methodsFor: 'accessing'!
  514. classCommentSource
  515. ^ selectedClass comment
  516. !
  517. classDeclarationSource
  518. | stream |
  519. stream := '' writeStream.
  520. selectedClass ifNil: [ ^ self classDeclarationTemplate ].
  521. stream
  522. nextPutAll: selectedClass superclass asString;
  523. nextPutAll: ' subclass: #';
  524. nextPutAll: selectedClass name;
  525. nextPutAll: String lf, String tab;
  526. nextPutAll: 'instanceVariableNames: '''.
  527. selectedClass instanceVariableNames
  528. do: [ :each | stream nextPutAll: each ]
  529. separatedBy: [ stream nextPutAll: ' ' ].
  530. stream
  531. nextPutAll: '''', String lf, String tab;
  532. nextPutAll: 'package: ''';
  533. nextPutAll: selectedClass category;
  534. nextPutAll: ''''.
  535. ^ stream contents
  536. !
  537. classDeclarationTemplate
  538. ^ 'Object subclass: #NameOfSubclass
  539. instanceVariableNames: ''''
  540. package: ''', self selectedPackage, ''''
  541. !
  542. classes
  543. ^ ((Smalltalk classes
  544. select: [ :each | each category = selectedPackage ])
  545. sort: [ :a :b | a name < b name ]) asSet
  546. !
  547. declarationSource
  548. ^ selectedTab = #instance
  549. ifTrue: [ self classDeclarationSource ]
  550. ifFalse: [ self metaclassDeclarationSource ]
  551. !
  552. dummyMethodSource
  553. ^ 'messageSelectorAndArgumentNames
  554. "comment stating purpose of message"
  555. | temporary variable names |
  556. statements'
  557. !
  558. label
  559. ^ selectedClass
  560. ifNil: [ 'Browser (nil)' ]
  561. ifNotNil: [ 'Browser: ', selectedClass name ]
  562. !
  563. metaclassDeclarationSource
  564. | stream |
  565. stream := '' writeStream.
  566. selectedClass ifNotNil: [
  567. stream
  568. nextPutAll: selectedClass asString;
  569. nextPutAll: ' class ';
  570. nextPutAll: 'instanceVariableNames: '''.
  571. selectedClass class instanceVariableNames
  572. do: [ :each | stream nextPutAll: each ]
  573. separatedBy: [ stream nextPutAll: ' ' ].
  574. stream nextPutAll: '''' ].
  575. ^ stream contents
  576. !
  577. methodSource
  578. ^ selectedMethod
  579. ifNil: [ self dummyMethodSource ]
  580. ifNotNil: [ selectedMethod source ]
  581. !
  582. methods
  583. | klass |
  584. selectedTab = #comment ifTrue: [ ^ #() ].
  585. selectedClass ifNotNil: [
  586. klass := selectedTab = #instance
  587. ifTrue: [ selectedClass ]
  588. ifFalse: [ selectedClass class ]].
  589. ^ (selectedProtocol
  590. ifNil: [
  591. klass
  592. ifNil: [ #() ]
  593. ifNotNil: [ klass methodDictionary values ]]
  594. ifNotNil: [
  595. klass methodsInProtocol: selectedProtocol ])
  596. sort: [ :a :b | a selector < b selector ]
  597. !
  598. packages
  599. | packages |
  600. packages := Array new.
  601. Smalltalk classes do: [ :each |
  602. (packages includes: each category) ifFalse: [
  603. packages add: each category ]].
  604. ^ packages sort
  605. !
  606. protocols
  607. | klass |
  608. selectedClass ifNotNil: [
  609. selectedTab = #comment ifTrue: [ ^ #() ].
  610. klass := selectedTab = #instance
  611. ifTrue: [ selectedClass ]
  612. ifFalse: [ selectedClass class ].
  613. klass methodDictionary isEmpty ifTrue: [
  614. ^ Array with: 'not yet classified' ].
  615. ^ klass protocols ].
  616. ^ Array new
  617. !
  618. selectedClass
  619. ^ selectedClass
  620. !
  621. selectedPackage
  622. ^ selectedPackage
  623. !
  624. source
  625. selectedTab = #comment ifFalse: [
  626. ^ (selectedProtocol notNil or: [ selectedMethod notNil ])
  627. ifFalse: [ self declarationSource ]
  628. ifTrue: [ self methodSource ]].
  629. ^ selectedClass
  630. ifNil: [ '' ]
  631. ifNotNil: [ self classCommentSource ]
  632. ! !
  633. !Browser methodsFor: 'actions'!
  634. addInstanceVariableNamed: aString toClass: aClass
  635. ClassBuilder new
  636. addSubclassOf: aClass superclass
  637. named: aClass name
  638. instanceVariableNames: (aClass instanceVariableNames copy add: aString; yourself)
  639. package: aClass package name
  640. !
  641. addNewClass
  642. | className |
  643. className := self prompt: 'New class'.
  644. (className notNil and: [ className notEmpty ]) ifTrue: [
  645. Object subclass: className instanceVariableNames: '' package: self selectedPackage.
  646. self
  647. resetClassesList;
  648. updateClassesList.
  649. self selectClass: (Smalltalk globals at: className) ]
  650. !
  651. addNewProtocol
  652. | newProtocol |
  653. newProtocol := self prompt: 'New method protocol'.
  654. (newProtocol notNil and: [ newProtocol notEmpty ]) ifTrue: [
  655. selectedMethod protocol: newProtocol.
  656. self setMethodProtocol: newProtocol ]
  657. !
  658. cancelChanges
  659. ^ unsavedChanges
  660. ifTrue: [ self confirm: 'Cancel changes?' ]
  661. ifFalse: [ true ]
  662. !
  663. commitPackage
  664. selectedPackage ifNotNil: [
  665. (Package named: selectedPackage) commit ]
  666. !
  667. compile
  668. | currentEditLine |
  669. self disableSaveButton.
  670. currentEditLine := sourceArea editor getCursor.
  671. selectedTab = #comment
  672. ifTrue: [
  673. selectedClass ifNotNil: [
  674. self compileClassComment ]]
  675. ifFalse: [
  676. (selectedProtocol notNil or: [ selectedMethod notNil ])
  677. ifFalse: [ self compileDefinition ]
  678. ifTrue: [ self compileMethodDefinition ]].
  679. sourceArea editor setCursor: currentEditLine.
  680. !
  681. compileClassComment
  682. selectedClass comment: sourceArea val
  683. !
  684. compileDefinition
  685. | newClass |
  686. newClass := Compiler new evaluateExpression: sourceArea val.
  687. self
  688. resetClassesList;
  689. updateCategoriesList;
  690. updateClassesList.
  691. self selectClass: newClass
  692. !
  693. compileMethodDefinition
  694. selectedTab = #instance
  695. ifTrue: [ self compileMethodDefinitionFor: selectedClass ]
  696. ifFalse: [ self compileMethodDefinitionFor: selectedClass class ]
  697. !
  698. compileMethodDefinitionFor: aClass
  699. | compiler method source node |
  700. source := sourceArea val.
  701. selectedProtocol ifNil: [ selectedProtocol := selectedMethod protocol ].
  702. compiler := Compiler new.
  703. compiler source: source.
  704. node := compiler parse: source.
  705. node isParseFailure ifTrue: [
  706. ^ self alert: 'PARSE ERROR: ', node reason, ', position: ', node position asString ].
  707. compiler currentClass: aClass.
  708. method := compiler eval: (compiler compileNode: node).
  709. compiler unknownVariables do: [ :each |
  710. "Do not try to redeclare javascript's objects"
  711. (PlatformInterface existsGlobal: each) ifFalse: [
  712. (self confirm: 'Declare ''', each, ''' as instance variable?') ifTrue: [
  713. self addInstanceVariableNamed: each toClass: aClass.
  714. ^ self compileMethodDefinitionFor: aClass ]] ].
  715. ClassBuilder new installMethod: method forClass: aClass protocol: selectedProtocol.
  716. self updateMethodsList.
  717. self selectMethod: method
  718. !
  719. copyClass
  720. | className |
  721. className := self prompt: 'Copy class'.
  722. (className notNil and: [ className notEmpty ]) ifTrue: [
  723. ClassBuilder new copyClass: self selectedClass named: className.
  724. self
  725. resetClassesList;
  726. updateClassesList.
  727. self selectClass: (Smalltalk globals at: className) ]
  728. !
  729. disableSaveButton
  730. saveButton ifNotNil: [
  731. saveButton at: 'disabled' put: true ].
  732. unsavedChanges := false
  733. !
  734. handleSourceAreaKeyDown: anEvent
  735. <if(anEvent.ctrlKey) {
  736. if(anEvent.keyCode === 83) { //ctrl+s
  737. self._compile();
  738. anEvent.preventDefault();
  739. return false;
  740. }
  741. }
  742. >
  743. !
  744. hideClassButtons
  745. classButtons asJQuery hide
  746. !
  747. hideMethodButtons
  748. methodButtons asJQuery hide
  749. !
  750. removeClass
  751. (self confirm: 'Do you really want to remove ', selectedClass name, '?')
  752. ifTrue: [
  753. Smalltalk removeClass: selectedClass.
  754. self resetClassesList.
  755. self selectClass: nil ]
  756. !
  757. removeMethod
  758. self cancelChanges ifTrue: [
  759. (self confirm: 'Do you really want to remove #', selectedMethod selector, '?')
  760. ifTrue: [
  761. selectedTab = #instance
  762. ifTrue: [ selectedClass removeCompiledMethod: selectedMethod ]
  763. ifFalse: [ selectedClass class removeCompiledMethod: selectedMethod ].
  764. self selectMethod: nil ]]
  765. !
  766. removePackage
  767. (self confirm: 'Do you really want to remove the whole package ', selectedPackage, ' with all its classes?')
  768. ifTrue: [
  769. Smalltalk removePackage: selectedPackage.
  770. self updateCategoriesList ]
  771. !
  772. renameClass
  773. | newName |
  774. newName := self prompt: 'Rename class ', selectedClass name.
  775. (newName notNil and: [ newName notEmpty ]) ifTrue: [
  776. selectedClass rename: newName.
  777. self
  778. updateClassesList;
  779. updateSourceAndButtons ]
  780. !
  781. renamePackage
  782. | newName |
  783. newName := self prompt: 'Rename package ', selectedPackage.
  784. newName ifNotNil: [
  785. newName notEmpty ifTrue: [
  786. Smalltalk renamePackage: selectedPackage to: newName.
  787. self updateCategoriesList ]]
  788. !
  789. search: aString
  790. self cancelChanges ifTrue: [ | searchedClass |
  791. searchedClass := Smalltalk globals at: aString.
  792. searchedClass isClass
  793. ifTrue: [ self class openOn: searchedClass ]
  794. ifFalse: [ self searchReferencesOf: aString ]]
  795. !
  796. searchClassReferences
  797. ReferencesBrowser search: selectedClass name
  798. !
  799. searchReferencesOf: aString
  800. ReferencesBrowser search: aString
  801. !
  802. selectCategory: aCategory
  803. self cancelChanges ifTrue: [
  804. selectedPackage := aCategory.
  805. selectedClass := selectedProtocol := selectedMethod := nil.
  806. self resetClassesList.
  807. self
  808. updateCategoriesList;
  809. updateClassesList;
  810. updateProtocolsList;
  811. updateMethodsList;
  812. updateSourceAndButtons ]
  813. !
  814. selectClass: aClass
  815. self cancelChanges ifTrue: [
  816. selectedClass := aClass.
  817. selectedProtocol := selectedMethod := nil.
  818. self
  819. updateClassesList;
  820. updateProtocolsList;
  821. updateMethodsList;
  822. updateSourceAndButtons ]
  823. !
  824. selectMethod: aMethod
  825. self cancelChanges ifTrue: [
  826. selectedMethod := aMethod.
  827. self
  828. updateProtocolsList;
  829. updateMethodsList;
  830. updateSourceAndButtons ]
  831. !
  832. selectProtocol: aString
  833. self cancelChanges ifTrue: [
  834. selectedProtocol := aString.
  835. selectedMethod := nil.
  836. self
  837. updateProtocolsList;
  838. updateMethodsList;
  839. updateSourceAndButtons ]
  840. !
  841. selectTab: aString
  842. self cancelChanges ifTrue: [
  843. selectedTab := aString.
  844. self selectProtocol: nil.
  845. self updateTabsList ]
  846. !
  847. setMethodProtocol: aString
  848. self cancelChanges ifTrue: [
  849. (self protocols includes: aString)
  850. ifFalse: [ self addNewProtocol ]
  851. ifTrue: [
  852. selectedMethod protocol: aString.
  853. selectedProtocol := aString.
  854. selectedMethod := selectedMethod.
  855. self
  856. updateProtocolsList;
  857. updateMethodsList;
  858. updateSourceAndButtons ]]
  859. !
  860. showClassButtons
  861. classButtons asJQuery show
  862. !
  863. showMethodButtons
  864. methodButtons asJQuery show
  865. ! !
  866. !Browser methodsFor: 'initialization'!
  867. initialize
  868. super initialize.
  869. selectedTab := #instance.
  870. selectedPackage := self packages first.
  871. unsavedChanges := false
  872. ! !
  873. !Browser methodsFor: 'rendering'!
  874. renderBottomPanelOn: html
  875. html div
  876. class: 'amber_sourceCode';
  877. with: [
  878. sourceArea := SourceArea new.
  879. sourceArea renderOn: html.
  880. sourceArea onKeyDown: [ :e |
  881. self handleSourceAreaKeyDown: e ].
  882. sourceArea onKeyUp: [ self updateStatus ]]
  883. !
  884. renderBoxOn: html
  885. self
  886. renderTopPanelOn: html;
  887. renderTabsOn: html;
  888. renderBottomPanelOn: html
  889. !
  890. renderButtonsOn: html
  891. saveButton := html button.
  892. saveButton
  893. with: 'Save';
  894. onClick: [ self compile ].
  895. methodButtons := html span.
  896. classButtons := html span.
  897. html div
  898. class: 'right';
  899. with: [
  900. html button
  901. with: 'DoIt';
  902. onClick: [ sourceArea doIt ].
  903. html button
  904. with: 'PrintIt';
  905. onClick: [ sourceArea printIt ].
  906. html button with: 'InspectIt';
  907. onClick: [ sourceArea inspectIt ]].
  908. self updateSourceAndButtons
  909. !
  910. renderTabsOn: html
  911. tabsList := html ul class: 'amber_tabs amber_browser'.
  912. self updateTabsList.
  913. !
  914. renderTopPanelOn: html
  915. html div
  916. class: 'top';
  917. with: [
  918. packagesList := html ul class: 'amber_column browser packages'.
  919. html div class: 'amber_packagesButtons'; with: [
  920. html button
  921. title: 'Commit classes in this package to disk';
  922. onClick: [ self commitPackage ];
  923. with: 'Commit'.
  924. html button
  925. title: 'Rename package';
  926. onClick: [ self renamePackage ];
  927. with: 'Rename'.
  928. html button
  929. title: 'Remove this package from the system';
  930. onClick: [ self removePackage ];
  931. with: 'Remove' ].
  932. classesList := ClassesList on: self.
  933. classesList renderOn: html.
  934. protocolsList := html ul class: 'amber_column browser protocols'.
  935. methodsList := html ul class: 'amber_column browser methods'.
  936. self
  937. updateCategoriesList;
  938. updateClassesList;
  939. updateProtocolsList;
  940. updateMethodsList.
  941. html div class: 'amber_clear' ]
  942. ! !
  943. !Browser methodsFor: 'testing'!
  944. canBeClosed
  945. ^ true
  946. ! !
  947. !Browser methodsFor: 'updating'!
  948. resetClassesList
  949. classesList resetNodes
  950. !
  951. updateCategoriesList
  952. packagesList contents: [ :html |
  953. self packages do: [ :each || li label |
  954. each isEmpty
  955. ifTrue: [ label := 'Unclassified' ]
  956. ifFalse: [ label := each ].
  957. li := html li.
  958. selectedPackage = each ifTrue: [
  959. li class: 'selected' ].
  960. li
  961. with: label;
  962. onClick: [ self selectCategory: each ]] ]
  963. !
  964. updateClassesList
  965. TabManager current update.
  966. classesList updateNodes
  967. !
  968. updateMethodsList
  969. methodsList contents: [ :html |
  970. self methods do: [ :each || li |
  971. li := html li.
  972. selectedMethod = each ifTrue: [
  973. li class: 'selected' ].
  974. li
  975. with: each selector;
  976. onClick: [ self selectMethod: each ]] ]
  977. !
  978. updateProtocolsList
  979. protocolsList contents: [ :html |
  980. self protocols do: [ :each || li |
  981. li := html li.
  982. selectedProtocol = each ifTrue: [
  983. li class: 'selected' ].
  984. li
  985. with: each;
  986. onClick: [ self selectProtocol: each ]] ]
  987. !
  988. updateSourceAndButtons
  989. | currentProtocol |
  990. self disableSaveButton.
  991. classButtons contents: [ :html |
  992. html button
  993. title: 'Create a new class';
  994. onClick: [ self addNewClass ];
  995. with: 'New class'.
  996. html button
  997. with: 'Rename class';
  998. onClick: [ self renameClass ].
  999. html button
  1000. with: 'Copy class';
  1001. onClick: [ self copyClass ].
  1002. html button
  1003. with: 'Remove class';
  1004. onClick: [ self removeClass ].
  1005. html button
  1006. with: 'References';
  1007. onClick: [ self searchClassReferences ]].
  1008. methodButtons contents: [ :html | | protocolSelect referencesSelect |
  1009. html button
  1010. with: 'Remove method';
  1011. onClick: [ self removeMethod ].
  1012. protocolSelect := html select.
  1013. protocolSelect
  1014. onChange: [ self setMethodProtocol: protocolSelect asJQuery val ];
  1015. with: [
  1016. html option
  1017. with: 'Method protocol';
  1018. at: 'disabled' put: 'disabled'.
  1019. html option
  1020. class: 'important';
  1021. with: 'New...'.
  1022. currentProtocol := selectedProtocol.
  1023. (currentProtocol isNil and: [ selectedMethod notNil ])
  1024. ifTrue: [ currentProtocol := selectedMethod category ].
  1025. self protocols do: [ :each | | option |
  1026. option := html option with: each.
  1027. currentProtocol = each ifTrue: [ option at: 'selected' put: 'selected' ] ] ].
  1028. selectedMethod isNil ifFalse: [
  1029. referencesSelect := html select.
  1030. referencesSelect
  1031. onChange: [ self searchReferencesOf: referencesSelect asJQuery val ];
  1032. with: [ |option|
  1033. html option
  1034. with: 'References';
  1035. at: 'disabled' put: 'disabled';
  1036. at: 'selected' put: 'selected'.
  1037. html option
  1038. class: 'important';
  1039. with: selectedMethod selector.
  1040. selectedMethod messageSends sorted do: [ :each |
  1041. html option with: each ]] ]].
  1042. selectedMethod isNil
  1043. ifTrue: [
  1044. self hideMethodButtons.
  1045. (selectedClass isNil or: [ selectedProtocol notNil ])
  1046. ifTrue: [ self hideClassButtons ]
  1047. ifFalse: [ self showClassButtons ]]
  1048. ifFalse: [
  1049. self hideClassButtons.
  1050. self showMethodButtons ].
  1051. sourceArea val: self source
  1052. !
  1053. updateStatus
  1054. sourceArea val = self source
  1055. ifTrue: [
  1056. saveButton ifNotNil: [
  1057. saveButton at: 'disabled' put: true ].
  1058. unsavedChanges := false ]
  1059. ifFalse: [
  1060. saveButton ifNotNil: [
  1061. saveButton removeAt: 'disabled' ].
  1062. unsavedChanges := true ]
  1063. !
  1064. updateTabsList
  1065. tabsList contents: [ :html || li |
  1066. li := html li.
  1067. selectedTab = #instance ifTrue: [ li class: 'selected' ].
  1068. li
  1069. with: [
  1070. html span class: 'ltab'.
  1071. html span class: 'mtab'; with: 'Instance'.
  1072. html span class: 'rtab' ];
  1073. onClick: [ self selectTab: #instance ].
  1074. li := html li.
  1075. selectedTab = #class ifTrue: [ li class: 'selected' ].
  1076. li
  1077. with: [
  1078. html span class: 'ltab'.
  1079. html span class: 'mtab'; with: 'Class'.
  1080. html span class: 'rtab' ];
  1081. onClick: [ self selectTab: #class ].
  1082. li := html li.
  1083. selectedTab = #comment ifTrue: [ li class: 'selected' ].
  1084. li
  1085. with: [
  1086. html span class: 'ltab'.
  1087. html span class: 'mtab'; with: 'Comment'.
  1088. html span class: 'rtab' ];
  1089. onClick: [ self selectTab: #comment ]]
  1090. ! !
  1091. !Browser class methodsFor: 'convenience'!
  1092. open
  1093. self new open
  1094. !
  1095. openOn: aClass
  1096. ^ self new
  1097. open;
  1098. selectCategory: aClass category;
  1099. selectClass: aClass
  1100. ! !
  1101. TabWidget subclass: #Debugger
  1102. instanceVariableNames: 'error selectedContext sourceArea ul ul2 inspector saveButton unsavedChanges selectedVariable selectedVariableName inspectButton'
  1103. package: 'IDE'!
  1104. !Debugger methodsFor: 'accessing'!
  1105. allVariables
  1106. | all |
  1107. all := Dictionary new.
  1108. self receiver class allInstanceVariableNames do: [ :each |
  1109. all at: each put: (self receiver instVarAt: each) ].
  1110. selectedContext locals keysAndValuesDo: [ :key :value |
  1111. all at: key put: value ].
  1112. ^ all
  1113. !
  1114. error
  1115. ^ error
  1116. !
  1117. error: anError
  1118. error := anError
  1119. !
  1120. label
  1121. ^ '[ Debugger ]'
  1122. !
  1123. method
  1124. ^ selectedContext method
  1125. !
  1126. receiver
  1127. ^ selectedContext receiver
  1128. !
  1129. source
  1130. ^ self method
  1131. ifNil: [ 'Method doesn''t exist!!' ]
  1132. ifNotNil: [ self method source ]
  1133. ! !
  1134. !Debugger methodsFor: 'actions'!
  1135. inspectSelectedVariable
  1136. selectedVariable inspect
  1137. !
  1138. proceed
  1139. self close.
  1140. selectedContext receiver perform: selectedContext selector withArguments: selectedContext temps
  1141. !
  1142. save
  1143. | protocol |
  1144. protocol := (selectedContext receiver class methodDictionary at: selectedContext selector) category.
  1145. selectedContext receiver class compile: sourceArea val category: protocol.
  1146. self updateStatus
  1147. !
  1148. selectContext: aContext
  1149. selectedContext := aContext.
  1150. selectedVariable := nil.
  1151. selectedVariableName := nil.
  1152. self
  1153. updateContextsList;
  1154. updateSourceArea;
  1155. updateInspector;
  1156. updateVariablesList;
  1157. updateStatus
  1158. !
  1159. selectVariable: anObject named: aString
  1160. selectedVariable := anObject.
  1161. selectedVariableName := aString.
  1162. inspector contents: [ :html | html with: anObject printString ].
  1163. self updateVariablesList
  1164. ! !
  1165. !Debugger methodsFor: 'initialization'!
  1166. initialize
  1167. super initialize.
  1168. unsavedChanges = false
  1169. ! !
  1170. !Debugger methodsFor: 'rendering'!
  1171. renderBottomPanelOn: html
  1172. html div
  1173. class: 'amber_sourceCode debugger';
  1174. with: [
  1175. sourceArea := SourceArea new.
  1176. sourceArea renderOn: html ].
  1177. ul2 := html ul class: 'amber_column debugger variables'.
  1178. inspector := html div class: 'amber_column debugger inspector'.
  1179. sourceArea
  1180. onKeyUp: [ self updateStatus ]
  1181. !
  1182. renderBoxOn: html
  1183. self
  1184. renderTopPanelOn: html;
  1185. renderBottomPanelOn: html
  1186. !
  1187. renderButtonsOn: html
  1188. saveButton := html button
  1189. with: 'Save';
  1190. onClick: [ self save ].
  1191. html button
  1192. with: 'DoIt';
  1193. onClick: [ sourceArea doIt ].
  1194. html button
  1195. with: 'PrintIt';
  1196. onClick: [ sourceArea printIt ].
  1197. html button
  1198. with: 'InspectIt';
  1199. onClick: [ sourceArea inspectIt ].
  1200. html button
  1201. with: 'Proceed';
  1202. onClick: [ self proceed ].
  1203. html button
  1204. with: 'Abandon';
  1205. onClick: [ self close ].
  1206. inspectButton := html button
  1207. class: 'amber_button debugger inspect';
  1208. with: 'Inspect';
  1209. onClick: [ self inspectSelectedVariable ].
  1210. self
  1211. updateSourceArea;
  1212. updateStatus;
  1213. updateVariablesList;
  1214. updateInspector
  1215. !
  1216. renderContext: aContext on: html
  1217. | li |
  1218. li := html li.
  1219. selectedContext = aContext ifTrue: [
  1220. li class: 'selected' ].
  1221. li
  1222. with: aContext asString;
  1223. onClick: [ self selectContext: aContext ].
  1224. aContext outerContext ifNotNil: [ self renderContext: aContext outerContext on: html ]
  1225. !
  1226. renderTopPanelOn: html
  1227. selectedContext := self error context.
  1228. html div
  1229. class: 'top';
  1230. with: [
  1231. html div
  1232. class: 'label';
  1233. with: self error messageText.
  1234. ul := html ul
  1235. class: 'amber_column debugger contexts';
  1236. with: [ self renderContext: self error context on: html ]]
  1237. ! !
  1238. !Debugger methodsFor: 'testing'!
  1239. canBeClosed
  1240. ^ true
  1241. ! !
  1242. !Debugger methodsFor: 'updating'!
  1243. updateContextsList
  1244. ul contents: [ :html |
  1245. self renderContext: self error context on: html ]
  1246. !
  1247. updateInspector
  1248. inspector contents: [ :html | ]
  1249. !
  1250. updateSourceArea
  1251. sourceArea val: self source
  1252. !
  1253. updateStatus
  1254. sourceArea val = self source
  1255. ifTrue: [
  1256. saveButton ifNotNil: [
  1257. saveButton at: 'disabled' put: true ].
  1258. unsavedChanges := false ]
  1259. ifFalse: [
  1260. saveButton ifNotNil: [
  1261. saveButton removeAt: 'disabled' ].
  1262. unsavedChanges := true ]
  1263. !
  1264. updateVariablesList
  1265. ul2 contents: [ :html | | li |
  1266. li := html li
  1267. with: 'self';
  1268. onClick: [ self selectVariable: self receiver named: 'self' ].
  1269. selectedVariableName = 'self' ifTrue: [ li class: 'selected' ].
  1270. self allVariables keysAndValuesDo: [ :key :value |
  1271. li := html li
  1272. with: key;
  1273. onClick: [ self selectVariable: value named: key ].
  1274. selectedVariableName = key ifTrue: [
  1275. li class: 'selected' ] ] ].
  1276. selectedVariable
  1277. ifNil: [ inspectButton at: 'disabled' put: true ]
  1278. ifNotNil: [ inspectButton removeAt: 'disabled' ]
  1279. ! !
  1280. TabWidget subclass: #IDEInspector
  1281. instanceVariableNames: 'label variables object selectedVariable variablesList valueTextarea diveButton sourceArea'
  1282. package: 'IDE'!
  1283. !IDEInspector methodsFor: 'accessing'!
  1284. label
  1285. ^ label ifNil: [ 'Inspector (nil)' ]
  1286. !
  1287. selectedVariable
  1288. ^ selectedVariable
  1289. !
  1290. selectedVariable: aString
  1291. selectedVariable := aString
  1292. !
  1293. setLabel: aString
  1294. label := aString
  1295. !
  1296. setVariables: aCollection
  1297. variables := aCollection
  1298. !
  1299. sourceArea
  1300. ^ sourceArea
  1301. !
  1302. variables
  1303. ^ variables
  1304. ! !
  1305. !IDEInspector methodsFor: 'actions'!
  1306. dive
  1307. (self variables at: self selectedVariable) inspect
  1308. !
  1309. inspect: anObject
  1310. object := anObject.
  1311. variables := #().
  1312. object inspectOn: self
  1313. !
  1314. refresh
  1315. self
  1316. inspect: object;
  1317. updateVariablesList;
  1318. updateValueTextarea
  1319. ! !
  1320. !IDEInspector methodsFor: 'rendering'!
  1321. renderBottomPanelOn: html
  1322. html div
  1323. class: 'amber_sourceCode';
  1324. with: [
  1325. sourceArea := SourceArea new
  1326. receiver: object;
  1327. onDoIt: [ self refresh ];
  1328. yourself.
  1329. sourceArea renderOn: html ]
  1330. !
  1331. renderBoxOn: html
  1332. self
  1333. renderTopPanelOn: html;
  1334. renderBottomPanelOn: html
  1335. !
  1336. renderButtonsOn: html
  1337. html button
  1338. with: 'DoIt';
  1339. onClick: [ self sourceArea doIt ].
  1340. html button
  1341. with: 'PrintIt';
  1342. onClick: [ self sourceArea printIt ].
  1343. html button
  1344. with: 'InspectIt';
  1345. onClick: [ self sourceArea inspectIt ].
  1346. self updateButtons
  1347. !
  1348. renderTopPanelOn: html
  1349. html div
  1350. class: 'top';
  1351. with: [
  1352. variablesList := html ul class: 'amber_column variables'.
  1353. valueTextarea := html textarea class: 'amber_column value'; at: 'readonly' put: 'readonly'; yourself.
  1354. html div class: 'amber_tabs inspector'; with: [
  1355. html button
  1356. class: 'amber_button inspector refresh';
  1357. with: 'Refresh';
  1358. onClick: [ self refresh ].
  1359. diveButton := html button
  1360. class: 'amber_button inspector dive';
  1361. with: 'Dive';
  1362. onClick: [ self dive ]].
  1363. html div class: 'amber_clear' ].
  1364. self
  1365. updateVariablesList;
  1366. updateValueTextarea.
  1367. ! !
  1368. !IDEInspector methodsFor: 'testing'!
  1369. canBeClosed
  1370. ^ true
  1371. ! !
  1372. !IDEInspector methodsFor: 'updating'!
  1373. selectVariable: aString
  1374. self selectedVariable: aString.
  1375. self
  1376. updateVariablesList;
  1377. updateValueTextarea;
  1378. updateButtons
  1379. !
  1380. updateButtons
  1381. (self selectedVariable notNil and: [ (self variables at: self selectedVariable) notNil ])
  1382. ifFalse: [ diveButton at: 'disabled' put: true ]
  1383. ifTrue: [ diveButton removeAt: 'disabled' ]
  1384. !
  1385. updateValueTextarea
  1386. valueTextarea asJQuery val: (self selectedVariable isNil
  1387. ifTrue: [ '' ]
  1388. ifFalse: [ (self variables at: self selectedVariable) printString ])
  1389. !
  1390. updateVariablesList
  1391. variablesList contents: [ :html |
  1392. self variables keysDo: [ :each || li |
  1393. li := html li.
  1394. li
  1395. with: each;
  1396. onClick: [ self selectVariable: each ].
  1397. self selectedVariable = each ifTrue: [
  1398. li class: 'selected' ]] ]
  1399. ! !
  1400. !IDEInspector class methodsFor: 'instance creation'!
  1401. inspect: anObject
  1402. ^ self new
  1403. inspect: anObject;
  1404. open;
  1405. yourself
  1406. !
  1407. on: anObject
  1408. ^ self new
  1409. inspect: anObject;
  1410. yourself
  1411. ! !
  1412. TabWidget subclass: #IDETranscript
  1413. instanceVariableNames: 'textarea'
  1414. package: 'IDE'!
  1415. !IDETranscript methodsFor: 'accessing'!
  1416. label
  1417. ^ 'Transcript'
  1418. ! !
  1419. !IDETranscript methodsFor: 'actions'!
  1420. clear
  1421. textarea asJQuery val: ''
  1422. !
  1423. cr
  1424. textarea asJQuery val: textarea asJQuery val, String cr.
  1425. !
  1426. open
  1427. TabManager current
  1428. open;
  1429. selectTab: self
  1430. !
  1431. show: anObject
  1432. textarea ifNil: [ self open ].
  1433. textarea asJQuery val: textarea asJQuery val, anObject asString.
  1434. ! !
  1435. !IDETranscript methodsFor: 'rendering'!
  1436. renderBoxOn: html
  1437. textarea := html textarea.
  1438. textarea
  1439. class: 'amber_transcript';
  1440. at: 'spellcheck' put: 'false'
  1441. !
  1442. renderButtonsOn: html
  1443. html button
  1444. with: 'Clear transcript';
  1445. onClick: [ self clear ]
  1446. ! !
  1447. IDETranscript class instanceVariableNames: 'current'!
  1448. !IDETranscript class methodsFor: 'initialization'!
  1449. initialize
  1450. Transcript register: self current
  1451. ! !
  1452. !IDETranscript class methodsFor: 'instance creation'!
  1453. current
  1454. ^ current ifNil: [ current := super new ]
  1455. !
  1456. new
  1457. self shouldNotImplement
  1458. !
  1459. open
  1460. TabManager current
  1461. open;
  1462. selectTab: self current
  1463. ! !
  1464. TabWidget subclass: #ProgressBar
  1465. instanceVariableNames: 'percent progressDiv div'
  1466. package: 'IDE'!
  1467. !ProgressBar methodsFor: 'accessing'!
  1468. percent
  1469. ^ percent ifNil: [ 0 ]
  1470. !
  1471. percent: aNumber
  1472. percent := aNumber
  1473. ! !
  1474. !ProgressBar methodsFor: 'rendering'!
  1475. renderOn: html
  1476. div := html div
  1477. class: 'progress_bar';
  1478. yourself.
  1479. self renderProgressBar
  1480. !
  1481. renderProgressBar
  1482. div contents: [ :html |
  1483. html div
  1484. class: 'progress';
  1485. style: 'width:', self percent asString, '%' ]
  1486. ! !
  1487. !ProgressBar methodsFor: 'updating'!
  1488. updatePercent: aNumber
  1489. self percent: aNumber.
  1490. self renderProgressBar
  1491. ! !
  1492. TabWidget subclass: #ReferencesBrowser
  1493. instanceVariableNames: 'implementors senders implementorsList input timer selector sendersList referencedClasses referencedClassesList matches matchesList'
  1494. package: 'IDE'!
  1495. !ReferencesBrowser methodsFor: 'accessing'!
  1496. classesAndMetaclasses
  1497. ^ Smalltalk classes, (Smalltalk classes collect: [ :each | each class ])
  1498. !
  1499. implementors
  1500. ^ implementors ifNil: [ implementors := Array new ]
  1501. !
  1502. label
  1503. ^ '[ References ]'
  1504. !
  1505. matches
  1506. ^ matches ifNil: [ matches := Array new ]
  1507. !
  1508. referencedClasses
  1509. ^ referencedClasses ifNil: [ referencedClasses := Array new ]
  1510. !
  1511. selector
  1512. ^ selector
  1513. !
  1514. senders
  1515. ^ senders ifNil: [ senders := Array new ]
  1516. ! !
  1517. !ReferencesBrowser methodsFor: 'actions'!
  1518. openBrowserOn: aMethod
  1519. | browser |
  1520. browser := Browser openOn: (aMethod methodClass isMetaclass
  1521. ifTrue: [ aMethod methodClass instanceClass ] ifFalse: [ aMethod methodClass ]).
  1522. aMethod methodClass isMetaclass ifTrue: [ browser selectTab: #class ].
  1523. browser
  1524. selectProtocol: aMethod category;
  1525. selectMethod: aMethod
  1526. !
  1527. search: aString
  1528. self
  1529. searchReferencesFor: aString;
  1530. updateImplementorsList;
  1531. updateSendersList;
  1532. updateReferencedClassesList;
  1533. updateMatchesList
  1534. !
  1535. searchMethodSource
  1536. | regex |
  1537. regex := selector allButFirst.
  1538. self classesAndMetaclasses do: [ :each |
  1539. each methodDictionary valuesDo: [ :value |
  1540. (value source match: regex) ifTrue: [
  1541. self matches add: value ]] ]
  1542. !
  1543. searchReferencedClasses
  1544. self classesAndMetaclasses do: [ :each |
  1545. each methodDictionary valuesDo: [ :value |
  1546. (value referencedClasses includes: selector) ifTrue: [
  1547. self referencedClasses add: value ]] ]
  1548. !
  1549. searchReferencesFor: aString
  1550. selector := aString.
  1551. implementors := Array new.
  1552. senders := Array new.
  1553. referencedClasses := Array new.
  1554. matches := Array new.
  1555. self searchMethodSource.
  1556. (selector match: '^[A-Z]')
  1557. ifFalse: [ self searchSelectorReferences ]
  1558. ifTrue: [ self searchReferencedClasses ]
  1559. !
  1560. searchSelectorReferences
  1561. self classesAndMetaclasses do: [ :each |
  1562. each methodDictionary keysAndValuesDo: [ :key :value |
  1563. key = selector ifTrue: [ self implementors add: value ].
  1564. (value messageSends includes: selector) ifTrue: [
  1565. self senders add: value ]] ]
  1566. ! !
  1567. !ReferencesBrowser methodsFor: 'initialization'!
  1568. initialize
  1569. super initialize.
  1570. selector := ''
  1571. ! !
  1572. !ReferencesBrowser methodsFor: 'private'!
  1573. setInputEvents
  1574. input
  1575. onKeyUp: [ timer := [ self search: input asJQuery val ] valueWithTimeout: 100 ];
  1576. onKeyDown: [ timer ifNotNil: [ timer clearTimeout ]]
  1577. ! !
  1578. !ReferencesBrowser methodsFor: 'rendering'!
  1579. renderBoxOn: html
  1580. self
  1581. renderInputOn: html;
  1582. renderImplementorsOn: html;
  1583. renderSendersOn: html;
  1584. renderReferencedClassesOn: html;
  1585. renderMatchesOn: html
  1586. !
  1587. renderImplementorsOn: html
  1588. implementorsList := html ul class: 'amber_column implementors'.
  1589. self updateImplementorsList
  1590. !
  1591. renderInputOn: html
  1592. input := html input
  1593. class: 'implementors';
  1594. yourself.
  1595. input asJQuery val: selector.
  1596. self setInputEvents
  1597. !
  1598. renderMatchesOn: html
  1599. matchesList := html ul class: 'amber_column matches'.
  1600. self updateMatchesList
  1601. !
  1602. renderReferencedClassesOn: html
  1603. referencedClassesList := html ul class: 'amber_column referenced_classes'.
  1604. self updateReferencedClassesList
  1605. !
  1606. renderSendersOn: html
  1607. sendersList := html ul class: 'amber_column senders'.
  1608. self updateSendersList
  1609. ! !
  1610. !ReferencesBrowser methodsFor: 'testing'!
  1611. canBeClosed
  1612. ^ true
  1613. ! !
  1614. !ReferencesBrowser methodsFor: 'updating'!
  1615. updateImplementorsList
  1616. implementorsList contents: [ :html |
  1617. html li
  1618. class: 'column_label';
  1619. with: 'Implementors (', self implementors size asString, ')';
  1620. style: 'font-weight: bold'.
  1621. self implementors do: [ :each || li |
  1622. li := html li.
  1623. li
  1624. with: (each methodClass asString, ' >> ', self selector);
  1625. onClick: [ self openBrowserOn: each ]] ]
  1626. !
  1627. updateMatchesList
  1628. matchesList contents: [ :html |
  1629. html li
  1630. class: 'column_label';
  1631. with: 'Regex matches (', self matches size asString, ')';
  1632. style: 'font-weight: bold'.
  1633. self matches do: [ :each || li |
  1634. li := html li.
  1635. li
  1636. with: (each methodClass asString, ' >> ', each selector);
  1637. onClick: [ self openBrowserOn: each ]] ]
  1638. !
  1639. updateReferencedClassesList
  1640. referencedClassesList contents: [ :html |
  1641. html li
  1642. class: 'column_label';
  1643. with: 'Class references (', self referencedClasses size asString, ')';
  1644. style: 'font-weight: bold'.
  1645. self referencedClasses do: [ :each |
  1646. html li
  1647. with: (each methodClass asString, ' >> ', each selector);
  1648. onClick: [ self openBrowserOn: each ]] ]
  1649. !
  1650. updateSendersList
  1651. sendersList contents: [ :html |
  1652. html li
  1653. class: 'column_label';
  1654. with: 'Senders (', self senders size asString, ')';
  1655. style: 'font-weight: bold'.
  1656. self senders do: [ :each |
  1657. html li
  1658. with: (each methodClass asString, ' >> ', each selector);
  1659. onClick: [ self openBrowserOn: each ]] ]
  1660. ! !
  1661. !ReferencesBrowser class methodsFor: 'instance creation'!
  1662. search: aString
  1663. ^ self new
  1664. searchReferencesFor: aString;
  1665. open
  1666. ! !
  1667. TabWidget subclass: #TestRunner
  1668. instanceVariableNames: 'selectedCategories packagesList selectedClasses classesList selectedMethods progressBar methodsList result statusDiv'
  1669. package: 'IDE'!
  1670. !TestRunner methodsFor: 'accessing'!
  1671. allClasses
  1672. ^ TestCase allSubclasses select: [ :each | each isAbstract not ]
  1673. !
  1674. classes
  1675. ^ (self allClasses
  1676. select: [ :each | self selectedCategories includes: each category ])
  1677. sort: [ :a :b | a name > b name ]
  1678. !
  1679. label
  1680. ^ 'SUnit'
  1681. !
  1682. packages
  1683. | packages |
  1684. packages := Array new.
  1685. self allClasses do: [ :each |
  1686. (packages includes: each category) ifFalse: [
  1687. packages add: each category ]].
  1688. ^ packages sort
  1689. !
  1690. progressBar
  1691. ^ progressBar ifNil: [ progressBar := ProgressBar new ]
  1692. !
  1693. result
  1694. ^ result
  1695. !
  1696. selectedCategories
  1697. ^ selectedCategories ifNil: [ selectedCategories := Array new ]
  1698. !
  1699. selectedClasses
  1700. ^ selectedClasses ifNil: [ selectedClasses := Array new ]
  1701. !
  1702. statusInfo
  1703. ^ self printTotal, self printPasses, self printErrors, self printFailures
  1704. !
  1705. testCases
  1706. | testCases |
  1707. testCases := #().
  1708. (self selectedClasses
  1709. select: [ :each | self selectedCategories includes: each category ])
  1710. do: [ :each | testCases addAll: each buildSuite ].
  1711. ^ testCases
  1712. ! !
  1713. !TestRunner methodsFor: 'actions'!
  1714. performFailure: aTestCase
  1715. aTestCase runCase
  1716. !
  1717. run: aCollection
  1718. | worker |
  1719. worker := TestSuiteRunner on: aCollection.
  1720. result := worker result.
  1721. worker announcer on: ResultAnnouncement do: [ :ann |
  1722. ann result == result ifTrue: [
  1723. self progressBar updatePercent: result runs / result total * 100.
  1724. self updateStatusDiv.
  1725. self updateMethodsList
  1726. ]
  1727. ].
  1728. worker run
  1729. !
  1730. selectAllCategories
  1731. self packages do: [ :each |
  1732. (selectedCategories includes: each) ifFalse: [
  1733. self selectedCategories add: each ]].
  1734. self
  1735. updateCategoriesList;
  1736. updateClassesList
  1737. !
  1738. selectAllClasses
  1739. self classes do: [ :each |
  1740. (selectedClasses includes: each) ifFalse: [
  1741. self selectedClasses add: each ]].
  1742. self
  1743. updateCategoriesList;
  1744. updateClassesList
  1745. !
  1746. toggleCategory: aCategory
  1747. (self isSelectedCategory: aCategory)
  1748. ifFalse: [ selectedCategories add: aCategory ]
  1749. ifTrue: [ selectedCategories remove: aCategory ].
  1750. self
  1751. updateCategoriesList;
  1752. updateClassesList
  1753. !
  1754. toggleClass: aClass
  1755. (self isSelectedClass: aClass)
  1756. ifFalse: [ selectedClasses add: aClass ]
  1757. ifTrue: [ selectedClasses remove: aClass ].
  1758. self
  1759. updateClassesList
  1760. ! !
  1761. !TestRunner methodsFor: 'initialization'!
  1762. initialize
  1763. super initialize.
  1764. result := TestResult new
  1765. ! !
  1766. !TestRunner methodsFor: 'printing'!
  1767. printErrors
  1768. ^ self result errors size asString , ' errors, '
  1769. !
  1770. printFailures
  1771. ^ self result failures size asString, ' failures'
  1772. !
  1773. printPasses
  1774. ^ (self result runs - self result errors size - self result failures size) asString , ' passes, '
  1775. !
  1776. printTotal
  1777. ^ self result total asString, ' runs, '
  1778. ! !
  1779. !TestRunner methodsFor: 'rendering'!
  1780. renderBoxOn: html
  1781. self
  1782. renderCategoriesOn: html;
  1783. renderClassesOn: html;
  1784. renderResultsOn: html
  1785. !
  1786. renderButtonsOn: html
  1787. html button
  1788. with: 'Run selected';
  1789. onClick: [ self run: self testCases ]
  1790. !
  1791. renderCategoriesOn: html
  1792. packagesList := html ul class: 'amber_column sunit packages'.
  1793. self updateCategoriesList
  1794. !
  1795. renderClassesOn: html
  1796. classesList := html ul class: 'amber_column sunit classes'.
  1797. self updateClassesList
  1798. !
  1799. renderErrorsOn: html
  1800. self result errors do: [ :each |
  1801. html li
  1802. class: 'errors';
  1803. with: each class name, ' >> ', each selector;
  1804. onClick: [ self performFailure: each ]]
  1805. !
  1806. renderFailuresOn: html
  1807. self result failures do: [ :each |
  1808. html li
  1809. class: 'failures';
  1810. with: each class name, ' >> ', each selector;
  1811. onClick: [ self performFailure: each ]]
  1812. !
  1813. renderResultsOn: html
  1814. statusDiv := html div.
  1815. html with: self progressBar.
  1816. methodsList := html ul class: 'amber_column sunit results'.
  1817. self updateMethodsList.
  1818. self updateStatusDiv
  1819. ! !
  1820. !TestRunner methodsFor: 'testing'!
  1821. isSelectedCategory: aCategory
  1822. ^ (self selectedCategories includes: aCategory)
  1823. !
  1824. isSelectedClass: aClass
  1825. ^ (self selectedClasses includes: aClass)
  1826. ! !
  1827. !TestRunner methodsFor: 'updating'!
  1828. updateCategoriesList
  1829. packagesList contents: [ :html |
  1830. html li
  1831. class: 'all';
  1832. with: 'All';
  1833. onClick: [ self selectAllCategories ].
  1834. self packages do: [ :each || li |
  1835. li := html li.
  1836. (self selectedCategories includes: each) ifTrue: [
  1837. li class: 'selected' ].
  1838. li
  1839. with: each;
  1840. onClick: [ self toggleCategory: each ]] ]
  1841. !
  1842. updateClassesList
  1843. classesList contents: [ :html |
  1844. (self selectedCategories isEmpty) ifFalse: [
  1845. html li
  1846. class: 'all';
  1847. with: 'All';
  1848. onClick: [ self selectAllClasses ]].
  1849. self classes do: [ :each || li |
  1850. li := html li.
  1851. (self selectedClasses includes: each) ifTrue: [
  1852. li class: 'selected' ].
  1853. li
  1854. with: each name;
  1855. onClick: [ self toggleClass: each ]] ]
  1856. !
  1857. updateMethodsList
  1858. methodsList contents: [ :html |
  1859. self renderErrorsOn: html.
  1860. self renderFailuresOn: html ]
  1861. !
  1862. updateStatusDiv
  1863. statusDiv class: 'sunit status ', result status.
  1864. statusDiv contents: [ :html |
  1865. html span with: self statusInfo ]
  1866. ! !
  1867. TabWidget subclass: #Workspace
  1868. instanceVariableNames: 'sourceArea'
  1869. package: 'IDE'!
  1870. !Workspace methodsFor: 'accessing'!
  1871. label
  1872. ^ 'Workspace'
  1873. ! !
  1874. !Workspace methodsFor: 'actions'!
  1875. clearWorkspace
  1876. sourceArea clear
  1877. !
  1878. doIt
  1879. sourceArea doIt
  1880. !
  1881. fileIn
  1882. sourceArea fileIn
  1883. !
  1884. inspectIt
  1885. sourceArea inspectIt
  1886. !
  1887. printIt
  1888. sourceArea printIt
  1889. !
  1890. show
  1891. super show.
  1892. sourceArea focus.
  1893. ! !
  1894. !Workspace methodsFor: 'rendering'!
  1895. renderBoxOn: html
  1896. sourceArea := SourceArea new.
  1897. sourceArea renderOn: html
  1898. !
  1899. renderButtonsOn: html
  1900. html button
  1901. with: 'DoIt';
  1902. title: 'ctrl+d';
  1903. onClick: [ self doIt ].
  1904. html button
  1905. with: 'PrintIt';
  1906. title: 'ctrl+p';
  1907. onClick: [ self printIt ].
  1908. html button
  1909. with: 'InspectIt';
  1910. title: 'ctrl+i';
  1911. onClick: [ self inspectIt ].
  1912. html button
  1913. with: 'FileIn';
  1914. title: 'ctrl+f';
  1915. onClick: [ self fileIn ].
  1916. html button
  1917. with: 'Clear workspace';
  1918. onClick: [ self clearWorkspace ]
  1919. ! !
  1920. !AssociativeCollection methodsFor: '*IDE'!
  1921. inspectOn: anInspector
  1922. | variables |
  1923. variables := Dictionary new.
  1924. variables at: '#self' put: self.
  1925. variables at: '#keys' put: self keys.
  1926. self keysAndValuesDo: [ :key :value |
  1927. variables at: key put: value ].
  1928. anInspector
  1929. setLabel: self printString;
  1930. setVariables: variables
  1931. ! !
  1932. !Collection methodsFor: '*IDE'!
  1933. inspectOn: anInspector
  1934. | variables |
  1935. variables := Dictionary new.
  1936. variables at: '#self' put: self.
  1937. self withIndexDo: [ :each :i |
  1938. variables at: i put: each ].
  1939. anInspector
  1940. setLabel: self printString;
  1941. setVariables: variables
  1942. ! !
  1943. !Date methodsFor: '*IDE'!
  1944. inspectOn: anInspector
  1945. | variables |
  1946. variables := Dictionary new.
  1947. variables at: '#self' put: self.
  1948. variables at: '#year' put: self year.
  1949. variables at: '#month' put: self month.
  1950. variables at: '#day' put: self day.
  1951. variables at: '#hours' put: self hours.
  1952. variables at: '#minutes' put: self minutes.
  1953. variables at: '#seconds' put: self seconds.
  1954. variables at: '#milliseconds' put: self milliseconds.
  1955. anInspector
  1956. setLabel: self printString;
  1957. setVariables: variables
  1958. ! !
  1959. !MethodContext methodsFor: '*IDE'!
  1960. inspectOn: anInspector
  1961. | variables |
  1962. variables := Dictionary new.
  1963. variables at: '#self' put: self.
  1964. variables at: '#home' put: self home.
  1965. variables at: '#receiver' put: self receiver.
  1966. variables at: '#selector' put: self selector.
  1967. variables at: '#locals' put: self locals.
  1968. self class instanceVariableNames do: [ :each |
  1969. variables at: each put: (self instVarAt: each) ].
  1970. anInspector
  1971. setLabel: self printString;
  1972. setVariables: variables
  1973. ! !
  1974. !Set methodsFor: '*IDE'!
  1975. inspectOn: anInspector
  1976. | variables i |
  1977. variables := Dictionary new.
  1978. variables at: '#self' put: self.
  1979. i := 1.
  1980. self do: [ :each |
  1981. variables at: i put: each.
  1982. i := i + 1 ].
  1983. anInspector
  1984. setLabel: self printString;
  1985. setVariables: variables
  1986. ! !
  1987. !String methodsFor: '*IDE'!
  1988. inspectOn: anInspector
  1989. | label |
  1990. super inspectOn: anInspector.
  1991. self printString size > 30
  1992. ifTrue: [ label := (self printString copyFrom: 1 to: 30), '...''' ]
  1993. ifFalse: [ label := self printString ].
  1994. anInspector setLabel: label
  1995. ! !