Skip to content

IntelliJ Some conclusions from existing plugins

Amir Sagiv edited this page Jul 1, 2017 · 1 revision

Here are some conclusions from "Identifier Highlighter"

  • One can create PsiFile via PsiDocumentMenager:

  • One can find all references to an object via ReferenceSearch

  • This pluging works all the time with "instanceof" instead using visitor because of the reason mentioned in #25

  • One can fine PsiIdentifier not by using the Psi tree, but by using string matching:

  • One can find the Psi tree upwards:

One can find initialization of PsiVariable:

Here are some conclusions from "Generate toString"

The plugin "Generate toString" has the coolest utils file named: "PsiAdapter". This file gives a similar behaviour to the auxiliary layer in the Eclipse Spartanizer project. We can get inspired by these methods when expanding the Utils functionality.

for example there are methods such as:

  • getPsiElementFactory (really useful when trying to change the source code)
  • findClass (return the class in which a PsiElement is in)
  • findParentMethod
  • isPrimitiveType
  • and much more When looking on the implementation of some of the methods (like addImportStatment) I see no explicit change of the source .java file. They change the Psi tree using direct change (like adding elment to import statments list) or by using replace method of PsiElement. So the change of the text in the file is dip inside the replace method.
Clone this wiki locally