Refactor: Introduce JetDeclaration#resolveToDescriptor utility
This commit is contained in:
@@ -20,6 +20,8 @@ import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
|
||||
public fun JetElement.getLazyResolveSession(): ResolutionFacade {
|
||||
return KotlinCacheService.getInstance(getProject()).getResolutionFacade(listOf(this))
|
||||
@@ -29,6 +31,10 @@ public fun JetElement.getAnalysisResults(vararg extraFiles: JetFile): AnalyzeExh
|
||||
return KotlinCacheService.getInstance(getProject()).getAnalysisResults(listOf(this) + extraFiles.toList())
|
||||
}
|
||||
|
||||
public fun JetDeclaration.resolveToDescriptor(): DeclarationDescriptor {
|
||||
return getLazyResolveSession().resolveToDescriptor(this)
|
||||
}
|
||||
|
||||
public fun JetElement.getBindingContext(): BindingContext {
|
||||
return getAnalysisResults().bindingContext
|
||||
}
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ public class JetStructureViewElement implements StructureViewTreeElement, Querya
|
||||
return null;
|
||||
}
|
||||
|
||||
return ResolvePackage.getLazyResolveSession(declaration).resolveToDescriptor(declaration);
|
||||
return ResolvePackage.resolveToDescriptor(declaration);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user