Berkay Özerbay 7062b73971 Fix PHPRenameVisitor and Being Able to Run Rename for PHP in Eval Plugin [LME-29]
Refactor addToken method

Refactor the addToken method to remove the originalElement parameter and streamline its usage across the visit methods. This change simplifies the method signature and ensures consistency in handling variable, field, and parameter elements.

Remove PHP module dependency.

Eliminated the `intellij.php.impl` module from the plugin's configuration and removed unused `PhpLangUtil` imports. This reduces unnecessary dependencies and simplifies the project.

Update offsets in PHP test fragments and actions

Adjusted the offset values for `name`, `color`, and `user` tokens in both `test.php_fragment` and `test2.php_fragment` files. This change ensures proper alignment with the code structure and correct token type identification.

Refactor reference check logic

Simplify conditional statement by renaming and inverting the reference check function. This improves readability and reduces the cognitive load for future code maintenance.

Simplify reference check logic in CommonActionsInvoker.kt

Refactored the code to remove type casting and streamline the reference check by introducing the `isNotThisReference` function. This improves code readability and maintainability.

Refactor token addition to include custom start offsets.

Modified the `addToken` method to accept an optional `startOffset` parameter and updated relevant calls to pass the correct offset, ensuring accurate token positioning in the PHP rename visitor logic.

Refactor logging setup in PhpRenameVisitor

Replaced direct Logger instance usage with logger<PhpRenameVisitor>() inside a companion object for consistency and cleaner code structure. This improves maintainability and follows standard logging practices.

Switch println to Logger for better logging

Replaced println statements with Logger in PhpRenameVisitor.kt to standardize logging practices. This change enables more robust and configurable logging control.

Update token type for PHP field in rename visitor

Correct the type property assignment for PHP fields from TOKEN to FIELD in the PhpRenameVisitor. This ensures that fields are accurately categorized, improving the rename functionality for PHP elements.

Add run configuration for PHP name suggestion evaluation (dev build)

fix typo

Enhance PHP rename visitor handling

Add detailed processing for different PHP elements like classes, methods, fields, functions, and parameters. Introduce utility methods for better variable and parameter handling within the rename visitor.

Optimize reference renaming in CommonActionsInvoker

Removed unnecessary logging from moveCaret and added conditional check to exclude PHP "this" references during renaming. This ensures more precise refactor operations and improves performance slightly.

update test files for PHP Rename

Split PhpRenameActionsProcessorTest into two classes

Separated tests into PhpRenameActionsProcessorTest1 and PhpRenameActionsProcessorTest2, each handling a different input file set. This change improves clarity and organization of the test files.

Remove obsolete run configuration for PHP Name Suggestion

Deleted the outdated run configuration file for the PHP Name Suggestion evaluation. This helps clean up unused configurations and streamline the project setup.

Add new PHP test cases for evaluation plugin

Introduced a new PHP file `test2.php` containing a trait `HasAuthor` with methods related to authorship functionality. Accompanied by necessary action and fragment files to support the new test cases in the evaluation plugin tests.


Merge-request: IJ-MR-142199
Merged-by: Berkay Özerbay <berkay.ozerbay@jetbrains.com>

GitOrigin-RevId: b85c18bd2d00cbb29ee6e11b2a4a2906eee69658
2024-08-13 17:48:00 +00:00

IntelliJ IDEA Community Edition official JetBrains project

These instructions will help you build IntelliJ IDEA Community Edition from source code, which is the basis for IntelliJ Platform development. The following conventions will be used to refer to directories on your machine:

  • <USER_HOME> is your home directory.
  • <IDEA_HOME> is the root directory for the IntelliJ source code.

Getting IntelliJ IDEA Community Edition Source Code

IntelliJ IDEA Community Edition source code is available from github.com/JetBrains/intellij-community by either cloning or downloading a zip file (based on a branch) into <IDEA_HOME>. The default is the master branch.

The master branch contains the source code which will be used to create the next major version of IntelliJ IDEA. The branch names and build numbers for older releases of IntelliJ IDEA can be found on the page of Build Number Ranges.

These Git operations can also be done through the IntelliJ IDEA user interface.

Speed Tip: If the complete repository history isn't needed, then using a shallow clone (git clone --depth 1) will save significant time.

On Windows: Two git options are required to check out sources on Windows. Since it's a common source of Git issues on Windows anyway, those options could be set globally (execute those commands before cloning any of intellij-community/android repositories):

  • git config --global core.longpaths true
  • git config --global core.autocrlf input

IntelliJ IDEA Community Edition requires additional Android modules from separate Git repositories. To clone these repositories, run one of the getPlugins scripts located in the <IDEA_HOME> directory. Use the --shallow argument if the complete repository history isn't needed. These scripts clone their respective master branches. Make sure you are inside the <IDEA_HOME> directory when running those scripts, so the modules get cloned inside the <IDEA_HOME> directory.

  • getPlugins.sh for Linux or macOS.
  • getPlugins.bat for Windows.

Note: Always git checkout the intellij-community and android Git repositories to the same branches/tags.

Building IntelliJ Community Edition

Version 2023.2 or newer of IntelliJ IDEA Community Edition or IntelliJ IDEA Ultimate Edition is required to build and develop for the IntelliJ Platform.

Opening the IntelliJ Source Code for Build

Using IntelliJ IDEA File | Open, select the <IDEA_HOME> directory.

IntelliJ Build Configuration

  1. It's recommended to use JetBrains Runtime 17 to compile the project. When you invoke Build Project for the first time, IntelliJ IDEA should suggest downloading it automatically.
  2. If the Maven plugin is disabled, add the path variable "MAVEN_REPOSITORY" pointing to <USER_HOME>/.m2/repository directory.
  3. Make sure you have at least 8GB of RAM on your computer. With the bare minimum of RAM, disable "Compile independent modules in parallel" option in the compiler settings. With notably more memory available, increase "User-local build process heap size" to 3000 - that will greatly reduce compilation time.

Note that it is important to use the variant of JetBrains Runtime without JCEF. So, if for some reason jbr-17 SDK points to an installation of JetBrains Runtime with JCEF, you need to change it: ensure that IntelliJ IDEA is running in internal mode (by adding idea.is.internal=true to idea.properties file), navigate to jbr-17 item in Project Structure | SDKs, click on 'Browse' button, choose 'Download...' item and select version 17 and vendor 'JetBrains Runtime'.

Building the IntelliJ Application Source Code

To build IntelliJ IDEA Community Edition from source, choose Build | Build Project from the main menu.

To build installation packages, run the installers.cmd command in <IDEA_HOME> directory. installers.cmd will work on both Windows and Unix systems.

Options to build installers are passed as system properties to installers.cmd command. You may find the list of available properties in BuildOptions.kt

Examples (./ should be added only for Linux/macOS):

  • Build installers only for current operating system: ./installers.cmd -Dintellij.build.target.os=current
  • Build source code incrementally (do not build what was already built before): ./installers.cmd -Dintellij.build.incremental.compilation=true

installers.cmd is used just to run OpenSourceCommunityInstallersBuildTarget from the command line. You may call it directly from IDEA, see run configuration Build IDEA Community Installers (current OS) for an example.

Dockerized Build Environment

To build installation packages inside a Docker container with preinstalled dependencies and tools, run the following command in <IDEA_HOME> directory (on Windows, use PowerShell):
docker run --rm -it -v ${PWD}:/community $(docker build -q . --target build_env)

Running IntelliJ IDEA

To run the IntelliJ IDEA built from source, choose Run | Run from the main menu. This will use the preconfigured run configuration "IDEA".

To run tests on the build, apply these setting to the Run | Edit Configurations... | Templates | JUnit configuration tab:

  • Working dir: <IDEA_HOME>/bin
  • VM options:
    • -ea

You can find other helpful information at https://www.jetbrains.com/opensource/idea. The "Contribute Code" section of that site describes how you can contribute to IntelliJ IDEA.

Running IntelliJ IDEA on CI/CD environment

To run tests outside of IntelliJ IDEA, run the tests.cmd command in <IDEA_HOME> directory. tests.cmd will work on both Windows and Unix systems.

Options to run tests are passed as system properties to tests.cmd command. You may find the list of available properties in TestingOptions.kt

Examples (./ should be added only for Linux/macOS):

  • Build source code incrementally (do not build what was already built before): ./tests.cmd -Dintellij.build.incremental.compilation=true
  • Run a specific test: ./tests.cmd -Dintellij.build.test.patterns=com.intellij.util.ArrayUtilTest

tests.cmd is used just to run CommunityRunTestsBuildTarget from the command line. You may call it directly from IDEA, see run configuration tests in community for an example.

Description
No description provided
Readme 5.3 GiB
Languages
Java 55.6%
Kotlin 29.2%
Python 8%
C 3.4%
HTML 1.7%
Other 1.5%