DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:intellij_idea

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:intellij_idea [2019-03-10 21:02] – [Configure Idea] Klap-indevel:intellij_idea [2022-10-27 19:03] (current) – [Path Mappings] andi
Line 26: Line 26:
 {{ :devel:idea-newproject.png?500 |New Project Dialog}} {{ :devel:idea-newproject.png?500 |New Project Dialog}}
  
-===== Configure Idea =====+===== Coding Style =====
  
-To setup idea for DokuWiki's [[coding style]], download the following file and place it into your ''.IntelliJIdea13/config/codestyles''(Win/*nix) ''~/Library/Preferences/IntelliJIdea13/codestyles''(OSX) folder:+To setup Idea for DokuWiki's [[coding style]], download the following file and place it into your ''.IntelliJIdea13/config/codestyles''(Win/*nix) ''~/Library/Preferences/IntelliJIdea13/codestyles''(OSX) folder:
  
 <file xml ~/.IntelliJIdea13/config/codestyles/DokuWiki.xml> <file xml ~/.IntelliJIdea13/config/codestyles/DokuWiki.xml>
Line 101: Line 101:
 Then go to ''File'' -> ''Settings...'' -> ''Editor'' -> ''Code Style'' and select ''DokuWiki'' from the drop down. (Maybe you have to restart first before scheme is shown) Then go to ''File'' -> ''Settings...'' -> ''Editor'' -> ''Code Style'' and select ''DokuWiki'' from the drop down. (Maybe you have to restart first before scheme is shown)
  
-Additionally you may want to configure the following inspections at ''File'' -> ''Settings...'' -> ''Inspections'':+Additionally you may want to configure the following inspections at ''File'' -> ''Settings...'' -> ''Editor'' -> ''Inspections'':
  
   * PHP   * PHP
Line 109: Line 109:
       * Missing PHPDoc comment: true       * Missing PHPDoc comment: true
   * Spelling: false   * Spelling: false
 +
 +===== Path Mappings =====
 +
 +IDEA can make more intelligent suggestions when it knows where which parts are located where. To do so you should add some directory markings.
 +
 +{{ :devel:ideadirectories.png?300|Pathmapping Example}}
 +
 +
 +  * focus the directory tree and press F4
 +  * this should open the Module Settings dialog
 +  * select a directory, then click on the appropriate "Mark as" button at the top
 +  * click the pen icon on the right to configure an associated namespace
 +
 +^ Directory ^ Mark as ^ Namespace ^
 +| ''_test/tests'' | Tests | ''dokuwiki\test'' |
 +| ''inc'' | Sources | ''dokuwiki'' |
 +| ''_test/mock'' | Sources | ''dokuwiki\test\mock'' |
 +| ''data'' | Excluded | |
 +| ''vendor'' | Excluded | |
 +
 +
 +
 +
 +===== Mapping of (plugin) git repositories =====
 +
 +IDEA will automatically keep track of git changes for the main DokuWiki checkout. But usually plugins and templates will have their own .git directory. Telling IDEA about it is a good idea.
 +
 +  - Click on File -> Settings...
 +  - Select "Version Control"
 +  - Select "Directory Mappings"
 +  - At the bottom of the list recognized git repositories are listed. Select to add.
 +
 +
 ===== Integrate Unit Tests ===== ===== Integrate Unit Tests =====
  
Line 115: Line 148:
 First set default configuration, then you don't have to do that in next steps First set default configuration, then you don't have to do that in next steps
  
-Under ''Defaults'' find ''PHPUnit'' and check ''Use alternative configuration file'', fill ''<path to>/_test/phpunit.xml'', leave everything as is and press ''Apply''.+Under ''Templates'' find ''PHPUnit'' and check ''Use alternative configuration file'', fill ''<path to>/_test/phpunit.xml'', leave everything as is and press ''Apply''.
  
-Click the //Add// button and choose ''PHPUnit''. Then fill in these values:+Click the ''+'' button (i.e. top left button with on hover 'Add New Configuration'and choose ''PHPUnit''. Then fill in these values:
  
   * Name: ''All Tests''   * Name: ''All Tests''
Line 143: Line 176:
  
 ====Individual/plugin test cases==== ====Individual/plugin test cases====
-In order to run individual test cases you need to add a few more settings. Go to ''File'' -> ''Settings...'' -> ''PHP'' -> ''PHPUnit'', here you need to enable ''Use configuration file'' and specify the ''<path to>/_test/phpunit.xml''. Then you need to mark either under ''Directories'' in the project settings or directly in the project tree the ''_test/tests'' via context menu option ''Mark directory As'' -> ''Test Source Root'' and do the same for any plugin test directories. After that you can run or debug individual test cases by choosing run or debug in the context menu of the file in the project tree.+In order to run individual test cases you need to add a few more settings. Go to ''File'' -> ''Settings...'' -> ''Languages & Frameworks'' -> ''PHP'' -> ''Test Frameworks'', 
 +Use ''+'' button to add a configuration. Here you need to enable ''Default configuration file'' and specify the ''<path to>/_test/phpunit.xml'' 
 + 
 +Then you need to mark either under ''Directories'' in the project settings or directly in the project tree the ''_test/tests'' via context menu option ''Mark directory As'' -> ''Test Source Root'' and do the same for any plugin test directories. After that you can run or debug individual test cases by choosing run or debug in the context menu of the file in the project tree.
  
 ==== PHPUnit autocompletion ==== ==== PHPUnit autocompletion ====
 +**Note**: only needed for older versions of IDEA intellij. Is today automatically retrieve from the ''phpunit.phar''.
  
 To use all the favor of Idea you have to add the PHPUnit source to your project. To add this you have to: To use all the favor of Idea you have to add the PHPUnit source to your project. To add this you have to:
Line 153: Line 190:
   - Select "Libraries" tab   - Select "Libraries" tab
   - Click on the "+" -> Java   - Click on the "+" -> Java
-  - Select your PHPUnit folder (eg. ''/usr/share/pear/PHPUnit''+  - Select your PHPUnit folder (eg. ''/usr/share/pear/PHPUnit'', ''/usr/share/php/PHPUnit'', etc
-  - In the following dialog choose "source"+  - In the following dialog choose "Sources"
   - Click "Ok"   - Click "Ok"
   - Click "Ok"   - Click "Ok"
Line 160: Line 197:
  
 Idea will now index the PHPUnit source and can provide auto completion inside of unit tests. Idea will now index the PHPUnit source and can provide auto completion inside of unit tests.
 +
 ===== Tips and Tricks ===== ===== Tips and Tricks =====
  
devel/intellij_idea.1552248175.txt.gz · Last modified: 2019-03-10 21:02 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki