Changes between Version 4 and Version 5 of ScriptableInterface
- Timestamp:
- Apr 19, 2012, 9:39:21 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ScriptableInterface
v4 v5 38 38 Here is the list of transformations that you can use via this interface: 39 39 40 '''rename/2''' 41 42 Renames [[RefactoringSteps/RenameVariable|variable]], [[RefactoringSteps/RenameFunction|function]], [[RefactoringSteps/RenameRecord|record]], [[RefactoringSteps/RenameRecordField|record field]], [[RefactoringSteps/RenameMacro|macro]], [[RefactoringSteps/RenameHeader|header file]] or [[RefactoringSteps/RenameModule|module file]]. 43 Example: 44 45 {{{ 46 #!erlang 47 ris:rename("mods[name=='mymod'].fun[name=='Colour']", "Color"). 48 }}} 40 41 '''eliminate/1''' 42 43 Eliminates the given variable(s). ([[RefactoringSteps/EliminateVariable|eliminate variable]]). 44 45 46 '''extfun/2, extract/2''' 47 48 This is the [[RefactoringSteps/ExtractFunction|extract function]] transformation. 49 50 51 '''inline/1''' 52 53 Inlines the given function(s), or macro(s). ([[RefactoringSteps/InlineFunction|inline function]], [[RefactoringSteps/InlineMacro|inline macro]]). 54 49 55 50 56 '''move/2''' 51 57 52 58 Moves the given [[RefactoringSteps/MoveFunction|function]], [[RefactoringSteps/MoveMacro|macro]], or [[RefactoringSteps/MoveRecord|record]] to another module. 59 53 60 Example: 54 61 {{{ … … 62 69 }}} 63 70 64 '''extfun/2, extract/2''' 65 66 67 68 69 70 71 72 '''rename/2''' 73 74 Renames [[RefactoringSteps/RenameVariable|variable]], [[RefactoringSteps/RenameFunction|function]], [[RefactoringSteps/RenameRecord|record]], [[RefactoringSteps/RenameRecordField|record field]], [[RefactoringSteps/RenameMacro|macro]], [[RefactoringSteps/RenameHeader|header file]] or [[RefactoringSteps/RenameModule|module file]]. 75 76 Example: 77 {{{ 78 #!erlang 79 ris:rename("mods[name=='mymod'].fun[name=='Colour']", "Color"). 80 }}} 81 82 83 84 85 86 {{{#!comment 87 '''reorder/2''' 88 89 Reorders the function parameters. ([[RefactoringSteps/ReorderParameters|reorder function paameters]]) 90 91 Example: 92 {{{ 93 #!erlang 94 ris:reorder("mod.fun[name==fun1,arity==3]", 95 [3,1,2]). 96 }}} 71 97 72 98 … … 91 117 In every modul, reorder every functions' parameters, whose name is fun1 and the arity is 3: 92 118 93 {{{94 #!erlang95 ris:reorder("mod.fun[name==fun1,arity==3]",96 [3,1,2]).97 }}}98 99 100 119 101 120 {{{ … … 111 130 112 131 ris:inline("mod[name==china].fun[name==sum] 113 .expr[type/=pattern and index==1]"). 132 .expr[type/=pattern and index==1]"). 133 }}} 114 134 }}} 115 135 … … 120 140 * '''intersect''': The following example takes the intersection of the files included by the two modules. 121 141 142 Example: 122 143 {{{ 123 144 ris:q({"mods[name==mod1].includes", intersect, … … 125 146 }}} 126 147 127 * '''union''': The union set operation. \\ 128 * '''minus''': The substraction set operation. \\ 148 * '''union''': The union set operation. (Example: same as above, just substitute 'intersect' with 'union') \\ 149 * '''minus''': The substraction set operation. (Example: same as above, just substitute 'intersect' with 'minus') \\ 150 * '''Sequence''': Queries can be sequenced to continue a query from where another has left off. This example first adds the module from file 'mymodule.erl'. The add call returns the entities loaded. A semantic query aggregate of a list works by executing the first query (or in this case, specifying a starting entity), and then running the next query in the chain (in this case getting the name of files included by the add call). 151 152 Example: 153 {{{ 154 #!erlang 155 ris:q([ris:add_byname("mymodule.erl"),".includes.name"]). 156 }}} 157 158 159 160 {{{#!comment 129 161 * '''range''': Ranges of expressions can be selected which denotes a list of continuous expressions between two syntactical siblings. An empty semantic query denotes the beginning or end of a block when used as the initial or final limit respectively. In this example, the expression range starts from the (first) match expression that contains "Var1" in the pattern side up to the end of the syntactical block. 130 162 … … 139 171 }}} 140 172 141 * '''Sequence''': Queries can be sequenced to continue a query from where another has left off. This example first adds the module from file 'mymodule.erl'. The add call returns the entities loaded. A semantic query aggregate of a list works by executing the first query (or in this case, specifying a starting entity), and then running the next query in the chain (in this case getting the name of files included by the add call).142 143 {{{144 #!erlang145 ris:q([ris:add_byname("mymodule.erl"),".includes.name"]).146 }}}147 148 173 * '''Another sequence example''': The following example shows an example for composition. It first renames all functions whose name is 'duck' to 'quack'. It then appends the suffix '_quacker' to the name of all functions which call these quacks. The new name is automatically converted to an atom. 149 150 174 151 175 {{{ … … 162 186 end). 163 187 }}} 188 }}} 164 189 165 190 == Textual display ==