From 5a5780076e4614f13b37e3da258801e94e422dfd Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 19 Nov 2018 10:45:48 +0100 Subject: [PATCH] prefer to use ArchiveFileType.INSTANCE directly to avoid possible earlier initialization due to FileTypeManager.getInstance call --- .../compiler/ant/LibraryPatterns.java | 21 ++++--------------- .../eclipse/EclipseCompilerConfigurable.java | 20 +++--------------- .../settings/CaptureConfigurable.java | 4 ++-- .../ConvertToRepositoryLibraryActionBase.kt | 19 +++-------------- .../JavaLibraryRootsDetectionTest.kt | 19 +++-------------- .../projectRoots/impl/JavaSdkImpl.java | 4 ++-- .../util/ExternalSystemApiUtil.java | 4 ++-- .../openapi/projectRoots/ui/PathEditor.java | 4 ++-- .../psiView/PsiViewerSourceWrapper.java | 4 ++-- .../impl/ProjectJdkTableImpl.java | 4 ++-- .../ui/DescendentBasedRootFilter.java | 20 +++--------------- .../fileChooser/FileChooserDescriptor.java | 20 +++--------------- .../openapi/fileChooser/FileElement.java | 20 +++--------------- .../src/com/intellij/openapi/vfs/VfsUtil.java | 4 ++-- .../openapi/vfs/newvfs/ArchiveFileSystem.java | 20 +++--------------- .../ui/util/JarSubfileCellAppearance.java | 21 ++++--------------- .../openapi/fileTypes/impl/FileTypesTest.java | 2 +- .../intelliLang/InjectionsSettingsUI.java | 19 +++-------------- .../configuration/PythonPathEditor.java | 4 ++-- 19 files changed, 49 insertions(+), 184 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/LibraryPatterns.java b/java/compiler/impl/src/com/intellij/compiler/ant/LibraryPatterns.java index f4d35b26fe0a..a1822b60a876 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/LibraryPatterns.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/LibraryPatterns.java @@ -1,22 +1,9 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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 com.intellij.compiler.ant; import com.intellij.compiler.ant.taskdefs.Include; import com.intellij.compiler.ant.taskdefs.PatternSet; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.fileTypes.*; import com.intellij.openapi.project.Project; @@ -25,7 +12,7 @@ import java.io.PrintWriter; import java.util.List; /** - * Library pattern generation (based on {@link FileTypes#ARCHIVE} file type). + * Library pattern generation (based on {@link ArchiveFileType#INSTANCE} file type). */ public class LibraryPatterns extends Generator { /** @@ -41,7 +28,7 @@ public class LibraryPatterns extends Generator { */ public LibraryPatterns(Project project, GenerationOptions genOptions) { myPatternSet = new PatternSet(BuildProperties.PROPERTY_LIBRARIES_PATTERNS); - final FileType type = FileTypes.ARCHIVE; + final FileType type = ArchiveFileType.INSTANCE; final List matchers = FileTypeManager.getInstance().getAssociations(type); for (FileNameMatcher m : matchers) { if (m instanceof ExactFileNameMatcher) { diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/eclipse/EclipseCompilerConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/eclipse/EclipseCompilerConfigurable.java index 2f2ef3d97c9a..232258ef0a6b 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/eclipse/EclipseCompilerConfigurable.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/eclipse/EclipseCompilerConfigurable.java @@ -1,25 +1,11 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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 com.intellij.compiler.impl.javaCompiler.eclipse; import com.intellij.compiler.impl.javaCompiler.CompilerModuleOptionsComponent; import com.intellij.compiler.options.ComparingUtils; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.compiler.CompilerBundle; import com.intellij.openapi.fileChooser.FileChooserDescriptor; -import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; @@ -52,7 +38,7 @@ public class EclipseCompilerConfigurable implements Configurable { myAdditionalOptionsField.setDescriptor(null, false); myPathToEcjField.addBrowseFolderListener( "Path to ecj compiler tool", null, project, - new FileChooserDescriptor(true, false, true, true, false, false).withFileFilter(file -> file.getFileType() == StdFileTypes.ARCHIVE) + new FileChooserDescriptor(true, false, true, true, false, false).withFileFilter(file -> file.getFileType() == ArchiveFileType.INSTANCE) ); } diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java index da17a5ac1d5d..1ab909804a52 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java @@ -7,6 +7,7 @@ import com.intellij.debugger.engine.JVMNameUtil; import com.intellij.debugger.jdi.DecompiledLocalVariable; import com.intellij.debugger.ui.JavaDebuggerSupport; import com.intellij.icons.AllIcons; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.ide.ui.laf.darcula.DarculaUIUtil; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CustomShortcutSet; @@ -16,7 +17,6 @@ import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserFactory; import com.intellij.openapi.fileChooser.FileSaverDescriptor; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; @@ -206,7 +206,7 @@ public class CaptureConfigurable implements SearchableConfigurable { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return super.isFileVisible(file, showHiddenFiles) && - (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == FileTypes.ARCHIVE); + (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == ArchiveFileType.INSTANCE); } @Override diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionBase.kt b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionBase.kt index 35ad1b3ef876..1d5bdbf7e142 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionBase.kt +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ConvertToRepositoryLibraryActionBase.kt @@ -1,20 +1,7 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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 com.intellij.openapi.roots.ui.configuration.projectRoot +import com.intellij.ide.highlighter.ArchiveFileType import com.intellij.jarRepository.JarRepositoryManager import com.intellij.jarRepository.RepositoryAttachDialog import com.intellij.jarRepository.RepositoryLibraryType @@ -256,7 +243,7 @@ private class ComparingJarFilesTask(project: Project, private val downloadedFile if (file.isDirectory) { file.children.forEach { collectNestedJars(it, result) } } - else if (file.fileType == StdFileTypes.ARCHIVE) { + else if (file.fileType == ArchiveFileType.INSTANCE) { val jarRootUrl = VfsUtil.getUrlForLibraryRoot(VfsUtil.virtualToIoFile(file)) VirtualFileManager.getInstance().refreshAndFindFileByUrl(jarRootUrl)?.let { result.add(it) } } diff --git a/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavaLibraryRootsDetectionTest.kt b/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavaLibraryRootsDetectionTest.kt index 3786241e3037..2c24a158baac 100644 --- a/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavaLibraryRootsDetectionTest.kt +++ b/java/idea-ui/testSrc/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavaLibraryRootsDetectionTest.kt @@ -1,20 +1,7 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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 com.intellij.openapi.roots.ui.configuration.libraryEditor +import com.intellij.ide.highlighter.ArchiveFileType import com.intellij.openapi.fileTypes.StdFileTypes import com.intellij.openapi.progress.EmptyProgressIndicator import com.intellij.openapi.roots.NativeLibraryOrderRootType @@ -94,7 +81,7 @@ class JavaLibraryRootsDetectionTest : LightPlatformTestCase() { val dir = directoryContent(content).generateInVirtualTempDir() val detector = LibraryRootsDetectorImpl(DefaultLibraryRootsComponentDescriptor().rootDetectors) val root = assertOneElement(dir.children.flatMap { file -> - val rootFile = if (file.fileType == StdFileTypes.ARCHIVE) JarFileSystem.getInstance().getJarRootForLocalFile(file)!! else file + val rootFile = if (file.fileType == ArchiveFileType.INSTANCE) JarFileSystem.getInstance().getJarRootForLocalFile(file)!! else file detector.detectRoots(rootFile, EmptyProgressIndicator()) }) val type = assertOneElement(root.types) diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java index 338fa56627cb..2784e77e0b12 100644 --- a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java +++ b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java @@ -2,12 +2,12 @@ package com.intellij.openapi.projectRoots.impl; import com.intellij.icons.AllIcons; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.projectRoots.*; import com.intellij.openapi.roots.AnnotationOrderRootType; @@ -74,7 +74,7 @@ public class JavaSdkImpl extends JavaSdk { } private void updateCache(VirtualFileEvent event) { - if (FileTypes.ARCHIVE.equals(fileTypeManager.getFileTypeByFileName(event.getFileName()))) { + if (ArchiveFileType.INSTANCE.equals(fileTypeManager.getFileTypeByFileName(event.getFileName()))) { String filePath = event.getFile().getPath(); if (myCachedSdkHomeToVersionString.keySet().removeIf(sdkHome -> FileUtil.isAncestor(sdkHome, filePath, false))) { myCachedVersionStringToJdkVersion.clear(); diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java index fac0d113cbb1..847a4ec139a4 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java @@ -2,6 +2,7 @@ package com.intellij.openapi.externalSystem.util; import com.intellij.execution.rmi.RemoteUtil; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.application.*; import com.intellij.openapi.externalSystem.ExternalSystemAutoImportAware; import com.intellij.openapi.externalSystem.ExternalSystemManager; @@ -17,7 +18,6 @@ import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalS import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings; import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings; import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListener; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; @@ -162,7 +162,7 @@ public class ExternalSystemApiUtil { @NotNull public static String getLocalFileSystemPath(@NotNull VirtualFile file) { - if (file.getFileType() == FileTypes.ARCHIVE) { + if (file.getFileType() == ArchiveFileType.INSTANCE) { final VirtualFile jar = JarFileSystem.getInstance().getVirtualFileForJar(file); if (jar != null) { return jar.getPath(); diff --git a/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java index b24b0404908c..6b5e9025e46c 100644 --- a/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java +++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java @@ -3,13 +3,13 @@ package com.intellij.openapi.projectRoots.ui; import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.LocalFileSystem; @@ -315,7 +315,7 @@ public class PathEditor { tempFile = LocalFileSystem.getInstance().findFileByPath(path); } if (tempFile != null && !tempFile.isDirectory()) { - return Boolean.valueOf(tempFile.getFileType().equals(FileTypes.ARCHIVE)); + return Boolean.valueOf(tempFile.getFileType().equals(ArchiveFileType.INSTANCE)); } return Boolean.FALSE; }).booleanValue(); diff --git a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerSourceWrapper.java b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerSourceWrapper.java index 1540245dda42..7d84c03b3909 100644 --- a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerSourceWrapper.java +++ b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerSourceWrapper.java @@ -1,6 +1,7 @@ // Copyright 2000-2018 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 com.intellij.internal.psiView; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.lang.Language; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileTypeManager; @@ -15,7 +16,6 @@ import javax.swing.*; import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; class PsiViewerSourceWrapper implements Comparable { @@ -78,7 +78,7 @@ class PsiViewerSourceWrapper implements Comparable { fileType != StdFileTypes.IDEA_MODULE && fileType != StdFileTypes.IDEA_PROJECT && fileType != StdFileTypes.IDEA_WORKSPACE && - fileType != FileTypes.ARCHIVE && + fileType != ArchiveFileType.INSTANCE && fileType != FileTypes.UNKNOWN && fileType != FileTypes.PLAIN_TEXT && !(fileType instanceof AbstractFileType) && diff --git a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkTableImpl.java b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkTableImpl.java index 4ee34f2d65bb..a86ccc61fffa 100644 --- a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkTableImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkTableImpl.java @@ -1,12 +1,12 @@ // Copyright 2000-2018 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 com.intellij.openapi.projectRoots.impl; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.*; import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.projectRoots.*; import com.intellij.openapi.util.Comparing; @@ -85,7 +85,7 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo if (fileName != null) { // avoid calling getFileType() because it will try to detect file type from content for unknown/text file types // consider only archive files that may contain libraries - if (!FileTypes.ARCHIVE.equals(myFileTypeManager.getFileTypeByFileName(fileName))) { + if (!ArchiveFileType.INSTANCE.equals(myFileTypeManager.getFileTypeByFileName(fileName))) { return; } } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/ui/DescendentBasedRootFilter.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/ui/DescendentBasedRootFilter.java index 7a00c559fc5b..5da46b952529 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/ui/DescendentBasedRootFilter.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/ui/DescendentBasedRootFilter.java @@ -1,22 +1,8 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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 com.intellij.openapi.roots.libraries.ui; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.vfs.JarFileSystem; @@ -55,7 +41,7 @@ public class DescendentBasedRootFilter extends RootFilter { return false; } for (VirtualFile child : rootCandidate.getChildren()) { - if (!child.isDirectory() && child.getFileType().equals(FileTypes.ARCHIVE)) { + if (!child.isDirectory() && child.getFileType().equals(ArchiveFileType.INSTANCE)) { final VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(child); if (jarRoot != null && containsFileOfType(jarRoot, progressIndicator)) { return true; diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java index 5a2c5369e5ed..f7c13f4c5f3a 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java +++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java @@ -1,23 +1,9 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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 com.intellij.openapi.fileChooser; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Iconable; import com.intellij.openapi.vfs.JarFileSystem; @@ -320,7 +306,7 @@ public class FileChooserDescriptor implements Cloneable { if (file.isDirectory() && (myChooseFolders || isFileSelectable(file))) { return file; } - boolean isJar = file.getFileType() == FileTypes.ARCHIVE; + boolean isJar = file.getFileType() == ArchiveFileType.INSTANCE; if (!isJar) { return acceptAsGeneralFile(file) ? file : null; } diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileElement.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileElement.java index 5731c8abb2b9..977800ea7738 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileElement.java +++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileElement.java @@ -1,22 +1,8 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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 com.intellij.openapi.fileChooser; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.vfs.JarFileSystem; @@ -110,7 +96,7 @@ public class FileElement { if (file == null) return false; if (isArchiveFileSystem(file) && file.getParent() == null) return true; return !file.isDirectory() && - FileTypeManager.getInstance().getFileTypeByFileName(file.getNameSequence()) == FileTypes.ARCHIVE && + FileTypeManager.getInstance().getFileTypeByFileName(file.getNameSequence()) == ArchiveFileType.INSTANCE && !isArchiveFileSystem(file.getParent()); } diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java index 7ce0e6962f5c..fe7f8fbd0aad 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java @@ -1,10 +1,10 @@ // Copyright 2000-2018 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 com.intellij.openapi.vfs; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.SystemInfo; @@ -266,7 +266,7 @@ public class VfsUtil extends VfsUtilCore { public static String getUrlForLibraryRoot(@NotNull File libraryRoot) { String path = FileUtil.toSystemIndependentName(libraryRoot.getAbsolutePath()); - if (FileTypeManager.getInstance().getFileTypeByFileName(libraryRoot.getName()) == FileTypes.ARCHIVE) { + if (FileTypeManager.getInstance().getFileTypeByFileName(libraryRoot.getName()) == ArchiveFileType.INSTANCE) { return VirtualFileManager.constructUrl(JarFileSystem.getInstance().getProtocol(), path + JarFileSystem.JAR_SEPARATOR); } else { diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/ArchiveFileSystem.java b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/ArchiveFileSystem.java index 08a40f060db0..5a8aeeb72c4d 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/ArchiveFileSystem.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/ArchiveFileSystem.java @@ -1,22 +1,8 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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 com.intellij.openapi.vfs.newvfs; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.fileTypes.FileTypeRegistry; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.io.FileAttributes; import com.intellij.openapi.util.text.StringUtil; @@ -251,6 +237,6 @@ public abstract class ArchiveFileSystem extends NewVirtualFileSystem { * Implementations should return {@code false} if the given file may not host this file system. */ protected boolean isCorrectFileType(@NotNull VirtualFile local) { - return FileTypeRegistry.getInstance().getFileTypeByFileName(local.getNameSequence()) == FileTypes.ARCHIVE; + return FileTypeRegistry.getInstance().getFileTypeByFileName(local.getNameSequence()) == ArchiveFileType.INSTANCE; } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java b/platform/platform-impl/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java index 49009bd11723..e8007ba1d59d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java +++ b/platform/platform-impl/src/com/intellij/openapi/roots/ui/util/JarSubfileCellAppearance.java @@ -1,21 +1,8 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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 com.intellij.openapi.roots.ui.util; -import com.intellij.openapi.fileTypes.FileTypes; +import com.intellij.ide.highlighter.ArchiveFileType; +import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VirtualFile; @@ -28,7 +15,7 @@ public class JarSubfileCellAppearance extends ValidFileCellAppearance { @Override protected Icon getIcon() { - return FileTypes.ARCHIVE.getIcon(); + return ((FileType)ArchiveFileType.INSTANCE).getIcon(); } @Override 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 7bbc396ebe75..5ef742bd3cf8 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 @@ -120,7 +120,7 @@ public class FileTypesTest extends PlatformTestCase { public void testAddNewExtension() { FileTypeAssocTable associations = new FileTypeAssocTable<>(); - associations.addAssociation(FileTypeManager.parseFromString("*.java"), FileTypes.ARCHIVE); + associations.addAssociation(FileTypeManager.parseFromString("*.java"), ArchiveFileType.INSTANCE); associations.addAssociation(FileTypeManager.parseFromString("*.xyz"), StdFileTypes.XML); associations.addAssociation(FileTypeManager.parseFromString("SomeSpecial*.java"), StdFileTypes.XML); // patterns should have precedence over extensions assertEquals(StdFileTypes.XML, associations.findAssociatedFileType("sample.xyz")); diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java index c48e446192c1..a52a30204664 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java @@ -1,23 +1,10 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 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.plugins.intelliLang; import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.ide.ui.SplitterProportionsDataImpl; import com.intellij.lang.Language; import com.intellij.openapi.actionSystem.*; @@ -722,7 +709,7 @@ public class InjectionsSettingsUI extends SearchableConfigurable.Parent.Abstract @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return super.isFileVisible(file, showHiddenFiles) && - (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == FileTypes.ARCHIVE); + (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == ArchiveFileType.INSTANCE); } @Override diff --git a/python/python-community-configure/src/com/jetbrains/python/configuration/PythonPathEditor.java b/python/python-community-configure/src/com/jetbrains/python/configuration/PythonPathEditor.java index 34bd358a33af..74a3696224c2 100644 --- a/python/python-community-configure/src/com/jetbrains/python/configuration/PythonPathEditor.java +++ b/python/python-community-configure/src/com/jetbrains/python/configuration/PythonPathEditor.java @@ -4,10 +4,10 @@ package com.jetbrains.python.configuration; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.intellij.icons.AllIcons; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.fileChooser.FileChooserDescriptor; -import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.projectRoots.SdkAdditionalData; import com.intellij.openapi.projectRoots.SdkModificator; import com.intellij.openapi.projectRoots.ui.SdkPathEditor; @@ -87,7 +87,7 @@ public class PythonPathEditor extends SdkPathEditor { @Override protected VirtualFile[] adjustAddedFileSet(Component component, VirtualFile[] files) { for (int i = 0, filesLength = files.length; i < filesLength; i++) { - if (!files[i].isDirectory() && files[i].getFileType() == FileTypes.ARCHIVE) { + if (!files[i].isDirectory() && files[i].getFileType() == ArchiveFileType.INSTANCE) { files[i] = JarFileSystem.getInstance().getJarRootForLocalFile(files[i]); } }