From 6cb479b2743d30d5e1894d69bfebf7184f6f5472 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 29 Apr 2015 17:25:15 +0200 Subject: [PATCH] Cleanup (deprecated content substitutor API dropped) --- .../DeprecatedClassFileDecompiler.java | 42 ------------------- .../psi/ClassFileViewProviderFactory.java | 12 +----- .../JavaClsStructureViewBuilderProvider.java | 15 +------ .../ContentBasedFileSubstitutor.java | 37 ---------------- .../psi/SingleRootFileViewProvider.java | 14 +++---- .../psi/impl/file/impl/FileManagerImpl.java | 18 ++------ .../ContentBasedClassFileProcessor.java | 26 ------------ .../EditorHighlighterFactoryImpl.java | 21 +--------- .../folding/impl/CodeFoldingManagerImpl.java | 4 +- .../folding/impl/FoldingUpdate.java | 26 ++++-------- .../src/META-INF/PlatformExtensionPoints.xml | 1 - .../impl/CompositeFoldingBuilderTest.java | 4 +- resources/src/META-INF/IdeaPlugin.xml | 3 -- 13 files changed, 25 insertions(+), 198 deletions(-) delete mode 100644 java/java-impl/src/com/intellij/psi/impl/compiled/DeprecatedClassFileDecompiler.java delete mode 100644 platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java delete mode 100644 platform/editor-ui-api/src/com/intellij/openapi/fileTypes/ContentBasedClassFileProcessor.java diff --git a/java/java-impl/src/com/intellij/psi/impl/compiled/DeprecatedClassFileDecompiler.java b/java/java-impl/src/com/intellij/psi/impl/compiled/DeprecatedClassFileDecompiler.java deleted file mode 100644 index 2e4c134b8ea1..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/compiled/DeprecatedClassFileDecompiler.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2014 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. - */ -package com.intellij.psi.impl.compiled; - -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.fileTypes.ContentBasedFileSubstitutor; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; - -/** @deprecated temporary solution, to remove in IDEA 14 */ -@SuppressWarnings("deprecation") -public class DeprecatedClassFileDecompiler implements ClassFileDecompiler.PlatformDecompiler { - @Override - public CharSequence decompile(@NotNull VirtualFile file) { - Project[] projects = ProjectManager.getInstance().getOpenProjects(); - if (projects.length > 0) { - Project project = projects[0]; - for (ContentBasedFileSubstitutor processor : Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME)) { - if (processor.isApplicable(project, file)) { - return processor.obtainFileText(project, file); - } - } - } - - return null; - } -} \ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java index 4a73a85da0bc..606597f45590 100644 --- a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -16,8 +16,6 @@ package com.intellij.psi; import com.intellij.lang.Language; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.fileTypes.ContentBasedFileSubstitutor; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.compiled.ClassFileDecompilers; import org.jetbrains.annotations.NotNull; @@ -36,14 +34,6 @@ public class ClassFileViewProviderFactory implements FileViewProviderFactory { return ((Full)decompiler).createFileViewProvider(file, manager, eventSystemEnabled); } - for (ContentBasedFileSubstitutor processor : Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME)) { - Language lang = processor.obtainLanguageForFile(file); - if (lang != null) { - FileViewProviderFactory factory = LanguageFileViewProviders.INSTANCE.forLanguage(language); - return factory.createFileViewProvider(file, language, manager, eventSystemEnabled); - } - } - return new ClassFileViewProvider(manager, file, eventSystemEnabled); } } \ No newline at end of file diff --git a/java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java b/java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java index 09f617e6f081..aa384a11c31e 100644 --- a/java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java +++ b/java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -25,8 +25,6 @@ import com.intellij.lang.LanguageStructureViewBuilder; import com.intellij.lang.PsiStructureViewFactory; import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.fileTypes.ContentBasedFileSubstitutor; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; @@ -55,17 +53,6 @@ public class JavaClsStructureViewBuilderProvider implements StructureViewBuilder } } - //noinspection deprecation - for (ContentBasedFileSubstitutor processor : Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME)) { - if (processor.isApplicable(project, file)) { - final Language language = processor.obtainLanguageForFile(file); - if (language != null) { - final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language); - if (factory != null) return factory.getStructureViewBuilder(psiFile); - } - } - } - if (psiFile instanceof PsiClassOwner) { return new TreeBasedStructureViewBuilder() { @Override diff --git a/platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java b/platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java deleted file mode 100644 index 890136b57644..000000000000 --- a/platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2014 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. - */ -package com.intellij.openapi.fileTypes; - -import com.intellij.lang.Language; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** @deprecated use com.intellij.psi.compiled.ClassFileDecompilers or com.intellij.psi.LanguageSubstitutors API (to remove in IDEA 14) */ -@SuppressWarnings("deprecation") -public interface ContentBasedFileSubstitutor { - ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.contentBasedClassFileProcessor"); - - boolean isApplicable(Project project, VirtualFile vFile); - - @NotNull - String obtainFileText(Project project, VirtualFile file); - - @Nullable - Language obtainLanguageForFile(VirtualFile file); -} diff --git a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java index e1a87534d033..b5d7fb6f6d1b 100644 --- a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java +++ b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -22,10 +22,12 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.undo.UndoConstants; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; -import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.impl.LoadTextUtil; -import com.intellij.openapi.fileTypes.*; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.fileTypes.FileTypeRegistry; +import com.intellij.openapi.fileTypes.LanguageFileType; +import com.intellij.openapi.fileTypes.PlainTextLanguage; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.FileIndexFacade; @@ -113,12 +115,6 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi return LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), file, project); } - final ContentBasedFileSubstitutor[] processors = Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME); - for (ContentBasedFileSubstitutor processor : processors) { - Language language = processor.obtainLanguageForFile(file); - if (language != null) return language; - } - return PlainTextLanguage.INSTANCE; } diff --git a/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java index 4515f3eca207..726afe0ef1fc 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -22,9 +22,7 @@ import com.intellij.lang.Language; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; -import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.fileTypes.ContentBasedFileSubstitutor; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.project.DumbService; @@ -264,18 +262,10 @@ public class FileManagerImpl implements FileManager { @Nullable private Language getLanguage(@NotNull VirtualFile file) { - final FileType fileType = file.getFileType(); - Project project = myManager.getProject(); + FileType fileType = file.getFileType(); if (fileType instanceof LanguageFileType) { - return LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), file, project); - } - // Define language for binary file - final ContentBasedFileSubstitutor[] processors = Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME); - for (ContentBasedFileSubstitutor processor : processors) { - Language language = processor.obtainLanguageForFile(file); - if (language != null) { - return language; - } + Language language = ((LanguageFileType)fileType).getLanguage(); + return LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, myManager.getProject()); } return null; diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/ContentBasedClassFileProcessor.java b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/ContentBasedClassFileProcessor.java deleted file mode 100644 index 0ca530bb8246..000000000000 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/ContentBasedClassFileProcessor.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2000-2014 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. - */ -package com.intellij.openapi.fileTypes; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; - -/** @deprecated use com.intellij.psi.compiled.ClassFileDecompilers or com.intellij.psi.LanguageSubstitutors API (to remove in IDEA 14) */ -public interface ContentBasedClassFileProcessor extends ContentBasedFileSubstitutor { - @NotNull - SyntaxHighlighter createHighlighter(Project project, VirtualFile vFile); -} diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java index e90693927d34..f886fe6d040a 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -20,7 +20,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; -import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileTypes.*; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; @@ -86,23 +85,7 @@ public class EditorHighlighterFactoryImpl extends EditorHighlighterFactory { } } - SyntaxHighlighter highlighter = null; - for (ContentBasedFileSubstitutor processor : Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME)) { - boolean applicable; - try { - applicable = processor.isApplicable(project, vFile); - } - catch (Exception e) { - LOG.error(e); - continue; - } - if (applicable && processor instanceof ContentBasedClassFileProcessor) { - highlighter = ((ContentBasedClassFileProcessor)processor).createHighlighter(project, vFile); - } - } - if (highlighter == null) { - highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, vFile); - } + SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, vFile); return createEditorHighlighter(highlighter, settings); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java index 7a3695f46fcb..a1f3b4061124 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -229,7 +229,7 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec } - final FoldingUpdate.FoldingMap foldingMap = FoldingUpdate.getFoldingsFor(myProject, file, document, true); + final FoldingUpdate.FoldingMap foldingMap = FoldingUpdate.getFoldingsFor(file, document, true); return new CodeFoldingState() { @Override diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java index 333725920ac6..65e35365983a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -29,8 +29,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.FoldingModel; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.fileTypes.ContentBasedFileSubstitutor; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Couple; @@ -51,7 +49,8 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -import static com.intellij.codeInsight.folding.impl.UpdateFoldRegionsOperation.ApplyDefaultStateMode.*; +import static com.intellij.codeInsight.folding.impl.UpdateFoldRegionsOperation.ApplyDefaultStateMode.EXCEPT_CARET_REGION; +import static com.intellij.codeInsight.folding.impl.UpdateFoldRegionsOperation.ApplyDefaultStateMode.NO; public class FoldingUpdate { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.folding.impl.FoldingUpdate"); @@ -117,7 +116,7 @@ public class FoldingUpdate { final Editor editor, final boolean applyDefaultState) { - final FoldingMap elementsToFoldMap = getFoldingsFor(project, file, document, quick); + final FoldingMap elementsToFoldMap = getFoldingsFor(file, document, quick); final UpdateFoldRegionsOperation operation = new UpdateFoldRegionsOperation(project, editor, file, elementsToFoldMap, applyDefaultState ? EXCEPT_CARET_REGION : NO, false); Runnable runnable = new Runnable() { @@ -134,16 +133,6 @@ public class FoldingUpdate { return CachedValueProvider.Result.create(runnable, ArrayUtil.toObjectArray(dependencies)); } - private static boolean isContentSubstituted(PsiFile file, Project project) { - final ContentBasedFileSubstitutor[] processors = Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME); - for (ContentBasedFileSubstitutor processor : processors) { - if (processor.isApplicable(project, file.getVirtualFile())) { - return true; - } - } - return false; - } - private static final Key LAST_UPDATE_INJECTED_STAMP_KEY = Key.create("LAST_UPDATE_INJECTED_STAMP_KEY"); @Nullable public static Runnable updateInjectedFoldRegions(@NotNull final Editor editor, @NotNull final PsiFile file, final boolean applyDefaultState) { @@ -244,11 +233,12 @@ public class FoldingUpdate { return true; } - static FoldingMap getFoldingsFor(@NotNull Project project, @NotNull PsiFile file, @NotNull Document document, boolean quick) { + static FoldingMap getFoldingsFor(@NotNull PsiFile file, @NotNull Document document, boolean quick) { FoldingMap foldingMap = new FoldingMap(); - if (!isContentSubstituted(file, project)) { - getFoldingsFor(file instanceof PsiCompiledFile ? ((PsiCompiledFile)file).getDecompiledPsiFile() : file, document, foldingMap, quick); + if (file instanceof PsiCompiledFile) { + file = ((PsiCompiledFile)file).getDecompiledPsiFile(); } + getFoldingsFor(file, document, foldingMap, quick); return foldingMap; } diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml index 36ba59e269c9..4e251f1703b7 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml @@ -132,7 +132,6 @@ - diff --git a/platform/platform-tests/testSrc/com/intellij/codeInsight/folding/impl/CompositeFoldingBuilderTest.java b/platform/platform-tests/testSrc/com/intellij/codeInsight/folding/impl/CompositeFoldingBuilderTest.java index 000ab69e0335..a907336d68c7 100644 --- a/platform/platform-tests/testSrc/com/intellij/codeInsight/folding/impl/CompositeFoldingBuilderTest.java +++ b/platform/platform-tests/testSrc/com/intellij/codeInsight/folding/impl/CompositeFoldingBuilderTest.java @@ -1,6 +1,6 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -50,7 +50,7 @@ public class CompositeFoldingBuilderTest extends AbstractEditorTest { LanguageFolding.INSTANCE.addExplicitExtension(PlainTextLanguage.INSTANCE, second); try { - FoldingUpdate.FoldingMap foldingMap = FoldingUpdate.getFoldingsFor(getProject(), getFile(), getEditor().getDocument(), false); + FoldingUpdate.FoldingMap foldingMap = FoldingUpdate.getFoldingsFor(getFile(), getEditor().getDocument(), false); Collection descriptors = foldingMap.get(getFile()); assert descriptors.size() == 1: "Only one descriptor allowed for the same text range. Descriptors: " + descriptors; diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index d505255c77e1..5475754ee879 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -1130,9 +1130,6 @@ - -