1 | | [[PageOutline]] |
2 | | |
3 | | [http://http://erlide.org/ ErlIDE] is an Eclipse-based development |
4 | | environment, which aims to assist programming of large scale Erlang |
5 | | applications. In order to integrate RefactorErl into Eclipse, we are |
6 | | engaged in creating an Eclipse plugin based on ErlIDE, which can enable |
7 | | access to all the functionality provided by RefactorErl, whilst |
8 | | utilising ErlIDE features as well. A prototype of the Eclipse plugin is |
9 | | already available. |
10 | | |
11 | | = Installation = |
12 | | |
13 | | == Software requirements == |
14 | | * The plugin is being developed and tested in [http://www.eclipse.org/ Eclipse 3.5.2]. (It likely works with newer versions as well.) |
15 | | * This user interface is built upon [http://erlide.org/ ErlIDE], therefore it is required to have it with Eclipse. Inasmuch as the main structure |
16 | | of ErlIDE has been changed in its version |
17 | | ''v0.11.6.201107010651'', it is necessary to get the latest version. |
18 | | * Finally, you can download the plugin itself from the RefactorErl homepage. |
19 | | |
20 | | == Deployment == |
21 | | To install this plugin you need to download the source code from the |
22 | | home page of the [http://plc.inf.elte.hu/erlang/dl/ RefactorErl]. In |
23 | | order to generate the binaryes of the plugin you can compile it using |
24 | | '''''ant''''' or the compiler of Eclipse. Finally you have to copy the |
25 | | generated jar files into your Eclipse plugin directory. In Eclipse 3.5.x: |
26 | | {{{ |
27 | | <user home>/.eclipse/org.eclipse.platform_3.5.0_155965261/plugin |
28 | | }}} |
29 | | |
30 | | == Compiling the plugin in Eclipse == |
31 | | todo |
32 | | |
33 | | == Compile plugin using Ant == |
34 | | todo |
35 | | |
36 | | == Configuration == |
37 | | The plugin, in order to be able to access RefactorErl, has to be set |
38 | | up before the first usage. For the configuration dialog, go to |
39 | | '''Window / Preferences / RefactorErl'''. |
40 | | |
41 | | Start background process automatically:: |
42 | | If set, the plugin launches a new instance of the tool, otherwise an |
43 | | already running RefactorErl process will be used. |
44 | | RefactorErl directory:: |
45 | | The installation directory of the tool. |
46 | | Working directory:: |
47 | | A temporary directory, used to store the configuration files of |
48 | | RefactorErl. It is assumed to be a writable directory. |
49 | | Waiting time:: |
50 | | This parameter represents the waiting time (in seconds) after |
51 | | starting RefactorErl process (has to be set to greater than 1). The |
52 | | slower access is possible to Erlang nodes, the greater value is suggested. |
53 | | Synchronize workspace automatically then model changed:: |
54 | | If a source file has been changed, the extension automatically updates |
55 | | its inner representation within the tool. |
56 | | Reset database before full synchronization:: |
57 | | Resets the database and erases its contents in the case of a full |
58 | | synchronisation. The use of this feature is recommended for RefactorErl |
59 | | developers only. |
60 | | |
61 | | = Database management = |
62 | | The Eclipse extension supports every database management functionality |
63 | | that is available in the RefactorErl tool. These can be executed from |
64 | | the top menu: |
65 | | * Add file, |
66 | | * Drop file, |
67 | | * Reset database, |
68 | | * Load directory, |
69 | | * Undo (one step only). |
70 | | |
71 | | You can get a list of the database contents by clicking on |
72 | | '''RefactorErl / Files / Database contents'''. A new tab, called |
73 | | '''Database contents''' pops up showing the modules having been loaded |
74 | | into RefactorErl. Also, you can select and drop modules from the tool |
75 | | database, and you can open files for editing. |
76 | | |
77 | | |
78 | | = Executing refactoring transformations = |
79 | | todo |
80 | | |
81 | | = Executing semantic queries = |
82 | | todo |
83 | | |
84 | | = Clustering = |
85 | | |
86 | | The RefactorErl tool provides a feature for reorganising the structure |
87 | | of the software, called clustering. It determines semantic |
88 | | dependencies among the modules and functions and makes suggestion to |
89 | | the developer how to repartition the software: blocks of modules, |
90 | | headers etc. As the RefactorErl tool, the Eclipse plugin supports the |
91 | | clustering on different entities like functions or modules. Although |
92 | | the module clustering can be executed using both genetic and |
93 | | agglomerative algorithms, the function clustering supports only the |
94 | | former one. |
95 | | |
96 | | To execute a clustering algorithm, you should select either of them |
97 | | from the top menu (e.g: '''RefactorErl / Module / Genetic'''). Every |
98 | | clustering method has the same input window, where you can adjust the |
99 | | parameters of the algorithm. (It's the usage and the required |
100 | | parameters of the different methods are detailed in |
101 | | [wiki:ModuleFunctionClustering Clustering] section). When the calculation |
102 | | has been finished, a new window pops up with the results of the clustering |
103 | | algorithm. |
| 1 | |
| 2 | = Introduction |
| 3 | Most services provided by RefactorErl are accessible from the Eclipse IDE after installing the RefactorErl plugin in Eclipse. In this guide, we also refer to this plugin as the //Eclipse interface//. |
| 4 | The following functionalities are available from the Eclipse interface: |
| 5 | * [#db Database management] |
| 6 | * [#sq Semantic queries] |
| 7 | * [#ref Refactoring] |
| 8 | * [#dep Dependency graph drawing] |
| 9 | * [#dup Duplicated code analysis] |
| 10 | * [#inv Code investigations] |
| 11 | |
| 12 | A short description for each functionality can be found at the beginning of the relevant sections. |
| 13 | |
| 14 | While not required, it's recommended to install [http://www.erlide.org the Erlide plugin] in Eclipse. Erlide enhances features of the RefactorErl plugin and transforms Eclipse into a complete Erlang IDE. |
| 15 | |
| 16 | [=#install] |
| 17 | = Installation |
| 18 | == Quick summary |
| 19 | 1. Install the [#instdep dependencies]. |
| 20 | 1. To [#pluginst install the RefactorErl plugin in Eclipse], click on the **Help > Install new software** buttons in the Eclipse menu, click **Add...** in the appearing window, and paste the following link in the **Location** text field of the window named **Add Repository**: http://plc.inf.elte.hu/erlang/dl/update/ |
| 21 | 1. [#firsttime After the installation], navigate to the preference pages by clicking **Window > Preferences > RefactorErl**, and fill in the **RefactorErl Base Directory** field with the path to the base directory of a locally installed RefactorErl application. In case you would like to connect to a remotely located RefactorErl node instead, fill in the node address of this node in the **Server address** field. |
| 22 | |
| 23 | [=#instdep] |
| 24 | == Dependencies |
| 25 | * Java 8 JRE/JDK or newer. |
| 26 | * Eclipse 4.4.0 Luna or newer. |
| 27 | * RefactorErl 0.9.14.09 or newer. (Not needed in case a remote RefactorErl node is available.) |
| 28 | * GraphViz (Optional. Needed for displaying dependency graphs in SVG.) |
| 29 | {{{#!comment |
| 30 | * GEF4/Zest 2.0 Eclipse plugin (Optional. Needed for drawing Zest graphical representations of dependency graphs) |
| 31 | }}} |
| 32 | * Erlide 0.29 or newer (Optional.) |
| 33 | |
| 34 | === Java & Eclipse |
| 35 | Please see the developers' site for instructions concerning the obtainment and installation of [https://www.oracle.com/java/ Java] and [https:/www.eclipse.org/ Eclipse]. |
| 36 | |
| 37 | === RefactorErl |
| 38 | Detailed instructions for installing RefactorErl can be found on the [wiki:Install related wiki page]. Of the various dependencies listed in the guide, the RefactorErl plugin depends only on the RefactorErl base system. This means that if you do not intend to use other interfaces besides the Eclipse interface, you don't need to install any other dependencies (Yaws, Erlang Wx, ...) listed on the referenced wiki page apart from the base system. |
| 39 | |
| 40 | As a remainder, here are the steps you need to follow in order to install RefactorErl: |
| 41 | 1. Install Erlang from your system package manager, or from an installer provided by [https://www.erlang-solutions.com/downloads/download-erlang-otp Erlang Solutions], or you can build [http://www.erlang.org/download.html Erlang from source]. Prior to installation make sure that the version of the Erlang package to be installed is supported by RefactorErl. |
| 42 | 1. Download [https://plc.inf.elte.hu/erlang/ RefactorErl]. |
| 43 | 1. Uncompress the archive to the directory where you want RefactorErl to reside. |
| 44 | 1. Enter the `refactorerl-x.y.z.v` directory you just uncompressed (here `x.y.z.v` denotes a version number). |
| 45 | Type the command `bin\referl -build tool` in a terminal window. |
| 46 | Wait for the build process to finish. If the build ends with an error, please refer to the wiki page mentioned before. |
| 47 | 1. Test the tool by typing `bin\referl` in your terminal. If the build was succesful, an Erlang shell should appear. |
| 48 | |
| 49 | You will have to supply the location of the refactorerl-x.y.z.v directory (where we typed in the commands) to the RefactorErl plugin after the plugin is installed into Eclipse. |
| 50 | |
| 51 | === GraphViz |
| 52 | Optional. GraphViz is used to draw SVG representations of dependency graphs. You will have to supply the location of the `dot` executable of an installed GraphViz application the first time you use the SVG drawing feature. |
| 53 | |
| 54 | Hint: On UNIX-like systems, you can use the `type -a dot` command to locate the `dot` executable on your system. |
| 55 | |
| 56 | GraphViz can be obtained from the [http://www.graphviz.org developers' website] or presumably from the package manager of your local system. |
| 57 | |
| 58 | {{{#!comment |
| 59 | === GEF4/Zest 2.0 |
| 60 | Optional. Zest 2.0 is used to draw dynamically adjustable Zest representations of dependency graphs. |
| 61 | |
| 62 | The up-to-date version of the Zest 2.0 Eclipse plugin can be obtained from the [https://wiki.eclipse.org/GEF/GEF4 developers' website]. |
| 63 | |
| 64 | You can also download Zest 2.0 from the RefactorErl update site. Just select the **GEF4/Zest 2.0** entry besides the RefactorErl plugin entry in the list after you added the update site in Eclipse. See the [#pluginst relevant section] for more information. |
| 65 | Please note, that the version hosted on the RefactorErl update site might not be up-to-date. |
| 66 | }}} |
| 67 | |
| 68 | === Erlide |
| 69 | Optional. |
| 70 | |
| 71 | The up-to-date version of the Erlide Eclipse plugin can be obtained from the [http://www.erlide.org developers' website]. |
| 72 | |
| 73 | You can also download Erlide from the RefactorErl update site. Just select the **Erlang language tools IDE** entry besides the RefactorErl plugin entry in the list after you added the update site in Eclipse. See the [#pluginst relevant section] for more information. |
| 74 | Please note, that the version hosted on the RefactorErl update site might not be up-to-date. |
| 75 | |
| 76 | [=#pluginst] |
| 77 | == Installing the RefactorErl plugin in Eclipse |
| 78 | |
| 79 | The RefactorErl plugin can be installed in Eclipse via our update site. |
| 80 | |
| 81 | First copy the following link on the clipboard (eg. Right click > Copy Link Location): http://plc.inf.elte.hu/erlang/dl/update/ |
| 82 | |
| 83 | Open Eclipse and click on the **Help > Install new software** buttons in the Eclipse menu. |
| 84 | {{{ |
| 85 | #!comment |
| 86 | KÉP |
| 87 | }}} |
| 88 | |
| 89 | Click **Add...** in the appearing window, and paste the link we just copied to the clipboard in the **Location** text field of the window named **Add Repository**. Click OK. |
| 90 | {{{ |
| 91 | #!comment |
| 92 | KÉP |
| 93 | }}} |
| 94 | |
| 95 | In the original **Install** window select the RefactorErl group and a list should appear, containing the plugins available from the update site we specified in the last step. {{{ |
| 96 | #!comment |
| 97 | KÉP |
| 98 | }}} |
| 99 | |
| 100 | To install the RefactorErl plugin, select the **RefactorErl Eclipse UI** entry. |
| 101 | The list might contain additional entries for optional dependencies (Erlang language tools IDE {{{#!comment , GEF4/Zest 2.0}}}). Installing these plugins is not required, but it will enhance some features of the RefactorErl plugin. Please note, that the version of these dependencies hosted on the RefactorErl update site might not be up-to-date. |
| 102 | |
| 103 | After clicking **Next** on this window, Eclipse will lead you through a series of simple steps before the installation. After the installation is finished, you will need to restart Eclipse. |
| 104 | |
| 105 | == Uninstalling the RefactorErl plugin |
| 106 | The RefactorErl plugin can be uninstalled from Eclipse like most other Eclipse plugins. |
| 107 | 1. Open Eclipse |
| 108 | 1. Click on **Help > Installation Details** |
| 109 | 1. In the appearing window select the **RefactorErl Eclipse UI** entry. Click on the **Uninstall** button. |
| 110 | |
| 111 | [=#firsttime] |
| 112 | == First time launch |
| 113 | If the plugin installation was successful in the last step, an error message will appear the first time Eclipse is launched. This happens because we didn't set the path to RefactorErl yet. |
| 114 | {{{ |
| 115 | #!comment |
| 116 | KÉP |
| 117 | }}} |
| 118 | |
| 119 | The RefactorErl plugin can automatically start a local RefactorErl application and connect to it. Please, see the corresponding section of this guide, if RefactorErl is not yet installed on your system. |
| 120 | It is also possible to connect to a RefactorErl application running on a remote server. You do not need to install RefactorErl on your local system to do this. |
| 121 | |
| 122 | Navigate to the preference pages by clicking **Window > Preferences > RefactorErl**. |
| 123 | {{{ |
| 124 | #!comment |
| 125 | KÉP |
| 126 | }}} |
| 127 | |
| 128 | In case you would like to connect to a local RefactorErl application, fill in the **RefactorErl Base Directory** field with the path to the base directory of a locally installed RefactorErl application. |
| 129 | |
| 130 | In case you would like to connect to a remotely located RefactorErl node instead, fill in the node address of this node in the **Server address** field. |
| 131 | |
| 132 | Click **OK**. Click **Yes** on the dialog inquiring wheter you want to reconnect to RefactorErl. If the connection was successful, a `Connected to RefactorErl` message will appear in the left side of the status bar at the bottom of the Eclipse window. |
| 133 | {{{ |
| 134 | #!comment |
| 135 | KÉP |
| 136 | }}} |
| 137 | |
| 138 | Congratulations, now you can start using RefactorErl with the Eclipse interface! |
| 139 | |
| 140 | = Using the RefactorErl Eclipse interface |
| 141 | This section will guide you through the most important interface features. While we include a basic description for each feature group, it may be neccessary for you to read the corresponding wiki pages for an in-depth understanding of the feature group in question. |
| 142 | |
| 143 | If you open the RefactorErl perspective or the Erlang perspective (if Erlide is installed) inside Eclipse, a new menu button, with the text **RefactorErl** on it, will appear in the Eclipse top menu. Much of the features are accessible through the **RefactorErl** menu, and some features can be accessed in more than one way. |
| 144 | |
| 145 | For the rest of this guide we will assume that you have the RefactorErl or the Erlang perspective opened and one of these is the active perspective. As a reminder, perspectives can be opened via the **Window > Open Perspective > Other** button in the Eclipse top menu. |
| 146 | |
| 147 | [=#db] |
| 148 | == Database management |
| 149 | The RefactorErl server uses an internal database to store syntactic and semantic information on the source code. RefactorErl provides most of its services with the use of this information. In order for RefactorErl to be able to analyse a source file, that source file must be added to the database. |
| 150 | |
| 151 | See the [wiki:ManagingFiles wiki page about database management] for a more detailed description of database management in RefactorErl. |
| 152 | |
| 153 | Database management features available in the Eclipse interface include: |
| 154 | * Listing the source files in the database |
| 155 | * Showing the contents of a source file |
| 156 | * Adding new source files or directories of source files |
| 157 | * Dropping source files or directories |
| 158 | * Synchronizing the database with the (possibly modified) source files on the disk |
| 159 | * Synchronizing the GUI and the database in case of connection errors or other irregularities |
| 160 | * Appending values to the `appdata` and `include` environment variables |
| 161 | * Removing previously added values from the environment variables |
| 162 | * Resetting the database |
| 163 | |
| 164 | You can open a view containing the list of files, called the //Database view//, by clicking **RefactorErl > Database > Show Database** in the top menu. |
| 165 | |
| 166 | {{{ |
| 167 | #!comment |
| 168 | KÉP |
| 169 | }}} |
| 170 | |
| 171 | When you click in the //Database view// with the right mouse button, a context menu will appear, containing all database management features. Some of them, like the //drop// and //show// features, are dependent on the files or directories selected in the view. |
| 172 | Most database management features (the ones not depending on file selection) are also available in the **RefactorErl > Database** menu. |
| 173 | |
| 174 | Source files can also be opened by double clicking on their name in the //Database view//. |
| 175 | |
| 176 | [=#sq] |
| 177 | == Semantic queries |
| 178 | RefactorErl provides a semantic query language as a straightforward way to query the information residing in the database. See the [wiki:SemanticQuery wiki page on semantic queries] for a detailed description of this feature. |
| 179 | |
| 180 | The RefactorErl plugin for Eclipse provides an interface to |
| 181 | * write and execute semantic queries with autocompletion support, |
| 182 | * show the results of the previously executed query, |
| 183 | * show a history of preceding queries and their results. |
| 184 | |
| 185 | Before we examine the interface, we have to note the following distinction: A semantic query can be //global// or it can be //position based//. Position based queries start with the `@` character. |
| 186 | As an example `mod.funs` is a global query, because it returns all functions of all modules in the database. On the other hand `@fun.references` is a position based query, because it returns all references to the function specified by a position on the source file. |
| 187 | |
| 188 | You can execute a global query by writing your query in the textfield initially with the text `Semantic query` in the Eclipse toolbar and pressing the return key. |
| 189 | You can also execute global queries by clicking on **RefactorErl > Queries > Start query**. A dialog will appear, where you can type the global query. |
| 190 | {{{ |
| 191 | #!comment |
| 192 | KÉP |
| 193 | }}} |
| 194 | |
| 195 | To execute a position based query, open the source file where you want to start the query from, and click on the desired position in the text of the file with the right mouse button. In the appearing context menu, select **Run query from position**. A dialog will appear, where you can type a position based query (or even a global query). |
| 196 | |
| 197 | {{{ |
| 198 | #!comment |
| 199 | KÉP |
| 200 | }}} |
| 201 | |
| 202 | After a successful query execution a view, called //Query result view// will appear with the results of your query. You can double click on a line of the result, and if it's possible, an editor tab will open with the file containing the content of that line, highlighting the content in question. |
| 203 | |
| 204 | The **RefactorErl > Queries > Show query history** button will open the //Query history view//. Double clicking on a query in the //Query history view// will show a results of this query in a //Query result view//. Please note, that these are historical results, it may or may not be consistent with the current content of the database. |
| 205 | |
| 206 | |
| 207 | [=#ref] |
| 208 | == Refactoring |
| 209 | See the [wiki:RefactoringSteps wiki page about the available refactorings] for a detailed description of this feature. |
| 210 | [=#dep] |
| 211 | == Dependency graph drawing |
| 212 | See the [wiki:Dependency wiki page about dependency analysis] for a detailed description of this feature. |
| 213 | [=#dup] |
| 214 | == Duplicated code analysis |
| 215 | See the [wiki:CloneIdentifiErl wiki page about duplicated code analysis] for a detailed description of this feature. |
| 216 | [=#inv] |
| 217 | == Code investigations |