# HG changeset patch # User Jan Vrany # Date 1407426497 -3600 # Node ID 51c4ee46f5c047db16a9fcdf0cee7aa19d942d64 # Parent 8aaf6403a01dfcbe8122eb5c355bcc19dfbbd360 Support for completion of Java catch clause (completes exception classes) diff -r 8aaf6403a01d -r 51c4ee46f5c0 Make.proto --- a/Make.proto Thu Aug 07 15:02:26 2014 +0100 +++ b/Make.proto Thu Aug 07 16:48:17 2014 +0100 @@ -34,7 +34,7 @@ # add the path(es) here:, # ********** OPTIONAL: MODIFY the next lines *** # LOCALINCLUDES=-Ifoo -Ibar -LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/lint -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser -I$(INCLUDE_TOP)/stx/goodies/regex -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libbasic2 -I$(INCLUDE_TOP)/stx/libbasic3 -I$(INCLUDE_TOP)/stx/libcomp -I$(INCLUDE_TOP)/stx/libhtml -I$(INCLUDE_TOP)/stx/libjava -I$(INCLUDE_TOP)/stx/libjava/tools -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/libview -I$(INCLUDE_TOP)/stx/libview2 -I$(INCLUDE_TOP)/stx/libwidg -I$(INCLUDE_TOP)/stx/libwidg2 +LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/lint -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser -I$(INCLUDE_TOP)/stx/goodies/regex -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libbasic2 -I$(INCLUDE_TOP)/stx/libbasic3 -I$(INCLUDE_TOP)/stx/libcomp -I$(INCLUDE_TOP)/stx/libhtml -I$(INCLUDE_TOP)/stx/libjava -I$(INCLUDE_TOP)/stx/libjava/tools -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/libview -I$(INCLUDE_TOP)/stx/libview2 -I$(INCLUDE_TOP)/stx/libwidg -I$(INCLUDE_TOP)/stx/libwidg2 # if you need any additional defines for embedded C code, @@ -134,6 +134,7 @@ cd ../../libview && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" cd ../../libview2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" cd ../refactoryBrowser/browser && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" + cd ../sunit && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" cd ../../libwidg && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" cd ../refactoryBrowser/lint && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" cd ../../libhtml && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)" diff -r 8aaf6403a01d -r 51c4ee46f5c0 SmallSense__AbstractJavaCompletionEngine.st --- a/SmallSense__AbstractJavaCompletionEngine.st Thu Aug 07 15:02:26 2014 +0100 +++ b/SmallSense__AbstractJavaCompletionEngine.st Thu Aug 07 16:48:17 2014 +0100 @@ -63,42 +63,68 @@ !AbstractJavaCompletionEngine methodsFor:'completion-individual'! addClassesStartingWith: prefix - ^ self addClassesStartingWith: prefix fullName: false + ^ self addClassesStartingWith:prefix matchFullName:false "Created: / 03-10-2013 / 11:16:08 / Jan Vrany " "Modified: / 15-05-2014 / 07:25:24 / Jan Vrany " ! -addClassesStartingWith: prefixArg fullName: matchFullName +addClassesStartingWith:prefixArg filter: filter + ^ self addClassesStartingWith:prefixArg matchFullName:false filter: filter + + "Created: / 07-08-2014 / 15:04:02 / Jan Vrany " +! + +addClassesStartingWith:prefixArg matchFullName:matchFullName + ^ self addClassesStartingWith:prefixArg matchFullName:matchFullName filter: nil + + "Created: / 15-05-2014 / 07:24:20 / Jan Vrany " + "Modified: / 07-08-2014 / 15:03:43 / Jan Vrany " +! + +addClassesStartingWith:prefixArg matchFullName:matchFullName filter: filter | prefix | prefix := prefixArg. matchFullName ifTrue:[ - prefix := prefix copyReplaceAll: $. with: $/. + prefix := prefix copyReplaceAll:$. with:$/. ]. - context environment allClassesDo: [:cls | - cls isJavaClass ifTrue:[ - | name i | + context environment + allClassesDo:[:cls | + (cls isJavaClass and:[ cls isAnonymous not and:[filter isNil or:[filter value: cls]]]) ifTrue:[ + | name i | - matchFullName ifTrue:[ - (cls binaryName startsWith: prefix) ifTrue:[ - result add: ((PO forClas: cls) showPrefix: true; yourself). + matchFullName ifTrue:[ + (prefix isEmpty or:[cls binaryName startsWith:prefix]) ifTrue:[ + result add:((PO forClass:cls) + showPrefix:true; + yourself). + ]. + ] ifFalse:[ + name := cls lastName. + i := name lastIndexOf:$/. + prefix isEmptyOrNil ifTrue:[ + result add:(PO forClass:cls). + ] ifFalse:[ + ((name size >= (i + prefix size)) + and:[ + (name at:i + 1) == prefix first + and:[ + (name at:i + prefix size) == prefix last + and:[ + (2 to:prefix size - 1) + allSatisfy:[:o | (name at:i + o) == (prefix at:o) ] + ] + ] + ]) + ifTrue:[ result add:(PO forClass:cls). ]. + ] ]. - ] ifFalse:[ - name := cls lastName. - i := name lastIndexOf: $/. - ((name size >= (i + prefix size)) - and:[(name at: i + 1) == prefix first - and:[(name at: i + prefix size) == prefix last - and:[(2 to: prefix size - 1) allSatisfy:[:o| (name at: i + o) == (prefix at: o)]]]]) - ifTrue:[ - result add: (PO forClass: cls). - ]. ]. ]. - ]. - "Created: / 15-05-2014 / 07:24:20 / Jan Vrany " + "Created: / 07-08-2014 / 15:03:04 / Jan Vrany " + "Modified: / 07-08-2014 / 16:05:52 / Jan Vrany " ! addConstructorsForClass: aJavaClass fullName: showFullName @@ -111,6 +137,20 @@ "Created: / 15-05-2014 / 12:05:20 / Jan Vrany " ! +addExceptionsStartingWith: prefix + "raise an error: this method should be implemented (TODO)" + + ^ self addExceptionsStartingWith: prefix matchFullName: false + + "Created: / 07-08-2014 / 14:59:36 / Jan Vrany " +! + +addExceptionsStartingWith: prefix matchFullName: matchFullName + ^ self addClassesStartingWith: prefix matchFullName: matchFullName filter: [ :cls | cls isThrowable ]. + + "Created: / 07-08-2014 / 15:04:45 / Jan Vrany " +! + addFieldsForType: type | seen | diff -r 8aaf6403a01d -r 51c4ee46f5c0 SmallSense__AbstractJavaCompletionEngineSimple.st --- a/SmallSense__AbstractJavaCompletionEngineSimple.st Thu Aug 07 15:02:26 2014 +0100 +++ b/SmallSense__AbstractJavaCompletionEngineSimple.st Thu Aug 07 16:48:17 2014 +0100 @@ -122,13 +122,15 @@ #completeImport: . '[[:import:]] ( [[:Identifier:]](\.[[:Identifier:]])*\.? )? [[:CARET:]]' . #completeNew: . '[[:new:]] ( [[:Identifier:]](\.[[:Identifier:]])*\.?)? [[:CARET:]]' . #completeLocalDef: . '( ', PatternPrimitiveType , ' | ' , PatternReferenceType , ') [[:Identifier:]] [[:CARET:]]' . + #completeCatch: . '[[:catch:]] \( (' , PatternReferenceType , ' \.? )? [[:CARET:]]' . } " - self flush + self flush. self patternsForCompletion " "Created: / 19-05-2014 / 11:51:29 / Jan Vrany " + "Modified: / 07-08-2014 / 16:44:04 / Jan Vrany " ! ! !AbstractJavaCompletionEngineSimple class methodsFor:'queries'! @@ -308,6 +310,31 @@ "Modified: / 24-06-2014 / 11:13:20 / Jan Vrany " ! +completeCatch: match + | prefix | + + match size == 3 ifTrue:[ + self addExceptionsStartingWith: nil matchFullName: false. + ] ifFalse:[ + match size == 4 ifTrue:[ + prefix := (match at: 3) value asString. + self addExceptionsStartingWith: prefix matchFullName: prefix first isLowercase. + ] ifFalse:[ + | last | + + last := match size - 1"Carret token". + (match at: last) value == $. ifTrue:[ + last := last - 1. + ]. + prefix := String streamContents:[:s | 3 to: last do:[:i | s nextPutAll: (match at: i) value asString] ]. + self addExceptionsStartingWith: prefix matchFullName: true + ]. + ]. + + "Created: / 07-08-2014 / 14:59:36 / Jan Vrany " + "Modified: / 07-08-2014 / 16:10:20 / Jan Vrany " +! + completeImport: match | prefix | diff -r 8aaf6403a01d -r 51c4ee46f5c0 SmallSense__AbstractJavaCompletionEngineTests.st --- a/SmallSense__AbstractJavaCompletionEngineTests.st Thu Aug 07 15:02:26 2014 +0100 +++ b/SmallSense__AbstractJavaCompletionEngineTests.st Thu Aug 07 16:48:17 2014 +0100 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE Copyright (C) 2013-2014 Jan Vrany @@ -68,3 +70,115 @@ ^ self == AbstractJavaCompletionEngineTests. ! ! +!AbstractJavaCompletionEngineTests methodsFor:'tests - completion'! + +test_complete_catch_01a + " + Test catch completion + " + + | java_io_IOException | + + self complete:'try { + do(something); + } catch ( IOE┃'. + + java_io_IOException := context environment == Smalltalk + ifTrue:[ context environment classNamed: #'JAVA::java::io::IOException' ] + ifFalse:[ context environment classNamed: #'java/io/IOException']. + + self assert: result notEmpty. + self assert: (result allSatisfy:[:each | each isSmallSenseClassPO ]). + self assert: (result contains:[:each | each klass == java_io_IOException ]). + + "Created: / 07-08-2014 / 15:11:57 / Jan Vrany " +! + +test_complete_catch_01b + " + Test catch completion + " + + | java_io_IOException | + + self complete:'try { + do(something); + } catch ( ┃'. + + java_io_IOException := context environment == Smalltalk + ifTrue:[ context environment classNamed: #'JAVA::java::io::IOException' ] + ifFalse:[ context environment classNamed: #'java/io/IOException']. + + self assert: result notEmpty. + self assert: (result allSatisfy:[:each | each isSmallSenseClassPO ]). + self assert: (result contains:[:each | each klass == java_io_IOException ]). + + "Created: / 07-08-2014 / 16:02:29 / Jan Vrany " +! + +test_complete_catch_01c + " + Test catch completion + " + + | java_io_IOException | + + self complete:'try { + do(something); + } catch ( java.io.IO┃'. + + java_io_IOException := context environment == Smalltalk + ifTrue:[ context environment classNamed: #'JAVA::java::io::IOException' ] + ifFalse:[ context environment classNamed: #'java/io/IOException']. + + self assert: result notEmpty. + self assert: (result allSatisfy:[:each | each isSmallSenseClassPO ]). + self assert: (result contains:[:each | each klass == java_io_IOException ]). + + "Created: / 07-08-2014 / 16:07:40 / Jan Vrany " +! + +test_complete_catch_01d + " + Test catch completion + " + + | java_io_IOException | + + self complete:'try { + do(something); + } catch ( java.io.┃'. + + java_io_IOException := context environment == Smalltalk + ifTrue:[ context environment classNamed: #'JAVA::java::io::IOException' ] + ifFalse:[ context environment classNamed: #'java/io/IOException']. + + self assert: result notEmpty. + self assert: (result allSatisfy:[:each | each isSmallSenseClassPO ]). + self assert: (result contains:[:each | each klass == java_io_IOException ]). + + "Created: / 07-08-2014 / 16:08:46 / Jan Vrany " +! + +test_complete_catch_01e + " + Test catch completion + " + + | java_io_IOException | + + self complete:'try { + do(something); + } catch ( jav┃'. + + java_io_IOException := context environment == Smalltalk + ifTrue:[ context environment classNamed: #'JAVA::java::io::IOException' ] + ifFalse:[ context environment classNamed: #'java/io/IOException']. + + self assert: result notEmpty. + self assert: (result allSatisfy:[:each | each isSmallSenseClassPO ]). + self assert: (result contains:[:each | each klass == java_io_IOException ]). + + "Created: / 07-08-2014 / 16:20:02 / Jan Vrany " +! ! + diff -r 8aaf6403a01d -r 51c4ee46f5c0 SmallSense__ClassPO.st --- a/SmallSense__ClassPO.st Thu Aug 07 15:02:26 2014 +0100 +++ b/SmallSense__ClassPO.st Thu Aug 07 16:48:17 2014 +0100 @@ -96,12 +96,17 @@ showPrefix ifTrue:[ label := klass name. (context notNil and:[klass isJavaClass]) ifTrue:[ - context language isJava ifTrue:[ + | lang | + + lang := context language. + (lang notNil and:[lang isJava]) ifTrue:[ label := klass javaName ] ifFalse:[ - context language isSmalltalk ifTrue:[ + (lang notNil and:[lang isSmalltalk]) ifTrue:[ label := 'JAVA ' , (klass binaryName copyReplaceAll: $/ with: Character space) - ] + ] ifFalse:[ + label := klass nameWithoutNameSpacePrefix. + ]. ] ]. ] ifFalse:[ @@ -112,7 +117,7 @@ ^label "Created: / 20-05-2014 / 11:29:38 / Jan Vrany " - "Modified: / 24-07-2014 / 17:30:08 / Jan Vrany " + "Modified: / 07-08-2014 / 16:19:43 / Jan Vrany " ! showPrefix diff -r 8aaf6403a01d -r 51c4ee46f5c0 abbrev.stc --- a/abbrev.stc Thu Aug 07 15:02:26 2014 +0100 +++ b/abbrev.stc Thu Aug 07 16:48:17 2014 +0100 @@ -65,9 +65,9 @@ SmallSense::MethodKeywordRestPO SmallSense__MethodKeywordRestPO stx:goodies/smallsense 'SmallSense-Core-Interface-PO' 0 SmallSense::JavaCompletionEngineSimple SmallSense__JavaCompletionEngineSimple stx:goodies/smallsense 'SmallSense-Java' 2 SmallSense::GroovyCompletionEngineSimple SmallSense__GroovyCompletionEngineSimple stx:goodies/smallsense 'SmallSense-Groovy' 2 +SmallSense::CompletionEngineTests SmallSense__CompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1 SmallSense::AbstractJavaCompletionEngineTests SmallSense__AbstractJavaCompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1 SmallSense::BaseTestClass SmallSense__BaseTestClass stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1 -SmallSense::CompletionEngineTests SmallSense__CompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1 SmallSense::FinderTests SmallSense__FinderTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1 SmallSense::GroovyCompletionEngineSimpleTests SmallSense__GroovyCompletionEngineSimpleTests stx:goodies/smallsense 'SmallSense-Tests' 1 SmallSense::JavaCompletionEngineEnvironmentResource SmallSense__JavaCompletionEngineEnvironmentResource stx:goodies/smallsense 'SmallSense-Tests' 1 diff -r 8aaf6403a01d -r 51c4ee46f5c0 bc.mak --- a/bc.mak Thu Aug 07 15:02:26 2014 +0100 +++ b/bc.mak Thu Aug 07 16:48:17 2014 +0100 @@ -34,7 +34,7 @@ -LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\lint -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser -I$(INCLUDE_TOP)\stx\goodies\regex -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libbasic2 -I$(INCLUDE_TOP)\stx\libbasic3 -I$(INCLUDE_TOP)\stx\libcomp -I$(INCLUDE_TOP)\stx\libhtml -I$(INCLUDE_TOP)\stx\libjava -I$(INCLUDE_TOP)\stx\libjava\tools -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\libview -I$(INCLUDE_TOP)\stx\libview2 -I$(INCLUDE_TOP)\stx\libwidg -I$(INCLUDE_TOP)\stx\libwidg2 +LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\lint -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser -I$(INCLUDE_TOP)\stx\goodies\regex -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libbasic2 -I$(INCLUDE_TOP)\stx\libbasic3 -I$(INCLUDE_TOP)\stx\libcomp -I$(INCLUDE_TOP)\stx\libhtml -I$(INCLUDE_TOP)\stx\libjava -I$(INCLUDE_TOP)\stx\libjava\tools -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\libview -I$(INCLUDE_TOP)\stx\libview2 -I$(INCLUDE_TOP)\stx\libwidg -I$(INCLUDE_TOP)\stx\libwidg2 LOCALDEFINES= STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) -headerDir=. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) -varPrefix=$(LIBNAME) @@ -61,6 +61,7 @@ pushd ..\..\libview & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " pushd ..\..\libview2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " pushd ..\refactoryBrowser\browser & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " + pushd ..\sunit & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " pushd ..\..\libwidg & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " pushd ..\refactoryBrowser\lint & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " pushd ..\..\libhtml & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) " diff -r 8aaf6403a01d -r 51c4ee46f5c0 extensions.st --- a/extensions.st Thu Aug 07 15:02:26 2014 +0100 +++ b/extensions.st Thu Aug 07 16:48:17 2014 +0100 @@ -476,12 +476,19 @@ | cls | cls := env at:nm. - (cls notNil - and:[ cls isBehavior and:[ (matches includesIdentical:cls) not ] ]) + (cls notNil and:[ cls isBehavior and:[ (matches includesIdentical:cls) not ] ]) ifTrue:[ - (matcher value:cls) ifTrue:[ - matches add:cls - ]. + "cls isJavaClass"false ifTrue:[ + cls isAnonymous ifFalse:[ + (matcher value:cls) ifTrue:[ + matches add:cls + ]. + ]. + ] ifFalse:[ + (matcher value:cls) ifTrue:[ + matches add:cls + ]. + ] ]. ]. relax := relax + 1. @@ -500,6 +507,7 @@ ] "Created: / 06-04-2012 / 12:56:10 / Jan Vrany " + "Modified: / 07-08-2014 / 13:10:50 / Jan Vrany " ! ! !UserPreferences methodsFor:'accessing-SmallSense'! diff -r 8aaf6403a01d -r 51c4ee46f5c0 smallsense.rc --- a/smallsense.rc Thu Aug 07 15:02:26 2014 +0100 +++ b/smallsense.rc Thu Aug 07 16:48:17 2014 +0100 @@ -25,7 +25,7 @@ VALUE "LegalCopyright", "Copyright Jan Vrany 2013-2014\0" VALUE "ProductName", "SmallSense\0" VALUE "ProductVersion", "6.2.4.0\0" - VALUE "ProductDate", "Thu, 24 Jul 2014 09:27:12 GMT\0" + VALUE "ProductDate", "Thu, 07 Aug 2014 15:45:08 GMT\0" END END diff -r 8aaf6403a01d -r 51c4ee46f5c0 stx_goodies_smallsense.st --- a/stx_goodies_smallsense.st Thu Aug 07 15:02:26 2014 +0100 +++ b/stx_goodies_smallsense.st Thu Aug 07 16:48:17 2014 +0100 @@ -231,9 +231,9 @@ #'SmallSense::MethodKeywordRestPO' #'SmallSense::JavaCompletionEngineSimple' #'SmallSense::GroovyCompletionEngineSimple' + (#'SmallSense::CompletionEngineTests' autoload) (#'SmallSense::AbstractJavaCompletionEngineTests' autoload) (#'SmallSense::BaseTestClass' autoload) - (#'SmallSense::CompletionEngineTests' autoload) (#'SmallSense::FinderTests' autoload) (#'SmallSense::GroovyCompletionEngineSimpleTests' autoload) (#'SmallSense::JavaCompletionEngineEnvironmentResource' autoload) @@ -242,6 +242,8 @@ (#'SmallSense::TestCase' autoload) (#'SmallSense::TokenPatternMatcherTests' autoload) ) + + "Modified: / 07-08-2014 / 11:59:02 / Jan Vrany " ! extensionMethodNames