refactoring_custom/SmallSense__CustomRBLocalSourceCodeFormatter.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 13 Nov 2017 22:26:12 -0300
changeset 1060 af3a048f9618
parent 833 297eb38e4eee
child 1072 a44c741ee5ef
permissions -rw-r--r--
Fixed xompletion of instance variables in inspector
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
828
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
     1
"
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
     2
A custom code generation and refactoring support for Smalltalk/X
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
     3
Copyright (C) 2013-2015 Jakub Nesveda
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
     4
Copyright (C) 2013-now  Jan Vrany
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
     5
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
     6
This library is free software; you can redistribute it and/or
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
     7
modify it under the terms of the GNU Lesser General Public
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
     8
License as published by the Free Software Foundation; either
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
     9
version 2.1 of the License.
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    10
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    11
This library is distributed in the hope that it will be useful,
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    12
but WITHOUT ANY WARRANTY; without even the implied warranty of
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    14
Lesser General Public License for more details.
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    15
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    16
You should have received a copy of the GNU Lesser General Public
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    17
License along with this library; if not, write to the Free Software
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    19
"
833
297eb38e4eee Package jn:refactoring_custom renamed to stx:goodies/smallsense/refactoring_custom
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 830
diff changeset
    20
"{ Package: 'stx:goodies/smallsense/refactoring_custom' }"
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    21
830
1a88f5e65fe2 Classes moved to namespace SmallSense
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 828
diff changeset
    22
"{ NameSpace: SmallSense }"
803
95cdac772759 Fixed failing tests caused by new STX release
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 781
diff changeset
    23
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    24
CustomSourceCodeFormatter subclass:#CustomRBLocalSourceCodeFormatter
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    25
	instanceVariableNames:'localFormatterSettings originalFormatterSettings formatterClass'
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    26
	classVariableNames:''
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    27
	poolDictionaries:''
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    28
	category:'Interface-Refactoring-Custom'
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    29
!
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    30
776
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    31
!CustomRBLocalSourceCodeFormatter class methodsFor:'documentation'!
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    32
828
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    33
copyright
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    34
"
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    35
A custom code generation and refactoring support for Smalltalk/X
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    36
Copyright (C) 2013-2015 Jakub Nesveda
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    37
Copyright (C) 2013-now  Jan Vrany
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    38
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    39
This library is free software; you can redistribute it and/or
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    40
modify it under the terms of the GNU Lesser General Public
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    41
License as published by the Free Software Foundation; either
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    42
version 2.1 of the License.
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    43
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    44
This library is distributed in the hope that it will be useful,
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    45
but WITHOUT ANY WARRANTY; without even the implied warranty of
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    46
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    47
Lesser General Public License for more details.
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    48
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    49
You should have received a copy of the GNU Lesser General Public
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    50
License along with this library; if not, write to the Free Software
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    51
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    52
"
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    53
!
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 804
diff changeset
    54
776
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    55
documentation
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    56
"
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    57
    Source code formatter based on RBFormatter, but with settings stored in instance variable.
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    58
    Formatting itself temporarily changes global settings then performs formatting and
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    59
    ensures that original settings are restored.
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    60
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    61
    [author:]
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    62
        Jakub Nesveda <nesvejak@fit.cvut.cz> 
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    63
"
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    64
! !
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
    65
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    66
!CustomRBLocalSourceCodeFormatter methodsFor:'accessing'!
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    67
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    68
doesNotUnderstand: aMessage
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    69
    "Store RBFormatter local settings"
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    70
    | selector arguments |
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    71
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    72
    selector := aMessage selector asSymbol.
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    73
    arguments := aMessage arguments.
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    74
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    75
    ((formatterClass class canUnderstand: selector) and: [arguments size <= 1]) ifTrue: [
804
14025d247548 Improved code quality/readibility with help of Smalllint
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 803
diff changeset
    76
        (arguments isEmpty) ifTrue: [
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    77
            ^ localFormatterSettings at: selector.
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    78
        ] ifFalse: [
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    79
            | accessor |
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    80
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    81
            accessor := (selector copyFrom:1 to:(selector size - 1)) asSymbol.
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    82
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    83
            ^ localFormatterSettings at: accessor put: (arguments first).
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    84
        ]
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    85
    ].
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    86
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    87
    ^ super doesNotUnderstand: aMessage.
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    88
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    89
    "Created: / 28-08-2014 / 22:39:16 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
804
14025d247548 Improved code quality/readibility with help of Smalllint
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 803
diff changeset
    90
    "Modified: / 25-01-2015 / 15:37:39 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    91
!
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    92
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    93
formatterClass
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    94
    ^ formatterClass
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    95
!
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    96
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    97
formatterClass:something
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
    98
    formatterClass := something.
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    99
! !
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   100
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   101
!CustomRBLocalSourceCodeFormatter methodsFor:'formatting'!
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   102
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   103
formatParseTree:aParseTree
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   104
    "Return parse tree formatted as source code with custom RBFormatter settings"
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   105
    | source |
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   106
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   107
    [
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   108
        self setUpFormatterSettings.
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   109
        aParseTree source notNil ifTrue:[
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   110
            "normally aParseTree >> formattedCode should return formatted string,
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   111
            but there is some error with building syntax-valid source code"
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   112
            source := self formatSourceCode: aParseTree source
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   113
        ] ifFalse:[
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   114
            source := aParseTree formattedCode
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   115
        ].
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   116
    ] ensure: [
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   117
        self restoreFormatterSettings.
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   118
    ].
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   119
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   120
    ^ source
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   121
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   122
    "Modified: / 29-08-2014 / 00:12:31 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   123
!
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   124
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   125
formatSourceCode:aSourceCodeString
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   126
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   127
    ^ formatterClass format: aSourceCodeString
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   128
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   129
    "Created: / 28-08-2014 / 23:58:41 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   130
    "Modified: / 31-08-2014 / 10:59:36 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   131
! !
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   132
781
07c16cc3cf55 Same method protocol name (initialization) for initialize method
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 776
diff changeset
   133
!CustomRBLocalSourceCodeFormatter methodsFor:'initialization'!
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   134
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   135
initialize
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   136
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   137
    localFormatterSettings := IdentityDictionary new.
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   138
    formatterClass := RBFormatter.
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   139
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   140
    "Created: / 28-08-2014 / 23:05:44 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   141
    "Modified: / 31-08-2014 / 10:58:58 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   142
!
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   143
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   144
restoreFormatterSettings
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   145
    "see setUpFormatterSettings "
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   146
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   147
    originalFormatterSettings keysAndValuesDo: [ :key :value |
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   148
        formatterClass perform: key asMutator with: value.   
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   149
    ].
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   150
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   151
    "Modified: / 31-08-2014 / 14:59:41 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   152
!
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   153
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   154
setUpFormatterSettings
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   155
    "Settings for RBFormatter to keep formatting settings independent on system settings.
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   156
    Actually this is not perfect solution because of global scope modifications - imagine
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   157
    parallel execution. "
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   158
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   159
    originalFormatterSettings := IdentityDictionary new.
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   160
    localFormatterSettings keysAndValuesDo: [ :key :value |
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   161
        originalFormatterSettings at: key put: (formatterClass perform: key).
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   162
        formatterClass perform: key asMutator with: value.   
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   163
    ].
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   164
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   165
    "Created: / 20-08-2014 / 22:21:17 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
662
9d766cee6d31 add unit tests for CustomSourceCodeFormatter(s)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 653
diff changeset
   166
    "Modified: / 31-08-2014 / 15:00:09 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
653
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   167
! !
7ad678c3b850 first draft (14 tests not passing) - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   168
776
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
   169
!CustomRBLocalSourceCodeFormatter class methodsFor:'documentation'!
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
   170
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
   171
version_HG
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
   172
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
   173
    ^ '$Changeset: <not expanded> $'
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
   174
! !
60cfe4149838 added missing source code formatting classes documentation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 662
diff changeset
   175