mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (deprecated content substitutor API dropped)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
+1
-14
@@ -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
|
||||
|
||||
@@ -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<ContentBasedFileSubstitutor> 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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
-26
@@ -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);
|
||||
}
|
||||
+2
-19
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
@@ -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<Object> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,6 @@
|
||||
<extensionPoint name="editorTypedHandler" beanClass="com.intellij.openapi.editor.actionSystem.EditorTypedHandlerBean">
|
||||
<with attribute="implementationClass" implements="com.intellij.openapi.editor.actionSystem.TypedActionHandler"/>
|
||||
</extensionPoint>
|
||||
<extensionPoint name="contentBasedClassFileProcessor" interface="com.intellij.openapi.fileTypes.ContentBasedClassFileProcessor"/>
|
||||
|
||||
<extensionPoint name="additionalTextAttributes" beanClass="com.intellij.openapi.editor.colors.impl.AdditionalTextAttributesEP" />
|
||||
<extensionPoint name="bundledColorScheme" beanClass="com.intellij.openapi.editor.colors.impl.BundledColorSchemeEP"/>
|
||||
|
||||
+2
-2
@@ -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<FoldingDescriptor> descriptors = foldingMap.get(getFile());
|
||||
|
||||
assert descriptors.size() == 1: "Only one descriptor allowed for the same text range. Descriptors: " + descriptors;
|
||||
|
||||
@@ -1130,9 +1130,6 @@
|
||||
|
||||
<filetype.decompiler filetype="CLASS" implementationClass="com.intellij.psi.impl.compiled.ClassFileDecompiler"/>
|
||||
<filetype.stubBuilder filetype="CLASS" implementationClass="com.intellij.psi.impl.compiled.ClassFileStubBuilder"/>
|
||||
<!--suppress DeprecatedClassUsageInspection -->
|
||||
<applicationService serviceInterface="com.intellij.psi.impl.compiled.ClassFileDecompiler$PlatformDecompiler"
|
||||
serviceImplementation="com.intellij.psi.impl.compiled.DeprecatedClassFileDecompiler"/>
|
||||
|
||||
<weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.ReferenceListWeigher" id="referenceList"
|
||||
order="before samePsiMember"/>
|
||||
|
||||
Reference in New Issue
Block a user