SmallSense__SmalltalkQuickFixer.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 25 Oct 2017 23:42:41 +0100
changeset 1058 6d4bf422a7dd
parent 889 54e2a1443d3d
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:
889
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
     1
"{ Encoding: utf8 }"
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
     2
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     3
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     4
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 315
diff changeset
     5
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
     6
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     7
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
     8
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
     9
License as published by the Free Software Foundation; either
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    10
version 2.1 of the License. 
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    11
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    12
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
    13
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
    14
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
    15
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
    16
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    17
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
    18
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
    19
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
    20
"
249
8bc64027b189 Package renamed to stx:goodies/smallsense
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 174
diff changeset
    21
"{ Package: 'stx:goodies/smallsense' }"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
"{ NameSpace: SmallSense }"
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    25
Object subclass:#SmalltalkQuickFixer
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	instanceVariableNames:'view rule fixes'
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	classVariableNames:''
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
	poolDictionaries:''
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    29
	category:'SmallSense-Smalltalk-Lint'
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
Object subclass:#QuickFix
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
	instanceVariableNames:'rule label action'
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
	classVariableNames:''
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
	poolDictionaries:''
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    36
	privateIn:SmalltalkQuickFixer
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    39
!SmalltalkQuickFixer class methodsFor:'documentation'!
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    40
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    41
copyright
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    42
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    43
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 315
diff changeset
    44
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
    45
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    46
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
    47
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
    48
License as published by the Free Software Foundation; either
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    49
version 2.1 of the License. 
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
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
    52
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
    53
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
    54
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
    55
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    56
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
    57
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
    58
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
    59
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    60
! !
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    62
!SmalltalkQuickFixer class methodsFor:'instance creation'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
315
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    64
forView: view
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
315
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    66
    ^self new initializeForView: view
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
315
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    68
    "Created: / 15-12-2014 / 16:45:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
312
ce4e697a363c Few changes in SmallLint Critics Window
Claus Gittinger
parents: 296
diff changeset
    71
!SmalltalkQuickFixer methodsFor:'accessing'!
ce4e697a363c Few changes in SmallLint Critics Window
Claus Gittinger
parents: 296
diff changeset
    72
315
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    73
fixesForRule: rule
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    74
    ^ fixes select:[:fix | fix rule == rule ]
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    75
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    76
    "Created: / 15-12-2014 / 16:47:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
312
ce4e697a363c Few changes in SmallLint Critics Window
Claus Gittinger
parents: 296
diff changeset
    77
! !
ce4e697a363c Few changes in SmallLint Critics Window
Claus Gittinger
parents: 296
diff changeset
    78
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    79
!SmalltalkQuickFixer methodsFor:'adding'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
fix
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
    "Create and return new quick fix. Caller MUST set its 
315
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    83
     rule, label and action"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
    | fix |
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
    fix := QuickFix new.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
    fixes add: fix.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
    ^fix
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
    "Created: / 01-02-2012 / 10:51:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
315
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    92
    "Modified (comment): / 15-12-2014 / 16:48:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    95
!SmalltalkQuickFixer methodsFor:'initialization'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
315
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
    97
initializeForView: aCodeView2
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
    view := aCodeView2.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
    fixes := OrderedCollection new: 3.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
315
0a4845a0c211 Update to catchup changes in libtool: refactoring to support multiple lint warnings at line
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 312
diff changeset
   101
    "Created: / 15-12-2014 / 16:46:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
   104
!SmalltalkQuickFixer methodsFor:'performing fixes'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
performFix: index
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
    index <= fixes size ifTrue:[
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
        (fixes at: index) performFix.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
    ] ifFalse:[
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
        ^ Dialog warn: ('No such fix (%1)' bindWith: index).
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
    ]
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
    "Created: / 16-02-2012 / 14:48:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
   117
!SmalltalkQuickFixer methodsFor:'utilities'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
97
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   119
apply: changes 
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   120
    changes isEmptyOrNil ifTrue: [
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   121
        ^ self
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   122
    ].
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   123
    (changes size == 1 and: [ changes anElement isMethodCodeChange ]) ifTrue: [
296
981a82217e4c UX improvement for quick fixes: do not scroll to the top
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   124
        "/ Only one change, modify the code directly in the editor
981a82217e4c UX improvement for quick fixes: do not scroll to the top
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   125
981a82217e4c UX improvement for quick fixes: do not scroll to the top
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   126
        | oldSource newSource |
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
92
67592095147e Improvement in QuickFixer - if the fix is local to the method, only update codeview's contents.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   128
        oldSource := view contents asString string.
97
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   129
        newSource := changes anElement source asString.
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   130
        oldSource ~= newSource ifTrue: [
296
981a82217e4c UX improvement for quick fixes: do not scroll to the top
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   131
            | line |
981a82217e4c UX improvement for quick fixes: do not scroll to the top
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   132
889
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   133
            view 
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   134
                undoableDo:[
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   135
                    line := view firstLineShown.
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   136
                    view replaceContentsWith:newSource asStringCollection.
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   137
"/                    view contents: newSource asStringCollection clear: false.
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   138
                    view modified: true.
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   139
                    view isCodeView2 ifTrue: [
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   140
                        view reallyModifiedChannel value: true.
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   141
                    ].
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   142
                    view scrollToLine:line.     
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   143
                ]
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   144
                info:'Rewrite the code'.
92
67592095147e Improvement in QuickFixer - if the fix is local to the method, only update codeview's contents.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   145
        ].
97
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   146
    ] ifFalse: [
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
        | browser |
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
97
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   149
        browser := view application topApplication.
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   150
        (browser respondsTo: #performRefactoring:) ifTrue: [
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   151
            browser performRefactoring: changes.
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   152
        ] ifFalse: [
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   153
            self breakPoint: #jv.
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   154
            Dialog warn:'Sorry, this application does not support quick fixes'
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   155
        ]
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
    ]
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
    "Created: / 16-02-2012 / 14:46:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
296
981a82217e4c UX improvement for quick fixes: do not scroll to the top
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   159
    "Modified: / 16-10-2014 / 03:05:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
   162
!SmalltalkQuickFixer::QuickFix methodsFor:'accessing'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
action
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
    ^ action
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
action:aBlock
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
    action := aBlock.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
label
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
    ^ label
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
label:aString
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
    label := aString.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
performFix
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
    ^action value
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
    "Created: / 16-02-2012 / 14:48:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
rule
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
    ^ rule
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
rule:anRBLintRule
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
    rule := anRBLintRule.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
   195
!SmalltalkQuickFixer class methodsFor:'documentation'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
version_HG
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
    ^ '$Changeset: <not expanded> $'
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
version_SVN
320
5242593726f0 Updated from upstream repository to revision 0a4845a0c211
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 315
diff changeset
   203
    ^ '$Id$'
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205