code samples: apply "Plugin DevKit | Code | Extension class should be final and non-public"

This commit is contained in:
Yann Cébron 2023-10-25 13:51:48 +02:00
parent 742a193219
commit 0cb1bffa21
37 changed files with 67 additions and 66 deletions

View File

@ -16,7 +16,7 @@ import org.jetbrains.annotations.NotNull;
* Implements an inspection to detect when String references are compared using 'a==b' or 'a!=b'.
* The quick fix converts these comparisons to 'a.equals(b) or '!a.equals(b)' respectively.
*/
public class ComparingStringReferencesInspection extends AbstractBaseJavaLocalInspectionTool {
final class ComparingStringReferencesInspection extends AbstractBaseJavaLocalInspectionTool {
private final ReplaceWithEqualsQuickFix myQuickFix = new ReplaceWithEqualsQuickFix();

View File

@ -17,7 +17,7 @@ import org.jetbrains.annotations.Nullable;
* Implements an intention action to replace a ternary statement with if-then-else.
*/
@NonNls
public class ConditionalOperatorConverter extends PsiElementBaseIntentionAction implements IntentionAction {
final class ConditionalOperatorConverter extends PsiElementBaseIntentionAction implements IntentionAction {
/**
* Checks whether this intention is available at the caret offset in file - the caret must sit just before a "?"

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.editor;
@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
* The execute method inserts a fixed string at Offset 0 of the document.
* Document changes are made in the context of a write action.
*/
class MyTypedHandler extends TypedHandlerDelegate {
final class MyTypedHandler extends TypedHandlerDelegate {
@NotNull
@Override

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.facet;
@ -18,7 +18,7 @@ import javax.swing.*;
* Provides creation of {@link DemoFacet} and associated Configuration.
* Allows application of this facet to all {@link ModuleType} instances.
*/
public class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration> {
final class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration> {
public static final String FACET_ID = "DEMO_FACET_ID";
public static final String FACET_NAME = "SDK Facet";

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.framework;
@ -15,11 +15,11 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class DemoFramework extends FrameworkTypeEx {
final class DemoFramework extends FrameworkTypeEx {
public static final String FRAMEWORK_ID = "org.intellij.sdk.framework.DemoFramework";
protected DemoFramework() {
DemoFramework() {
super(FRAMEWORK_ID);
}

View File

@ -6,9 +6,9 @@ import com.intellij.codeInsight.template.TemplateActionContext;
import com.intellij.codeInsight.template.TemplateContextType;
import org.jetbrains.annotations.NotNull;
public class MarkdownContext extends TemplateContextType {
final class MarkdownContext extends TemplateContextType {
protected MarkdownContext() {
MarkdownContext() {
super("Markdown");
}

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.liveTemplates;
@ -7,7 +7,7 @@ import com.intellij.codeInsight.template.macro.MacroBase;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
public class TitleCaseMacro extends MacroBase {
final class TitleCaseMacro extends MacroBase {
public TitleCaseMacro() {
super("titleCase", "titleCase(String)");

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Invoked on opening a project.
*/
public class ProjectOpenStartupActivity implements StartupActivity.DumbAware {
final class ProjectOpenStartupActivity implements StartupActivity.DumbAware {
@Override
public void runActivity(@NotNull Project project) {

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.module;
@ -12,11 +12,11 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class DemoModuleType extends ModuleType<DemoModuleBuilder> {
final class DemoModuleType extends ModuleType<DemoModuleBuilder> {
private static final String ID = "DEMO_MODULE_TYPE";
public DemoModuleType() {
DemoModuleType() {
super(ID);
}

View File

@ -13,11 +13,11 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.tree.DefaultTreeModel;
public class ImagesProjectViewPane extends ProjectViewPane {
final class ImagesProjectViewPane extends ProjectViewPane {
public static final String ID = "IMAGES";
protected ImagesProjectViewPane(Project project) {
ImagesProjectViewPane(Project project) {
super(project);
}

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.project.wizard;
@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class DemoModuleWizardStep extends ModuleBuilder {
final class DemoModuleWizardStep extends ModuleBuilder {
public void setupRootModel(@NotNull ModifiableRootModel modifiableRootModel) {
}

View File

@ -5,11 +5,11 @@ import com.intellij.execution.configurations.ConfigurationTypeBase;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.util.NotNullLazyValue;
public class DemoRunConfigurationType extends ConfigurationTypeBase {
final class DemoRunConfigurationType extends ConfigurationTypeBase {
static final String ID = "DemoRunConfiguration";
protected DemoRunConfigurationType() {
DemoRunConfigurationType() {
super(ID, "Demo", "Demo run configuration type",
NotNullLazyValue.createValue(() -> AllIcons.Nodes.Console));
addFactory(new DemoConfigurationFactory(this));

View File

@ -10,7 +10,7 @@ import javax.swing.*;
/**
* Provides controller functionality for application settings.
*/
public class AppSettingsConfigurable implements Configurable {
final class AppSettingsConfigurable implements Configurable {
private AppSettingsComponent mySettingsComponent;

View File

@ -19,12 +19,12 @@ import org.jetbrains.annotations.Nullable;
name = "org.intellij.sdk.settings.AppSettingsState",
storages = @Storage("SdkSettingsPlugin.xml")
)
public class AppSettingsState implements PersistentStateComponent<AppSettingsState> {
final class AppSettingsState implements PersistentStateComponent<AppSettingsState> {
public String userId = "John Q. Public";
public boolean ideaStatus = false;
public static AppSettingsState getInstance() {
static AppSettingsState getInstance() {
return ApplicationManager.getApplication().getService(AppSettingsState.class);
}

View File

@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
public class SimpleAnnotator implements Annotator {
final class SimpleAnnotator implements Annotator {
// Define strings for the Simple language prefix - used for annotations, line markers, etc.
public static final String SIMPLE_PREFIX_STR = "simple";

View File

@ -17,7 +17,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Objects;
public class SimpleChooseByNameContributor implements ChooseByNameContributorEx {
final class SimpleChooseByNameContributor implements ChooseByNameContributorEx {
@Override
public void processNames(@NotNull Processor<? super String> processor,

View File

@ -12,7 +12,7 @@ import com.intellij.psi.codeStyle.CustomCodeStyleSettings;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class SimpleCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
final class SimpleCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
@Override
public CustomCodeStyleSettings createCustomSettings(@NotNull CodeStyleSettings settings) {

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Map;
public class SimpleColorSettingsPage implements ColorSettingsPage {
final class SimpleColorSettingsPage implements ColorSettingsPage {
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[]{
new AttributesDescriptor("Key", SimpleSyntaxHighlighter.KEY),

View File

@ -1,11 +1,11 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
import com.intellij.lang.Commenter;
import org.jetbrains.annotations.Nullable;
public class SimpleCommenter implements Commenter {
final class SimpleCommenter implements Commenter {
@Nullable
@Override

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -9,9 +9,9 @@ import com.intellij.util.ProcessingContext;
import org.intellij.sdk.language.psi.SimpleTypes;
import org.jetbrains.annotations.NotNull;
public class SimpleCompletionContributor extends CompletionContributor {
final class SimpleCompletionContributor extends CompletionContributor {
public SimpleCompletionContributor() {
SimpleCompletionContributor() {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(SimpleTypes.VALUE),
new CompletionProvider<>() {
public void addCompletions(@NotNull CompletionParameters parameters,

View File

@ -1,3 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
import com.intellij.lang.documentation.AbstractDocumentationProvider;
@ -16,7 +17,7 @@ import java.util.List;
*
* @see <a href="https://plugins.jetbrains.com/docs/intellij/documentation.html">Documentation (IntelliJ Platform Docs)</a>
*/
public class SimpleDocumentationProvider extends AbstractDocumentationProvider {
final class SimpleDocumentationProvider extends AbstractDocumentationProvider {
/**
* For the Simple Language, we don't have online documentation. However, if your language provides

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class SimpleFileType extends LanguageFileType {
public final class SimpleFileType extends LanguageFileType {
public static final SimpleFileType INSTANCE = new SimpleFileType();

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -13,7 +13,7 @@ import org.intellij.sdk.language.psi.SimpleTokenSets;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class SimpleFindUsagesProvider implements FindUsagesProvider {
final class SimpleFindUsagesProvider implements FindUsagesProvider {
@Nullable
@Override

View File

@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SimpleFoldingBuilder extends FoldingBuilderEx implements DumbAware {
final class SimpleFoldingBuilder extends FoldingBuilderEx implements DumbAware {
@Override
public FoldingDescriptor @NotNull [] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -7,7 +7,7 @@ import com.intellij.psi.codeStyle.CodeStyleSettings;
import org.intellij.sdk.language.psi.SimpleTypes;
import org.jetbrains.annotations.NotNull;
public class SimpleFormattingModelBuilder implements FormattingModelBuilder {
final class SimpleFormattingModelBuilder implements FormattingModelBuilder {
private static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) {
return new SpacingBuilder(settings, SimpleLanguage.INSTANCE)

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -7,7 +7,7 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable;
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
import org.jetbrains.annotations.NotNull;
public class SimpleLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
final class SimpleLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
@NotNull
@Override

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
public class SimpleLineMarkerProvider extends RelatedItemLineMarkerProvider {
final class SimpleLineMarkerProvider extends RelatedItemLineMarkerProvider {
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element,

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -18,7 +18,7 @@ import org.intellij.sdk.language.psi.SimpleTokenSets;
import org.intellij.sdk.language.psi.SimpleTypes;
import org.jetbrains.annotations.NotNull;
public class SimpleParserDefinition implements ParserDefinition {
final class SimpleParserDefinition implements ParserDefinition {
public static final IFileElementType FILE = new IFileElementType(SimpleLanguage.INSTANCE);

View File

@ -10,7 +10,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class SimplePropertyIconProvider extends IconProvider {
final class SimplePropertyIconProvider extends IconProvider {
@Override
public @Nullable Icon getIcon(@NotNull PsiElement element, int flags) {

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -8,7 +8,7 @@ import org.intellij.sdk.language.psi.SimpleProperty;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class SimpleRefactoringSupportProvider extends RefactoringSupportProvider {
final class SimpleRefactoringSupportProvider extends RefactoringSupportProvider {
@Override
public boolean isMemberInplaceRenameAvailable(@NotNull PsiElement elementToRename, @Nullable PsiElement context) {

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
import static org.intellij.sdk.language.SimpleAnnotator.SIMPLE_PREFIX_STR;
import static org.intellij.sdk.language.SimpleAnnotator.SIMPLE_SEPARATOR_STR;
public class SimpleReferenceContributor extends PsiReferenceContributor {
final class SimpleReferenceContributor extends PsiReferenceContributor {
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.intellij.sdk.language;
@ -16,7 +16,7 @@ import org.intellij.sdk.language.psi.SimpleProperty;
import org.intellij.sdk.language.psi.SimpleTypes;
import org.jetbrains.annotations.NotNull;
public class SimpleSpellcheckingStrategy extends SpellcheckingStrategy {
final class SimpleSpellcheckingStrategy extends SpellcheckingStrategy {
@Override
public @NotNull Tokenizer<?> getTokenizer(PsiElement element) {

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.intellij.sdk.language;
@ -12,7 +12,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.Icon;
public class SimpleStructureAwareNavbar extends StructureAwareNavBarModelExtension {
final class SimpleStructureAwareNavbar extends StructureAwareNavBarModelExtension {
@NotNull
@Override

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.intellij.sdk.language;
@ -11,7 +11,7 @@ import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class SimpleStructureViewFactory implements PsiStructureViewFactory {
final class SimpleStructureViewFactory implements PsiStructureViewFactory {
@Nullable
@Override

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language;
@ -8,7 +8,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
public class SimpleSyntaxHighlighterFactory extends SyntaxHighlighterFactory {
final class SimpleSyntaxHighlighterFactory extends SyntaxHighlighterFactory {
@NotNull
@Override

View File

@ -15,7 +15,7 @@ import java.awt.*;
import java.util.Calendar;
import java.util.Objects;
public class CalendarToolWindowFactory implements ToolWindowFactory, DumbAware {
final class CalendarToolWindowFactory implements ToolWindowFactory, DumbAware {
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {

View File

@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.treeStructureProvider;
@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
public class TextOnlyTreeStructureProvider implements TreeStructureProvider {
final class TextOnlyTreeStructureProvider implements TreeStructureProvider {
@NotNull
@Override