diff --git a/java/java-psi-impl/java-psi-impl.iml b/java/java-psi-impl/java-psi-impl.iml
index ccd2d51410f9..6c15172b7e3d 100644
--- a/java/java-psi-impl/java-psi-impl.iml
+++ b/java/java-psi-impl/java-psi-impl.iml
@@ -12,6 +12,7 @@
+
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java
index 2d438b251553..0839f23eeee9 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java
@@ -23,6 +23,9 @@ import com.intellij.lang.FileASTNode;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.extensions.Extensions;
+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;
@@ -54,7 +57,7 @@ import java.lang.ref.SoftReference;
import java.util.*;
public class ClsFileImpl extends ClsRepositoryPsiElement implements PsiJavaFile, PsiFileWithStubSupport, PsiFileEx,
- Queryable, PsiClassOwnerEx {
+ Queryable, PsiClassOwnerEx, PsiCompiledFile {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsFileImpl");
/** YOU absolutely MUST NOT hold PsiLock under the MIRROR_LOCK */
@@ -313,6 +316,19 @@ public class ClsFileImpl extends ClsRepositoryPsiElement
}
}
+ @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;
+ }
+ }
+ }
+ return (PsiFile) getMirror();
+ }
+
@Override
public long getModificationStamp() {
return getVirtualFile().getModificationStamp();
@@ -365,7 +381,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement
ClsFileImpl psiFile = null;
if (provider != null) {
final PsiFile psi = provider.getPsi(provider.getBaseLanguage());
- if (psi instanceof ClsFileImpl) {
+ if (psi instanceof PsiCompiledFile) {
psiFile = (ClsFileImpl)psi;
}
}
diff --git a/platform/core-api/src/com/intellij/psi/PsiCompiledFile.java b/platform/core-api/src/com/intellij/psi/PsiCompiledFile.java
new file mode 100644
index 000000000000..31b082e6a004
--- /dev/null
+++ b/platform/core-api/src/com/intellij/psi/PsiCompiledFile.java
@@ -0,0 +1,24 @@
+/*
+ * 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;
+
+/**
+ * @author Evgeny Gerashchenko
+ * @since 3/1/12
+ */
+public interface PsiCompiledFile extends PsiFile, PsiCompiledElement {
+ PsiFile getDecompiledPsiFile();
+}