Replaced JetDecompiledData.getClsFileIfKotlin() with getClsFile() and isKotlinFile()
This commit is contained in:
@@ -22,7 +22,6 @@ import com.intellij.psi.impl.compiled.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.plugin.libraries.JetDecompiledData;
|
||||
|
||||
/**
|
||||
* @author Evgeny Gerashchenko
|
||||
@@ -50,7 +49,7 @@ public class JetClsNavigationPolicy implements ClsCustomNavigationPolicy {
|
||||
@Nullable
|
||||
private static JetDeclaration getJetDeclarationByClsElement(ClsElementImpl clsElement) {
|
||||
VirtualFile virtualFile = clsElement.getContainingFile().getVirtualFile();
|
||||
if (virtualFile == null || JetDecompiledData.getClsFileIfKotlin(clsElement.getProject(), virtualFile) == null) {
|
||||
if (virtualFile == null || !JetDecompiledData.isKotlinFile(clsElement.getProject(), virtualFile)) {
|
||||
return null;
|
||||
}
|
||||
JetDecompiledData decompiledData = JetDecompiledData.getDecompiledData((ClsFileImpl) clsElement.getContainingFile());
|
||||
|
||||
@@ -34,14 +34,15 @@ public class JetContentBasedFileSubstitutor implements ContentBasedClassFileProc
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(Project project, VirtualFile file) {
|
||||
return JetDecompiledData.getClsFileIfKotlin(project, file) != null;
|
||||
return JetDecompiledData.isKotlinFile(project, file);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String obtainFileText(Project project, VirtualFile file) {
|
||||
ClsFileImpl clsFile = JetDecompiledData.getClsFileIfKotlin(project, file);
|
||||
if (clsFile != null) {
|
||||
if (JetDecompiledData.isKotlinFile(project, file)) {
|
||||
ClsFileImpl clsFile = JetDecompiledData.getClsFile(project, file);
|
||||
assert clsFile != null;
|
||||
return JetDecompiledData.getDecompiledData(clsFile).getJetFile().getText();
|
||||
}
|
||||
return "";
|
||||
|
||||
@@ -21,7 +21,9 @@ import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.compiled.ClsElementImpl;
|
||||
import com.intellij.psi.impl.compiled.ClsFileImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -58,9 +60,8 @@ public class JetDecompiledData {
|
||||
return myClsElementsToJetElements.get(clsElement);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public static ClsFileImpl getClsFileIfKotlin(@NotNull Project project, @NotNull VirtualFile vFile) {
|
||||
public static ClsFileImpl getClsFile(@NotNull Project project, @NotNull VirtualFile vFile) {
|
||||
if (!FileTypeManager.getInstance().isFileOfType(vFile, JavaClassFileType.INSTANCE)) {
|
||||
return null;
|
||||
}
|
||||
@@ -72,8 +73,16 @@ public class JetDecompiledData {
|
||||
if (clsFile.getClasses().length != 1) {
|
||||
return null;
|
||||
}
|
||||
return clsFile;
|
||||
}
|
||||
|
||||
public static boolean isKotlinFile(@NotNull Project project, @NotNull VirtualFile vFile) {
|
||||
ClsFileImpl clsFile = getClsFile(project, vFile);
|
||||
if (clsFile == null) {
|
||||
return false;
|
||||
}
|
||||
PsiClass psiClass = clsFile.getClasses()[0];
|
||||
return DecompiledDataFactory.isKotlinNamespaceClass(psiClass) || DecompiledDataFactory.isKotlinClass(psiClass) ? clsFile : null;
|
||||
return DecompiledDataFactory.isKotlinNamespaceClass(psiClass) || DecompiledDataFactory.isKotlinClass(psiClass);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user