diff --git a/reference_guide.md b/reference_guide.md index 430876ed8fb..b279d1fbc55 100644 --- a/reference_guide.md +++ b/reference_guide.md @@ -2,10 +2,7 @@ title: Architecture Reference Guide --- -This documentation section contains more in-depth explanation of different API components. -If you are not familiar with *IntelliJ Platform* API please refer to -[Basics](basics.md) -section. +This documentation section contains more in-depth explanation of different API components. If you are not familiar with the *IntelliJ Platform* API please refer to the [Basics](basics.md) section. * [Project Model](reference_guide/project_model.md) * [Project Wizard](reference_guide/project_wizard.md) @@ -16,4 +13,4 @@ section. * [Messaging Infrastructure](reference_guide/messaging_infrastructure.md) * [Multiple Carets](reference_guide/multiple_carets.md) * [Color Scheme Management](reference_guide/color_scheme_management.md) -* [User Interface Components](user_interface_components/user_interface_components.md) \ No newline at end of file +* [User Interface Components](user_interface_components/user_interface_components.md) diff --git a/reference_guide/project_model.md b/reference_guide/project_model.md index 09229be6d40..65cf6130e19 100644 --- a/reference_guide/project_model.md +++ b/reference_guide/project_model.md @@ -2,37 +2,18 @@ title: Project Model. Roots and Libraries. Configuring Project from Code. --- -This section considers internal architecture *IntelliJ Platform* projects -and gives overview for classes and packages of the API used to manipulate with projects and their components, such as modules, facets, libraries, SDK. -For general information about the concept of a projects and concepts related to it, refer to -[Project](http://www.jetbrains.com/idea/help/project.html), -[Module](http://www.jetbrains.com/idea/help/module.html), -[Library](http://www.jetbrains.com/idea/help/library.html), -and -[Facet](http://www.jetbrains.com/idea/help/facet.html) -in -[IntelliJ IDEA Web Help](https://www.jetbrains.com/idea/help/intellij-idea.html). +This section considers the internal architecture of *IntelliJ Platform* projects and gives an overview for classes and packages of the API used to manipulate with projects and their components, such as modules, facets, libraries, SDK. +For general information about the concept of a projects and concepts related to it, refer to [Project](http://www.jetbrains.com/idea/help/project.html), [Module](http://www.jetbrains.com/idea/help/module.html), [Library](http://www.jetbrains.com/idea/help/library.html), and [Facet](http://www.jetbrains.com/idea/help/facet.html) in the [IntelliJ IDEA Web Help](https://www.jetbrains.com/idea/help/intellij-idea.html). ## Project Structure -A project consists of one or several modules. -Each module includes the plugin source code and so called order entries that refer to SDK and libraries the module uses. -By default, all modules uses the project SDK. -In addition, a module can optionally have a set of facets. -This document explains how you can explore and change the structure of projects using API. +A project consists of one or several modules. Each module includes source code and so called order entries that refer to SDK and libraries the module uses. By default, all modules use the project SDK. In addition, a module can optionally have a set of facets. This document explains how you can explore and change the structure of projects using API. Main project structure components are: -* [Project](/reference_guide/project_model/project.md) - itself - +* [Project](/reference_guide/project_model/project.md) * [Module](/reference_guide/project_model/module.md) - * [SDK](/reference_guide/project_model/sdk.md) - * [Library](/reference_guide/project_model/library.md) - * [Facet](/reference_guide/project_model/facet.md) - - diff --git a/reference_guide/project_model/module.md b/reference_guide/project_model/module.md index c100b4f2a96..8c1e30dbbf2 100644 --- a/reference_guide/project_model/module.md +++ b/reference_guide/project_model/module.md @@ -1,32 +1,24 @@ --- title: Module --- -A module is a discrete unit of functionality that can be run, tested, and debugged independently. -Modules includes such things as source code, build scripts, unit tests, deployment descriptors, etc. -In the project, each module can use a specific SDK or inherit SDK defined on the project level (see the [SDK](sdk.md) section later in this document). -A module can depend on other modules of the project. - -## Getting Current Module -To determine the module in the project in question to which the specified `VirtualFile` belongs use `ModuleUtilCore#findModuleForFile`. -Use `ModuleUtilCore#findModuleForPsiElement` to find the module for a given `PsiElement`. - -## Accessing Module Roots -Information about module roots can be accessed via the class -[ModuleRootManager.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootManager.java), -for example, an instance of -[ModuleFileIndex.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleFileIndex.java) -can be obtained, which is analogical to the -[ProjectFileIndex.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java) -but in the scope of a module + +A _module_ is a discrete unit of functionality that can be run, tested, and debugged independently. Modules includes such things as source code, build scripts, unit tests, deployment descriptors, etc. In the project, each module can use a specific SDK or inherit the SDK defined on the project level (see the [SDK](sdk.md) section later in this guide). A module can depend on other modules of the project. + +## Getting the current module + +To determine the module in the project in question to which the specified `VirtualFile` belongs use `ModuleUtilCore#findModuleForFile`. Use `ModuleUtilCore#findModuleForPsiElement` to find the module for a given `PsiElement`. + +## Accessing module roots + +Information about module roots can be accessed via the class [ModuleRootManager.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootManager.java), for example, an instance of [ModuleFileIndex.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleFileIndex.java) can be obtained, which is similar to the [ProjectFileIndex.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java) but in the scope of a module. ```java ModuleRootManager.getInstance(currentModule).getFileIndex() ``` -### Checking Belonging to a Module Source Root +## Checking belonging to a module source root -To check if a virtual file or directory belongs to a module source root, use the `ProjectFileIndex.getSourceRootForFile` method. -This method returns null if the file or directory does not belong to any source root of modules in the project. +To check if a virtual file or directory belongs to a module source root, use the `ProjectFileIndex.getSourceRootForFile` method. This method returns null if the file or directory does not belong to any source root of modules in the project. ```java VirtualFile moduleSourceRoot = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(virtualFileOrDirectory); diff --git a/reference_guide/project_model/project.md b/reference_guide/project_model/project.md index 281c2193fa4..b9c88286096 100644 --- a/reference_guide/project_model/project.md +++ b/reference_guide/project_model/project.md @@ -2,82 +2,46 @@ title: Project --- -In IntelliJ IDEA, a project encapsulates all your source code, libraries, build instructions into a single organizational unit. -Everything you do in IntelliJ IDEA, is done within the context of a project. -A project defines some collections referred to as modules and libraries. -Depending on the logical and functional requirements to the project, you can create a single-module or a multi-module project. +In *IntelliJ IDEA*, a project encapsulates all your source code, libraries, build instructions into a single organizational unit. Everything you do in *IntelliJ IDEA*, is done within the context of a project. A project defines some collections referred to as modules and libraries. Depending on the logical and functional requirements to the project, you can create a single-module or a multi-module project. -## Working with Projects +## Working with projects -*IntelliJ Platform* stores the project configuration data in XML files. -The list of those files depends on the plugin -[project](http://www.jetbrains.com/idea/help/project.html) -format. -For file-based format projects, the information core to the project itself (e.g. location of the component modules, compiler settings, etc.) is stored in the <%project name%>.IPR file. -The information about modules the project includes is stored in <%module name%>.IML files. -Module files are created for each module. +The *IntelliJ Platform* stores the project configuration data in XML files. The list of those files depends on the plugin [project](http://www.jetbrains.com/idea/help/project.html) format. -For directory-based format projects, the project and workspace settings are stored in a number of XML files under the <%Project home directory%>/.idea directory. -Each XML file is responsible for its own set of settings and can be recognized by its name: projectCodeStyle.xml, encodings.xml, vcs.xml etc. -As for the file-based format projects, .IML files describe modules. +For file based format projects, the information core to the project itself (e.g. location of the component modules, compiler settings, etc.) is stored in the `%project_name%.ipr` file. The information about modules the project includes is stored in `%module_name%.iml` files. Module files are created for each module. -Main classes providing work with the project model are located in the package -[projectModel-api.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-api/src/com/intellij/openapi). -Basic API classes and interfaces for the concepts of -[project](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/project/Project.java), -[module](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/module/Module.java), -[application](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/application/Application.java), -and -[component](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/components/ProjectComponent.java) -are placed in the -[core-api.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/core-api/src/com/intellij/openapi) -package. +For directory based format projects, the project and workspace settings are stored in a number of XML files under the `%project_home_directory%/.idea` directory. Each XML file is responsible for its own set of settings and can be recognized by its name: `projectCodeStyle.xml`, `encodings.xml`, `vcs.xml` etc. As for the file-based format projects, `.iml` files describe modules. +Main classes providing work with the project model are located in the package [projectModel-api.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-api/src/com/intellij/openapi). Basic API classes and interfaces for the concepts of [project](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/project/Project.java), [module](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/module/Module.java), [application](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/application/Application.java), and [component](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/components/ProjectComponent.java) are placed in the [core-api.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/core-api/src/com/intellij/openapi) package. -### Finding Source Roots - -To get an array of all the source roots for a project use -`ProjectRootManager.getContentSourceRoots()` -method like this code snippet shows: +### Finding source roots +To get an array of all the source roots for a project use `ProjectRootManager.getContentSourceRoots()` method like this code snippet shows: ```java VirtualFile[] vFiles = ProjectRootManager.getInstance(project).getContentSourceRoots(); ``` +### Checking if a file belongs to a project -### Checking if File Belongs to a Project - -Use -[ProjectFileIndex.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java) -to get this information. +Use [ProjectFileIndex.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java) to get this information. ### Getting an Instance of the ProjectFileIndex Interface -Use the ProjectRootManager.getFileIndex() method. For example: +Use the `ProjectRootManager.getFileIndex()` method. For example: ```java ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); ``` -Note that this method returns `null` if the file does not belong to any module. -You can also use the `ProjectFileIndex.getContentRootForFile()` method to get the module content root to which the specified file or directory belongs: +Note that this method returns `null` if the file does not belong to any module. You can also use the `ProjectFileIndex.getContentRootForFile()` method to get the module content root to which the specified file or directory belongs: ```java VirtualFile moduleContentRoot = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(virtualFileOrDirectory); -``` +``` ## Changing the project structure -Utility classes which can be used for modifying a project structure can be found in the package -[projectModel-impl.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-impl/src/com/intellij/openapi). -It's -[roots](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-impl/src/com/intellij/openapi/roots/) -subpackage contains instances and utilities meant to work with project and module source roots, including -[ModuleRootModificationUtil.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootModificationUtil.java) -and -[ProjectRootUtil.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java) - -Refer to the -[basic example](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/com/intellij/tutorials/project/model/ModificationAction.java) -of on-the-fly project structure modification to learn how it can be implemented. +Utility classes which can be used for modifying a project structure can be found in the package [projectModel-impl.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-impl/src/com/intellij/openapi). It's [roots](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-impl/src/com/intellij/openapi/roots/) subpackage contains instances and utilities meant to work with project and module source roots, including [ModuleRootModificationUtil.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootModificationUtil.java) and [ProjectRootUtil.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java). + +Refer to the [basic example](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/com/intellij/tutorials/project/model/ModificationAction.java) of on-the-fly project structure modification to learn how it can be implemented. diff --git a/reference_guide/project_model/sdk.md b/reference_guide/project_model/sdk.md index 12506b20753..dc05188a59f 100644 --- a/reference_guide/project_model/sdk.md +++ b/reference_guide/project_model/sdk.md @@ -2,51 +2,40 @@ title: SDK --- -Every project uses a Software Development Kit (SDK). -For Java projects, SDK is referred to as JDK (Java Development Kit). -SDK determines which API library is used to build the project. If your project is multi-module, the project SDK by default is common for all modules within the project. -Optionally, you can configure individual SDK for each module. -For more information about SDKs, see -[SDK](https://www.jetbrains.com/idea/help/sdk.html) -and -[Configuring Global, Project and Module SDKs](https://www.jetbrains.com/idea/help/configuring-global-project-and-module-sdks.html) -in IntelliJ IDEA Web Help. - -### Getting Project SDK Information - -Main information about the project SDK can be accessed via -[ProjectRootManager.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectRootManager.java) -like the following example shows +Every project uses a Software Development Kit (SDK). For Java projects, the SDK is referred to as the JDK (Java Development Kit). The SDK determines which API library is used to build the project. If your project is multi-module, the project SDK by default is common for all modules within the project. Optionally, you can configure individual SDKs for each module. For more information about SDKs, see [SDK](https://www.jetbrains.com/idea/help/sdk.html) and [Configuring Global, Project and Module SDKs](https://www.jetbrains.com/idea/help/configuring-global-project-and-module-sdks.html) in IntelliJ IDEA Web Help. + +## Getting project SDK information + +Main information about the project SDK can be accessed via [ProjectRootManager.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectRootManager.java) like the following example shows ```java String projectSdk = ProjectRootManager.getInstance(project).getProjectSdk(); ``` -### Getting And Setting Project SDK Attributes +## Getting and setting project SDK attributes -* To get the project-level SDK +* To get the project level SDK ```java Sdk projectSDK = ProjectRootManager.getInstance(project).getProjectSdk(); ``` -* To get the project-level SDK name: +* To get the project level SDK name: ```java String projectSDKName = ProjectRootManager.getInstance(project).getProjectSdkName(); ``` -* To set the project-level SDK: +* To set the project level SDK: ```java ProjectRootManager.getInstance(project).setProjectSdk(Sdk jdk); ``` -* To set the project-level SDK name: +* To set the project level SDK name: ```java ProjectRootManager.getInstance(project).setProjectSdkName(String name); ``` -See the following [code sample](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/com/intellij/tutorials/project/model/ProjectSdkAction.java) -to get more familiar with SDK manipulation tool set. +See the following [code sample](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/com/intellij/tutorials/project/model/ProjectSdkAction.java) to get more familiar with SDK manipulation tool set.