IDE.st 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751
  1. Widget subclass: #TabManager
  2. instanceVariableNames: 'selectedTab tabs opened ul'
  3. category: 'IDE'!
  4. !TabManager methodsFor: 'accessing'!
  5. tabs
  6. ^tabs ifNil: [tabs := Array new]
  7. ! !
  8. !TabManager methodsFor: 'actions'!
  9. updateBodyMargin
  10. self setBodyMargin: '#jtalk' asJQuery height + 27
  11. !
  12. updatePosition
  13. <jQuery('#jtalk').css('top', '').css('bottom', '27px')>
  14. !
  15. removeBodyMargin
  16. self setBodyMargin: 0
  17. !
  18. setBodyMargin: anInteger
  19. '.jtalkBody' asJQuery cssAt: 'margin-bottom' put: anInteger asString, 'px'
  20. !
  21. onResize: aBlock
  22. <jQuery('#jtalk').resizable({
  23. handles: 'n',
  24. resize: aBlock,
  25. minHeight: 230
  26. })>
  27. !
  28. onWindowResize: aBlock
  29. <jQuery(window).resize(aBlock)>
  30. !
  31. open
  32. opened ifFalse: [
  33. 'body' asJQuery addClass: 'jtalkBody'.
  34. '#jtalk' asJQuery show.
  35. ul asJQuery show.
  36. self updateBodyMargin.
  37. selectedTab show.
  38. opened := true]
  39. !
  40. close
  41. opened ifTrue: [
  42. '#jtalk' asJQuery hide.
  43. ul asJQuery hide.
  44. selectedTab hide.
  45. self removeBodyMargin.
  46. 'body' asJQuery removeClass: 'jtalkBody'.
  47. opened := false]
  48. !
  49. newBrowserTab
  50. Browser open
  51. !
  52. selectTab: aWidget
  53. self open.
  54. selectedTab := aWidget.
  55. self tabs do: [:each |
  56. each hide].
  57. aWidget show.
  58. self update
  59. !
  60. closeTab: aWidget
  61. self removeTab: aWidget.
  62. self selectTab: self tabs last.
  63. aWidget remove.
  64. self update
  65. ! !
  66. !TabManager methodsFor: 'adding/Removing'!
  67. addTab: aWidget
  68. self tabs add: aWidget.
  69. '#jtalk' asJQuery append: aWidget.
  70. aWidget hide
  71. !
  72. removeTab: aWidget
  73. self tabs remove: aWidget.
  74. self update
  75. ! !
  76. !TabManager methodsFor: 'initialization'!
  77. initialize
  78. super initialize.
  79. opened := true.
  80. 'body' asJQuery
  81. append: self;
  82. append: [:html | html div id: 'jtalk'];
  83. addClass: 'jtalkBody'.
  84. self
  85. addTab: Transcript current;
  86. addTab: Workspace new.
  87. self selectTab: self tabs last.
  88. self
  89. onResize: [self updateBodyMargin; updatePosition];
  90. onWindowResize: [self updatePosition]
  91. ! !
  92. !TabManager methodsFor: 'rendering'!
  93. renderOn: html
  94. ul := html ul
  95. id: 'jtalkTabs';
  96. yourself.
  97. self renderTabs
  98. !
  99. renderTabFor: aWidget on: html
  100. | li |
  101. li := html li.
  102. selectedTab = aWidget ifTrue: [
  103. li class: 'selected'].
  104. li with: [
  105. html span
  106. with: aWidget label;
  107. onClick: [self selectTab: aWidget].
  108. aWidget canBeClosed ifTrue: [
  109. html span
  110. class: 'close';
  111. with: 'x';
  112. onClick: [self closeTab: aWidget]]]
  113. !
  114. renderTabs
  115. ul contents: [:html |
  116. html li
  117. class: 'closeAll';
  118. with: 'x';
  119. onClick: [self close].
  120. self tabs do: [:each |
  121. self renderTabFor: each on: html].
  122. html li
  123. class: 'newtab';
  124. with: ' + ';
  125. onClick: [self newBrowserTab]]
  126. ! !
  127. !TabManager methodsFor: 'updating'!
  128. update
  129. self renderTabs
  130. ! !
  131. TabManager class instanceVariableNames: 'current'!
  132. !TabManager class methodsFor: 'instance creation'!
  133. current
  134. ^current ifNil: [current := super new]
  135. !
  136. new
  137. self shouldNotImplement
  138. ! !
  139. smalltalk.setup(smalltalk.TabManager);
  140. Widget subclass: #TabWidget
  141. instanceVariableNames: 'div'
  142. category: 'IDE'!
  143. !TabWidget methodsFor: 'accessing'!
  144. label
  145. self subclassResponsibility
  146. ! !
  147. !TabWidget methodsFor: 'actions'!
  148. open
  149. TabManager current addTab: self.
  150. TabManager current selectTab: self
  151. !
  152. show
  153. div asJQuery show
  154. !
  155. hide
  156. div asJQuery hide
  157. !
  158. remove
  159. div asJQuery remove
  160. ! !
  161. !TabWidget methodsFor: 'rendering'!
  162. renderOn: html
  163. div := html div
  164. class: 'jtalkTool';
  165. yourself.
  166. self renderTab
  167. !
  168. renderBoxOn: html
  169. !
  170. renderButtonsOn: html
  171. !
  172. update
  173. self renderTab
  174. !
  175. renderTab
  176. div contents: [:html |
  177. html div
  178. class: 'jt_box';
  179. with: [self renderBoxOn: html].
  180. html div
  181. class: 'jt_buttons';
  182. with: [self renderButtonsOn: html]]
  183. ! !
  184. !TabWidget methodsFor: 'testing'!
  185. canBeClosed
  186. ^false
  187. ! !
  188. !TabWidget class methodsFor: 'instance creation'!
  189. open
  190. ^self new open
  191. ! !
  192. smalltalk.setup(smalltalk.TabWidget);
  193. TabWidget subclass: #Workspace
  194. instanceVariableNames: 'sourceArea'
  195. category: 'IDE'!
  196. !Workspace methodsFor: 'accessing'!
  197. label
  198. ^'[Workspace]'
  199. ! !
  200. !Workspace methodsFor: 'actions'!
  201. clearWorkspace
  202. sourceArea clear
  203. !
  204. doIt
  205. sourceArea doIt
  206. !
  207. printIt
  208. sourceArea printIt
  209. !
  210. inspectIt
  211. sourceArea inspectIt
  212. ! !
  213. !Workspace methodsFor: 'rendering'!
  214. renderBoxOn: html
  215. sourceArea := SourceArea new.
  216. sourceArea renderOn: html
  217. !
  218. renderButtonsOn: html
  219. html button
  220. with: 'DoIt';
  221. title: 'ctrl+d';
  222. onClick: [self doIt].
  223. html button
  224. with: 'PrintIt';
  225. title: 'ctrl+p';
  226. onClick: [self printIt].
  227. html button
  228. with: 'InspectIt';
  229. title: 'ctrl+i';
  230. onClick: [self inspectIt].
  231. html button
  232. with: 'Clear workspace';
  233. onClick: [self clearWorkspace]
  234. ! !
  235. smalltalk.setup(smalltalk.Workspace);
  236. TabWidget subclass: #Transcript
  237. instanceVariableNames: 'textarea'
  238. category: 'IDE'!
  239. !Transcript methodsFor: 'accessing'!
  240. label
  241. ^'[Transcript]'
  242. ! !
  243. !Transcript methodsFor: 'actions'!
  244. show: anObject
  245. textarea asJQuery val: textarea asJQuery val, anObject asString.
  246. !
  247. cr
  248. textarea asJQuery val: textarea asJQuery val, String cr.
  249. !
  250. clear
  251. textarea asJQuery val: ''
  252. ! !
  253. !Transcript methodsFor: 'rendering'!
  254. renderBoxOn: html
  255. textarea := html textarea.
  256. textarea asJQuery call: 'tabby'.
  257. textarea
  258. class: 'jt_transcript';
  259. at: 'spellcheck' put: 'false'
  260. !
  261. renderButtonsOn: html
  262. html button
  263. with: 'Clear transcript';
  264. onClick: [self clear]
  265. ! !
  266. Transcript class instanceVariableNames: 'current'!
  267. !Transcript class methodsFor: 'instance creation'!
  268. open
  269. self current open
  270. !
  271. new
  272. self shouldNotImplement
  273. !
  274. current
  275. ^current ifNil: [current := super new]
  276. ! !
  277. !Transcript class methodsFor: 'printing'!
  278. show: anObject
  279. self current show: anObject
  280. !
  281. cr
  282. self current show: String cr
  283. !
  284. clear
  285. self current clear
  286. ! !
  287. smalltalk.setup(smalltalk.Transcript);
  288. TabWidget subclass: #Browser
  289. instanceVariableNames: 'selectedCategory selectedClass selectedProtocol selectedMethod commitButton categoriesList classesList protocolsList methodsList sourceArea tabsList selectedTab saveButton classButtons methodButtons unsavedChanges input'
  290. category: 'IDE'!
  291. !Browser methodsFor: 'accessing'!
  292. label
  293. ^selectedClass
  294. ifNil: ['Browser (nil)']
  295. ifNotNil: [selectedClass name]
  296. !
  297. categories
  298. | categories |
  299. categories := Array new.
  300. Smalltalk current classes do: [:each |
  301. (categories includes: each category) ifFalse: [
  302. categories add: each category]].
  303. ^categories sort
  304. !
  305. classes
  306. ^(Smalltalk current classes
  307. select: [:each | each category = selectedCategory])
  308. sort: [:a :b | a name > b name]
  309. !
  310. protocols
  311. | klass |
  312. selectedClass ifNotNil: [
  313. selectedTab = #comment ifTrue: [^#()].
  314. klass := selectedTab = #instance
  315. ifTrue: [selectedClass]
  316. ifFalse: [selectedClass class].
  317. klass methodDictionary isEmpty ifTrue: [
  318. ^Array with: 'not yet classified'].
  319. ^klass protocols].
  320. ^Array new
  321. !
  322. methods
  323. | klass |
  324. selectedTab = #comment ifTrue: [^#()].
  325. selectedClass ifNotNil: [
  326. klass := selectedTab = #instance
  327. ifTrue: [selectedClass]
  328. ifFalse: [selectedClass class]].
  329. ^(selectedProtocol
  330. ifNil: [
  331. klass
  332. ifNil: [#()]
  333. ifNotNil: [klass methodDictionary values]]
  334. ifNotNil: [
  335. klass methodDictionary values select: [:each |
  336. each category = selectedProtocol]]) sort: [:a :b | a selector > b selector]
  337. !
  338. source
  339. selectedTab = #comment ifFalse: [
  340. ^(selectedProtocol notNil or: [selectedMethod notNil])
  341. ifFalse: [self declarationSource]
  342. ifTrue: [self methodSource]].
  343. ^selectedClass
  344. ifNil: ['']
  345. ifNotNil: [self classCommentSource]
  346. !
  347. methodSource
  348. ^selectedMethod
  349. ifNil: [self dummyMethodSource]
  350. ifNotNil: [selectedMethod source]
  351. !
  352. dummyMethodSource
  353. ^'messageSelectorAndArgumentNames
  354. "comment stating purpose of message"
  355. | temporary variable names |
  356. statements'
  357. !
  358. declarationSource
  359. ^selectedTab = #instance
  360. ifTrue: [self classDeclarationSource]
  361. ifFalse: [self metaclassDeclarationSource]
  362. !
  363. classDeclarationSource
  364. | stream |
  365. stream := '' writeStream.
  366. selectedClass ifNotNil: [
  367. stream
  368. nextPutAll: selectedClass superclass asString;
  369. nextPutAll: ' subclass: #';
  370. nextPutAll: selectedClass name;
  371. nextPutAll: String lf, String tab;
  372. nextPutAll: 'instanceVariableNames: '''.
  373. selectedClass instanceVariableNames
  374. do: [:each | stream nextPutAll: each]
  375. separatedBy: [stream nextPutAll: ' '].
  376. stream
  377. nextPutAll: '''', String lf, String tab;
  378. nextPutAll: 'category: ''';
  379. nextPutAll: selectedClass category;
  380. nextPutAll: ''''].
  381. ^stream contents
  382. !
  383. metaclassDeclarationSource
  384. | stream |
  385. stream := '' writeStream.
  386. selectedClass ifNotNil: [
  387. stream
  388. nextPutAll: selectedClass asString;
  389. nextPutAll: ' class ';
  390. nextPutAll: 'instanceVariableNames: '''.
  391. selectedClass class instanceVariableNames
  392. do: [:each | stream nextPutAll: each]
  393. separatedBy: [stream nextPutAll: ' '].
  394. stream nextPutAll: ''''].
  395. ^stream contents
  396. !
  397. classCommentSource
  398. ^selectedClass comment
  399. !
  400. selectedClass
  401. ^selectedClass
  402. ! !
  403. !Browser methodsFor: 'actions'!
  404. disableSaveButton
  405. saveButton ifNotNil: [
  406. saveButton at: 'disabled' put: true].
  407. unsavedChanges := false
  408. !
  409. hideClassButtons
  410. classButtons asJQuery hide
  411. !
  412. showClassButtons
  413. classButtons asJQuery show
  414. !
  415. hideMethodButtons
  416. methodButtons asJQuery hide
  417. !
  418. showMethodButtons
  419. methodButtons asJQuery show
  420. !
  421. compile
  422. self disableSaveButton.
  423. selectedTab = #comment ifTrue: [
  424. selectedClass ifNotNil: [
  425. self compileClassComment]].
  426. (selectedProtocol notNil or: [selectedMethod notNil])
  427. ifFalse: [self compileDefinition]
  428. ifTrue: [self compileMethodDefinition]
  429. !
  430. compileClassComment
  431. selectedClass comment: sourceArea val
  432. !
  433. compileMethodDefinition
  434. selectedTab = #instance
  435. ifTrue: [self compileMethodDefinitionFor: selectedClass]
  436. ifFalse: [self compileMethodDefinitionFor: selectedClass class]
  437. !
  438. compileMethodDefinitionFor: aClass
  439. | compiler method source node |
  440. source := sourceArea val.
  441. selectedProtocol ifNil: [selectedProtocol := selectedMethod category].
  442. compiler := Compiler new.
  443. node := compiler parse: source.
  444. node isParseFailure ifTrue: [
  445. ^self alert: 'PARSE ERROR: ', node reason, ', position: ', node position asString].
  446. compiler currentClass: aClass.
  447. method := compiler eval: (compiler compileNode: node).
  448. method category: selectedProtocol.
  449. compiler unknownVariables do: [:each |
  450. (self confirm: 'Declare ''', each, ''' as instance variable?') ifTrue: [
  451. self addInstanceVariableNamed: each toClass: aClass.
  452. ^self compileMethodDefinitionFor: aClass]].
  453. aClass addCompiledMethod: method.
  454. compiler setupClass: aClass.
  455. self updateMethodsList.
  456. self selectMethod: method
  457. !
  458. compileDefinition
  459. | newClass |
  460. newClass := Compiler new loadExpression: sourceArea textarea asJQuery val.
  461. self
  462. resetClassesList;
  463. updateCategoriesList;
  464. updateClassesList
  465. !
  466. commitCategory
  467. selectedCategory ifNotNil: [
  468. (Ajax url: self class commitPathJs, '/', selectedCategory, '.js')
  469. at: 'type' put: 'PUT';
  470. at: 'data' put: (Exporter new exportCategory: selectedCategory);
  471. at: 'error' put: [self alert: 'Commit failed!!'];
  472. send.
  473. (Ajax url: self class commitPathJs, '/', selectedCategory, '.deploy.js')
  474. at: 'type' put: 'PUT';
  475. at: 'data' put: (Exporter new exportCategory: selectedCategory);
  476. at: 'error' put: [self alert: 'Commit failed!!'];
  477. send.
  478. (Ajax url: self class commitPathSt, '/', selectedCategory, '.st')
  479. at: 'type' put: 'PUT';
  480. at: 'data' put: (ChunkExporter new exportCategory: selectedCategory);
  481. at: 'error' put: [self alert: 'Commit failed!!'];
  482. send]
  483. !
  484. cancelChanges
  485. ^unsavedChanges
  486. ifTrue: [self confirm: 'Cancel changes?']
  487. ifFalse: [true]
  488. !
  489. removeClass
  490. (self confirm: 'Do you really want to remove ', selectedClass name, '?')
  491. ifTrue: [
  492. Smalltalk current removeClass: selectedClass.
  493. self resetClassesList.
  494. self selectClass: nil]
  495. !
  496. removeMethod
  497. self cancelChanges ifTrue: [
  498. (self confirm: 'Do you really want to remove #', selectedMethod selector, '?')
  499. ifTrue: [
  500. selectedTab = #instance
  501. ifTrue: [selectedClass removeCompiledMethod: selectedMethod]
  502. ifFalse: [selectedClass class removeCompiledMethod: selectedMethod].
  503. self selectMethod: nil]]
  504. !
  505. setMethodProtocol: aString
  506. self cancelChanges ifTrue: [
  507. (self protocols includes: aString)
  508. ifFalse: [self addNewProtocol]
  509. ifTrue: [
  510. selectedMethod category: aString.
  511. selectedProtocol := aString.
  512. selectedMethod := selectedMethod.
  513. self
  514. updateProtocolsList;
  515. updateMethodsList;
  516. updateSourceAndButtons]]
  517. !
  518. addNewProtocol
  519. | newProtocol |
  520. newProtocol := self prompt: 'New method protocol'.
  521. newProtocol notEmpty ifTrue: [
  522. selectedMethod category: newProtocol.
  523. self setMethodProtocol: newProtocol]
  524. !
  525. selectCategory: aCategory
  526. self cancelChanges ifTrue: [
  527. selectedCategory := aCategory.
  528. selectedClass := selectedProtocol := selectedMethod := nil.
  529. self resetClassesList.
  530. self
  531. updateCategoriesList;
  532. updateClassesList;
  533. updateProtocolsList;
  534. updateMethodsList;
  535. updateSourceAndButtons]
  536. !
  537. selectClass: aClass
  538. self cancelChanges ifTrue: [
  539. selectedClass := aClass.
  540. selectedProtocol := selectedMethod := nil.
  541. self
  542. updateClassesList;
  543. updateProtocolsList;
  544. updateMethodsList;
  545. updateSourceAndButtons]
  546. !
  547. selectProtocol: aString
  548. self cancelChanges ifTrue: [
  549. selectedProtocol := aString.
  550. selectedMethod := nil.
  551. self
  552. updateProtocolsList;
  553. updateMethodsList;
  554. updateSourceAndButtons]
  555. !
  556. selectMethod: aMethod
  557. self cancelChanges ifTrue: [
  558. selectedMethod := aMethod.
  559. self
  560. updateProtocolsList;
  561. updateMethodsList;
  562. updateSourceAndButtons]
  563. !
  564. selectTab: aString
  565. self cancelChanges ifTrue: [
  566. selectedTab := aString.
  567. self selectProtocol: nil.
  568. self updateTabsList]
  569. !
  570. renameClass
  571. | newName |
  572. newName := self prompt: 'Rename class ', selectedClass name.
  573. newName notEmpty ifTrue: [
  574. selectedClass rename: newName.
  575. self
  576. updateClassesList;
  577. updateSourceAndButtons]
  578. !
  579. addInstanceVariableNamed: aString toClass: aClass
  580. ClassBuilder new
  581. addSubclassOf: aClass superclass named: aClass name instanceVariableNames: (aClass instanceVariableNames copy add: aString; yourself)
  582. !
  583. searchReferencesOf: aString
  584. ReferencesBrowser search: aString
  585. !
  586. searchClassReferences
  587. ReferencesBrowser search: selectedClass name
  588. !
  589. search: aString
  590. self cancelChanges ifTrue: [| searchedClass |
  591. searchedClass := Smalltalk current at: aString.
  592. searchedClass isClass
  593. ifTrue: [self class openOn: searchedClass]
  594. ifFalse: [self searchReferencesOf: aString]]
  595. ! !
  596. !Browser methodsFor: 'initialization'!
  597. initialize
  598. super initialize.
  599. selectedTab := #instance.
  600. unsavedChanges := false
  601. ! !
  602. !Browser methodsFor: 'rendering'!
  603. renderBoxOn: html
  604. self
  605. renderTopPanelOn: html;
  606. renderTabsOn: html;
  607. renderBottomPanelOn: html
  608. !
  609. renderTopPanelOn: html
  610. html div
  611. class: 'top';
  612. with: [
  613. self renderInputOn: html.
  614. categoriesList := html ul class: 'jt_column browser categories'.
  615. commitButton := html button
  616. class: 'jt_commit';
  617. title: 'Commit classes in this category to disk';
  618. onClick: [self commitCategory];
  619. with: 'Commit category'.
  620. classesList := ClassesList on: self.
  621. classesList renderOn: html.
  622. protocolsList := html ul class: 'jt_column browser protocols'.
  623. methodsList := html ul class: 'jt_column browser methods'.
  624. self
  625. updateCategoriesList;
  626. updateClassesList;
  627. updateProtocolsList;
  628. updateMethodsList.
  629. html div class: 'jt_clear']
  630. !
  631. renderTabsOn: html
  632. tabsList := html ul class: 'jt_tabs'.
  633. self updateTabsList.
  634. !
  635. renderBottomPanelOn: html
  636. html div
  637. class: 'jt_sourceCode';
  638. with: [
  639. sourceArea := SourceArea new.
  640. sourceArea renderOn: html.
  641. sourceArea textarea
  642. onKeyUp: [self updateStatus]]
  643. !
  644. renderButtonsOn: html
  645. saveButton := html button.
  646. saveButton
  647. with: 'Save';
  648. onClick: [self compile].
  649. methodButtons := html span.
  650. classButtons := html span.
  651. html div
  652. class: 'right';
  653. with: [
  654. html button
  655. with: 'DoIt';
  656. onClick: [sourceArea doIt].
  657. html button
  658. with: 'PrintIt';
  659. onClick: [sourceArea printIt].
  660. html button with: 'InspectIt';
  661. onClick: [sourceArea inspectit]].
  662. self updateSourceAndButtons
  663. !
  664. renderInputOn: html
  665. input := html input
  666. class: 'implementors';
  667. yourself.
  668. input onKeyPress: [:event |
  669. event keyCode = 13 ifTrue: [
  670. self search: input asJQuery val]]
  671. ! !
  672. !Browser methodsFor: 'testing'!
  673. canBeClosed
  674. ^true
  675. ! !
  676. !Browser methodsFor: 'updating'!
  677. updateCategoriesList
  678. categoriesList contents: [:html |
  679. self categories do: [:each || li label |
  680. each isEmpty
  681. ifTrue: [label := 'Unclassified']
  682. ifFalse: [label := each].
  683. li := html li.
  684. selectedCategory = each ifTrue: [
  685. li class: 'selected'].
  686. li
  687. with: label;
  688. onClick: [self selectCategory: each]]]
  689. !
  690. updateClassesList
  691. TabManager current update.
  692. classesList updateNodes.
  693. "classesList contents: [:html |
  694. self classes do: [:each || li |
  695. li := html li.
  696. selectedClass = each ifTrue: [
  697. li class: 'selected'].
  698. li
  699. with: each name;
  700. onClick: [self selectClass: each]]]"
  701. !
  702. updateProtocolsList
  703. protocolsList contents: [:html |
  704. self protocols do: [:each || li |
  705. li := html li.
  706. selectedProtocol = each ifTrue: [
  707. li class: 'selected'].
  708. li
  709. with: each;
  710. onClick: [self selectProtocol: each]]]
  711. !
  712. updateMethodsList
  713. methodsList contents: [:html |
  714. self methods do: [:each || li |
  715. li := html li.
  716. selectedMethod = each ifTrue: [
  717. li class: 'selected'].
  718. li
  719. with: each selector;
  720. onClick: [self selectMethod: each]]]
  721. !
  722. updateTabsList
  723. tabsList contents: [:html || li |
  724. li := html li.
  725. selectedTab = #instance ifTrue: [li class: 'selected'].
  726. li
  727. with: 'Instance';
  728. onClick: [self selectTab: #instance].
  729. li := html li.
  730. selectedTab = #class ifTrue: [li class: 'selected'].
  731. li
  732. with: 'Class';
  733. onClick: [self selectTab: #class].
  734. li := html li.
  735. selectedTab = #comment ifTrue: [li class: 'selected'].
  736. li
  737. with: 'Comment';
  738. onClick: [self selectTab: #comment]]
  739. !
  740. updateSourceAndButtons
  741. self disableSaveButton.
  742. classButtons contents: [:html |
  743. html button
  744. with: 'Rename class';
  745. onClick: [self renameClass].
  746. html button
  747. with: 'Remove class';
  748. onClick: [self removeClass].
  749. html button
  750. with: 'References';
  751. onClick: [self searchClassReferences]].
  752. methodButtons contents: [:html |
  753. html button
  754. with: 'Remove method';
  755. onClick: [self removeMethod].
  756. html select
  757. onChange: [:e :select | self setMethodProtocol: select val];
  758. with: [
  759. html option
  760. with: 'Method protocol';
  761. at: 'disabled' put: 'disabled'.
  762. html option
  763. class: 'important';
  764. with: 'New...'.
  765. self protocols do: [:each |
  766. html option with: each]].
  767. selectedMethod isNil ifFalse: [
  768. html select
  769. onChange: [:e :select | self searchReferencesOf: select val];
  770. with: [
  771. html option
  772. with: 'References';
  773. at: 'disabled' put: 'disabled'.
  774. html option
  775. class: 'important';
  776. with: selectedMethod selector.
  777. selectedMethod messageSends sorted do: [:each |
  778. html option with: each]]]].
  779. selectedMethod isNil
  780. ifTrue: [
  781. self hideMethodButtons.
  782. (selectedClass isNil or: [selectedProtocol notNil])
  783. ifTrue: [self hideClassButtons]
  784. ifFalse: [self showClassButtons]]
  785. ifFalse: [
  786. self hideClassButtons.
  787. self showMethodButtons].
  788. sourceArea val: self source
  789. !
  790. updateStatus
  791. sourceArea textarea asJQuery val = self source
  792. ifTrue: [
  793. saveButton ifNotNil: [
  794. saveButton at: 'disabled' put: true].
  795. unsavedChanges := false]
  796. ifFalse: [
  797. saveButton ifNotNil: [
  798. saveButton removeAt: 'disabled'].
  799. unsavedChanges := true]
  800. !
  801. resetClassesList
  802. classesList resetNodes
  803. ! !
  804. !Browser class methodsFor: 'accessing'!
  805. commitPathJs
  806. ^'js'
  807. !
  808. commitPathSt
  809. ^'st'
  810. ! !
  811. !Browser class methodsFor: 'convenience'!
  812. openOn: aClass
  813. ^self new
  814. open;
  815. selectCategory: aClass category;
  816. selectClass: aClass
  817. !
  818. open
  819. self new open
  820. ! !
  821. smalltalk.setup(smalltalk.Browser);
  822. TabWidget subclass: #Inspector
  823. instanceVariableNames: 'label variables object selectedVariable variablesList valueTextarea workspaceTextarea diveButton'
  824. category: 'IDE'!
  825. !Inspector methodsFor: 'accessing'!
  826. label
  827. ^label ifNil: ['Inspector (nil)']
  828. !
  829. variables
  830. ^variables
  831. !
  832. setVariables: aCollection
  833. variables := aCollection
  834. !
  835. setLabel: aString
  836. label := aString
  837. !
  838. selectedVariable
  839. ^selectedVariable
  840. !
  841. selectedVariable: aString
  842. selectedVariable := aString
  843. ! !
  844. !Inspector methodsFor: 'actions'!
  845. inspect: anObject
  846. object := anObject.
  847. variables := #().
  848. object inspectOn: self
  849. !
  850. dive
  851. (self variables at: self selectedVariable) inspect
  852. !
  853. refresh
  854. self
  855. inspect: object;
  856. updateVariablesList;
  857. updateValueTextarea
  858. ! !
  859. !Inspector methodsFor: 'rendering'!
  860. renderBoxOn: html
  861. self
  862. renderTopPanelOn: html;
  863. renderBottomPanelOn: html
  864. !
  865. renderTopPanelOn: html
  866. html div
  867. class: 'top';
  868. with: [
  869. variablesList := html ul class: 'jt_column variables'.
  870. valueTextarea := html textarea class: 'jt_column value'; at: 'readonly' put: 'readonly'.
  871. self
  872. updateVariablesList;
  873. updateValueTextarea.
  874. html div class: 'jt_clear']
  875. !
  876. renderBottomPanelOn: html
  877. html div
  878. class: 'jt_sourceCode';
  879. with: [
  880. workspaceTextarea := html textarea
  881. class: 'source';
  882. at: 'spellcheck' put: 'false'.
  883. workspaceTextarea asJQuery call: 'tabby']
  884. !
  885. renderButtonsOn: html
  886. html button
  887. with: 'Refresh';
  888. onClick: [self refresh].
  889. diveButton := html button
  890. with: 'Dive';
  891. onClick: [self dive].
  892. self updateButtons
  893. ! !
  894. !Inspector methodsFor: 'testing'!
  895. canBeClosed
  896. ^true
  897. ! !
  898. !Inspector methodsFor: 'updating'!
  899. updateVariablesList
  900. variablesList contents: [:html |
  901. self variables keys do: [:each || li |
  902. li := html li.
  903. li
  904. with: each;
  905. onClick: [self selectVariable: each].
  906. self selectedVariable = each ifTrue: [
  907. li class: 'selected']]]
  908. !
  909. selectVariable: aString
  910. self selectedVariable: aString.
  911. self
  912. updateVariablesList;
  913. updateValueTextarea;
  914. updateButtons
  915. !
  916. updateValueTextarea
  917. valueTextarea asJQuery val: (self selectedVariable isNil
  918. ifTrue: ['']
  919. ifFalse: [(self variables at: self selectedVariable) printString])
  920. !
  921. updateButtons
  922. (self selectedVariable notNil and: [(self variables at: self selectedVariable) notNil])
  923. ifFalse: [diveButton at: 'disabled' put: true]
  924. ifTrue: [diveButton removeAt: 'disabled']
  925. ! !
  926. !Inspector class methodsFor: 'instance creation'!
  927. on: anObject
  928. ^self new
  929. inspect: anObject;
  930. yourself
  931. ! !
  932. smalltalk.setup(smalltalk.Inspector);
  933. TabWidget subclass: #ReferencesBrowser
  934. instanceVariableNames: 'implementors senders implementorsList input timer selector sendersList referencedClasses referencedClassesList'
  935. category: 'IDE'!
  936. !ReferencesBrowser methodsFor: 'accessing'!
  937. implementors
  938. ^implementors ifNil: [implementors := Array new]
  939. !
  940. label
  941. ^'[ReferencesBrowser]'
  942. !
  943. selector
  944. ^selector
  945. !
  946. senders
  947. ^senders ifNil: [senders := Array new]
  948. !
  949. classesAndMetaclasses
  950. ^Smalltalk current classes, (Smalltalk current classes collect: [:each | each class])
  951. !
  952. referencedClasses
  953. ^referencedClasses ifNil: [referencedClasses := Array new]
  954. ! !
  955. !ReferencesBrowser methodsFor: 'actions'!
  956. openBrowserOn: aMethod
  957. | browser |
  958. browser := Browser openOn: (aMethod class isMetaclass
  959. ifTrue: [aMethod methodClass instanceClass] ifFalse: [aMethod methodClass]).
  960. aMethod methodClass isMetaclass ifTrue: [browser selectTab: #class].
  961. browser
  962. selectProtocol: aMethod category;
  963. selectMethod: aMethod
  964. !
  965. searchReferencesFor: aString
  966. selector := aString.
  967. implementors := Array new.
  968. senders := Array new.
  969. referencedClasses := Array new.
  970. (selector match: '^[A-Z]')
  971. ifFalse: [self searchSelectorReferencesFor: selector]
  972. ifTrue: [self searchReferencedClassesFor: selector]
  973. !
  974. search: aString
  975. self
  976. searchReferencesFor: aString;
  977. updateImplementorsList;
  978. updateSendersList;
  979. updateReferencedClassesList
  980. !
  981. searchReferencedClassesFor: aString
  982. self classesAndMetaclasses do: [:each |
  983. each methodDictionary values do: [:value |
  984. (((value referencedClasses select: [:each | each notNil])collect: [:each | each name]) includes: selector) ifTrue: [
  985. self referencedClasses add: value]]]
  986. !
  987. searchSelectorReferencesFor: aString
  988. self classesAndMetaclasses do: [:each |
  989. each methodDictionary keysAndValuesDo: [:key :value |
  990. key = selector ifTrue: [self implementors add: value]].
  991. each methodDictionary keysAndValuesDo: [:key :value |
  992. (value messageSends includes: selector) ifTrue: [
  993. self senders add: value]]]
  994. ! !
  995. !ReferencesBrowser methodsFor: 'initialization'!
  996. initialize
  997. super initialize.
  998. selector := ''
  999. ! !
  1000. !ReferencesBrowser methodsFor: 'private'!
  1001. setInputEvents
  1002. input
  1003. onKeyUp: [timer := [self search: input asJQuery val] valueWithTimeout: 100];
  1004. onKeyDown: [timer ifNotNil: [timer clearTimeout]]
  1005. ! !
  1006. !ReferencesBrowser methodsFor: 'rendering'!
  1007. renderBoxOn: html
  1008. self
  1009. renderInputOn: html;
  1010. renderImplementorsOn: html;
  1011. renderSendersOn: html;
  1012. renderReferencedClassesOn: html
  1013. !
  1014. renderInputOn: html
  1015. input := html input
  1016. class: 'implementors';
  1017. yourself.
  1018. input asJQuery val: selector.
  1019. self setInputEvents
  1020. !
  1021. renderImplementorsOn: html
  1022. implementorsList := html ul class: 'jt_column implementors'.
  1023. self updateImplementorsList
  1024. !
  1025. renderSendersOn: html
  1026. sendersList := html ul class: 'jt_column senders'.
  1027. self updateSendersList
  1028. !
  1029. renderReferencedClassesOn: html
  1030. referencedClassesList := html ul class: 'jt_column referenced_classes'.
  1031. self updateReferencedClassesList
  1032. ! !
  1033. !ReferencesBrowser methodsFor: 'testing'!
  1034. canBeClosed
  1035. ^true
  1036. ! !
  1037. !ReferencesBrowser methodsFor: 'updating'!
  1038. updateImplementorsList
  1039. implementorsList contents: [:html |
  1040. html li
  1041. class: 'column_label';
  1042. with: 'Implementors (', self implementors size asString, ')';
  1043. style: 'font-weight: bold'.
  1044. self implementors do: [:each || li |
  1045. li := html li.
  1046. li
  1047. with: (each methodClass asString, ' >> ', self selector);
  1048. onClick: [self openBrowserOn: each]]]
  1049. !
  1050. updateSendersList
  1051. sendersList contents: [:html |
  1052. html li
  1053. class: 'column_label';
  1054. with: 'Senders (', self senders size asString, ')';
  1055. style: 'font-weight: bold'.
  1056. self senders do: [:each |
  1057. html li
  1058. with: (each methodClass asString, ' >> ', each selector);
  1059. onClick: [self openBrowserOn: each]]]
  1060. !
  1061. updateReferencedClassesList
  1062. referencedClassesList contents: [:html |
  1063. html li
  1064. class: 'column_label';
  1065. with: 'Class references (', self referencedClasses size asString, ')';
  1066. style: 'font-weight: bold'.
  1067. self referencedClasses do: [:each |
  1068. html li
  1069. with: (each methodClass asString, ' >> ', each selector);
  1070. onClick: [self openBrowserOn: each]]]
  1071. ! !
  1072. !ReferencesBrowser class methodsFor: 'instance creation'!
  1073. search: aString
  1074. ^self new
  1075. searchReferencesFor: aString;
  1076. open
  1077. ! !
  1078. smalltalk.setup(smalltalk.ReferencesBrowser);
  1079. Widget subclass: #SourceArea
  1080. instanceVariableNames: 'textarea'
  1081. category: 'IDE'!
  1082. !SourceArea methodsFor: 'accessing'!
  1083. val
  1084. ^textarea asJQuery val
  1085. !
  1086. val: aString
  1087. textarea asJQuery val: aString
  1088. !
  1089. currentLine
  1090. | lines startLine endLine|
  1091. lines := textarea asJQuery val tokenize: String lf.
  1092. startLine := endLine := 0.
  1093. lines do: [:each |
  1094. endLine := startLine + each size.
  1095. startLine := endLine + 1.
  1096. endLine >= self selectionStart ifTrue: [
  1097. self selectionEnd: endLine.
  1098. ^each]]
  1099. !
  1100. selection
  1101. <return document.selection>
  1102. !
  1103. selectionEnd
  1104. ^textarea element selectionEnd
  1105. !
  1106. selectionStart
  1107. ^textarea element selectionStart
  1108. !
  1109. selectionStart: anInteger
  1110. textarea element selectionStart: anInteger
  1111. !
  1112. selectionEnd: anInteger
  1113. textarea element selectionEnd: anInteger
  1114. !
  1115. textarea
  1116. ^textarea
  1117. ! !
  1118. !SourceArea methodsFor: 'actions'!
  1119. clear
  1120. textarea asJQuery val: ''
  1121. !
  1122. doIt
  1123. | selection |
  1124. textarea asJQuery focus.
  1125. self selectionStart = self selectionEnd
  1126. ifTrue: [selection := self currentLine]
  1127. ifFalse: [
  1128. selection := textarea asJQuery val copyFrom: self selectionStart + 1 to: self selectionEnd + 1].
  1129. ^self eval: selection
  1130. !
  1131. eval: aString
  1132. | compiler node |
  1133. compiler := Compiler new.
  1134. node := compiler parseExpression: aString.
  1135. node isParseFailure ifTrue: [
  1136. ^self alert: node reason, ', position: ', node position].
  1137. ^compiler loadExpression: aString
  1138. !
  1139. handleKeyDown: anEvent
  1140. <if(anEvent.ctrlKey) {
  1141. if(anEvent.keyCode === 80) { //ctrl+p
  1142. self._printIt();
  1143. anEvent.preventDefault();
  1144. return false;
  1145. }
  1146. if(anEvent.keyCode === 68) { //ctrl+d
  1147. self._doIt();
  1148. anEvent.preventDefault();
  1149. return false;
  1150. }
  1151. if(anEvent.keyCode === 73) { //ctrl+i
  1152. self._inspectIt();
  1153. anEvent.preventDefault();
  1154. return false;
  1155. }
  1156. }>
  1157. !
  1158. inspectIt
  1159. self doIt inspect
  1160. !
  1161. print: aString
  1162. | start |
  1163. start := self selectionEnd.
  1164. textarea asJQuery val: (
  1165. (textarea asJQuery val copyFrom: 1 to: start),
  1166. ' ', aString, ' ',
  1167. (textarea asJQuery val copyFrom: start + 1 to: textarea asJQuery val size)).
  1168. self selectionStart: start.
  1169. self selectionEnd: start + aString size + 2
  1170. !
  1171. printIt
  1172. self print: self doIt printString
  1173. ! !
  1174. !SourceArea methodsFor: 'rendering'!
  1175. renderOn: html
  1176. textarea := html textarea.
  1177. textarea asJQuery call: 'tabby'.
  1178. textarea onKeyDown: [:e | self handleKeyDown: e].
  1179. textarea
  1180. class: 'jt_workspace';
  1181. at: 'spellcheck' put: 'false'
  1182. ! !
  1183. smalltalk.setup(smalltalk.SourceArea);
  1184. Widget subclass: #ClassesList
  1185. instanceVariableNames: 'browser ul nodes'
  1186. category: 'IDE'!
  1187. !ClassesList methodsFor: 'accessing'!
  1188. category
  1189. ^self browser selectedCategory
  1190. !
  1191. nodes
  1192. nodes ifNil: [nodes := self getNodes].
  1193. ^nodes
  1194. !
  1195. browser
  1196. ^browser
  1197. !
  1198. browser: aBrowser
  1199. browser := aBrowser
  1200. !
  1201. getNodes
  1202. | classes children others |
  1203. classes := self browser classes.
  1204. children := #().
  1205. others := #().
  1206. classes do: [:each |
  1207. (classes includes: each superclass)
  1208. ifFalse: [children add: each]
  1209. ifTrue: [others add: each]].
  1210. ^children collect: [:each |
  1211. ClassesListNode on: each browser: self browser classes: others level: 0]
  1212. !
  1213. resetNodes
  1214. nodes := nil
  1215. ! !
  1216. !ClassesList methodsFor: 'rendering'!
  1217. renderOn: html
  1218. ul := html ul
  1219. class: 'jt_column browser classes';
  1220. yourself.
  1221. self updateNodes
  1222. !
  1223. updateNodes
  1224. ul contents: [:html |
  1225. self nodes do: [:each |
  1226. each renderOn: html]]
  1227. ! !
  1228. !ClassesList class methodsFor: 'instance creation'!
  1229. on: aBrowser
  1230. ^self new
  1231. browser: aBrowser;
  1232. yourself
  1233. ! !
  1234. smalltalk.setup(smalltalk.ClassesList);
  1235. Widget subclass: #ClassesListNode
  1236. instanceVariableNames: 'browser theClass level nodes'
  1237. category: 'IDE'!
  1238. !ClassesListNode methodsFor: 'accessing'!
  1239. nodes
  1240. ^nodes
  1241. !
  1242. theClass
  1243. ^theClass
  1244. !
  1245. theClass: aClass
  1246. theClass := aClass
  1247. !
  1248. browser
  1249. ^browser
  1250. !
  1251. browser: aBrowser
  1252. browser := aBrowser
  1253. !
  1254. level
  1255. ^level
  1256. !
  1257. level: anInteger
  1258. level := anInteger
  1259. !
  1260. label
  1261. | str |
  1262. str := String new writeStream.
  1263. self level timesRepeat: [
  1264. str nextPutAll: '&nbsp;&nbsp;&nbsp;&nbsp;'].
  1265. str nextPutAll: self theClass name.
  1266. ^str contents
  1267. !
  1268. getNodesFrom: aCollection
  1269. | children others |
  1270. children := #().
  1271. others := #().
  1272. aCollection do: [:each |
  1273. (each superclass = self theClass)
  1274. ifTrue: [children add: each]
  1275. ifFalse: [others add: each]].
  1276. nodes:= children collect: [:each |
  1277. ClassesListNode on: each browser: self browser classes: others level: self level + 1]
  1278. ! !
  1279. !ClassesListNode methodsFor: 'rendering'!
  1280. renderOn: html
  1281. | li |
  1282. li := html li
  1283. onClick: [self browser selectClass: self theClass].
  1284. li asJQuery contents: self label.
  1285. self browser selectedClass = self theClass ifTrue: [
  1286. li class: 'selected'].
  1287. self nodes do: [:each |
  1288. each renderOn: html]
  1289. ! !
  1290. !ClassesListNode class methodsFor: 'instance creation'!
  1291. on: aClass browser: aBrowser classes: aCollection level: anInteger
  1292. ^self new
  1293. theClass: aClass;
  1294. browser: aBrowser;
  1295. level: anInteger;
  1296. getNodesFrom: aCollection;
  1297. yourself
  1298. ! !
  1299. smalltalk.setup(smalltalk.ClassesListNode);
  1300. TabWidget subclass: #Debugger
  1301. instanceVariableNames: 'error selectedContext sourceArea ul'
  1302. category: 'IDE'!
  1303. !Debugger methodsFor: 'accessing'!
  1304. error
  1305. ^error
  1306. !
  1307. error: anError
  1308. error := anError
  1309. !
  1310. label
  1311. ^'[Debugger]'
  1312. ! !
  1313. !Debugger methodsFor: 'actions'!
  1314. selectContext: aContext
  1315. selectedContext := aContext.
  1316. self updateContextsList.
  1317. self updateSourceArea
  1318. ! !
  1319. !Debugger methodsFor: 'rendering'!
  1320. renderBoxOn: html
  1321. self
  1322. renderTopPanelOn: html;
  1323. renderBottomPanelOn: html
  1324. !
  1325. renderTopPanelOn: html
  1326. selectedContext := self error context.
  1327. html div
  1328. class: 'top';
  1329. with: [
  1330. html div
  1331. class: 'label';
  1332. with: self error messageText.
  1333. ul := html ul
  1334. class: 'jt_column debugger contexts';
  1335. with: [self renderContext: self error context on: html]]
  1336. !
  1337. renderContext: aContext on: html
  1338. | li |
  1339. li := html li.
  1340. selectedContext = aContext ifTrue: [
  1341. li class: 'selected'].
  1342. li
  1343. with: aContext asString;
  1344. onClick: [self selectContext: aContext].
  1345. aContext home ifNotNil: [self renderContext: aContext home on: html]
  1346. !
  1347. renderBottomPanelOn: html
  1348. html div
  1349. class: 'jt_sourceCode';
  1350. with: [
  1351. sourceArea := SourceArea new.
  1352. sourceArea renderOn: html].
  1353. self updateSourceArea
  1354. ! !
  1355. !Debugger methodsFor: 'testing'!
  1356. canBeClosed
  1357. ^true
  1358. ! !
  1359. !Debugger methodsFor: 'updating'!
  1360. updateContextsList
  1361. ul contents: [:html |
  1362. self renderContext: self error context on: html]
  1363. !
  1364. updateSourceArea
  1365. sourceArea val: (selectedContext receiver class methodAt: selectedContext selector) source
  1366. ! !
  1367. smalltalk.setup(smalltalk.Debugger);
  1368. ErrorHandler subclass: #DebugErrorHandler
  1369. instanceVariableNames: ''
  1370. category: 'IDE'!
  1371. !DebugErrorHandler methodsFor: 'error handling'!
  1372. handleError: anError
  1373. [Debugger new
  1374. error: anError;
  1375. open] on: Error do: [:error |
  1376. ErrorHandler new handleError: error]
  1377. ! !
  1378. !DebugErrorHandler class methodsFor: 'initialization'!
  1379. initialize
  1380. self register
  1381. ! !
  1382. smalltalk.setup(smalltalk.DebugErrorHandler);
  1383. !Object methodsFor: '*IDE'!
  1384. inspect
  1385. Inspector new
  1386. inspect: self;
  1387. open
  1388. !
  1389. inspectOn: anInspector
  1390. | variables |
  1391. variables := Dictionary new.
  1392. variables at: '#self' put: self.
  1393. self class allInstanceVariableNames do: [:each |
  1394. variables at: each put: (self instVarAt: each)].
  1395. anInspector
  1396. setLabel: self printString;
  1397. setVariables: variables
  1398. ! !
  1399. !Date methodsFor: '*IDE'!
  1400. inspectOn: anInspector
  1401. | variables |
  1402. variables := Dictionary new.
  1403. variables at: '#self' put: self.
  1404. variables at: '#year' put: self year.
  1405. variables at: '#month' put: self month.
  1406. variables at: '#day' put: self day.
  1407. variables at: '#hours' put: self hours.
  1408. variables at: '#minutes' put: self minutes.
  1409. variables at: '#seconds' put: self seconds.
  1410. variables at: '#milliseconds' put: self milliseconds.
  1411. anInspector
  1412. setLabel: self printString;
  1413. setVariables: variables
  1414. ! !
  1415. !Collection methodsFor: '*IDE'!
  1416. inspectOn: anInspector
  1417. | variables |
  1418. variables := Dictionary new.
  1419. variables at: '#self' put: self.
  1420. self withIndexDo: [:each :i |
  1421. variables at: i put: each].
  1422. anInspector
  1423. setLabel: self printString;
  1424. setVariables: variables
  1425. ! !
  1426. !String methodsFor: '*IDE'!
  1427. inspectOn: anInspector
  1428. | label |
  1429. super inspectOn: anInspector.
  1430. self printString size > 30
  1431. ifTrue: [label := (self printString copyFrom: 1 to: 30), '...''']
  1432. ifFalse: [label := self printString].
  1433. anInspector setLabel: label
  1434. ! !
  1435. !MethodContext methodsFor: '*IDE'!
  1436. inspectOn: anInspector
  1437. | variables |
  1438. variables := Dictionary new.
  1439. variables at: '#self' put: self.
  1440. variables at: '#home' put: self home.
  1441. variables at: '#receiver' put: self receiver.
  1442. variables at: '#selector' put: self selector.
  1443. variables at: '#temps' put: self temps.
  1444. self class instanceVariableNames do: [:each |
  1445. variables at: each put: (self instVarAt: each)].
  1446. anInspector
  1447. setLabel: self printString;
  1448. setVariables: variables
  1449. ! !
  1450. !Dictionary methodsFor: '*IDE'!
  1451. inspectOn: anInspector
  1452. | variables |
  1453. variables := Dictionary new.
  1454. variables at: '#self' put: self.
  1455. variables at: '#keys' put: self keys.
  1456. self keysAndValuesDo: [:key :value |
  1457. variables at: key put: value].
  1458. anInspector
  1459. setLabel: self printString;
  1460. setVariables: variables
  1461. ! !