mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 02:07:50 +08:00
actualized 'Project Model' section
fixed broken URLs fixed style issues and typo
This commit is contained in:
parent
377953daa7
commit
8dd5790bca
@ -26,7 +26,7 @@ OrderEntry orderEntry : fileIndex.getOrderEntriesForFile(virtualFile));
|
||||
|
||||
## Checking Belonging to a Library
|
||||
|
||||
The ProjectFileIndex interface implements a number of methods you can use to check whether the specified file belongs to the project library classes or library sources.
|
||||
The [ProjectFileIndex](https://github.com/JetBrains/intellij-community/blob/master/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java) interface implements a number of methods you can use to check whether the specified file belongs to the project library classes or library sources.
|
||||
You can use the following methods:
|
||||
|
||||
* To check if a specified virtual file is a compiled class file use
|
||||
|
@ -3,7 +3,7 @@ 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 section later in this document).
|
||||
In the project, each module can use a specific SDK or inherit SDK defined on the project level (see the [SDK](/reference_guide/project_model/sdk.html) section later in this document).
|
||||
A module can depend on other modules of the project.
|
||||
|
||||
## Getting Current Module
|
||||
@ -16,7 +16,7 @@ Module module = ProjectRootManager.getInstance(project).getFileIndex().getModule
|
||||
|
||||
|
||||
## Accessing Module Roots
|
||||
Information about model roots can be accessed via the class
|
||||
Information about module roots can be accessed via the class
|
||||
[ModuleRootManager.java](https://github.com/JetBrains/intellij-community/blob/master/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootManager.java),
|
||||
for example, an instance of
|
||||
[ModuleFileIndex.java](https://github.com/JetBrains/intellij-community/blob/master/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleFileIndex.java)
|
||||
@ -30,12 +30,9 @@ ModuleRootManager.getInstance(currentModule).getFileIndex()
|
||||
|
||||
### 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.
|
||||
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);
|
||||
```
|
||||
|
@ -60,8 +60,8 @@ Use the ProjectRootManager.getFileIndex() method. For example:
|
||||
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);
|
||||
@ -74,10 +74,10 @@ Utility classes which can be used for modifying a project structure can be found
|
||||
It's
|
||||
[roots](https://github.com/JetBrains/intellij-community/blob/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://github.com/JetBrains/intellij-community/blob/master/platform/projectModel-impl/src/com/intellij/openapi/roots/ModuleRootModificationUtil.java)
|
||||
[ModuleRootModificationUtil.java](https://github.com/JetBrains/intellij-community/blob/master/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootModificationUtil.java)
|
||||
and
|
||||
[ProjectRootUtil.java](https://github.com/JetBrains/intellij-community/blob/master/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java)
|
||||
|
||||
Refer to the
|
||||
[basic example](https://github.com/JetBrains/intellij-sdk/blob/master/code_samples/project_model/src/com/intellij/plugins/project/model/ModificationAction.java)
|
||||
[basic example](https://github.com/JetBrains/intellij-sdk/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.
|
||||
|
@ -12,9 +12,9 @@ and
|
||||
[Configuring Project JDK](http://www.jetbrains.com/idea/webhelp/configuring-project-jdk.html)
|
||||
in IntelliJ IDEA Web Help.
|
||||
|
||||
### Getting Project Sdk Information
|
||||
### Getting Project SDK Information
|
||||
|
||||
Main information about the project Sdk can be accessed via
|
||||
Main information about the project SDK can be accessed via
|
||||
[ProjectRootManager.java](https://github.com/JetBrains/intellij-community/blob/master/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectRootManager.java)
|
||||
like the following example shows
|
||||
|
||||
@ -48,5 +48,5 @@ String projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();
|
||||
ProjectRootManager.getInstance(project).setProjectSdkName(String name);
|
||||
```
|
||||
|
||||
See the following [code sample](https://github.com/JetBrains/intellij-sdk/blob/master/code_samples/project_model/src/com/intellij/plugins/project/model/ProjectSdkAction.java)
|
||||
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user