--- a/SmallSense__AbstractJavaCompletionSimple.st Thu May 15 10:40:02 2014 +0100
+++ b/SmallSense__AbstractJavaCompletionSimple.st Thu May 15 14:41:52 2014 +0100
@@ -123,16 +123,31 @@
anyMatched ifFalse:[
stream position: 0.
tokens := stream contents.
- (tokens size > 2 and:[tokens last type == $. or:[tokens last type == #Identifier and:[ (tokens at: tokens size - 1) type == $. ]]]) ifTrue:[
+ tokens isEmptyOrNil ifTrue:[ ^ result ].
+
+ tokens last type == #Identifier ifTrue:[
+ tokens size == 1 ifTrue:[
+ "/ Only one token on line, complete local variable or receiver's field.
+ self completeLocalOrField: tokens.
+ ] ifFalse:[
+ "/ If preceeding token is dot, complete method or field of the receiver.
+ (tokens at: tokens size - 1) type == $. ifTrue:[
+ self completeMethodOrField: tokens.
+ ] ifFalse:[
+ "/ Else try to complete field.
+ self completeLocalOrField: tokens.
+ ].
+ ].
+ ] ifFalse:[
+ "/ Else if last token in dot, complete method or field of the receiver
+ tokens last type == $. ifTrue:[
self completeMethodOrField: tokens.
- ].
+ ]].
].
-
-
^ result
"Created: / 02-10-2013 / 13:55:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified (format): / 15-05-2014 / 07:52:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 15-05-2014 / 14:02:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
completeImport: match
@@ -147,6 +162,12 @@
"Created: / 15-05-2014 / 06:57:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+completeLocalOrField: tokens
+ ^ self shouldImplement
+
+ "Created: / 15-05-2014 / 14:01:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
completeMethodOrField: tokens
| type dotIndex |
@@ -172,18 +193,41 @@
!
completeNew: match
- | prefix |
+ | prefix classes full |
- prefix := nil.
+ match size < 2 ifTrue:[
+ ^ self.
+ ].
+
match size > 2 ifTrue:[
prefix := String streamContents:[:s | 2 to: match size do:[:i | s nextPutAll: (match at: i) value asString] ].
- self addClassesStartingWith: prefix fullName: true.
+ full := true.
] ifFalse:[
prefix := (match at: 2) value.
- self addClassesStartingWith: prefix
+ full := false.
+ ].
+ prefix replaceAll: $. with: $/.
+ classes := Set new.
+ context environment allClassesDo:[:cls |
+ (cls isJavaClass and:[cls isPublic]) ifTrue:[
+ full ifTrue:[
+ (cls binaryName startsWith: prefix) ifTrue:[
+ classes add: cls.
+ ].
+ ] ifFalse:[
+ (cls lastName startsWith: prefix) ifTrue:[
+ classes add: cls.
+ ].
+ ].
+ ].
+ ].
+
+ classes do:[:cls |
+ self addConstructorsForClass: cls fullName: full.
].
"Created: / 15-05-2014 / 07:16:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 15-05-2014 / 13:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!AbstractJavaCompletionSimple methodsFor:'guesswork'!
@@ -239,10 +283,13 @@
].
].
- ^ Type withClass: (context environment classNamed:#'JAVA::java::lang::Object')
+ ^ Type unknown
+"/ ^ Type withClass:
+"/ (context environment classNamed:#'JAVA::java::lang::Object')
+"/ ? (context environment classNamed:#'java/lang/Object')
"Created: / 15-05-2014 / 08:09:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 15-05-2014 / 09:42:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 15-05-2014 / 13:04:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
guessTypeOfMethod: name of: type numArgs: nargs