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