Got rid of unnecessary dependency of java-psi-impl on platform-api: extracted ContentBasedClassFileProcessor.getDecompiledPsiFile() to separate extension point in ClsFileDecompiledPsiFileProvider, in java-psi-api module.

This commit is contained in:
Evgeny Gerashchenko
2012-03-26 15:13:29 +04:00
parent 21cd342aef
commit 23ee0bb758
5 changed files with 43 additions and 18 deletions
@@ -0,0 +1,37 @@
/*
* Copyright 2000-2012 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;
import com.intellij.openapi.extensions.ExtensionPointName;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Evgeny Gerashchenko
* @since 3/20/12
*/
public interface ClsFileDecompiledPsiFileProvider {
ExtensionPointName<ClsFileDecompiledPsiFileProvider> EP_NAME = ExtensionPointName.create("com.intellij.psi.clsDecompiledFileProvider");
/**
* Returns decompiled PSI associated with this classfile
*
* @param clsFile instance of ClsFile
* @return decompiled PSI file
*/
@Nullable
PsiFile getDecompiledPsiFile(@NotNull PsiJavaFile clsFile);
}
-1
View File
@@ -12,7 +12,6 @@
<orderEntry type="module" module-name="resources-en" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="asm" level="project" />
<orderEntry type="module" module-name="platform-api" />
</component>
</module>
@@ -26,8 +26,6 @@ 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.ContentBasedClassFileProcessor;
import com.intellij.openapi.fileTypes.ContentBasedFileSubstitutor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.progress.NonCancelableSection;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
@@ -327,12 +325,10 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
@Override
public PsiFile getDecompiledPsiFile() {
for (ContentBasedFileSubstitutor processor : Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME)) {
if (processor instanceof ContentBasedClassFileProcessor && processor.isApplicable(getProject(), getVirtualFile())) {
PsiFile decompiledPsiFile = ((ContentBasedClassFileProcessor)processor).getDecompiledPsiFile(this);
if (decompiledPsiFile != null) {
return decompiledPsiFile;
}
for (ClsFileDecompiledPsiFileProvider provider : Extensions.getExtensions(ClsFileDecompiledPsiFileProvider.EP_NAME)) {
PsiFile decompiledPsiFile = provider.getDecompiledPsiFile(this);
if (decompiledPsiFile != null) {
return decompiledPsiFile;
}
}
return (PsiFile) getMirror();
@@ -34,13 +34,4 @@ public interface ContentBasedClassFileProcessor extends ContentBasedFileSubstitu
*/
@NotNull
SyntaxHighlighter createHighlighter(Project project, VirtualFile vFile);
/**
* Returns decompiled PSI associated with this classfile
*
* @param clsFile instance of ClsFile
* @return decompiled PSI file
*/
@Nullable
PsiFile getDecompiledPsiFile(PsiFile clsFile);
}
@@ -532,6 +532,8 @@
<extensionPoint name="psi.clsCustomNavigationPolicy"
interface="com.intellij.psi.impl.compiled.ClsCustomNavigationPolicy" />
<extensionPoint name="psi.clsDecompiledFileProvider"
interface="com.intellij.psi.ClsFileDecompiledPsiFileProvider"/>
<extensionPoint name="codeBlockProvider"
beanClass="com.intellij.lang.LanguageExtensionPoint"/>