SmallSense__CodeNavigationService.st
changeset 176 df6d3225d1e4
parent 174 3e08d765d86f
parent 166 c7e0cc97c3f9
child 249 8bc64027b189
--- a/SmallSense__CodeNavigationService.st	Wed Feb 26 19:24:50 2014 +0100
+++ b/SmallSense__CodeNavigationService.st	Wed Feb 26 19:28:14 2014 +0100
@@ -215,9 +215,26 @@
 !
 
 navigateToTypeReference: node
-    | className classes |
+    | classType className classes |
+
+    classType := node resolvedType.
+    classType notNil ifTrue:[
+        className := node resolvedType leafComponentType compoundName asStringWith: $/.
+    ] ifFalse:[ 
+        | unit |
 
-    className := node resolvedType leafComponentType compoundName asStringWith: $/.
+        unit := service codeView syntaxElements tree.
+        "/ Search imports...
+        unit imports do:[:import | 
+            import tokens last = node token ifTrue:[ 
+                className := import tokens asStringWith:$/.
+            ].
+        ].
+        "/ If not imported, Try compilation unit's package...
+        className isNil ifTrue:[ 
+            className := (unit currentPackage tokens asStringWith: $/) , '/' , node token.
+        ].
+    ].
     "/ Kludge - support both old and new Java class naming scheme
     classes := (JavaClass canUnderstand: #binaryName) 
                     ifTrue:[self environment allClasses select:[:cls | cls isJavaClass and:[cls binaryName = className]]]
@@ -234,7 +251,7 @@
     self halt: 'Not yet supported'.
 
     "Created: / 24-09-2013 / 10:16:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 26-11-2013 / 22:59:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 15-02-2014 / 23:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CodeNavigationService::Navigator methodsFor:'navigation - Smalltalk'!