From a4e9a0121a7d7fec223f5c0bc0c292cc60406e91 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 25 Sep 2020 15:10:42 +0200 Subject: [PATCH] test for FileType constructor to be non-public to avoid duplicates and double instantiation because file types must be singletons GitOrigin-RevId: d448ee007d87edbaf095f8fbe7e1b51ce8c7d9bc --- .../intellij/lang/regexp/RegExpFileType.java | 11 ++++++-- .../regexp/intention/CheckRegExpForm.java | 2 +- .../RedundantEscapeInspectionTest.java | 6 +++-- .../RepeatedSpaceInspectionTest.java | 7 +++--- .../inspection/RegExpInspectionTestCase.java | 6 ++--- .../images/fileTypes/impl/ImageFileType.java | 3 +++ json/src/com/intellij/json/JsonFileType.java | 2 +- .../ide/highlighter/ArchiveFileType.java | 3 +++ .../intellij/ide/scratch/ScratchFileType.java | 2 +- .../openapi/fileTypes/UserBinaryFileType.java | 4 +++ .../openapi/fileTypes/UserFileType.java | 3 +++ .../openapi/fileTypes/ex/FakeFileType.java | 2 ++ .../fileTypes/impl/AbstractFileType.java | 5 ++++ .../fileTypes/impl/FileTypeManagerImpl.java | 12 ++++----- .../openapi/fileTypes/impl/FileTypesTest.java | 25 ++++++++++++++++++- .../vfs/encoding/FileEncodingTest.java | 2 +- .../changes/ignore/lang/IgnoreFileType.java | 2 +- .../vcs/changes/patch/PatchFileType.java | 3 +++ .../vcs/log/ui/editor/VcsLogEditor.kt | 2 +- .../idea/eclipse/config/EclipseFileType.java | 3 +++ .../idea/maven/config/MavenConfigFileType.kt | 2 +- .../editor/ResourceBundleFileType.java | 3 +++ .../space/chat/editor/SpaceChatFile.kt | 2 +- .../terminal/vfs/TerminalSessionFileType.java | 3 +++ .../intellij/uiDesigner/GuiFormFileType.java | 3 +++ .../PyFunctionTypeAnnotationFileType.java | 2 +- .../doctest/PyDocstringFileType.java | 2 +- .../com/jetbrains/python/pyi/PyiFileType.java | 2 +- .../commandLine/CommandLineFileType.java | 2 +- .../src/com/jetbrains/pyqt/QtUIFileType.java | 2 +- .../remote/vfs/PyRemoteDebugFileType.java | 3 +++ .../spellchecker/DictionaryFileType.java | 3 +++ 32 files changed, 103 insertions(+), 31 deletions(-) rename RegExpSupport/test/org/intellij/lang/regexp/{inspection => }/RedundantEscapeInspectionTest.java (86%) rename RegExpSupport/test/org/intellij/lang/regexp/{inspection => }/RepeatedSpaceInspectionTest.java (87%) diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpFileType.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpFileType.java index 613b3a7bd657..35dbe0ea0474 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpFileType.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpFileType.java @@ -31,9 +31,11 @@ public class RegExpFileType extends LanguageFileType { super(RegExpLanguage.INSTANCE); } - public RegExpFileType(@NotNull Language language) { + private RegExpFileType(@NotNull Language language) { super(language); - if (!(language.getBaseLanguage() instanceof RegExpLanguage)) throw new AssertionError(); + if (!(language.getBaseLanguage() instanceof RegExpLanguage)) { + throw new IllegalArgumentException(String.valueOf(language.getBaseLanguage())); + } } @Override @@ -61,4 +63,9 @@ public class RegExpFileType extends LanguageFileType { public Icon getIcon() { return getLanguage() == RegExpLanguage.INSTANCE ? AllIcons.FileTypes.Regexp : null; } + + @NotNull + public static LanguageFileType forLanguage(@NotNull Language language) { + return new RegExpFileType(language); + } } diff --git a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java index cb14e6c934b8..57d98b58f25f 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java @@ -84,7 +84,7 @@ public final class CheckRegExpForm { } else { // for correct syntax highlighting - fileType = new RegExpFileType(language); + fileType = RegExpFileType.forLanguage(language); } final EditorTextField myRegExp = new EditorTextField(document, project, fileType, false, false) { @Override diff --git a/RegExpSupport/test/org/intellij/lang/regexp/inspection/RedundantEscapeInspectionTest.java b/RegExpSupport/test/org/intellij/lang/regexp/RedundantEscapeInspectionTest.java similarity index 86% rename from RegExpSupport/test/org/intellij/lang/regexp/inspection/RedundantEscapeInspectionTest.java rename to RegExpSupport/test/org/intellij/lang/regexp/RedundantEscapeInspectionTest.java index 2025dc668843..cbbb02a23860 100644 --- a/RegExpSupport/test/org/intellij/lang/regexp/inspection/RedundantEscapeInspectionTest.java +++ b/RegExpSupport/test/org/intellij/lang/regexp/RedundantEscapeInspectionTest.java @@ -1,9 +1,11 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package org.intellij.lang.regexp.inspection; +package org.intellij.lang.regexp; import com.intellij.codeInspection.LocalInspectionTool; import org.intellij.lang.regexp.RegExpFileType; import org.intellij.lang.regexp.ecmascript.EcmaScriptRegexpLanguage; +import org.intellij.lang.regexp.inspection.RedundantEscapeInspection; +import org.intellij.lang.regexp.inspection.RegExpInspectionTestCase; import org.jetbrains.annotations.NotNull; /** @@ -26,7 +28,7 @@ public class RedundantEscapeInspectionTest extends RegExpInspectionTestCase { public void testEscapedU() { quickfixTest("\\u", "u", "Remove redundant escape", - new RegExpFileType(EcmaScriptRegexpLanguage.INSTANCE)); + RegExpFileType.forLanguage(EcmaScriptRegexpLanguage.INSTANCE)); } public void testPoundSign() { diff --git a/RegExpSupport/test/org/intellij/lang/regexp/inspection/RepeatedSpaceInspectionTest.java b/RegExpSupport/test/org/intellij/lang/regexp/RepeatedSpaceInspectionTest.java similarity index 87% rename from RegExpSupport/test/org/intellij/lang/regexp/inspection/RepeatedSpaceInspectionTest.java rename to RegExpSupport/test/org/intellij/lang/regexp/RepeatedSpaceInspectionTest.java index f2c47f3fbfd5..f715fe093119 100644 --- a/RegExpSupport/test/org/intellij/lang/regexp/inspection/RepeatedSpaceInspectionTest.java +++ b/RegExpSupport/test/org/intellij/lang/regexp/RepeatedSpaceInspectionTest.java @@ -1,9 +1,10 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package org.intellij.lang.regexp.inspection; +package org.intellij.lang.regexp; import com.intellij.codeInspection.LocalInspectionTool; -import org.intellij.lang.regexp.RegExpFileType; import org.intellij.lang.regexp.ecmascript.EcmaScriptRegexpLanguage; +import org.intellij.lang.regexp.inspection.RegExpInspectionTestCase; +import org.intellij.lang.regexp.inspection.RepeatedSpaceInspection; import org.jetbrains.annotations.NotNull; /** @@ -38,7 +39,7 @@ public class RepeatedSpaceInspectionTest extends RegExpInspectionTestCase { public void testEscapedWhitespace() { quickfixTest("\\ ", " {3}", "Replace with ' {3}", - new RegExpFileType(EcmaScriptRegexpLanguage.INSTANCE)); + RegExpFileType.forLanguage(EcmaScriptRegexpLanguage.INSTANCE)); } public void testNoStringIndexOutOfBoundsException() { diff --git a/RegExpSupport/test/org/intellij/lang/regexp/inspection/RegExpInspectionTestCase.java b/RegExpSupport/test/org/intellij/lang/regexp/inspection/RegExpInspectionTestCase.java index 7dab5f9a129b..e71abd1245ba 100644 --- a/RegExpSupport/test/org/intellij/lang/regexp/inspection/RegExpInspectionTestCase.java +++ b/RegExpSupport/test/org/intellij/lang/regexp/inspection/RegExpInspectionTestCase.java @@ -7,6 +7,7 @@ import com.intellij.codeInspection.InspectionProfileEntry; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.ex.InspectionProfileImpl; +import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.profile.codeInspection.ProjectInspectionProfileManager; import com.intellij.testFramework.fixtures.BasePlatformTestCase; @@ -26,7 +27,7 @@ public abstract class RegExpInspectionTestCase extends BasePlatformTestCase { highlightTest(code, RegExpFileType.INSTANCE); } - protected void highlightTest(@Language("RegExp") String code, RegExpFileType fileType) { + protected void highlightTest(@Language("RegExp") String code, FileType fileType) { final LocalInspectionTool inspection = getInspection(); myFixture.enableInspections(inspection); final HighlightDisplayKey displayKey = HighlightDisplayKey.find(inspection.getShortName()); @@ -46,7 +47,7 @@ public abstract class RegExpInspectionTestCase extends BasePlatformTestCase { quickfixTest(before, after, hint, RegExpFileType.INSTANCE); } - protected void quickfixTest(@Language("RegExp") String before, @Language("RegExp") String after, String hint, RegExpFileType fileType) { + protected void quickfixTest(@Language("RegExp") String before, @Language("RegExp") String after, String hint, FileType fileType) { highlightTest(before, fileType); myFixture.launchAction(myFixture.findSingleIntention(hint)); myFixture.checkResult(after); @@ -54,7 +55,6 @@ public abstract class RegExpInspectionTestCase extends BasePlatformTestCase { protected final void quickfixAllTest(@Language("RegExp") String before, @Language("RegExp") String after) { InspectionProfileEntry inspection = getInspection(); - assert inspection != null : "getInspection() needs to return a non-null value for quickFixAllTest() to work"; quickfixTest(before, after, InspectionsBundle.message("fix.all.inspection.problems.in.file", inspection.getDisplayName())); } } \ No newline at end of file diff --git a/images/src/org/intellij/images/fileTypes/impl/ImageFileType.java b/images/src/org/intellij/images/fileTypes/impl/ImageFileType.java index 3e92381cbb26..e5d91e11a601 100644 --- a/images/src/org/intellij/images/fileTypes/impl/ImageFileType.java +++ b/images/src/org/intellij/images/fileTypes/impl/ImageFileType.java @@ -11,6 +11,9 @@ import javax.swing.*; public final class ImageFileType extends UserBinaryFileType { public static final ImageFileType INSTANCE = new ImageFileType(); + private ImageFileType() { + } + @NotNull @Override public String getName() { diff --git a/json/src/com/intellij/json/JsonFileType.java b/json/src/com/intellij/json/JsonFileType.java index 0f47a3cf768a..9335cff41df8 100644 --- a/json/src/com/intellij/json/JsonFileType.java +++ b/json/src/com/intellij/json/JsonFileType.java @@ -23,7 +23,7 @@ public class JsonFileType extends LanguageFileType{ super(language, secondary); } - public JsonFileType() { + protected JsonFileType() { super(JsonLanguage.INSTANCE); } diff --git a/platform/core-api/src/com/intellij/ide/highlighter/ArchiveFileType.java b/platform/core-api/src/com/intellij/ide/highlighter/ArchiveFileType.java index 9c823ee150db..468a029d264a 100644 --- a/platform/core-api/src/com/intellij/ide/highlighter/ArchiveFileType.java +++ b/platform/core-api/src/com/intellij/ide/highlighter/ArchiveFileType.java @@ -26,6 +26,9 @@ import javax.swing.*; public class ArchiveFileType implements FileType { public static final ArchiveFileType INSTANCE = new ArchiveFileType(); + protected ArchiveFileType() { + } + @Override @NotNull public String getName() { diff --git a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileType.java b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileType.java index 9bf958aceec3..3ffa671ea130 100644 --- a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileType.java +++ b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileType.java @@ -23,7 +23,7 @@ public class ScratchFileType extends LanguageFileType implements FileTypeIdentif public static final LanguageFileType INSTANCE = new ScratchFileType(); - ScratchFileType() { + private ScratchFileType() { super(PlainTextLanguage.INSTANCE, true); } diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/UserBinaryFileType.java b/platform/platform-api/src/com/intellij/openapi/fileTypes/UserBinaryFileType.java index 57b1c16359ea..e3f2297eba4e 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileTypes/UserBinaryFileType.java +++ b/platform/platform-api/src/com/intellij/openapi/fileTypes/UserBinaryFileType.java @@ -18,6 +18,10 @@ package com.intellij.openapi.fileTypes; import com.intellij.openapi.options.SettingsEditor; public class UserBinaryFileType extends UserFileType { + public static final UserBinaryFileType INSTANCE = new UserBinaryFileType(); + protected UserBinaryFileType() { + } + @Override public SettingsEditor getEditor() { return null; diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/UserFileType.java b/platform/platform-api/src/com/intellij/openapi/fileTypes/UserFileType.java index b66be74644b1..d4d9c1bc331e 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileTypes/UserFileType.java +++ b/platform/platform-api/src/com/intellij/openapi/fileTypes/UserFileType.java @@ -17,6 +17,9 @@ public abstract class UserFileType> implements FileTyp private Icon myIcon; private String myIconPath; + protected UserFileType() { + } + public abstract SettingsEditor getEditor(); @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FakeFileType.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FakeFileType.java index 621ecc0794ff..d7a25ce39ad9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FakeFileType.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FakeFileType.java @@ -8,6 +8,8 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; public abstract class FakeFileType implements FileTypeIdentifiableByVirtualFile { + protected FakeFileType() { + } @Override @NotNull diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/AbstractFileType.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/AbstractFileType.java index 4aed0ac1abec..6d3abce025da 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/AbstractFileType.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/AbstractFileType.java @@ -354,4 +354,9 @@ public class AbstractFileType extends UserFileType implements public void setCommenter(@NotNull Commenter commenter) { myCommenter = commenter; } + + @Override + public String toString() { + return "AbstractFileType "+mySyntaxTable; + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index 9a67b4451d0e..6e0cc63ce3ba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -39,7 +39,6 @@ import com.intellij.testFramework.LightVirtualFile; import com.intellij.ui.GuiUtils; import com.intellij.util.*; import com.intellij.util.containers.CollectionFactory; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.io.URLUtil; import com.intellij.util.messages.MessageBusConnection; import org.jdom.Element; @@ -361,11 +360,10 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent } private static void initializeMatchers(@NotNull FileTypeBean bean) { - bean.addMatchers(ContainerUtil.concat( - parse(StringUtil.notNullize(bean.extensions)), - parse(StringUtil.notNullize(bean.fileNames), token -> new ExactFileNameMatcher(token)), - parse(StringUtil.notNullize(bean.fileNamesCaseInsensitive), token -> new ExactFileNameMatcher(token, true)), - parse(StringUtil.notNullize(bean.patterns), token -> FileNameMatcherFactory.getInstance().createMatcher(token)))); + bean.addMatchers(parse(StringUtil.notNullize(bean.extensions))); + bean.addMatchers(parse(StringUtil.notNullize(bean.fileNames), token -> new ExactFileNameMatcher(token))); + bean.addMatchers(parse(StringUtil.notNullize(bean.fileNamesCaseInsensitive), token -> new ExactFileNameMatcher(token, true))); + bean.addMatchers(parse(StringUtil.notNullize(bean.patterns), token -> FileNameMatcherFactory.getInstance().createMatcher(token))); } private void instantiatePendingFileTypes() { @@ -1175,7 +1173,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent Element element = typeElement.getChild(AbstractFileType.ELEMENT_HIGHLIGHTING); if (element == null) { - type = new UserBinaryFileType(); + type = UserBinaryFileType.INSTANCE; } else { SyntaxTable table = AbstractFileType.readSyntaxTable(element); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java index deb813c4df3f..bc31f9c6c657 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java @@ -53,6 +53,8 @@ import org.junit.Assume; import javax.swing.*; import java.io.File; import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -653,7 +655,7 @@ public class FileTypesTest extends HeavyPlatformTestCase { } public void testIfDetectorRanThenIdeaReopenedTheDetectorShouldBeReRun() throws IOException { - final UserBinaryFileType stuffType = new UserBinaryFileType(); + final UserBinaryFileType stuffType = new UserBinaryFileType(){}; stuffType.setName("stuffType"); final Set detectorCalled = ContainerUtil.newConcurrentSet(); @@ -1037,6 +1039,9 @@ public class FileTypesTest extends HeavyPlatformTestCase { } private static class MyReplaceableByContentDetectionFileType implements FileType, PlainTextLikeFileType { + private MyReplaceableByContentDetectionFileType() { + } + @NotNull @Override public String getName() { @@ -1094,6 +1099,9 @@ public class FileTypesTest extends HeavyPlatformTestCase { private static class MyTestFileType implements FileType { public static final String NAME = "Foo files"; + private MyTestFileType() { + } + @NotNull @Override public String getName() { @@ -1138,6 +1146,9 @@ public class FileTypesTest extends HeavyPlatformTestCase { private static class MyHaskellFileType implements FileType { public static final String NAME = "Haskell"; + private MyHaskellFileType() { + } + @NotNull @Override public String getName() { @@ -1178,4 +1189,16 @@ public class FileTypesTest extends HeavyPlatformTestCase { return null; } } + + public void testFileTypeConstructorsMustBeNonPublic() { + FileType[] fileTypes = myFileTypeManager.getRegisteredFileTypes(); + LOG.debug("Registered file types: "+fileTypes.length); + for (FileType fileType : fileTypes) { + if (fileType.getClass() == AbstractFileType.class) continue; + Constructor[] constructors = fileType.getClass().getDeclaredConstructors(); + for (Constructor constructor : constructors) { + assertFalse("FileType constructor must be non-public to avoid duplicates but got: " + constructor, Modifier.isPublic(constructor.getModifiers())); + } + } + } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/encoding/FileEncodingTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/encoding/FileEncodingTest.java index 7b532a29ceab..18e7d08e237b 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/encoding/FileEncodingTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/encoding/FileEncodingTest.java @@ -980,7 +980,7 @@ public class FileEncodingTest extends HeavyPlatformTestCase implements TestDialo public void testEncodingDetectionRequestsRunInOneThreadForEachDocument() { Set detectThreads = ContainerUtil.newConcurrentSet(); class MyFT extends LanguageFileType implements FileTypeIdentifiableByVirtualFile { - MyFT() { + private MyFT() { super(new Language("my") { }); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ignore/lang/IgnoreFileType.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ignore/lang/IgnoreFileType.java index 6c00994990dc..72b8b404b3e9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ignore/lang/IgnoreFileType.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ignore/lang/IgnoreFileType.java @@ -38,7 +38,7 @@ public class IgnoreFileType extends LanguageFileType { @NotNull public static final IgnoreFileType INSTANCE = new IgnoreFileType(); - protected IgnoreFileType() { + private IgnoreFileType() { this(IgnoreLanguage.INSTANCE); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchFileType.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchFileType.java index d87e5f3a5f39..b4640b60f553 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchFileType.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchFileType.java @@ -20,6 +20,9 @@ public class PatchFileType implements FileType { public static final String NAME = "PATCH"; //NON-NLS + private PatchFileType() { + } + @Override @NotNull @NonNls diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/editor/VcsLogEditor.kt b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/editor/VcsLogEditor.kt index 84d3a14e8b83..25787fde8951 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/editor/VcsLogEditor.kt +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/editor/VcsLogEditor.kt @@ -21,7 +21,7 @@ import javax.swing.Icon import javax.swing.JComponent import javax.swing.JPanel -class VcsLogFileType : FileType { +class VcsLogFileType private constructor() : FileType { override fun getName(): String = "VcsLog" override fun getDescription(): String = VcsLogBundle.message("vcs.log.file.type.description") override fun getDefaultExtension(): String = "" diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseFileType.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseFileType.java index 4ff9b35f36b7..3972d7742f43 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseFileType.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseFileType.java @@ -16,6 +16,9 @@ import javax.swing.*; public class EclipseFileType implements FileType { public static final FileType INSTANCE = new EclipseFileType(); + private EclipseFileType() { + } + @Override @NotNull @NonNls diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/config/MavenConfigFileType.kt b/plugins/maven/src/main/java/org/jetbrains/idea/maven/config/MavenConfigFileType.kt index f973e18a9dd8..99eef2550691 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/config/MavenConfigFileType.kt +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/config/MavenConfigFileType.kt @@ -8,7 +8,7 @@ import org.jetbrains.idea.maven.dom.MavenDomBundle import org.jetbrains.idea.maven.project.MavenProjectBundle import javax.swing.Icon -class MavenConfigFileType : LanguageFileType(PlainTextLanguage.INSTANCE, true) { +class MavenConfigFileType private constructor(): LanguageFileType(PlainTextLanguage.INSTANCE, true) { override fun getName(): String { return "MavenConfig" diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleFileType.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleFileType.java index 4269c5d071b3..eb65852ecd94 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleFileType.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleFileType.java @@ -23,6 +23,9 @@ import org.jetbrains.annotations.NotNull; public class ResourceBundleFileType extends FakeFileType { public static final ResourceBundleFileType INSTANCE = new ResourceBundleFileType(); + private ResourceBundleFileType() { + } + @Override @NotNull public String getName() { diff --git a/plugins/space/src/main/kotlin/com/intellij/space/chat/editor/SpaceChatFile.kt b/plugins/space/src/main/kotlin/com/intellij/space/chat/editor/SpaceChatFile.kt index aa076a5023cf..c6a33b9fa614 100644 --- a/plugins/space/src/main/kotlin/com/intellij/space/chat/editor/SpaceChatFile.kt +++ b/plugins/space/src/main/kotlin/com/intellij/space/chat/editor/SpaceChatFile.kt @@ -46,7 +46,7 @@ internal class SpaceChatIconProvider : FileIconProvider { } } -private class SpaceChatFileType : FileType { +private class SpaceChatFileType private constructor(): FileType { override fun getName(): String = "SpaceChat" diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionFileType.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionFileType.java index 706cda994219..e0b628b3f2ab 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionFileType.java +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionFileType.java @@ -12,6 +12,9 @@ public class TerminalSessionFileType extends FakeFileType { public final static TerminalSessionFileType INSTANCE = new TerminalSessionFileType(); + private TerminalSessionFileType() { + } + @Override @NotNull public String getName() { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/GuiFormFileType.java b/plugins/ui-designer/src/com/intellij/uiDesigner/GuiFormFileType.java index b65410ea2c14..ee4350cdd7d7 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/GuiFormFileType.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/GuiFormFileType.java @@ -32,6 +32,9 @@ public class GuiFormFileType implements /*UIBased*/FileType { @NonNls public static final String DEFAULT_EXTENSION = "form"; @NonNls public static final String DOT_DEFAULT_EXTENSION = "." + DEFAULT_EXTENSION; + private GuiFormFileType() { + } + @Override @NotNull public String getName() { diff --git a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/functionTypeComments/PyFunctionTypeAnnotationFileType.java b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/functionTypeComments/PyFunctionTypeAnnotationFileType.java index 62d058a6767f..0018ded99d24 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/functionTypeComments/PyFunctionTypeAnnotationFileType.java +++ b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/functionTypeComments/PyFunctionTypeAnnotationFileType.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.NotNull; public class PyFunctionTypeAnnotationFileType extends PythonFileType { public static final PyFunctionTypeAnnotationFileType INSTANCE = new PyFunctionTypeAnnotationFileType(); - public PyFunctionTypeAnnotationFileType() { + private PyFunctionTypeAnnotationFileType() { super(PyFunctionTypeAnnotationDialect.INSTANCE); } diff --git a/python/python-psi-impl/src/com/jetbrains/python/documentation/doctest/PyDocstringFileType.java b/python/python-psi-impl/src/com/jetbrains/python/documentation/doctest/PyDocstringFileType.java index 9db5c3927b7b..eab1efec2474 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/documentation/doctest/PyDocstringFileType.java +++ b/python/python-psi-impl/src/com/jetbrains/python/documentation/doctest/PyDocstringFileType.java @@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull; public class PyDocstringFileType extends PythonFileType { public static final PythonFileType INSTANCE = new PyDocstringFileType(); - protected PyDocstringFileType() { + private PyDocstringFileType() { super(new PyDocstringLanguageDialect()); } diff --git a/python/python-psi-impl/src/com/jetbrains/python/pyi/PyiFileType.java b/python/python-psi-impl/src/com/jetbrains/python/pyi/PyiFileType.java index 1a140fee9d71..d0e4e394b36c 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/pyi/PyiFileType.java +++ b/python/python-psi-impl/src/com/jetbrains/python/pyi/PyiFileType.java @@ -26,7 +26,7 @@ public class PyiFileType extends PythonFileType { @NotNull public static final PythonFileType INSTANCE = new PyiFileType(); - protected PyiFileType() { + private PyiFileType() { super(new PyiLanguageDialect()); } diff --git a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineFileType.java b/python/src/com/jetbrains/commandInterface/commandLine/CommandLineFileType.java index 5167604828b4..12170ac95a64 100644 --- a/python/src/com/jetbrains/commandInterface/commandLine/CommandLineFileType.java +++ b/python/src/com/jetbrains/commandInterface/commandLine/CommandLineFileType.java @@ -32,7 +32,7 @@ public final class CommandLineFileType extends LanguageFileType { */ static final String EXTENSION = "cmdline"; - CommandLineFileType() { + private CommandLineFileType() { super(CommandLineLanguage.INSTANCE); } diff --git a/python/src/com/jetbrains/pyqt/QtUIFileType.java b/python/src/com/jetbrains/pyqt/QtUIFileType.java index b44211f9d418..97a67f0e892b 100644 --- a/python/src/com/jetbrains/pyqt/QtUIFileType.java +++ b/python/src/com/jetbrains/pyqt/QtUIFileType.java @@ -13,7 +13,7 @@ import javax.swing.*; public class QtUIFileType extends QtFileType implements FileType { public static final QtUIFileType INSTANCE = new QtUIFileType(); - protected QtUIFileType() { + private QtUIFileType() { super("Qt UI file", PyBundle.message("qt.ui.designer.form.filetype.description"), "ui"); } diff --git a/python/src/com/jetbrains/python/debugger/remote/vfs/PyRemoteDebugFileType.java b/python/src/com/jetbrains/python/debugger/remote/vfs/PyRemoteDebugFileType.java index 1220254dfe63..956b13492799 100644 --- a/python/src/com/jetbrains/python/debugger/remote/vfs/PyRemoteDebugFileType.java +++ b/python/src/com/jetbrains/python/debugger/remote/vfs/PyRemoteDebugFileType.java @@ -11,6 +11,9 @@ import javax.swing.*; public class PyRemoteDebugFileType implements FileType { public static final PyRemoteDebugFileType INSTANCE = new PyRemoteDebugFileType(); + private PyRemoteDebugFileType() { + } + @NotNull @Override public String getName() { diff --git a/spellchecker/src/com/intellij/spellchecker/DictionaryFileType.java b/spellchecker/src/com/intellij/spellchecker/DictionaryFileType.java index 45e342e8cc08..e5945d855cbd 100644 --- a/spellchecker/src/com/intellij/spellchecker/DictionaryFileType.java +++ b/spellchecker/src/com/intellij/spellchecker/DictionaryFileType.java @@ -15,6 +15,9 @@ import javax.swing.*; public class DictionaryFileType implements FileType { public static final DictionaryFileType INSTANCE = new DictionaryFileType(); + private DictionaryFileType() { + } + @NotNull @Override public String getName() {