refactoring_custom/SmallSense__CustomJavaScriptSimpleSetterMethodsCodeGenerator.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 02 Jul 2018 08:46:03 +0200
changeset 1073 c591c75fe5a8
parent 1072 a44c741ee5ef
permissions -rw-r--r--
Tagged Smalltalk/X 8.0.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
828
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
     1
"
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
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: 808
diff changeset
     3
Copyright (C) 2013-2015 Jakub Nesveda
1072
a44c741ee5ef Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 833
diff changeset
     4
Copyright (C) 2015 Jan Vrany
828
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
     5
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
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: 808
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: 808
diff changeset
     8
License as published by the Free Software Foundation; either
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
     9
version 2.1 of the License.
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    10
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
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: 808
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: 808
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: 808
diff changeset
    14
Lesser General Public License for more details.
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    15
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
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: 808
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: 808
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: 808
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' }"
808
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
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 }"
808
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    23
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    24
CustomSimpleSetterMethodsCodeGenerator subclass:#CustomJavaScriptSimpleSetterMethodsCodeGenerator
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    25
	instanceVariableNames:''
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    26
	classVariableNames:''
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    27
	poolDictionaries:''
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    28
	category:'Interface-Refactoring-Custom-Generators'
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    29
!
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    30
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    31
!CustomJavaScriptSimpleSetterMethodsCodeGenerator class methodsFor:'documentation'!
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    32
828
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    33
copyright
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    34
"
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
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: 808
diff changeset
    36
Copyright (C) 2013-2015 Jakub Nesveda
1072
a44c741ee5ef Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 833
diff changeset
    37
Copyright (C) 2015 Jan Vrany
828
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    38
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
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: 808
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: 808
diff changeset
    41
License as published by the Free Software Foundation; either
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    42
version 2.1 of the License.
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    43
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
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: 808
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: 808
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: 808
diff changeset
    47
Lesser General Public License for more details.
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    48
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
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: 808
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: 808
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: 808
diff changeset
    52
"
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    53
!
4c5acc592dc7 Added copyright notice
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 808
diff changeset
    54
808
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    55
documentation
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    56
"
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    57
    Same purpose like superclass, but for STX JavaScript language.
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    58
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    59
    [author:]
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    60
        Jakub Nesveda <nesvejak@fit.cvut.cz>
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    61
"
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    62
! !
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    63
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    64
!CustomJavaScriptSimpleSetterMethodsCodeGenerator class methodsFor:'queries'!
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    65
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    66
availableForProgrammingLanguages
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    67
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    68
    ^ {STXJavaScriptLanguage instance}
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    69
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    70
    "Created: / 31-01-2015 / 18:16:04 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    71
! !
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    72
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    73
!CustomJavaScriptSimpleSetterMethodsCodeGenerator methodsFor:'code generation'!
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    74
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    75
sourceForClass: aClass variableName: aName
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    76
    "Returns simple setter for given STX JavaScript class and variable name."
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    77
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    78
    | methodName comment argName |
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    79
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    80
    methodName := aName.
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    81
    argName := self argNameForMethodName: methodName.  
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    82
    comment := ''.
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    83
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    84
    userPreferences generateCommentsForSetters ifTrue:[
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    85
        | varType |
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    86
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    87
        varType := self varTypeOf: aName class: aClass. 
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    88
        comment := '
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    89
    // set the value of the %1 variable ''%2'' (automatically generated)'.
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    90
        comment := comment bindWith: varType with: aName.
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    91
    ].
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    92
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    93
    ^ methodName, '(', argName, ') {', comment, '
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    94
    ', aName, ' = ', argName, ';
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    95
}'.
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    96
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    97
    "Created: / 31-01-2015 / 18:15:11 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    98
! !
0067eb50c5ea Added prototype JavaScript (setter method) code generator (CustomJavaScriptSimpleSetterMethodsCodeGenerator)
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    99