sandbox/old-modules/help/jackpot30-help.tex
branchdonation_review
changeset 1043 57843026e60b
parent 1027 205b7632914c
parent 1040 f7b6892fd754
child 1044 7feb751ba76b
     1.1 --- a/sandbox/old-modules/help/jackpot30-help.tex	Mon Dec 19 11:37:36 2016 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,119 +0,0 @@
     1.4 -\documentclass{article}
     1.5 -\usepackage{verbdef}
     1.6 -\usepackage{hyperref}
     1.7 -
     1.8 -\verbdef\simplevariable=$[0-9A-Za-z_]+=
     1.9 -\verbdef\statementvariable=$[0-9A-Za-z_]+;=
    1.10 -\verbdef\multipletreevariable=$[0-9A-Za-z_]+$=
    1.11 -\verbdef\multiplestatementvariable=$[0-9A-Za-z_]+$;=
    1.12 -\verbdef\wholepattern=$_=
    1.13 -\verbdef\reserved=$$[0-9A-Za-z_]+=
    1.14 -
    1.15 -\begin{document}
    1.16 -
    1.17 -\section{Rules Language}
    1.18 -
    1.19 -\subsection{Basic Structure}
    1.20 -
    1.21 -The rules file consists of any number of transformation rules.
    1.22 -The rule is defined as follows:
    1.23 -\begin{verbatim}
    1.24 -    <pattern>
    1.25 -=> <fix-pattern>
    1.26 -=> <fix-pattern>
    1.27 -;;
    1.28 -\end{verbatim}
    1.29 -
    1.30 -Each occurrence of \verb=<pattern>= in the source code can be rewritten to one
    1.31 -of the \verb=<fix-pattern>=s. For example, the following transformation rule:
    1.32 -\begin{verbatim}
    1.33 -   $1 == null
    1.34 -=> null == $1
    1.35 -;;
    1.36 -\end{verbatim}
    1.37 -
    1.38 -will rewrite the following code:
    1.39 -\begin{verbatim}
    1.40 -if (a == null) {
    1.41 -   System.err.println("a is null");
    1.42 -}
    1.43 -\end{verbatim}
    1.44 -to:
    1.45 -\begin{verbatim}
    1.46 -if (null == a) {
    1.47 -    System.err.println("a is null");
    1.48 -}
    1.49 -\end{verbatim}
    1.50 -
    1.51 -Note: \verb=$1$= is a variable, explained \hyperref{below}{in Section~}{variables}{}.
    1.52 -
    1.53 -Note: batch refactoring will typically use only the first applicable fix patterns
    1.54 -of each applicable rule.
    1.55 -
    1.56 -\subsection{Patterns}
    1.57 -
    1.58 -The pattern is a Java expression, statement or several statements.
    1.59 -All references to classes in the pattern need to be resolvable, i.e. either fully
    1.60 -qualified names need to be used, or the custom import section must be used
    1.61 -(see \hyperref{Custom Imports}{Section~}{custom-import}{}).
    1.62 -
    1.63 -TODO: equivalence - static elements are checked only against themselves, blocks with
    1.64 -one statement considered equivalent to single statement.
    1.65 -
    1.66 -Note: variable declaration is a Java statement.
    1.67 -
    1.68 -\subsection{Variables}
    1.69 -
    1.70 -Variables start with the dollar sign (\verb=$=). In the pattern, first occurrences
    1.71 -of a variable is bound to the actual sub-tree that appears in the code. Second and
    1.72 -following occurrences of the variable the actual sub-tree is verified against the subtree
    1.73 -bound to the variable. The pattern occurs in the text only if the actual sub-tree
    1.74 -matches the sub-tree bound to the variable. In the fix pattern, all occurrences of
    1.75 -the variables are replaced with the tree(s) bound to the respective variables.
    1.76 -
    1.77 -The forms of the variables are:
    1.78 -\begin{description}
    1.79 -\item[\simplevariable]{any expression}
    1.80 -\item[\statementvariable]{any statement}
    1.81 -\item[\multipletreevariable]{any number of sub-trees (except statements - see next definition)}
    1.82 -\item[\multiplestatementvariable]{any number of statements}
    1.83 -\item[\wholepattern]{for patterns undefined, for fixes and conditions automatically bound to the current matched region}
    1.84 -\item[\reserved]{reserved -- do not use}
    1.85 -\end{description}
    1.86 -
    1.87 -\subsection{Conditions}
    1.88 -
    1.89 -Both the search and fix patterns may specify additional conditions. These conditions
    1.90 -are specified after \verb=::=. Currently, the conditions have the following
    1.91 -limitations:
    1.92 -
    1.93 -\begin{verbatim}
    1.94 -   $1.isDirectory() :: $1 instanceof java.io.File
    1.95 -=> !$1.isFile()
    1.96 -;;
    1.97 -\end{verbatim}
    1.98 -
    1.99 -will rewrite the following code:
   1.100 -\begin{verbatim}
   1.101 -java.io.File testFile = new java.io.File("/tmp");
   1.102 -if (testFile.isDirectory()) {
   1.103 -    System.err.println("/tmp is a directory");
   1.104 -}
   1.105 -\end{verbatim}
   1.106 -to:
   1.107 -\begin{verbatim}
   1.108 -java.io.File testFile = new java.io.File("/tmp");
   1.109 -if (!testFile.isFile()) {
   1.110 -    System.err.println("/tmp is a directory");
   1.111 -}
   1.112 -\end{verbatim}
   1.113 -
   1.114 -\subsection{Display Names and Localization}
   1.115 -
   1.116 -\subsection{Custom Conditions}
   1.117 -
   1.118 -\subsection{Custom Import}
   1.119 -
   1.120 -\subsection{Options}
   1.121 -
   1.122 -\end{document}