PK ȖD{ { intellij.devkit.core.xml
LocalQuickFix
and IntentionAction
implementations that prevent intention preview
action from functioning properly. Additionally, excessive @SafeFieldForPreview
annotations are reported on fields
whose types are known to be safe.
Intention preview is an IntelliJ platform feature that displays how quick-fix or intention action
will change the current file when applied. To implement this in quick fixes,
LocalQuickFix.generatePreview()
is called with a custom ProblemDescriptor
that points to the non-physical copy of current file. In intention actions, IntentionAction.generatePreview()
is called with the non-physical copy of current file and imaginary editor.
Normally, these methods just delegate to LocalQuickFix.applyFix()
or IntentionAction.invoke()
.
However, some quick-fixes may refer directly or indirectly to physical elements and use them for writing. As a result,
preview won't work, as the quick-fix will attempt to update physical PSI instead of non-physical one.
To avoid this, default implementation of generatePreview()
delegates only if all the
instance fields of a quick fix or intention action class have safe types: primitives, Strings, etc.
You may fix this problem in a number of ways:
@SafeFieldForPreview
. You can also use
@SafeTypeForPreview
if the field type can never store any writable PSI reference.
getFileModifierForPreview()
method and create a copy of the quick-fix
rebinding it to the non-physical file copy which is supplied as a parameter. Use
PsiTreeUtil.findSameElementInCopy()
to find the corresponding PSI elements inside the
supplied non-physical copy.
ProblemDescriptor.getPsiElement()
in quick fix or from the supplied file/editor in intention action.
You may also inherit the abstract LocalQuickFixAndIntentionActionOnPsiElement
class and
implement its invoke()
and isAvailable()
methods, which have
startElement
and endElement
parameters. These parameters are automatically
mapped to a non-physical file copy for you.
generatePreview()
method and provide completely custom preview behavior.
For example, it's possible to display a custom HTML document instead of actual preview if your action
does something besides modifying a current file.
This inspection does not report if a custom implementation of getFileModifierForPreview()
or generatePreview()
exists. However, this doesn't mean that the implementation is correct and preview works.
Please test. Also note that preview result is calculated in background thread, so you cannot start a write action
during the preview or do any operation that requires a write action. Finally, no preview is generated automatically
if startInWriteAction()
returns false
. In this case, having custom generatePreview()
implementation is desired.
New in 2022.1
PK ? 2 inspectionDescriptions/ComponentNotRegistered.html Reports plugin components and actions that are not registered in aplugin.xml
descriptor.
This eases developing new components when using the "Create Class" intention and helps keep track of potentially obsolete components.
Provided quick-fix to register the component adds necessary registration in plugin.xml
descriptor.
Configure the inspection:
The following problems are reported:
AnAction
class.java.io.File.equals()/hashCode()/compareTo()
methods.
These do not honor case-insensitivity on macOS.
Use com.intellij.openapi.util.io.FileUtil.filesEquals()/fileHashCode()/compareFiles()
methods instead.
Must be run in batch mode, IDE internal mode must be enabled.
PK 'ԛ 5 inspectionDescriptions/IncorrectParentDisposable.html Reports usingApplication
or Project
as a parent Disposable
in plugin code.
Such usages will lead to plugins not being unloaded correctly. Please see Choosing a Disposable Parent in SDK Docs.
PK SLǥ C inspectionDescriptions/InspectionDescriptionNotFoundInspection.html Reports inspections that are missing an HTML description file, i.e. a file containing a text like this.The Create description file quick-fix creates a template HTML description file.
PK CqTG G 5 inspectionDescriptions/InspectionUsingGrayColors.html Reports usages ofjava.awt.Color
to create gray colors.
The Convert to 'Gray' quick fix replaces it using com.intellij.ui.Gray
constants instead.
Examples:
// bad: Color gray = new Color(37, 37, 37); // good: Color gray = Gray._37;PK gep p B inspectionDescriptions/IntentionDescriptionNotFoundInspection.html Reports intentions that are missing an HTML description file,
before.template
file or after.template
file.
These are shown in Settings | Editor | Intentions.
The Create description file quick-fix creates a template HTML description file.
PK A# * inspectionDescriptions/LeakableMapKey.html Reports usingLanguage
or FileType
as a map key in plugin code.
Such usages might lead to inability to unload the plugin properly.
Please consider using String
as keys instead.
See Dynamic Plugins in SDK Docs for more information.
PK C 4 inspectionDescriptions/MissingAccessibleContext.html Reports Swing components that do not provide accessibility context.This information is used by screen readers. Failing to provide it makes the component inaccessible for visually impaired users.
Example:
ListCellRenderer<String> renderer = (list, val, index, sel, cell) -> {
JPanel panel = new JPanel();
return panel;
};
To fix the problem, you should either call setAccessibleName()
on the returned JPanel
or override its getAccessibleContext()
method.
The returned text should reflect the purpose
of the component. For example, in the case of ListCellRenderer
, this would be the text of the menu
item.
ActionUpdateThreadAware
that implicitly state the deprecated and costly ActionUpdateThread.OLD_EDT
mode.
When an action or an action group defines its own update
method, IntelliJ Platform tries to mimic
the old synchronous way of calling update
and getChildren
methods in the UI thread and
supply it with all the data in AnActionEvent.dataContext
.
To do that, it caches all the possible data on a background thread beforehand even if it is not needed.
Provide one of the two new modes ActionUpdateThread.EDT
or ActionUpdateThread.BGT
by overriding the getActionUpdateThread
method.
See ActionUpdateThread
documentation for more information.
PK jw , inspectionDescriptions/MissingRecentApi.html
Reports usages of IntelliJ Platform API introduced in a version newer than the one specified in <idea-version>
@since-build
in plugin.xml
.
Using such API may lead to incompatibilities of the plugin with older IDE versions.
To avoid possible issues when running the plugin in older IDE versions, increase since-build
accordingly,
or remove usages of this API.
Configure the inspection:
If <idea-version>
@since/until-build
attributes are not specified in plugin.xml
, set Since/Until explicitly.
PK UA* * 1 inspectionDescriptions/NonDefaultConstructor.html
Reports extension/service class having a non-default (empty) constructor.
Other dependencies should be acquired when needed in corresponding methods only.
Constructor having Project
for extension/service on the corresponding level is allowed.
PK tЇ 2 inspectionDescriptions/PluginXmlDynamicPlugin.html
Reports dynamic plugin problems.
Dynamic plugins can be installed, updated and uninstalled without restarting the IDE (supported in 2020.1 and later).
Please see Dynamic Plugins for further reference.
New in 2020.1
PK P : inspectionDescriptions/PluginXmlExtensionRegistration.html
Reports problems with extension registration in plugin.xml
.
The following problems are reported:
- Missing
language
declaration.
If the extension does not target a specific language, use quick fix to create an
explicit declaration for "any language".
- Inspections: missing attributes
- Services: redundant
serviceInterface
declaration
com.intellij.stubElementTypeHolder
without externalIdPrefix
, see Stub Indexes
New in 2022.3
PK q3Ԫ - inspectionDescriptions/PluginXmlValidity.html
Reports problems in plugin.xml
.
Invalid configuration can lead to problems at runtime.
PK }s` > inspectionDescriptions/PostfixTemplateDescriptionNotFound.html
Reports postfix templates missing an HTML description file, before.template
file or after.template
file.
These are shown in Settings | Editor | General | Postfix Completion.
The Create description file quick-fix creates a template HTML description file.
PK ۩C 2 inspectionDescriptions/PresentationAnnotation.html
Reports invalid and deprecated value for icon
attribute in com.intellij.ide.presentation.Presentation
annotation.
PK >% % 3 inspectionDescriptions/PsiElementConcatenation.html
Reports direct usage of PsiElement
and PsiType
in strings.
When building strings for PsiJavaParserFacade.createExpressionFromText()
(or similar methods), PsiElement.getText()
should be used
instead.
PK sv : inspectionDescriptions/QuickFixGetFamilyNameViolation.html
Reports QuickFix#getFamilyName()
using contextual information.
This method must not use any non-static information.
PK R6 6 , inspectionDescriptions/SerializableCtor.html
Reports non-default constructor in serializable classes.
The platform's IonObjectSerializer
requires specifying @PropertyMapping
explicitly.
Quick-fix generates necessary @PropertyMapping
annotation for the constructor.
PK } } &