From 369c534de0fbc98be59dc3da7c56b936d58077db Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Mon, 2 Jan 2023 18:29:42 +0100 Subject: [PATCH] modifying_psi.md: Add simpler example of creating PSI --- topics/basics/architectural_overview/modifying_psi.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/topics/basics/architectural_overview/modifying_psi.md b/topics/basics/architectural_overview/modifying_psi.md index 8f98c3bc3..4ea63ec87 100644 --- a/topics/basics/architectural_overview/modifying_psi.md +++ b/topics/basics/architectural_overview/modifying_psi.md @@ -1,6 +1,6 @@ [//]: # (title: Modifying the PSI) - + The PSI is a read/write representation of the source code as a tree of elements corresponding to a source file's structure. You can modify the PSI by *adding*, *replacing*, and *deleting* PSI elements. @@ -17,7 +17,9 @@ In the most general case, you use the `createFileFromText()` method of [`PsiFile See also [](psi_files.md#how-do-i-create-a-psi-file). Most languages provide factory methods that let you create specific code constructs more easily. -For example, the [`PsiJavaParserFacade`](%gh-ic%/java/java-psi-api/src/com/intellij/psi/PsiJavaParserFacade.java) class contains methods such as `createMethodFromText()`, which creates a Java method from the given text. +Examples: +* [`PsiJavaParserFacade`](%gh-ic%/java/java-psi-api/src/com/intellij/psi/PsiJavaParserFacade.java) class contains methods such as `createMethodFromText()`, which creates a Java method from the given text +* [`SimpleElementFactory.createProperty()`](%gh-sdk-samples%/simple_language_plugin/src/main/java/org/intellij/sdk/language/psi/SimpleElementFactory.java) creating a Simple language property When you're implementing refactorings, [intentions](code_intentions.md), or inspection [quickfixes](code_inspections_and_intentions.md) that work with existing code, the text that you pass to the various `createFromText()` methods will combine hard-coded fragments and fragments of code taken from the existing file. For small code fragments (individual identifiers), you can simply append the text from the existing code to the text of the code fragment you are building.