Introduce DecompiledUtils
This commit is contained in:
@@ -21,10 +21,10 @@ import com.intellij.lang.documentation.AbstractDocumentationProvider;
|
||||
import com.intellij.lang.java.JavaDocumentationProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.impl.compiled.ClsClassImpl;
|
||||
import com.intellij.psi.impl.compiled.ClsFileImpl;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.plugin.libraries.JetDecompiledData;
|
||||
import org.jetbrains.jet.plugin.libraries.DecompiledUtils;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||
import org.jetbrains.jet.plugin.references.BuiltInsReferenceResolver;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
@@ -117,7 +117,8 @@ public class JetQuickDocumentationProvider extends AbstractDocumentationProvider
|
||||
if (JetLanguage.INSTANCE == declaration.getLanguage()) return true;
|
||||
ClsClassImpl clsClass = PsiTreeUtil.getParentOfType(declaration, ClsClassImpl.class);
|
||||
if (clsClass == null) return false;
|
||||
return JetDecompiledData.isKotlinFile((ClsFileImpl) clsClass.getContainingFile());
|
||||
VirtualFile file = clsClass.getContainingFile().getVirtualFile();
|
||||
return file != null && DecompiledUtils.isKotlinCompiledFile(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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 org.jetbrains.jet.plugin.libraries;
|
||||
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.KotlinClassFileHeader;
|
||||
|
||||
public final class DecompiledUtils {
|
||||
|
||||
public static boolean isKotlinCompiledFile(@NotNull VirtualFile file) {
|
||||
if (!StdFileTypes.CLASS.getDefaultExtension().equals(file.getExtension())) {
|
||||
return false;
|
||||
}
|
||||
//TODO: check index
|
||||
return KotlinClassFileHeader.readKotlinHeaderFromClassFile(file).isKotlinCompiledFile();
|
||||
}
|
||||
|
||||
private DecompiledUtils() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user