diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000000000000000000000000000000000000..f2784d8fec4511202db38f892dc98e1634a583f3 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,7 @@ +<component name="ProjectCodeStyleConfiguration"> + <code_scheme name="Project" version="173"> + <option name="LINE_SEPARATOR" value=" " /> + <option name="RIGHT_MARGIN" value="150" /> + <option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" /> + </code_scheme> +</component> \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml index a55e7a179bde3e4e772c29c0c85e53354aa54618..79ee123c2b23e069e35ed634d687e17f731cc702 100644 --- a/.idea/codeStyles/codeStyleConfig.xml +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -1,5 +1,5 @@ <component name="ProjectCodeStyleConfiguration"> <state> - <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" /> + <option name="USE_PER_PROJECT_SETTINGS" value="true" /> </state> </component> \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index c6526892eb8d90c330871093fd22fa80248489ba..ef7fcbec9ba24d5d435f2d745ceaa5b215a72edd 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -4,6 +4,7 @@ <inspection_tool class="DeprecatedIsStillUsed" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="Deprecation" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="ListIndexOfReplaceableByContains" enabled="true" level="WARNING" enabled_by_default="true" /> + <inspection_tool class="LongLine" enabled="true" level="WEAK WARNING" enabled_by_default="true" /> <inspection_tool class="OverlyStrongTypeCast" enabled="true" level="WARNING" enabled_by_default="true"> <option name="ignoreInMatchingInstanceof" value="false" /> </inspection_tool> @@ -16,10 +17,11 @@ <option name="doNotWeakenToJavaLangObject" value="true" /> <option name="onlyWeakentoInterface" value="true" /> </inspection_tool> - <inspection_tool class="WeakerAccess" enabled="true" level="WEAK WARNING" enabled_by_default="true"> - <option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="true" /> - <option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="true" /> + <inspection_tool class="WeakerAccess" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="false" /> + <option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="false" /> <option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" /> + <disabledExtension id="moduleInfo" /> </inspection_tool> </profile> </component> \ No newline at end of file diff --git a/.idea/runConfigurations/All_in_ttool.xml b/.idea/runConfigurations/All_in_ttool.xml new file mode 100644 index 0000000000000000000000000000000000000000..c61daedb2d41f1af434be26971e291115a0c3de7 --- /dev/null +++ b/.idea/runConfigurations/All_in_ttool.xml @@ -0,0 +1,25 @@ +<component name="ProjectRunConfigurationManager"> + <configuration default="false" name="All in ttool" type="JUnit" factoryName="JUnit" nameIsGenerated="true"> + <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> + <module name="ttool" /> + <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> + <option name="ALTERNATIVE_JRE_PATH" /> + <option name="PACKAGE_NAME" value="" /> + <option name="MAIN_CLASS_NAME" value="" /> + <option name="METHOD_NAME" value="" /> + <option name="TEST_OBJECT" value="package" /> + <option name="VM_PARAMETERS" value="-ea" /> + <option name="PARAMETERS" value="" /> + <option name="WORKING_DIRECTORY" value="file://ttool/build" /> + <option name="ENV_VARIABLES" /> + <option name="PASS_PARENT_ENVS" value="true" /> + <option name="TEST_SEARCH_SCOPE"> + <value defaultName="singleModule" /> + </option> + <envs /> + <patterns /> + <method> + <option name="Make" enabled="false" /> + </method> + </configuration> +</component> \ No newline at end of file diff --git a/doc/dev_infrastructure/ttool_development_infrastructure.tex b/doc/dev_infrastructure/ttool_development_infrastructure.tex index 25c8d40b222767173950fea2b2ac0450c416fb3c..e656d3794a32685d379ebe06a4eb095a97d269f7 100644 --- a/doc/dev_infrastructure/ttool_development_infrastructure.tex +++ b/doc/dev_infrastructure/ttool_development_infrastructure.tex @@ -471,7 +471,148 @@ can be changed by editing the debug launch configuration. \section{Development with IntelliJ} -TODO +IntelliJ IDEA is another Integrated Development Environment popular especially +among Java developers. It can be used to work on TTool and provides +functionalities globally similar to Eclipse. + +\subsection{Installing and configuring IntelliJ} + +Download IntelliJ IDEA here: \url{https://www.jetbrains.com/idea/}. + +Unzip IntelliJ folder where you want to keep the executable. Launch it by using +the \texttt{idea.sh} script under the \texttt{bin} folder. Click on \emph{Open} +and navigate to the root of the TTool git repository. + +\subsection{The IDE window layout} + +A quick presentation of the user interface is given here: +\url{https://www.jetbrains.com/help/idea/guided-tour-around-the-user-interface.html}. +IntelliJ consists of an editor window and multiple tool windows. Some of the +important tool windows are: +\begin{itemize} + \item \textbf{Project}. Show the structure of the project. In the case of + TTool it displays the different sub-projects and the source folders + (code, test, resource, etc.) for each sub-project. It can be used in + addition to the navigation bar to navigate between files. + \item \textbf{TODO}. List TODOs in the project files. + \item \textbf{Structure}. Show the structure of a class (methods, fields, + etc.). + \item \textbf{Version control}. Show information related to the versioning + system used (git in our case). This enables to see the commits that have + modified the current file, the state of the various branches, the files + that have been modified since the last commit or to directly make a + commit. + \item \textbf{Terminal}. This opens a pseudo-terminal window that can be + used directly from IntelliJ. +\end{itemize} + +Note that these tool windows are movable from the different panes and that the +toolbar that enables to select which tool window to display can be shown/hidden +by clicking on the icon on the lower-left side of the IntelliJ window. + +\subsection{Adding and running JUnit tests} + +When you are editing a Java class, you can jump to the corresponding test class +by right-clicking on the editor window (on a specific method or anywhere in the +class), and select \emph{Go To -> Test}. +IntelliJ will look for a corresponding test class and will propose to create a +new one. If you decide to create a new test class, select \emph{JUnit4} as the +testing library and pick the methods for which you want to add tests. Once the +test is written, you will have a green arrow in the left margin of the editor +next to each test method. You can either click on the arrow corresponding to a +specific method to run the corresponding test, or click on the arrow next to the +class name to run all the tests in this class. + +In some cases, the tests need to use resources. You need to add these resources +to the \emph{test resources} root folder (see section +\ref{sec:intellij:subprojects} to see how this root folder is configured) and +to ensure that the test is running from the correct directory. To do this, run +the test once. You will see in the right section of the navigation bar a +shortcut to run the previous test. Expand the configuration selection list and +click on \emph{Edit Configurations...}. You can see all the available +configurations and modify options for each of them. In particular, you can +change the \emph{Working directory} (which should probably be +\texttt{ttool/build}) or require actions to do before running this +configuration (at the bottom of the window). You can share your configurations +so that other can use them but be careful not to share something with absolute +paths. + +\subsection{Debugging TTool} + +IntelliJ integrates a debugger that is helpful to find some bugs. You can either +launch TTool in debug mode by clicking on the bug icon in the right part of the +navigation bar when the \emph{TTool} configuration is selected, or debug a +specific test by selecting \emph{debug} in the drop-down menu that appears when +clicking on the arrow for this test. + +You can add breakpoints by clicking in the editor's left margin. You can the +right click on the breakpoint to modify it (log something, do not interrupt, add +a condition to the breakpoint, etc.). During debugging, when a breakpoint is +reached or the program was paused, you can see the current value of the +variables, see the stack frames, see the existing threads, add a watch point to +see how an expression evaluates, resume the program, execute step-by-step, etc. + +\subsection{Configuring new sub-projects} +\label{sec:intellij:subprojects} + +As described in section \ref{sec:code_orga}, TTool is composed of multiple +sub-projects. In IntelliJ, this is achieved by using \emph{modules}. You can see +the existing modules in the \emph{File -> Project structure...} menu. On the +left pane, click on \emph{Modules}. In particular, the \texttt{shared} module +consists of all the code used by other modules and the \texttt{ttool} module is +the main TTool application. + +For each of these modules, you can add \emph{content roots} (path that will +contain sub-folders for sources, tests, resources and test resources). Then you +can select a sub-folder for a content root and mark it either as a source, test, +resource or test resource folder. + +On the second tab, it is possible to modify the compile path. Note that if you +had a module then it must be compiled with gradle without requiring IntelliJ. +This is why you will need to update the compile path in order to generate the +output into the sub-project's build directory. + +Finally, you can add dependencies in the third tab. This is useful in particular +if a sub-project requires an external library. + +In the project structure window, on the left pane, you can select +\emph{Artifacts} to see the final results that can be built from the application +(the \texttt{ttool.jar} file for instance). As of today (February 2018), these +artifacts are: +\begin{itemize} + \item some files needed by TTool during its execution + \item the external libraries that TTool depends on + \item the \texttt{ttool.jar} archive +\end{itemize} + +\subsection{Configuration of code inspection and indentation rules} + +IntelliJ enables to improve coding practice by providing warnings (e.g., unused +variable) that are +visible in the editor and by enabling to automatically correct them. These +warnings have different levels (error, warning, weak warning, etc.) and they are +fully configurable. In order to configure them, you can click on the icon at the +extreme right of the status bar and click on \emph{configure inspections}. You +can choose which inspection should be enabled and which warning level should be +raised when code does not follow these inspections. In order to provide a +common coding standard among TTool developers, the configuration of these +inspections is stored in a profile that is versioned by Git. You should thus not +modify this profile without asking other developers. + +Similarly to these warnings, IntelliJ enables to harmonize code style by +defining a profile that is shared between all developers. To see the code style +options, go to \emph{File -> Settings} and navigate to \emph{Editor -> Code +Style}. As for warnings, do not modify this shared profile except if you know +what you are doing. + +Finally, IntelliJ enables to correct code style issues and some warnings +automatically. To do that, right click on the file in the project tool window +and select \emph{Reformat code}. + +\subsection{Tips and tricks} + +Note that there is a vim plugin available in IntelliJ that supports some of vim +commands. \section{Coding Information} Here are gathered all tricks on how TTool source codes are organized, and what function is coded where, and also how to extend TTool, e.g. adding a new diagram. @@ -605,6 +746,7 @@ make documentation and make sure no warning is printed. \subsection{Code organization} +\label{sec:code_orga} The TTool repository actually hosts the source code of different standalone projects. Here is a description of these sub-projects: \begin{itemize} diff --git a/src/main/shared.iml b/src/main/shared.iml index 2f401a19025e2e2f48bdeedd6d118c4c7665dea9..73f46c9a41a7303d88958c12219c3cd5e3e50d2c 100644 --- a/src/main/shared.iml +++ b/src/main/shared.iml @@ -4,15 +4,10 @@ <output url="file://$MODULE_DIR$/../../build/classes/main" /> <output-test url="file://$MODULE_DIR$/../../build/classes/test" /> <exclude-output /> - <content url="file://$MODULE_DIR$/java"> + <content url="file://$MODULE_DIR$/.."> <sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" /> - </content> - <content url="file://$MODULE_DIR$/resources"> <sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" /> </content> - <content url="file://$MODULE_DIR$/../../tests/util/fr.tpt.ttool.tests.util/src"> - <sourceFolder url="file://$MODULE_DIR$/../../tests/util/fr.tpt.ttool.tests.util/src" isTestSource="true" /> - </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="library" name="libs" level="project" /> diff --git a/ttool/src/main/ttool.iml b/ttool/src/main/ttool.iml index 1213f58b477ce5bbc31c8b38cb350278ac0f0d5c..da9d39bad486082c1d2d6f58b6e0d89fbbabdd9d 100644 --- a/ttool/src/main/ttool.iml +++ b/ttool/src/main/ttool.iml @@ -4,14 +4,11 @@ <output url="file://$MODULE_DIR$/../../build/classes/main/java" /> <output-test url="file://$MODULE_DIR$/../../build/classes/test/java" /> <exclude-output /> - <content url="file://$MODULE_DIR$/java"> + <content url="file://$MODULE_DIR$/.."> <sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" /> - </content> - <content url="file://$MODULE_DIR$/../test/java"> <sourceFolder url="file://$MODULE_DIR$/../test/java" isTestSource="true" /> - </content> - <content url="file://$MODULE_DIR$/../test/resources"> <sourceFolder url="file://$MODULE_DIR$/../test/resources" type="java-test-resource" /> + <excludeFolder url="file://$MODULE_DIR$/../test/libs" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" />