diff --git a/images/ASTClass.png b/images/ASTClass.png new file mode 100644 index 0000000..720012f Binary files /dev/null and b/images/ASTClass.png differ diff --git a/images/ASTCondition.png b/images/ASTCondition.png new file mode 100644 index 0000000..4cf26c6 Binary files /dev/null and b/images/ASTCondition.png differ diff --git a/images/ASTConditionEx.png b/images/ASTConditionEx.png new file mode 100644 index 0000000..683331b Binary files /dev/null and b/images/ASTConditionEx.png differ diff --git a/images/ASTConditionField.png b/images/ASTConditionField.png new file mode 100644 index 0000000..c9072ef Binary files /dev/null and b/images/ASTConditionField.png differ diff --git a/images/ASTField.png b/images/ASTField.png new file mode 100644 index 0000000..21b1a3d Binary files /dev/null and b/images/ASTField.png differ diff --git a/images/ASTFinish.png b/images/ASTFinish.png new file mode 100644 index 0000000..d1a9898 Binary files /dev/null and b/images/ASTFinish.png differ diff --git a/images/ASTLoop.png b/images/ASTLoop.png new file mode 100644 index 0000000..423491e Binary files /dev/null and b/images/ASTLoop.png differ diff --git a/images/ASTLoopField.png b/images/ASTLoopField.png new file mode 100644 index 0000000..23a297a Binary files /dev/null and b/images/ASTLoopField.png differ diff --git a/images/ASTMetArgs.png b/images/ASTMetArgs.png new file mode 100644 index 0000000..cabe6ef Binary files /dev/null and b/images/ASTMetArgs.png differ diff --git a/images/ASTMethod1.png b/images/ASTMethod1.png new file mode 100644 index 0000000..72b346a Binary files /dev/null and b/images/ASTMethod1.png differ diff --git a/images/ASTMethod2.png b/images/ASTMethod2.png new file mode 100644 index 0000000..7a41e22 Binary files /dev/null and b/images/ASTMethod2.png differ diff --git a/images/ExampleAST.png b/images/ExampleAST.png new file mode 100644 index 0000000..d02f08d Binary files /dev/null and b/images/ExampleAST.png differ diff --git a/images/NodeClass.png b/images/NodeClass.png deleted file mode 100644 index db7cdf8..0000000 Binary files a/images/NodeClass.png and /dev/null differ diff --git a/paper.pdf b/paper.pdf index 4634d04..b00f2b5 100644 Binary files a/paper.pdf and b/paper.pdf differ diff --git a/paper.tex b/paper.tex index b2ef372..a1a9a6e 100644 --- a/paper.tex +++ b/paper.tex @@ -112,54 +112,117 @@ We developed an algorithm to extract the structure of the project in the source \begin{equation*} N^{Class} = \lbrace N_{i} \in N | F \left( N_{i}.data \right) = \text{`Class'} \rbrace, \end{equation*} - + + \begin{table}[] + \begin{tabular}{|l|c|} + \hline + \multicolumn{1}{|c|}{Source code string} & Nodes \\ \hline + public class Main \{ & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTClass.png}} \\ \hline + \end{tabular} + \end{table} + \item Select nodes with the `Class field' as the $N^{Vars}$ set from the $N^{Class}$ set: \begin{equation*} N^{Vars} = \lbrace N_{i}^{Class} \in N^{Class} | F \left( N_{i}^{Class}.data \right) = \text{`Field'} \rbrace, \end{equation*} + + \begin{table}[] + \begin{tabular}{|l|c|} + \hline + \multicolumn{1}{|c|}{Source code string} & Nodes \\ \hline + private String a; & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTField.png}} \\ \hline + \end{tabular} + \end{table} + \item Select nodes with the `Methods' type as the $N^{Methods}$ set from the $N^{Class}$ set: \begin{equation*} N^{Methods} = \lbrace N_{i}^{Class} \in N^{Class} | F \left( N_{i}^{Class}.data \right) = \text{`Method'} \rbrace, \end{equation*} + + \begin{table}[] + \begin{tabular}{|l|c|} + \hline + \multicolumn{1}{|c|}{Source code string} & Nodes \\ \hline + void run() \{ & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTMethod1.png}} \\ \hline + void show(String text) \{ & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTMethod2.png}} \\ \hline + \end{tabular} + \end{table} + \item Select nodes with the `Method Argument' type as the $N^{MethodsArgs}$ set from the $N^{Methods}$ set: \begin{equation*} N^{MethodsArgs} = \lbrace N_{i}^{Methods} \in N^{Methods} | F \left( N_{i}^{Methods}.data \right) = \text{`Arg'} \rbrace, \end{equation*} + + \begin{table}[] + \begin{tabular}{|l|c|} + \hline + \multicolumn{1}{|c|}{Source code string} & Nodes \\ \hline + void show(String text) \{ & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTMetArgs.png}} \\ \hline + \end{tabular} + \end{table} + \item Select nodes with the `Operator' type as the $N^{MethodsOps}$ from the $N^{Methods}$ set: \begin{equation*} N^{MethodsOps} = \lbrace N_{i}^{Methods} \in N^{Methods} | F \left( N_{i}^{Methods}.data \right) = \text{`Operator'} \rbrace, \end{equation*} + + \begin{table}[] + \begin{tabular}{|l|c|} + \hline + \multicolumn{1}{|c|}{Source code string} & Nodes \\ \hline + while(true) \{ & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTLoop.png}} \\ \hline + int a = 1; & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTLoopField.png}} \\ \hline + if (a == 1) \{ & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTCondition.png}} \\ \hline + this.show("Hello") & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTConditionEx.png}} \\ \hline + int c = "Foo"; & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTConditionField.png}} \\ \hline + System.out.println(text); & \raisebox{-\totalheight}{\includegraphics[width=10cm]{images/ASTFinish.png}} \\ \hline + \end{tabular} + \end{table} + \item Create the set of ties $R$ between the nodes from sets obtained in previous steps. \item Save the resulting AST in a graph database (GDB). \end{enumerate} In this algorithm, F (*) is a search function that finds nested nodes. The function input is a node or subtree, and the output is a node of the desired type. -Figure \ref{fig:SourceCodeAndAST} shows the resulting AST for the following source code: +Figure 1\ref{fig:ExampleAST} shows the resulting ACT for the following source code: \begin{lstlisting} - package com.example.demo.simple; - public class Main { - private String a; - void run() { - while(true) { - int a = 1; - if (a == 1) { - this.show("Hello") - } + package laba1; + public class Scheduler { + private final int time = 5; + private ArrayList threads = new ArrayList(); + + void scheduler() { + for (int i=0; i streams = new ArrayList<>(); + + void plan() { + for (Stream stream: streams) { + stream.run(QUANT); + System.out.println(stream.toString()); + } } } \end{lstlisting} \begin{figure} \centering - \includegraphics[width=0.71\textwidth]{images/AST.png} - \caption{Sample source code and its AST.} \label{fig:SourceCodeAndAST} + \includegraphics[width=0.71\textwidth]{images/ExampleAST.png} + \caption{Sample AST.} \label{fig:ExampleAST} \end{figure}