AutomagicSourcePorter.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 17 Feb 2021 15:24:09 +0100
branchjv
changeset 4568 524471ef6575
parent 4564 c139d9cb01a9
child 4569 bb9d02f27592
permissions -rw-r--r--
Changing the encoding style header for fileOutAs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4564
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     1
"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     2
COPYRIGHT (c) 2020 LabWare
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     3
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     4
              All Rights Reserved
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     5
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     6
 This software is furnished under a license and may be used
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     7
 only in accordance with the terms of that license and with the
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     9
 be provided or otherwise made available to, or used by, any
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    10
 other person.  No title to or ownership of the software is
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    11
 hereby transferred.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    12
"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    13
"{ Package: 'stx:libbasic3' }"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    14
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    15
"{ NameSpace: Smalltalk }"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    16
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    17
Object subclass:#AutomagicSourcePorter
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    18
	instanceVariableNames:'source klass klassMap'
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    19
	classVariableNames:''
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    20
	poolDictionaries:''
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    21
	category:'Kernel-Classes-Support-Autoporting'
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    22
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    23
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    24
AutomagicSourcePorter class instanceVariableNames:'defaultKlassMap'
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    25
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    26
"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    27
 No other class instance variables are inherited by this class.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    28
"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    29
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    30
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    31
!AutomagicSourcePorter class methodsFor:'documentation'!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    32
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    33
copyright
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    34
"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    35
COPYRIGHT (c) 2020 LabWare
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    36
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    37
              All Rights Reserved
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    38
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    39
 This software is furnished under a license and may be used
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    40
 only in accordance with the terms of that license and with the
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    41
 inclusion of the above copyright notice.   This software may not
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    42
 be provided or otherwise made available to, or used by, any
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    43
 other person.  No title to or ownership of the software is
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    44
 hereby transferred.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    45
"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    46
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    47
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    48
documentation
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    49
"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    50
    This is an abstract base superclass for automagic code porting
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    51
    from Smalltalk/X to other dialects. These can be / are used when
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    52
    exporting code to be consumed by others.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    53
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    54
    [author:]
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    55
        Jan Vrany <jan.vrany@labware.com>
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    56
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    57
    [instance variables:]
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    58
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    59
    [class variables:]
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    60
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    61
    [see also:]
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    62
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    63
"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    64
! !
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    65
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    66
!AutomagicSourcePorter class methodsFor:'instance creation'!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    67
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    68
new
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    69
    "return an initialized instance"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    70
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    71
    ^ self basicNew initialize.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    72
! !
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    73
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    74
!AutomagicSourcePorter class methodsFor:'accessing'!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    75
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    76
defaultKlassMap
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    77
    defaultKlassMap isNil ifTrue:[ 
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    78
        defaultKlassMap := Dictionary withKeysAndValues: self defaultKlassMapEntries.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    79
    ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    80
    ^ defaultKlassMap
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    81
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    82
    "Created: / 01-07-2020 / 12:31:35 / Jan Vrany <jan.vrany@labware.com>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    83
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    84
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    85
defaultKlassMapEntries
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    86
    ^ #()
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    87
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    88
    "Created: / 01-07-2020 / 12:32:22 / Jan Vrany <jan.vrany@labware.com>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    89
! !
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    90
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    91
!AutomagicSourcePorter methodsFor:'initialization'!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    92
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    93
initialize
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    94
    "Invoked when a new instance is created."
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    95
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    96
    super initialize.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    97
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    98
    "/ please change as required (and remove this comment)
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    99
    "/ source := nil.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   100
    "/ klass := nil.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   101
    klassMap := self class defaultKlassMap copy
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   102
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   103
    "Modified: / 29-10-2018 / 15:54:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   104
    "Modified: / 01-07-2020 / 12:30:46 / Jan Vrany <jan.vrany@labware.com>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   105
! !
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   106
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   107
!AutomagicSourcePorter methodsFor:'porting'!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   108
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   109
portClass: aClass source: aString
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   110
    "Perform all automatic source code transformation on a method's source
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   111
     and return new source with all the necessary modifications."
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   112
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   113
    source := aString.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   114
    klass := aClass.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   115
    self rewriteClassDefinition.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   116
    ^ source
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   117
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   118
    "Created: / 24-10-2018 / 11:06:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   119
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   120
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   121
portMethod: aMethod source: aString
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   122
    "Perform all automatic source code transformation on a method's source
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   123
     and return new source with all the necessary modifications."
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   124
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   125
    source := aString.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   126
    klass := aMethod mclass.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   127
    self rewrite.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   128
    ^ source
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   129
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   130
    "Created: / 24-10-2018 / 11:05:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   131
! !
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   132
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   133
!AutomagicSourcePorter methodsFor:'private'!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   134
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   135
collectClassRewritesFrom: aCollection into: aDictionary
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   136
    "Collect all renames for class names in `aCollection` and
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   137
     add an entru for each class that has to be renamed in
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   138
     (output) `aDictionary`.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   139
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   140
     The renames are collected as folllows:
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   141
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   142
       (i) If there's a explicit rename rule in `klassMap` use that one.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   143
      (ii) If not, strip namespace prefix (for Bee does not like Smalltalk/X style 
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   144
           namespace prefixes)
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   145
    "
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   146
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   147
    aCollection do:[:name |
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   148
        |idx nsName clsName|
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   149
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   150
        (klassMap includesKey:name) ifTrue:[
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   151
            "/ (i) an explicit rename...
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   152
            aDictionary at:name put:(klassMap at:name).
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   153
        ] ifFalse:[
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   154
            (name includes:$:) ifTrue:[
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   155
                "/ (ii) a class with namespace prefix...
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   156
                idx := name indexOfSubCollection:'::'.   
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   157
                nsName := name copyTo:idx-1.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   158
                clsName := name copyFrom:idx+2.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   159
                aDictionary at:name put:clsName.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   160
            ]
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   161
        ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   162
    ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   163
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   164
    "Created: / 24-10-2018 / 11:34:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   165
! !
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   166
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   167
!AutomagicSourcePorter methodsFor:'rewriting'!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   168
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   169
rewrite
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   170
    self assert: source isString.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   171
    self assert: klass isBehavior.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   172
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   173
    self
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   174
        rewriteEOLComments; checkSource;
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   175
        rewriteClassReferences; checkSource;
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   176
        rewriteSimpleExpressions; checkSource
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   177
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   178
    "Created: / 16-10-2018 / 20:29:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   179
    "Modified: / 05-11-2018 / 14:43:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   180
    "Modified: / 01-07-2020 / 12:48:38 / Jan Vrany <jan.vrany@labware.com>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   181
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   182
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   183
rewriteClassDefinition
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   184
    |parser globalsToRename symbolsToRename replacer tree|
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   185
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   186
    parser := Parser for: source.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   187
    parser foldConstants:false.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   188
    parser parseExpressionWithSelf: nil
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   189
            notifying:nil
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   190
            ignoreErrors:false
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   191
            ignoreWarnings:false
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   192
            inNameSpace: Smalltalk.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   193
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   194
    globalsToRename := Dictionary new.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   195
    symbolsToRename := Dictionary new.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   196
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   197
    self collectClassRewritesFrom: parser usedGlobals into: globalsToRename.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   198
    self collectClassRewritesFrom: parser usedSymbols into: symbolsToRename.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   199
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   200
    (globalsToRename isEmpty and:[symbolsToRename isEmpty]) ifTrue:[^ self ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   201
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   202
    replacer := ParseTreeSourceRewriter new.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   203
    replacer alwaysPerformAllSearches:true.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   204
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   205
    globalsToRename keysAndValuesDo:[:oldName :newName |
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   206
        replacer replaceVariable: oldName with: newName.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   207
    ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   208
    symbolsToRename keysAndValuesDo:[:oldName :newName |
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   209
        replacer replaceLiteral: oldName with: newName.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   210
    ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   211
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   212
    tree := RBParser parseExpression:source.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   213
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   214
    replacer executeTree: tree.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   215
    source := replacer executeReplacementsInSource:source.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   216
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   217
    "Created: / 24-10-2018 / 11:15:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   218
! !
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   219
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   220
!AutomagicSourcePorter methodsFor:'rewriting-individual'!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   221
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   222
rewriteClassReferences
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   223
    |parser globalsToRename symbolsToRename replacer tree|
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   224
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   225
    "/ all references to namespace variables
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   226
    parser := Parser new.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   227
    parser foldConstants:false.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   228
    parser
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   229
        parseMethod:source 
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   230
        in:klass
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   231
        ignoreErrors:false
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   232
        ignoreWarnings:false.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   233
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   234
    globalsToRename := Dictionary new.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   235
    symbolsToRename := Dictionary new.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   236
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   237
    self collectClassRewritesFrom: parser usedGlobals into: globalsToRename.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   238
    "/ NO, following is bad as it rewrites every symbol, not only class names!!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   239
    "/ DONT DO THAT!!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   240
    "/ self collectClassRewritesFrom: parser usedGlobals into: symbolsToRename.   
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   241
    (globalsToRename isEmpty and:[symbolsToRename isEmpty]) ifTrue:[^ self ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   242
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   243
    replacer := ParseTreeSourceRewriter new.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   244
    replacer alwaysPerformAllSearches:true.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   245
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   246
    globalsToRename keysAndValuesDo:[:oldName :newName |
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   247
        replacer replaceVariable: oldName with: newName.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   248
    ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   249
    symbolsToRename keysAndValuesDo:[:oldName :newName |
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   250
        replacer replaceLiteral: oldName with: newName.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   251
    ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   252
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   253
    tree := RBParser parseMethod:source.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   254
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   255
    replacer executeTree: tree.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   256
    source := replacer executeReplacementsInSource:source.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   257
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   258
    self checkSource
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   259
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   260
    "Created: / 24-10-2018 / 10:17:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   261
    "Modified: / 05-11-2018 / 19:31:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   262
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   263
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   264
rewriteEOLComments
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   265
    |parser eolComments xlatedComment newSource|
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   266
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   267
    "/ Short-circuit if there's no EOL-comment in the code...
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   268
    (source includesSubString: '"/') ifFalse: [ ^ self ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   269
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   270
    parser := Parser new.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   271
    parser foldConstants:false.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   272
    parser saveComments:true.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   273
    parser parseMethod:source in:klass ignoreErrors:true ignoreWarnings:true.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   274
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   275
    eolComments := parser comments select:[:each | each isEndOfLineComment].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   276
    eolComments notEmpty ifTrue:[
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   277
        "/ start with the last (so I don't have to update the positions)
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   278
        eolComments sort:[:a :b | a startPosition < b startPosition].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   279
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   280
        eolComments reverseDo:[:each |
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   281
            xlatedComment := source copyFrom:(each startPosition+2) to:each endPosition.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   282
            (xlatedComment includes:$") ifTrue:[
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   283
                "/ self halt.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   284
                xlatedComment := xlatedComment copyReplaceAll:$" with:$'.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   285
            ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   286
            newSource := source copyTo:(each startPosition-1).
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   287
            newSource := newSource,'" ',xlatedComment,'"'.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   288
            newSource := newSource,(source copyFrom:(each endPosition + 1)).
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   289
            source := newSource.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   290
        ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   291
    ].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   292
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   293
    "Created: / 16-10-2018 / 20:38:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   294
    "Modified: / 06-11-2018 / 21:00:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   295
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   296
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   297
rewriteSimpleExpressions
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   298
    "To be overridden by subclasses, empty by default"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   299
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   300
    "Modified: / 01-07-2020 / 12:50:12 / Jan Vrany <jan.vrany@labware.com>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   301
! !
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   302
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   303
!AutomagicSourcePorter methodsFor:'utilities'!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   304
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   305
checkSource
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   306
    "Check the source is syntactically correct, if not,
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   307
     raise an error."
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   308
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   309
    RBParser 
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   310
        parseMethod:source
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   311
        onError:[:aString :pos | self error: 'Invalid source: ', aString , ' at ', pos printString].
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   312
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   313
    "Created: / 17-10-2018 / 10:43:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   314
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   315
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   316
rewrite: matchPattern with: rewritePattern
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   317
    self rewrite: matchPattern with: rewritePattern when: [ :node | true ]
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   318
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   319
    "Created: / 29-10-2018 / 15:16:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   320
!
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   321
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   322
rewrite: matchPattern with: rewritePattern when: condition
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   323
    | replacer tree |
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   324
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   325
    replacer := ParseTreeSourceRewriter new.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   326
    replacer alwaysPerformAllSearches:true.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   327
    replacer replace: matchPattern with: rewritePattern when: condition.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   328
    tree := RBParser parseMethod:source.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   329
    replacer executeTree: tree.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   330
    source := replacer executeReplacementsInSource:source.
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   331
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   332
    self checkSource
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   333
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   334
    "Created: / 29-10-2018 / 15:15:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   335
! !
c139d9cb01a9 Refactor common bits from `BeeSourcePorter` to (abstract) `AutomagicSourcePorter`
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   336