Some more fixes for semi-modal navigation. development
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 01 Oct 2013 14:17:13 +0100
branchdevelopment
changeset 2781 bdabb1cf8408
parent 2780 7638771efcbe
child 2782 1b698ca5f0fd
Some more fixes for semi-modal navigation. Mostly works, but QualifiedNameReferences does not (they're somewhat tricky)
tools/JavaSourceDocument.st
tools/JavaSourceHighlighter.st
tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/FieldReference.st
tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/NameReference.st
tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/TypeReference.st
tools/tools.rc
--- a/tools/JavaSourceDocument.st	Sat Sep 28 01:49:52 2013 +0100
+++ b/tools/JavaSourceDocument.st	Tue Oct 01 14:17:13 2013 +0100
@@ -224,7 +224,7 @@
     ^ nil
 
     "Created: / 19-09-2013 / 18:10:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 26-09-2013 / 00:11:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-09-2013 / 10:34:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 inspector2Tabs
--- a/tools/JavaSourceHighlighter.st	Sat Sep 28 01:49:52 2013 +0100
+++ b/tools/JavaSourceHighlighter.st	Tue Oct 01 14:17:13 2013 +0100
@@ -775,27 +775,119 @@
 
 !JavaSourceHighlighter::Indexer methodsFor:'indexing'!
 
-index: node from: start to: stop
+add: node from: start to: stop
+    | element |
+
+    index add: (element := index newElementFor: node).
+    element start: start + 1; stop: stop + 1.
+    ^ element
+
+    "Created: / 01-10-2013 / 10:30:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+addFieldDeclaration: node from: start to: stop
+    | element binding fname previous |
 
-    | e |
+    element := self add: node from: start to: stop.
+    binding := node binding.
+    fname := (binding declaringClass compoundName asStringWith:$/) , '.' , binding name.
+    previous := fields at: fname ifAbsent: nil.
+    previous notNil ifTrue:[
+        previous next: element.
+    ].
+    fields at: fname put: element.
 
-    index add: (e := index newElementFor: node).
+    "Created: / 01-10-2013 / 10:33:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+addLocalDeclaration: node from: start to: stop
+    | element fname previous |
+
+    element := self add: node from: start to: stop.
+    fname := node name.
+    previous := locals at: fname ifAbsent: nil.
+    previous notNil ifTrue:[
+        previous next: element.
+    ].
+    locals at: fname put: element.
 
-    (node isKindOf: JAVA org eclipse jdt internal compiler ast SingleTypeReference theClass) ifTrue:[
-        | prev |
-        prev := types at: node token ifAbsent:[nil].
-        prev notNil ifTrue:[
-            prev next: e.
+    "Created: / 01-10-2013 / 11:44:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+addMessageSend: node from: start to: stop
+    self add: node from: start to: stop
+
+    "Created: / 01-10-2013 / 10:30:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+addTypeReference: node from: start to: stop
+    | element tname previous |
+
+    element := self add: node from: start to: stop.
+    tname := node getTypeName asStringWith: $/.
+    previous := types at: tname ifAbsent: nil.
+    previous notNil ifTrue:[
+        previous next: element.
+    ].
+    types at: tname put: element.
+
+    "Created: / 01-10-2013 / 10:33:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+addVariableReference: node from: start to: stop
+    | element binding name previous |
+
+    element := self add: node from: start to: stop.
+    binding := node binding.
+    (binding kind bitAnd: 2r100) == 2r100 "TYPE" ifTrue:[
+        name := binding compoundName asStringWith: $/.
+        previous := types at: name ifAbsent: nil.
+        previous notNil ifTrue:[
+            previous next: element.
         ].
-        types at: node token put: e.
+        types at: name put: element.   
+        ^ self.
     ].
 
-    (node isKindOf: JAVA org eclipse jdt internal compiler ast MessageSend theClass) ifTrue:[
-        e start: start + 1; stop: stop + 1.
-    ]
+    binding kind == 2r001 "FIELD" ifTrue:[
+        binding declaringClass isNil ifTrue:[
+            name := '???.' , binding name
+        ] ifFalse:[
+            name := (binding declaringClass compoundName asStringWith:$/) , '.' , binding name.
+        ].
+        previous := fields at: name ifAbsent: nil.
+        previous notNil ifTrue:[
+            previous next: element.
+        ].
+        fields at: name put: element.  
+        ^ self.
+    ].
 
-    "Created: / 17-09-2013 / 01:08:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 24-09-2013 / 03:02:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    binding kind == 2r010 "LOCAL" ifTrue:[
+        name := binding name.
+        previous := locals at: name ifAbsent: nil.
+        previous notNil ifTrue:[
+            previous next: element.
+        ].
+        locals at: name put: element.  
+        ^ self.   
+    ].
+
+    self error: 'Should not happen'
+
+    "Created: / 01-10-2013 / 10:33:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-10-2013 / 11:46:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+methodEnter: node
+    locals := Dictionary new
+
+    "Created: / 01-10-2013 / 10:44:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+methodLeave: node
+
+    "Created: / 01-10-2013 / 10:44:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaSourceHighlighter::Marker class methodsFor:'initialization'!
--- a/tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/FieldReference.st	Sat Sep 28 01:49:52 2013 +0100
+++ b/tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/FieldReference.st	Tue Oct 01 14:17:13 2013 +0100
@@ -4,6 +4,6 @@
 
 !(Java classForName:'org.eclipse.jdt.internal.compiler.ast.FieldReference') methodsFor:'* instance *'!
 
-isVariable
+isInstance
     ^ true
 ! !
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/NameReference.st	Tue Oct 01 14:17:13 2013 +0100
@@ -0,0 +1,14 @@
+"{ Package: 'stx:libjava/tools' }"
+
+!
+
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.NameReference') methodsFor:'* instance *'!
+
+isGlobal
+    ^ binding notNil or:[(binding kind bitAnd: 4) == 4]
+! !
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.NameReference') methodsFor:'* instance *'!
+
+isInstance
+    ^ binding notNil or:[binding kind == 1]
+! !
--- a/tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/TypeReference.st	Sat Sep 28 01:49:52 2013 +0100
+++ b/tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/TypeReference.st	Tue Oct 01 14:17:13 2013 +0100
@@ -9,6 +9,11 @@
 ! !
 !(Java classForName:'org.eclipse.jdt.internal.compiler.ast.TypeReference') methodsFor:'* instance *'!
 
+isVariable
+    ^ true
+! !
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.TypeReference') methodsFor:'* instance *'!
+
 navigateToUsing: navigator      
     ^ navigator navigateToTypeReference: self.
 ! !
--- a/tools/tools.rc	Sat Sep 28 01:49:52 2013 +0100
+++ b/tools/tools.rc	Tue Oct 01 14:17:13 2013 +0100
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Thu, 26 Sep 2013 08:00:57 GMT\0"
+      VALUE "ProductDate", "Tue, 01 Oct 2013 13:14:41 GMT\0"
     END
 
   END