SmallSense__SmalltalkQuickFixer.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 13:09:49 +0100
changeset 1078 0770d24b5310
parent 1072 a44c741ee5ef
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present - All source *.st files are now Unicode UTF8 without BOM Files are in two groups (fileOut works this way in Smalltalk/X): - containing a unicode character have "{ Encoding: utf8 }" at the header - ASCII only are without the header
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: 315
diff changeset
     3
Copyright (C) 2013-2015 Jan Vrany
1072
a44c741ee5ef Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 889
diff changeset
     4
Copyright (C) 2014 Claus Gittinger
a44c741ee5ef Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 889
diff changeset
     5
Copyright (C) 2015 Claus Gittinger
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
1072
a44c741ee5ef Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 889
diff changeset
    45
Copyright (C) 2014 Claus Gittinger
a44c741ee5ef Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 889
diff changeset
    46
Copyright (C) 2015 Claus Gittinger
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    47
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    48
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
    49
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
    50
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
    51
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
    52
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    53
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
    54
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
    55
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
    56
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
    57
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    58
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
    59
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
    60
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
    61
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    62
! !
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    64
!SmalltalkQuickFixer class methodsFor:'instance creation'!
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
forView: 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
    ^self new initializeForView: view
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
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
    70
    "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
    71
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
312
ce4e697a363c Few changes in SmallLint Critics Window
Claus Gittinger
parents: 296
diff changeset
    73
!SmalltalkQuickFixer methodsFor:'accessing'!
ce4e697a363c Few changes in SmallLint Critics Window
Claus Gittinger
parents: 296
diff changeset
    74
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
    75
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
    76
    ^ 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
    77
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
    78
    "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
    79
! !
ce4e697a363c Few changes in SmallLint Critics Window
Claus Gittinger
parents: 296
diff changeset
    80
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    81
!SmalltalkQuickFixer methodsFor:'adding'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
fix
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
    "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
    85
     rule, label and action"
64
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 |
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
    fix := QuickFix new.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
    fixes add: fix.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
    ^fix
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
    "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
    94
    "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
    95
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    97
!SmalltalkQuickFixer methodsFor:'initialization'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
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
    99
initializeForView: aCodeView2
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
    view := aCodeView2.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
    fixes := OrderedCollection new: 3.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
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
   103
    "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
   104
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
   106
!SmalltalkQuickFixer methodsFor:'performing fixes'!
64
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
performFix: index
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
    index <= fixes size ifTrue:[
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
        (fixes at: index) performFix.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
    ] ifFalse:[
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
        ^ 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
   114
    ]
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
    "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
   117
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
   119
!SmalltalkQuickFixer methodsFor:'utilities'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
97
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   121
apply: changes 
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   122
    changes isEmptyOrNil ifTrue: [
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   123
        ^ self
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   124
    ].
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   125
    (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
   126
        "/ 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
   127
981a82217e4c UX improvement for quick fixes: do not scroll to the top
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   128
        | oldSource newSource |
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
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
   130
        oldSource := view contents asString string.
97
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   131
        newSource := changes anElement source asString.
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   132
        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
   133
            | line |
981a82217e4c UX improvement for quick fixes: do not scroll to the top
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   134
889
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   135
            view 
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   136
                undoableDo:[
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   137
                    line := view firstLineShown.
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   138
                    view replaceContentsWith:newSource asStringCollection.
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   139
"/                    view contents: newSource asStringCollection clear: false.
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   140
                    view modified: true.
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   141
                    view isCodeView2 ifTrue: [
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   142
                        view reallyModifiedChannel value: true.
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
                    view scrollToLine:line.     
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   145
                ]
54e2a1443d3d class: SmallSense::SmalltalkQuickFixer
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   146
                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
   147
        ].
97
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   148
    ] ifFalse: [
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
        | browser |
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
97
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   151
        browser := view application topApplication.
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   152
        (browser respondsTo: #performRefactoring:) ifTrue: [
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   153
            browser performRefactoring: changes.
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   154
        ] ifFalse: [
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   155
            self breakPoint: #jv.
062cd1535107 Fix in SmallSense::SmalltalkQuickFixer>>#apply:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 92
diff changeset
   156
            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
   157
        ]
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
    ]
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
    "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
   161
    "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
   162
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
   164
!SmalltalkQuickFixer::QuickFix methodsFor:'accessing'!
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
action
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
    ^ action
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
action:aBlock
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
    action := aBlock.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
label
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
    ^ label
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
label:aString
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
    label := aString.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
!
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
performFix
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
    ^action value
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
    "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
   187
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
rule
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
    ^ rule
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
rule:anRBLintRule
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
    rule := anRBLintRule.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
   197
!SmalltalkQuickFixer class methodsFor:'documentation'!
64
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
version_HG
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
    ^ '$Changeset: <not expanded> $'
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
version_SVN
320
5242593726f0 Updated from upstream repository to revision 0a4845a0c211
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 315
diff changeset
   205
    ^ '$Id$'
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207