SmallSense__GroovyCompletionEngineSimple.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 25 Oct 2017 23:42:41 +0100
changeset 1058 6d4bf422a7dd
parent 382 4df672779edd
child 1072 a44c741ee5ef
permissions -rw-r--r--
Fix subscript out of bounds error in Smalltalk inderences ...caused by missing size-check when analysing typed prefix.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     1
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     2
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
     3
Copyright (C) 2013-2015 Jan Vrany
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     4
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     5
This library is free software; you can redistribute it and/or
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     6
modify it under the terms of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     7
License as published by the Free Software Foundation; either
354
cbffe76c9b5a Merged b1170c3a4585 and f65e37b6bd77
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
     8
version 2.1 of the License.
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     9
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    10
This library is distributed in the hope that it will be useful,
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    11
but WITHOUT ANY WARRANTY; without even the implied warranty of
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    13
Lesser General Public License for more details.
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    14
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    15
You should have received a copy of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    16
License along with this library; if not, write to the Free Software
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    18
"
249
8bc64027b189 Package renamed to stx:goodies/smallsense
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
    19
"{ Package: 'stx:goodies/smallsense' }"
120
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
"{ NameSpace: SmallSense }"
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
JavaCompletionEngineSimple subclass:#GroovyCompletionEngineSimple
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
	instanceVariableNames:''
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
	classVariableNames:''
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	poolDictionaries:''
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	category:'SmallSense-Groovy'
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
!
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    30
!GroovyCompletionEngineSimple class methodsFor:'documentation'!
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    31
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    32
copyright
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    33
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    34
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
    35
Copyright (C) 2013-2015 Jan Vrany
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    36
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    37
This library is free software; you can redistribute it and/or
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    38
modify it under the terms of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    39
License as published by the Free Software Foundation; either
354
cbffe76c9b5a Merged b1170c3a4585 and f65e37b6bd77
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
    40
version 2.1 of the License.
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    41
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    42
This library is distributed in the hope that it will be useful,
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    43
but WITHOUT ANY WARRANTY; without even the implied warranty of
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    44
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    45
Lesser General Public License for more details.
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    46
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    47
You should have received a copy of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    48
License along with this library; if not, write to the Free Software
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    49
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    50
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    51
! !
161
5ff416530ac4 Fx in Smalltalk code completion - do not complete inside comments.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 157
diff changeset
    52
225
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    53
!GroovyCompletionEngineSimple class methodsFor:'accessing-definitions'!
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    54
234
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    55
patternDefinitionsForAnalysis
354
cbffe76c9b5a Merged b1170c3a4585 and f65e37b6bd77
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
    56
    ^ super patternDefinitionsForAnalysis , {
234
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    57
        #analyzeLocalDef1:              .  '[[:def:]] [[:Identifier:]] ( = | ; )' .
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    58
    }
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    59
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    60
    "
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    61
    self flush; patternsForAnalysis
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    62
    "
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    63
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    64
    "Created: / 23-05-2014 / 10:24:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    65
!
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    66
225
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    67
patternDefinitionsForCompletion
354
cbffe76c9b5a Merged b1170c3a4585 and f65e37b6bd77
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
    68
cbffe76c9b5a Merged b1170c3a4585 and f65e37b6bd77
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
    69
    ^super patternDefinitionsForCompletion , {
225
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    70
        #completeLocalDef:              . '( ', PatternPrimitiveType , ' | ' , PatternReferenceType , ' | [[:def:]] ) [[:Identifier:]] [[:CARET:]]' .
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    71
    }
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    72
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    73
    "
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    74
    self flush.
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    75
    self patternsForCompletion
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    76
    "
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    77
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    78
    "Created: / 19-05-2014 / 12:32:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    79
! !
67c827ba6b28 Java/Groovy simple completion: better behaviour for completing local variable declaration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 207
diff changeset
    80
207
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    81
!GroovyCompletionEngineSimple methodsFor:'accessing-class'!
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    82
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    83
scannerClass
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    84
    "raise an error: this method should be implemented (TODO)"
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    85
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    86
    ^ GroovyScanner
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    87
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    88
    "Created: / 13-05-2014 / 17:46:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    89
! !
543ed815511c Make GroovyCompletionEngineSimple use a GrrovyScanner (instead of JavaScanner)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 206
diff changeset
    90
234
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    91
!GroovyCompletionEngineSimple methodsFor:'analysis'!
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    92
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    93
analyzeLocalDef1: match
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    94
    "Analyze:
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    95
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    96
    def <identifier> ;
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    97
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    98
    "
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
    99
    | name |
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
   100
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
   101
    self assert: match size = 3.
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
   102
    name := (match at: match size - 1) value.
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
   103
    locals at: name put: nil.
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
   104
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
   105
    "Created: / 23-05-2014 / 10:26:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
   106
! !
97857872ee47 Initial set of tests for GroovyCompletionEngineSimple (along with some fixes)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 225
diff changeset
   107
161
5ff416530ac4 Fx in Smalltalk code completion - do not complete inside comments.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 157
diff changeset
   108
!GroovyCompletionEngineSimple class methodsFor:'documentation'!
5ff416530ac4 Fx in Smalltalk code completion - do not complete inside comments.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 157
diff changeset
   109
5ff416530ac4 Fx in Smalltalk code completion - do not complete inside comments.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 157
diff changeset
   110
version_HG
5ff416530ac4 Fx in Smalltalk code completion - do not complete inside comments.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 157
diff changeset
   111
5ff416530ac4 Fx in Smalltalk code completion - do not complete inside comments.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 157
diff changeset
   112
    ^ '$Changeset: <not expanded> $'
5ff416530ac4 Fx in Smalltalk code completion - do not complete inside comments.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 157
diff changeset
   113
! !
5ff416530ac4 Fx in Smalltalk code completion - do not complete inside comments.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 157
diff changeset
   114