JetElement.getContainingJetFile() introduced
This commit is contained in:
@@ -1960,7 +1960,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
KotlinSyntheticClass.Kind.SAM_LAMBDA);
|
||||
}
|
||||
|
||||
Type asmType = state.getSamWrapperClasses().getSamWrapperClass(samInterface, (JetFile) expression.getContainingFile());
|
||||
Type asmType = state.getSamWrapperClasses().getSamWrapperClass(samInterface, expression.getContainingJetFile());
|
||||
|
||||
v.anew(asmType);
|
||||
v.dup();
|
||||
|
||||
@@ -344,7 +344,7 @@ public class PackageCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
public void generateClassOrObject(@NotNull JetClassOrObject classOrObject) {
|
||||
JetFile file = (JetFile) classOrObject.getContainingFile();
|
||||
JetFile file = classOrObject.getContainingJetFile();
|
||||
Type packagePartType = getPackagePartType(getPackageClassFqName(packageFragment.getFqName()), file.getVirtualFile());
|
||||
CodegenContext context = CodegenContext.STATIC.intoPackagePart(packageFragment, packagePartType);
|
||||
MemberCodegen.genClassOrObject(context, classOrObject, state, null);
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class PsiCodegenPredictor {
|
||||
}
|
||||
}
|
||||
else {
|
||||
FqName packageFqName = ((JetFile) declaration.getContainingFile()).getPackageFqName();
|
||||
FqName packageFqName = declaration.getContainingJetFile().getPackageFqName();
|
||||
|
||||
if (declaration instanceof JetNamedFunction) {
|
||||
JvmClassName packageClass = JvmClassName.byFqNameWithoutInnerClasses(getPackageClassFqName(packageFqName));
|
||||
|
||||
@@ -368,8 +368,8 @@ public class ReplInterpreter {
|
||||
state.beforeCompile();
|
||||
KotlinCodegenFacade.generatePackage(
|
||||
state,
|
||||
((JetFile) script.getContainingFile()).getPackageFqName(),
|
||||
Collections.singleton((JetFile) script.getContainingFile()),
|
||||
script.getContainingJetFile().getPackageFqName(),
|
||||
Collections.singleton(script.getContainingJetFile()),
|
||||
errorHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ import com.intellij.psi.NavigatablePsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface JetElement extends NavigatablePsiElement {
|
||||
@NotNull
|
||||
JetFile getContainingJetFile();
|
||||
|
||||
<D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data);
|
||||
|
||||
<R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data);
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.PsiReferenceService;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
|
||||
@@ -52,6 +53,14 @@ public class JetElementImpl extends ASTWrapperPsiElement implements JetElement {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetFile getContainingJetFile() {
|
||||
PsiFile file = getContainingFile();
|
||||
assert file instanceof JetFile : "JetElement not inside JetFile: " + file + " " + file.getText();
|
||||
return (JetFile) file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
|
||||
JetPsiUtil.visitChildren(this, visitor, data);
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.StubBasedPsiElement;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
@@ -58,6 +59,14 @@ public class JetElementImplStub<T extends StubElement> extends StubBasedPsiEleme
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetFile getContainingJetFile() {
|
||||
PsiFile file = getContainingFile();
|
||||
assert file instanceof JetFile : "JetElement not inside JetFile: " + file + " " + file.getText();
|
||||
return (JetFile) file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
|
||||
PsiElement child = getFirstChild();
|
||||
|
||||
@@ -160,6 +160,12 @@ public class JetFile extends PsiFileBase implements JetDeclarationContainer, Jet
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetFile getContainingJetFile() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
|
||||
JetPsiUtil.visitChildren(this, visitor, data);
|
||||
|
||||
@@ -321,7 +321,7 @@ public class JetPsiUtil {
|
||||
|
||||
public static void deleteClass(@NotNull JetClassOrObject clazz) {
|
||||
CheckUtil.checkWritable(clazz);
|
||||
JetFile file = (JetFile) clazz.getContainingFile();
|
||||
JetFile file = clazz.getContainingJetFile();
|
||||
if (isLocal(clazz) || file.getDeclarations().size() > 1) {
|
||||
PsiElement parent = clazz.getParent();
|
||||
CodeEditUtil.removeChild(parent.getNode(), clazz.getNode());
|
||||
@@ -912,7 +912,7 @@ public class JetPsiUtil {
|
||||
|
||||
@Nullable
|
||||
public static String getPackageName(@NotNull JetElement element) {
|
||||
JetFile file = (JetFile) element.getContainingFile();
|
||||
JetFile file = element.getContainingJetFile();
|
||||
JetPackageDirective header = PsiTreeUtil.findChildOfType(file, JetPackageDirective.class);
|
||||
|
||||
return header != null ? header.getQualifiedName() : null;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ImportsResolver {
|
||||
// SCRIPT: process script import directives
|
||||
for (JetScript script : c.getScripts().keySet()) {
|
||||
WritableScope scriptScope = ((ScriptDescriptorImpl) c.getScripts().get(script)).getScopeForBodyResolution();
|
||||
processImportsInFile(lookupMode, scriptScope, ((JetFile) script.getContainingFile()).getImportDirectives(), true);
|
||||
processImportsInFile(lookupMode, scriptScope, script.getContainingJetFile().getImportDirectives(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ public class LazyTopDownAnalyzer {
|
||||
}
|
||||
|
||||
for (JetScript script : c.getScripts().keySet()) {
|
||||
resolveAndCheckImports((JetFile) script.getContainingFile(), resolveSession);
|
||||
resolveAndCheckImports(script.getContainingJetFile(), resolveSession);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ScriptHeaderResolver {
|
||||
|
||||
|
||||
public void processScriptHierarchy(@NotNull TopDownAnalysisContext c, @NotNull JetScript script, @NotNull WritableScope outerScope) {
|
||||
JetFile file = (JetFile) script.getContainingFile();
|
||||
JetFile file = script.getContainingJetFile();
|
||||
FqName fqName = file.getPackageFqName();
|
||||
PackageFragmentDescriptor ns = packageFragmentProvider.getOrCreateFragment(fqName);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ScriptNameUtil {
|
||||
|
||||
@NotNull
|
||||
public static FqName classNameForScript(JetScript script) {
|
||||
JetFile file = (JetFile) script.getContainingFile();
|
||||
JetFile file = script.getContainingJetFile();
|
||||
JetScriptDefinition scriptDefinition = JetScriptDefinitionProvider.getInstance(file.getProject()).findScriptDefinition(file);
|
||||
|
||||
String name = file.getName();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ScriptParameterResolver {
|
||||
) {
|
||||
List<ValueParameterDescriptor> valueParameters = Lists.newArrayList();
|
||||
|
||||
JetFile file = (JetFile) declaration.getContainingFile();
|
||||
JetFile file = declaration.getContainingJetFile();
|
||||
JetScriptDefinition scriptDefinition = JetScriptDefinitionProvider.getInstance(file.getProject()).findScriptDefinition(file);
|
||||
|
||||
int index = 0;
|
||||
|
||||
@@ -177,7 +177,7 @@ public class LazyImportScope implements JetScope, LazyEntity {
|
||||
|
||||
ImportResolveStatus status = importedScopesProvider.invoke(importDirective).importResolveStatus;
|
||||
if (status != null && !status.descriptors.isEmpty()) {
|
||||
JetScope fileScope = resolveSession.getScopeProvider().getFileScope((JetFile) importDirective.getContainingFile());
|
||||
JetScope fileScope = resolveSession.getScopeProvider().getFileScope(importDirective.getContainingJetFile());
|
||||
ImportsResolver.reportUselessImport(importDirective, fileScope, status.descriptors, traceForImportResolve);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class LazyPackageMemberScope extends AbstractLazyMemberScope<PackageFragm
|
||||
@NotNull
|
||||
@Override
|
||||
protected JetScope getScopeForMemberDeclarationResolution(JetDeclaration declaration) {
|
||||
return resolveSession.getScopeProvider().getFileScope((JetFile) declaration.getContainingFile());
|
||||
return resolveSession.getScopeProvider().getFileScope(declaration.getContainingJetFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ public class LazyScriptDescriptor(
|
||||
val jetScript: JetScript,
|
||||
val _priority: Int
|
||||
) : ScriptDescriptor, LazyEntity, DeclarationDescriptorNonRootImpl(
|
||||
(jetScript.getContainingFile() as JetFile).getPackageFqName().let {
|
||||
jetScript.getContainingJetFile().getPackageFqName().let {
|
||||
fqName ->
|
||||
resolveSession.getPackageFragment(fqName).sure("Package not found $fqName")
|
||||
},
|
||||
@@ -102,7 +102,7 @@ public class LazyScriptDescriptor(
|
||||
return ChainedScope(
|
||||
this,
|
||||
"Scope for body resolution for " + this,
|
||||
resolveSession.getScopeProvider().getFileScope(jetScript.getContainingFile() as JetFile),
|
||||
resolveSession.getScopeProvider().getFileScope(jetScript.getContainingJetFile()),
|
||||
parametersScope
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ public class KotlinJavaFileStubProvider<T extends WithFileStub> implements Cache
|
||||
JetPsiUtil.isLocal(classOrObject),
|
||||
new StubGenerationStrategy<OutermostKotlinClassLightClassData>() {
|
||||
private JetFile getFile() {
|
||||
return (JetFile) classOrObject.getContainingFile();
|
||||
return classOrObject.getContainingJetFile();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ public class KotlinLightClassForExplicitDeclaration extends KotlinWrappingLightC
|
||||
|
||||
@Nullable
|
||||
public static KotlinLightClassForExplicitDeclaration create(@NotNull PsiManager manager, @NotNull JetClassOrObject classOrObject) {
|
||||
if (LightClassUtil.belongsToKotlinBuiltIns((JetFile) classOrObject.getContainingFile())) {
|
||||
if (LightClassUtil.belongsToKotlinBuiltIns(classOrObject.getContainingJetFile())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ public class KotlinLightClassForExplicitDeclaration extends KotlinWrappingLightC
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPackageName() {
|
||||
return ((JetFile) classOrObject.getContainingFile()).getPackageFqName().asString();
|
||||
return classOrObject.getContainingJetFile().getPackageFqName().asString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
|
||||
@NotNull
|
||||
@Override
|
||||
public LightClassConstructionContext getContextForClassOrObject(@NotNull JetClassOrObject classOrObject) {
|
||||
ResolveSessionForBodies session = AnalyzerFacadeWithCache.getLazyResolveSessionForFile((JetFile) classOrObject.getContainingFile());
|
||||
ResolveSessionForBodies session = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(classOrObject.getContainingJetFile());
|
||||
|
||||
if (JetPsiUtil.isLocal(classOrObject)) {
|
||||
BindingContext bindingContext = session.resolveToElement(classOrObject);
|
||||
|
||||
@@ -28,13 +28,13 @@ public class KotlinCacheManagerUtil {
|
||||
|
||||
@NotNull
|
||||
public static KotlinDeclarationsCache getDeclarationsFromProject(@NotNull JetElement element) {
|
||||
JetFile jetFile = (JetFile) element.getContainingFile();
|
||||
JetFile jetFile = element.getContainingJetFile();
|
||||
return KotlinCacheManager.getInstance(jetFile.getProject()).getDeclarationsFromProject(TargetPlatformDetector.getPlatform(jetFile));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static BindingContext getDeclarationsBindingContext(@NotNull JetElement element) {
|
||||
JetFile jetFile = (JetFile) element.getContainingFile();
|
||||
JetFile jetFile = element.getContainingJetFile();
|
||||
KotlinDeclarationsCache declarationsCache = KotlinCacheManager.getInstance(jetFile.getProject())
|
||||
.getDeclarationsFromProject(TargetPlatformDetector.getPlatform(jetFile));
|
||||
return declarationsCache.getBindingContext();
|
||||
|
||||
@@ -63,7 +63,7 @@ class KotlinResolveCache(
|
||||
|
||||
try {
|
||||
for (element in task!!.elements) {
|
||||
val file = element.getContainingFile() as JetFile
|
||||
val file = element.getContainingJetFile()
|
||||
val virtualFile = file.getVirtualFile()
|
||||
if (LightClassUtil.belongsToKotlinBuiltIns(file)
|
||||
|| virtualFile != null && LibraryUtil.findLibraryEntry(virtualFile, file.getProject()) != null) {
|
||||
|
||||
@@ -94,7 +94,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
||||
}
|
||||
|
||||
List<JetElement> elementsToCompact = new ArrayList<JetElement>();
|
||||
JetFile file = (JetFile) classOrObject.getContainingFile();
|
||||
JetFile file = classOrObject.getContainingJetFile();
|
||||
for (JetElement element : generateOverridingMembers(selectedElements, file)) {
|
||||
PsiElement added = body.addAfter(element, afterAnchor);
|
||||
afterAnchor = added;
|
||||
|
||||
@@ -25,7 +25,7 @@ public object ShortenReferences {
|
||||
}
|
||||
|
||||
public fun process(elements: Iterable<JetElement>) {
|
||||
for ((file, fileElements) in elements.groupBy { element -> element.getContainingFile() as JetFile }) {
|
||||
for ((file, fileElements) in elements.groupBy { element -> element.getContainingJetFile() }) {
|
||||
// first resolve all qualified references - optimization
|
||||
val referenceToContext = JetFileReferencesResolver.resolve(file, fileElements, visitShortNames = false)
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class JetPackagesContributor extends CompletionContributor {
|
||||
result = result.withPrefixMatcher(new PlainPrefixMatcher(name.substring(0, prefixLength)));
|
||||
|
||||
ResolveSessionForBodies resolveSession = AnalyzerFacadeWithCache
|
||||
.getLazyResolveSessionForFile((JetFile) simpleNameReference.getExpression().getContainingFile());
|
||||
.getLazyResolveSessionForFile(simpleNameReference.getExpression().getContainingJetFile());
|
||||
BindingContext bindingContext = resolveSession.resolveToElement(simpleNameReference.getExpression());
|
||||
|
||||
for (LookupElement variant : DescriptorLookupConverter.collectLookupElements(
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class MoveLambdaInsideParenthesesIntention : JetSelfTargetingIntention<Je
|
||||
}
|
||||
}
|
||||
if (element.getValueArguments().any { it?.getArgumentName() != null}) {
|
||||
val context = AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingFile() as JetFile).getBindingContext()
|
||||
val context = AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext()
|
||||
val resolvedCall = context[BindingContext.RESOLVED_CALL, element.getCalleeExpression()]
|
||||
val literalName = resolvedCall?.getResultingDescriptor()?.getValueParameters()?.last?.getName().toString()
|
||||
sb.append("$literalName = ")
|
||||
|
||||
@@ -43,7 +43,7 @@ public class RemoveExplicitTypeArguments : JetSelfTargetingIntention<JetCallExpr
|
||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
||||
if (element.getTypeArguments().isEmpty()) return false
|
||||
|
||||
val resolveSession = AnalyzerFacadeWithCache.getLazyResolveSessionForFile((element.getContainingFile() as JetFile))
|
||||
val resolveSession = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(element.getContainingJetFile())
|
||||
val injector = InjectorForMacros(element.getProject(), resolveSession.getModuleDescriptor())
|
||||
|
||||
val scope = context[BindingContext.RESOLUTION_SCOPE, element]
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class ReplaceWithInfixFunctionCallIntention : JetSelfTargetingIntention<J
|
||||
numOfTotalValueArguments == 1 &&
|
||||
callee != null) {
|
||||
if (valueArguments?.getArguments()?.size() == 1 && valueArguments?.getArguments()?.first()?.isNamed() ?: false) {
|
||||
val file: JetFile = element.getContainingFile() as JetFile
|
||||
val file: JetFile = element.getContainingJetFile()
|
||||
val bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache(file).getBindingContext()
|
||||
val descriptor = bindingContext.get(BindingContext.RESOLVED_CALL, callee)
|
||||
val valueArgumentsMap = descriptor?.getValueArguments()
|
||||
|
||||
@@ -140,7 +140,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
|
||||
|
||||
private static boolean hasPublicMemberDiagnostic(@NotNull JetNamedDeclaration declaration) {
|
||||
BindingContext bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) declaration.getContainingFile()).getBindingContext();
|
||||
BindingContext bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache(declaration.getContainingJetFile()).getBindingContext();
|
||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||
//noinspection ConstantConditions
|
||||
if (Errors.PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE == diagnostic.getFactory() && declaration == diagnostic.getPsiElement()) {
|
||||
@@ -152,7 +152,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
|
||||
@NotNull
|
||||
public static JetType getTypeForDeclaration(@NotNull JetNamedDeclaration declaration) {
|
||||
BindingContext bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) declaration.getContainingFile()).getBindingContext();
|
||||
BindingContext bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache(declaration.getContainingJetFile()).getBindingContext();
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
||||
|
||||
JetType type;
|
||||
|
||||
@@ -29,13 +29,13 @@ fun specifyTypeExplicitly(declaration: JetNamedFunction, typeReference: JetTypeR
|
||||
}
|
||||
|
||||
fun expressionType(expression: JetExpression): JetType? {
|
||||
val resolveSession = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(expression.getContainingFile() as JetFile)
|
||||
val resolveSession = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(expression.getContainingJetFile())
|
||||
val bindingContext = resolveSession.resolveToElement(expression)
|
||||
return bindingContext.get(BindingContext.EXPRESSION_TYPE, expression)
|
||||
}
|
||||
|
||||
fun functionReturnType(function: JetNamedFunction): JetType? {
|
||||
val resolveSession = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(function.getContainingFile() as JetFile)
|
||||
val resolveSession = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(function.getContainingJetFile())
|
||||
val bindingContext = resolveSession.resolveToElement(function)
|
||||
val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, function)
|
||||
if (descriptor == null) return null
|
||||
|
||||
@@ -105,7 +105,7 @@ public class JetSourceNavigationHelper {
|
||||
|
||||
@NotNull
|
||||
private static GlobalSearchScope createLibrarySourcesScope(@NotNull JetNamedDeclaration decompiledDeclaration) {
|
||||
JetFile containingFile = (JetFile) decompiledDeclaration.getContainingFile();
|
||||
JetFile containingFile = decompiledDeclaration.getContainingJetFile();
|
||||
VirtualFile libraryFile = containingFile.getVirtualFile();
|
||||
if (libraryFile == null) {
|
||||
return GlobalSearchScope.EMPTY_SCOPE;
|
||||
@@ -348,7 +348,7 @@ public class JetSourceNavigationHelper {
|
||||
|
||||
@Nullable
|
||||
public static PsiClass getOriginalPsiClassOrCreateLightClass(@NotNull JetClassOrObject classOrObject) {
|
||||
if (LightClassUtil.belongsToKotlinBuiltIns((JetFile) classOrObject.getContainingFile())) {
|
||||
if (LightClassUtil.belongsToKotlinBuiltIns(classOrObject.getContainingJetFile())) {
|
||||
Name className = classOrObject.getNameAsName();
|
||||
assert className != null : "Class from BuiltIns should have a name";
|
||||
ClassDescriptor classDescriptor = KotlinBuiltIns.getInstance().getBuiltInClassByName(className);
|
||||
@@ -374,7 +374,7 @@ public class JetSourceNavigationHelper {
|
||||
}
|
||||
String fqName = JvmClassName.byInternalName(internalName).getFqNameForClassNameWithoutDollars().asString();
|
||||
|
||||
JetFile file = (JetFile) classOrObject.getContainingFile();
|
||||
JetFile file = classOrObject.getContainingJetFile();
|
||||
|
||||
VirtualFile vFile = file.getVirtualFile();
|
||||
Project project = file.getProject();
|
||||
|
||||
+1
-1
@@ -380,7 +380,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith
|
||||
}
|
||||
|
||||
ResolveSessionForBodies resolveSession =
|
||||
AnalyzerFacadeWithCache.getLazyResolveSessionForFile((JetFile) callNameExpression.getContainingFile());
|
||||
AnalyzerFacadeWithCache.getLazyResolveSessionForFile(callNameExpression.getContainingJetFile());
|
||||
BindingContext bindingContext = resolveSession.resolveToElement(callNameExpression);
|
||||
|
||||
JetScope scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, callNameExpression);
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class AnalyzerFacadeWithCache {
|
||||
|
||||
@NotNull
|
||||
public static BindingContext getContextForElement(@NotNull JetElement jetElement) {
|
||||
ResolveSessionForBodies resolveSessionForBodies = getLazyResolveSessionForFile((JetFile) jetElement.getContainingFile());
|
||||
ResolveSessionForBodies resolveSessionForBodies = getLazyResolveSessionForFile(jetElement.getContainingJetFile());
|
||||
return resolveSessionForBodies.resolveToElement(jetElement);
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ResolveElementCache {
|
||||
BindingTrace trace = resolveSession.getStorageManager().createSafeTrace(
|
||||
new DelegatingBindingTrace(resolveSession.getBindingContext(), "trace to resolve element", resolveElement));
|
||||
|
||||
JetFile file = (JetFile) resolveElement.getContainingFile();
|
||||
JetFile file = resolveElement.getContainingJetFile();
|
||||
|
||||
if (resolveElement instanceof JetNamedFunction) {
|
||||
functionAdditionalResolve(resolveSession, (JetNamedFunction) resolveElement, trace, file);
|
||||
@@ -144,7 +144,7 @@ public class ResolveElementCache {
|
||||
}
|
||||
else if (resolveElement instanceof JetImportDirective) {
|
||||
JetImportDirective importDirective = (JetImportDirective) resolveElement;
|
||||
LazyImportScope scope = resolveSession.getScopeProvider().getExplicitImportsScopeForFile((JetFile) importDirective.getContainingFile());
|
||||
LazyImportScope scope = resolveSession.getScopeProvider().getExplicitImportsScopeForFile(importDirective.getContainingJetFile());
|
||||
scope.forceResolveAllContents();
|
||||
}
|
||||
else if (resolveElement instanceof JetAnnotationEntry) {
|
||||
@@ -346,7 +346,7 @@ public class ResolveElementCache {
|
||||
ScopeProvider provider = resolveSession.getScopeProvider();
|
||||
JetDeclaration parentDeclaration = PsiTreeUtil.getParentOfType(expression, JetDeclaration.class);
|
||||
if (parentDeclaration == null) {
|
||||
return provider.getFileScope((JetFile) expression.getContainingFile());
|
||||
return provider.getFileScope(expression.getContainingJetFile());
|
||||
}
|
||||
return provider.getResolutionScopeForDeclaration(parentDeclaration);
|
||||
}
|
||||
@@ -380,7 +380,7 @@ public class ResolveElementCache {
|
||||
|
||||
if (expression.getParent() instanceof JetDotQualifiedExpression) {
|
||||
JetExpression element = ((JetDotQualifiedExpression) expression.getParent()).getReceiverExpression();
|
||||
FqName fqName = ((JetFile) expression.getContainingFile()).getPackageFqName();
|
||||
FqName fqName = expression.getContainingJetFile().getPackageFqName();
|
||||
|
||||
PackageViewDescriptor filePackage = resolveSession.getModuleDescriptor().getPackage(fqName);
|
||||
assert filePackage != null : "File package should be already resolved and be found";
|
||||
|
||||
@@ -59,7 +59,7 @@ public class JetClassOrObjectTreeNode extends AbstractPsiBasedNode<JetClassOrObj
|
||||
data.setPresentableText(classOrObject.getName());
|
||||
|
||||
AbstractTreeNode parent = getParent();
|
||||
if (JetIconProvider.getMainClass((JetFile) classOrObject.getContainingFile()) != null) {
|
||||
if (JetIconProvider.getMainClass(classOrObject.getContainingJetFile()) != null) {
|
||||
if (parent instanceof JetFileTreeNode) {
|
||||
update(parent.getParent());
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AddNameToArgumentFix extends JetIntentionAction<JetValueArgument> {
|
||||
JetExpression callee = callElement.getCalleeExpression();
|
||||
if (!(callee instanceof JetReferenceExpression)) return Collections.emptyList();
|
||||
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) argument.getContainingFile()).getBindingContext();
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache(argument.getContainingJetFile()).getBindingContext();
|
||||
ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
|
||||
if (resolvedCall == null) return Collections.emptyList();
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class AutoImportFix extends JetHintAction<JetSimpleNameExpression> implem
|
||||
}
|
||||
|
||||
ResolveSessionForBodies resolveSessionForBodies =
|
||||
AnalyzerFacadeWithCache.getLazyResolveSessionForFile((JetFile) element.getContainingFile());
|
||||
AnalyzerFacadeWithCache.getLazyResolveSessionForFile(element.getContainingJetFile());
|
||||
|
||||
List<FqName> result = Lists.newArrayList();
|
||||
if (!isSuppressedTopLevelImportInPosition(element)) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ChangeFunctionLiteralReturnTypeFix extends JetIntentionAction<JetFu
|
||||
renderedType = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(type);
|
||||
functionLiteralReturnTypeRef = element.getFunctionLiteral().getReturnTypeRef();
|
||||
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) element.getContainingFile()).getBindingContext();
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext();
|
||||
JetType functionLiteralType = context.get(BindingContext.EXPRESSION_TYPE, element);
|
||||
assert functionLiteralType != null : "Type of function literal not available in binding context";
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
||||
public IntentionAction createAction(Diagnostic diagnostic) {
|
||||
JetExpression expression = QuickFixUtil.getParentElementOfType(diagnostic, JetExpression.class);
|
||||
assert expression != null : "HAS_NEXT_FUNCTION_TYPE_MISMATCH reported on element that is not within any expression";
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) expression.getContainingFile()).getBindingContext();
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache(expression.getContainingJetFile()).getBindingContext();
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = context.get(BindingContext.LOOP_RANGE_HAS_NEXT_RESOLVED_CALL, expression);
|
||||
if (resolvedCall == null) return null;
|
||||
JetFunction hasNextFunction = (JetFunction) BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor());
|
||||
@@ -184,7 +184,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
||||
public IntentionAction createAction(Diagnostic diagnostic) {
|
||||
JetBinaryExpression expression = QuickFixUtil.getParentElementOfType(diagnostic, JetBinaryExpression.class);
|
||||
assert expression != null : "COMPARE_TO_TYPE_MISMATCH reported on element that is not within any expression";
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) expression.getContainingFile()).getBindingContext();
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache(expression.getContainingJetFile()).getBindingContext();
|
||||
ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
|
||||
if (resolvedCall == null) return null;
|
||||
PsiElement compareTo = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor());
|
||||
|
||||
@@ -164,7 +164,7 @@ public abstract class ChangeFunctionSignatureFix extends JetIntentionAction<PsiE
|
||||
(DiagnosticWithParameters2<JetFunctionLiteral, Integer, List<JetType>>) diagnostic;
|
||||
JetFunctionLiteral functionLiteral = diagnosticWithParameters.getPsiElement();
|
||||
BindingContext bindingContext =
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) functionLiteral.getContainingFile()).getBindingContext();
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache(functionLiteral.getContainingJetFile()).getBindingContext();
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, functionLiteral);
|
||||
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ChangeVariableTypeFix extends JetIntentionAction<JetVariableDeclara
|
||||
@Override
|
||||
public IntentionAction createAction(Diagnostic diagnostic) {
|
||||
JetMultiDeclarationEntry entry = ChangeFunctionReturnTypeFix.getMultiDeclarationEntryThatTypeMismatchComponentFunction(diagnostic);
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) entry.getContainingFile()).getBindingContext();
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache(entry.getContainingJetFile()).getBindingContext();
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry);
|
||||
if (resolvedCall == null) return null;
|
||||
JetFunction componentFunction = (JetFunction) BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor());
|
||||
@@ -130,7 +130,7 @@ public class ChangeVariableTypeFix extends JetIntentionAction<JetVariableDeclara
|
||||
|
||||
JetProperty property = QuickFixUtil.getParentElementOfType(diagnostic, JetProperty.class);
|
||||
if (property != null) {
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) property.getContainingFile()).getBindingContext();
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache(property.getContainingJetFile()).getBindingContext();
|
||||
JetType lowerBoundOfOverriddenPropertiesTypes = QuickFixUtil.findLowerBoundOfOverriddenCallablesReturnTypes(context, property);
|
||||
|
||||
DeclarationDescriptor descriptor = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, property);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class QuickFixUtil {
|
||||
|
||||
@Nullable
|
||||
public static JetParameterList getParameterListOfCallee(@NotNull JetCallExpression callExpression) {
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) callExpression.getContainingFile()).getBindingContext();
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache(callExpression.getContainingJetFile()).getBindingContext();
|
||||
ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression());
|
||||
if (resolvedCall == null) return null;
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor());
|
||||
|
||||
@@ -254,7 +254,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
||||
}
|
||||
|
||||
private static void addFunctionLiteralParameterTypes(@NotNull String parameters, @NotNull List<JetExpression> inlinedExpressions) {
|
||||
JetFile containingFile = (JetFile) inlinedExpressions.get(0).getContainingFile();
|
||||
JetFile containingFile = inlinedExpressions.get(0).getContainingJetFile();
|
||||
List<JetFunctionLiteralExpression> functionsToAddParameters = Lists.newArrayList();
|
||||
|
||||
ResolveSessionForBodies resolveSessionForBodies = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(containingFile);
|
||||
@@ -314,7 +314,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
||||
}
|
||||
|
||||
private static void addTypeArguments(@NotNull String typeArguments, @NotNull List<JetExpression> inlinedExpressions) {
|
||||
JetFile containingFile = (JetFile) inlinedExpressions.get(0).getContainingFile();
|
||||
JetFile containingFile = inlinedExpressions.get(0).getContainingJetFile();
|
||||
List<JetCallExpression> callsToAddArguments = Lists.newArrayList();
|
||||
|
||||
ResolveSessionForBodies resolveSessionForBodies = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(containingFile);
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ public class KotlinIntroduceVariableHandler extends KotlinIntroduceHandlerBase {
|
||||
}
|
||||
}
|
||||
ResolveSessionForBodies resolveSession =
|
||||
AnalyzerFacadeWithCache.getLazyResolveSessionForFile((JetFile) expression.getContainingFile());
|
||||
AnalyzerFacadeWithCache.getLazyResolveSessionForFile(expression.getContainingJetFile());
|
||||
BindingContext bindingContext = resolveSession.resolveToElement(expression);
|
||||
final JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression); //can be null or error type
|
||||
JetScope scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expression);
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
public class KotlinMoveFilesOrDirectoriesHandler extends MoveFilesOrDirectoriesHandler {
|
||||
public static boolean isMovableClass(JetClassOrObject clazz) {
|
||||
if (!(clazz.getParent() instanceof JetFile)) return false;
|
||||
JetFile file = (JetFile) clazz.getContainingFile();
|
||||
JetFile file = clazz.getContainingJetFile();
|
||||
List<JetDeclaration> declarations = file.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
if (declaration instanceof JetClassOrObject && declaration != clazz) return false;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class RenameJetClassProcessor extends RenamePsiElementProcessor {
|
||||
JetClassOrObject classOrObject = getJetClassOrObject(element, false, null);
|
||||
|
||||
if (classOrObject != null) {
|
||||
JetFile file = (JetFile) classOrObject.getContainingFile();
|
||||
JetFile file = classOrObject.getContainingJetFile();
|
||||
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile != null) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class JetPsiHeuristicsUtil {
|
||||
if (isTopLevelDeclaration(classOrObject) && classOrObject.hasModifier(JetTokens.PRIVATE_KEYWORD)) {
|
||||
// The class is declared private in the targetPackage
|
||||
// It is visible in this package and all of its subpackages
|
||||
JetFile targetFile = (JetFile) classOrObject.getContainingFile();
|
||||
JetFile targetFile = classOrObject.getContainingJetFile();
|
||||
FqName targetPackage = targetFile.getPackageFqName();
|
||||
FqName fromPackage = fromFile.getPackageFqName();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ class A {
|
||||
private fun formatElement(var element: PsiElement): String {
|
||||
element = JetPsiUtil.ascendIfPropertyAccessor(element)
|
||||
if (element is JetNamedFunction || element is JetProperty) {
|
||||
val bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache((element.getContainingFile() as JetFile)).getBindingContext()
|
||||
val bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext()
|
||||
|
||||
val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
|
||||
if (declarationDescriptor is CallableMemberDescriptor) {
|
||||
|
||||
@@ -3,7 +3,7 @@ class A {
|
||||
element = JetPsiUtil.ascendIfPropertyAccessor(element);
|
||||
if (element instanceof JetNamedFunction || element instanceof JetProperty) {
|
||||
BindingContext bindingContext =
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) element.getContainingFile()).getBindingContext();
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache(element.getContainingJetFile()).getBindingContext();
|
||||
|
||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
||||
if (declarationDescriptor instanceof CallableMemberDescriptor) {
|
||||
|
||||
@@ -122,7 +122,7 @@ public abstract class AbstractOverrideImplementTest extends LightCodeInsightFixt
|
||||
final JetClassOrObject classOrObject = PsiTreeUtil.getParentOfType(elementAtCaret, JetClassOrObject.class);
|
||||
assertNotNull("Caret should be inside class or object", classOrObject);
|
||||
|
||||
final JetFile jetFile = (JetFile) classOrObject.getContainingFile();
|
||||
final JetFile jetFile = classOrObject.getContainingJetFile();
|
||||
final ResolveSessionForBodies resolveSession = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(jetFile);
|
||||
Set<CallableMemberDescriptor> descriptors =
|
||||
handler.collectMethodsToGenerate(classOrObject, resolveSession.resolveToElement(classOrObject));
|
||||
@@ -177,7 +177,7 @@ public abstract class AbstractOverrideImplementTest extends LightCodeInsightFixt
|
||||
final JetClassOrObject classOrObject = PsiTreeUtil.getParentOfType(elementAtCaret, JetClassOrObject.class);
|
||||
assertNotNull("Caret should be inside class or object", classOrObject);
|
||||
|
||||
final JetFile jetFile = (JetFile) classOrObject.getContainingFile();
|
||||
final JetFile jetFile = classOrObject.getContainingJetFile();
|
||||
final BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(classOrObject);
|
||||
Set<CallableMemberDescriptor> descriptors = handler.collectMethodsToGenerate(classOrObject, bindingContext);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user