class: Tools::NewSystemBrowser
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 10 Sep 2013 02:41:15 +0200
changeset 13539 0cf27034d702
parent 13538 bd35b9f1813a
child 13540 2204d5170d0b
class: Tools::NewSystemBrowser changed: #classDefinitionStringFor: #showClassDefinition: #showCode: Fixes for showing Java code. #showMethodsCode:scrollToTop:
Tools__NewSystemBrowser.st
--- a/Tools__NewSystemBrowser.st	Mon Sep 09 17:08:32 2013 +0200
+++ b/Tools__NewSystemBrowser.st	Tue Sep 10 02:41:15 2013 +0200
@@ -18861,6 +18861,7 @@
     "Created: / 24.2.2000 / 23:28:06 / cg"
 ! !
 
+
 !NewSystemBrowser methodsFor:'aspects-organization'!
 
 categoryMenuVisible
@@ -37596,6 +37597,7 @@
     HTMLDocumentView openFullOnDocumentationFile:'TOP.html'
 ! !
 
+
 !NewSystemBrowser methodsFor:'menu actions-inheritance'!
 
 inheritanceMenuNavigateToClass
@@ -49686,6 +49688,7 @@
     "Modified: / 19-10-2011 / 16:48:31 / cg"
 ! !
 
+
 !NewSystemBrowser methodsFor:'menus-dynamic-popup'!
 
 categoryPopUpMenu
@@ -50868,7 +50871,14 @@
         aClass fileOutDefinitionOn:s
     ] ifFalse:[
         aClass theNonMetaclass isJavaClass ifTrue:[
-            aClass fileOutDefinitionOn:s
+            | src |
+            src := aClass theNonMetaclass source.
+            src notNil ifTrue:[ ^ src ].
+            s nextPutLine: '// *** WARNING ***'.
+            s nextPutLine: '// Following code has been decompiled from loaded class'.
+            s nextPutLine: '// *** WARNING ***'.
+            s cr.
+            aClass theNonMetaclass fileOutDefinitionOn:s
         ] ifFalse:[
             aClass isMeta ifTrue:[
                 aClass
@@ -50890,6 +50900,7 @@
     ^ s contents withTabsExpanded.
 
     "Modified: / 10-11-2006 / 17:13:54 / cg"
+    "Modified: / 10-09-2013 / 01:31:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 commentOrDocumentationStringFromClass:aClass
@@ -51156,11 +51167,15 @@
 
     definition := self classDefinitionStringFor:aClass.
 
-    self doSyntaxColoring value ~~ false ifTrue:[
-        highlighter := aClass syntaxHighlighterClass.
-        highlighter notNil ifTrue:[
-            definition := highlighter formatClassDefinition:definition in:nil.
-        ]
+    "JV@2012-07-05: Some class definitions could be quite big, such as Java classes.
+     Don't format the code here, do it in background instead..."
+    definition size < 2500 ifTrue:[
+        self doSyntaxColoring value ~~ false ifTrue:[
+            highlighter := aClass syntaxHighlighterClass.
+            highlighter notNil ifTrue:[
+                definition := highlighter formatClassDefinition:definition in:nil.
+            ]
+        ].
     ].
 
     self showCode:definition.
@@ -51186,6 +51201,7 @@
     self updatePackageInfoForClass:aClass.
 
     "Modified: / 27-07-2012 / 22:26:12 / cg"
+    "Modified: / 10-09-2013 / 01:34:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 showClassDocumentation
@@ -51553,9 +51569,12 @@
 !
 
 showCode:aString
-    self showCode:aString scrollToTop:true
-
-    "Modified: / 1.3.2000 / 11:38:33 / cg"
+
+    "/Do not scroll to the top if the code is already displayed!!"
+    self showCode:aString scrollToTop:(self codeView contents string ~= aString)
+
+    "Modified: / 01-03-2000 / 11:38:33 / cg"
+    "Modified: / 10-09-2013 / 01:33:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 showCode:codeString scrollToTop:doScrollToTop
@@ -51644,24 +51663,32 @@
 !
 
 showMethodsCode:mthd scrollToTop:doScrollToTop
-    |code codeView doAutoFormat doSyntaxColoring|
-
-    "/Do no coloring here if CodeView2 is used,
-    "/since CodeView2 itself cares about the coloring!!
-    "/Not working correctly -> do the coloring until fixed in CodeView2
-    "(UserPreferences current useCodeView2In: #Browser)"false ifTrue:[
-        doSyntaxColoring := false
-    ] ifFalse:[
-        doSyntaxColoring := self doSyntaxColoring value == true.
-    ].
+    |code codeView doAutoFormat doSyntaxColoring doUpdateCode prevMthd doShowFullClassSource |
+
     doAutoFormat := self doAutoFormat value and:[RBFormatter notNil].
+    doShowFullClassSource := self navigationState isFullClassSourceBrowser
+                                or:[mthd isJavaMethod].
+    doUpdateCode := true.
     codeView := self codeView.
     self assert:codeView notNil.
 
     code := self sourceOfMethod:mthd.
     code isText ifTrue:[
+        "/Already done...
         doSyntaxColoring := false.
-    ].
+    ] ifFalse:[
+        "/Do no coloring here if CodeView2 is used,
+        "/since CodeView2 itself cares about the coloring!!
+        "/Not working correctly -> do the coloring until fixed in CodeView2
+        "/JV: Then make a bug report because otherwise it won't be
+        "/    ever fixed.
+        "(UserPreferences current useCodeView2In: #Browser)"false ifTrue:[
+            doSyntaxColoring := code size < 2000
+        ] ifFalse:[
+            doSyntaxColoring := self doSyntaxColoring value == true.
+        ].
+    ].
+
 
     doAutoFormat ifTrue:[
         Error catch:[
@@ -51669,43 +51696,63 @@
         ].
     ].
 
-    doSyntaxColoring ifTrue:[
-        "/ immediate coloring, if code is not too large;
-        "/ otherwise, do it in the background.
-        code size < 2000 " 10000 " ifTrue:[
-            Error handle:[:ex |
-                Transcript showCR:'error in syntaxHighlighter: ',ex description.
-            ] do:[
-                code := self syntaxHighlightedCodeFor:code method:mthd.
-            ].
-        ] ifFalse:[
-            self enqueueDelayedStartSyntaxHighlightProcess.
-        ].
-
-        [
-            codeView modifiedChannel removeDependent:self.
-            codeView modified:false.
+    doShowFullClassSource ifTrue:[
+        "As whole class source coce is shown,
+         there is no need to set codeview's content if previous method
+         belonged to the same class. Code is already shown, we need only
+         to scrool to it..."
+        "hmm...hmm...how implement it in a better, more generic way?"        
+        mthd isSynthetic not ifTrue:[
+            prevMthd := navigationState lastMethodShownInCodeView.
+            prevMthd notNil ifTrue:[
+                doUpdateCode := prevMthd isSynthetic or:[mthd mclass ~~ prevMthd mclass]
+            ].
+
+
+        ].
+    ].
+    doUpdateCode ifTrue:[
+        doSyntaxColoring ifTrue:[
+            "/ immediate coloring, if code is not too large;
+            "/ otherwise, do it in the background.
+            code size < 2000 " 10000 " ifTrue:[
+                Error handle:[:ex |
+                    Transcript showCR:'error in syntaxHighlighter: ',ex description.
+                ] do:[
+                    code := self syntaxHighlightedCodeFor:code method:mthd.
+                ].
+            ] ifFalse:[
+                self enqueueDelayedStartSyntaxHighlightProcess.
+            ].
+
+            [
+                codeView modifiedChannel removeDependent:self.
+                codeView modified:false.
+                self showCode:code scrollToTop:doScrollToTop.
+            ] ensure:[
+                codeView modifiedChannel addDependent:self.
+            ]
+        ] ifFalse:[
             self showCode:code scrollToTop:doScrollToTop.
-        ] ensure:[
-            codeView modifiedChannel addDependent:self.
-        ]
-    ] ifFalse:[
-        self showCode:code scrollToTop:doScrollToTop.
-    ].
+        ].
+    ].
+    navigationState lastMethodShownInCodeView: mthd.
 
     "/ scroll, for file-based classes (java, ruby, etc.)
-    mthd sourceLineNumber ~~ 1 ifTrue:[
-        doScrollToTop "ifTrue:" ifFalse:[
-            codeView scrollToLine:mthd sourceLineNumber
-        ]
+    doShowFullClassSource ifTrue:[
+        mthd sourceLineNumber ~~ 1 ifTrue:[
+            doScrollToTop "ifTrue:" ifFalse:[
+                codeView scrollToLine:mthd sourceLineNumber
+            ]
+        ].
     ].
     self codeAspect:(code ifNil:[nil] ifNotNil:[SyntaxHighlighter codeAspectMethod]).
     self normalLabel.
     self updatePackageInfoForMethod:mthd.
 
     "Created: / 01-03-2000 / 11:38:57 / cg"
-    "Modified (format): / 29-07-2011 / 11:45:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 27-07-2012 / 22:18:18 / cg"
+    "Modified: / 10-09-2013 / 01:29:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 showNothing
@@ -59106,11 +59153,11 @@
 !NewSystemBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.1978 2013-09-09 08:54:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.1979 2013-09-10 00:41:15 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.1978 2013-09-09 08:54:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.1979 2013-09-10 00:41:15 vrany Exp $'
 !
 
 version_HG
@@ -59119,7 +59166,7 @@
 !
 
 version_SVN
-    ^ '$Id: Tools__NewSystemBrowser.st,v 1.1978 2013-09-09 08:54:54 cg Exp $'
+    ^ '$Id: Tools__NewSystemBrowser.st,v 1.1979 2013-09-10 00:41:15 vrany Exp $'
 ! !