use of org.jetbrains.kotlin.resolve.lazy.ResolveSession in project kotlin by JetBrains.
the class AbstractOutOfBlockModificationTest method checkOOBWithDescriptorsResolve.
private void checkOOBWithDescriptorsResolve(boolean expectedOutOfBlock) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
((PsiModificationTrackerImpl) PsiManager.getInstance(myFixture.getProject()).getModificationTracker()).incOutOfCodeBlockModificationCounter();
}
});
PsiElement updateElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset() - 1);
KtExpression ktExpression = PsiTreeUtil.getParentOfType(updateElement, KtExpression.class, false);
KtDeclaration ktDeclaration = PsiTreeUtil.getParentOfType(updateElement, KtDeclaration.class, false);
KtElement ktElement = ktExpression != null ? ktExpression : ktDeclaration;
if (ktElement == null)
return;
ResolutionFacade facade = ResolutionUtils.getResolutionFacade(ktElement.getContainingKtFile());
ResolveSession session = facade.getFrontendService(ResolveSession.class);
session.forceResolveAll();
BindingContext context = session.getBindingContext();
if (ktExpression != null && ktExpression != ktDeclaration) {
@SuppressWarnings("ConstantConditions") boolean expressionProcessed = context.get(BindingContext.PROCESSED, ktExpression instanceof KtFunctionLiteral ? (KtLambdaExpression) ktExpression.getParent() : ktExpression) == Boolean.TRUE;
assertEquals("Expected out-of-block should result expression analyzed and vise versa", expectedOutOfBlock, expressionProcessed);
} else {
boolean declarationProcessed = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, ktDeclaration) != null;
assertEquals("Expected out-of-block should result declaration analyzed and vise versa", expectedOutOfBlock, declarationProcessed);
}
}
use of org.jetbrains.kotlin.resolve.lazy.ResolveSession in project kotlin by JetBrains.
the class SourceNavigationHelper method createAnalyzer.
@NotNull
private static KotlinCodeAnalyzer createAnalyzer(@NotNull Collection<KtNamedDeclaration> candidates, @NotNull Project project) {
MutableModuleContext context = ContextKt.ContextForNewModule(ContextKt.ProjectContext(project), Name.special("<library module>"), DefaultBuiltIns.getInstance(), null);
context.setDependencies(context.getModule(), context.getModule().getBuiltIns().getBuiltInsModule());
ResolveSession resolveSession = InjectionKt.createLazyResolveSession(context, getContainingFiles(candidates));
context.initializeModuleContents(resolveSession.getPackageFragmentProvider());
return resolveSession;
}
Aggregations