@Override @NotNull public JavaResolveResult[] multiResolve(final boolean incompleteCode) { FileElement fileElement = SharedImplUtil.findFileElement(this); if (fileElement == null) { LOG.error("fileElement == null!"); return JavaResolveResult.EMPTY_ARRAY; } final PsiManagerEx manager = fileElement.getManager(); if (manager == null) { LOG.error("getManager() == null!"); return JavaResolveResult.EMPTY_ARRAY; } PsiFile file = SharedImplUtil.getContainingFile(fileElement); boolean valid = file != null && file.isValid(); if (!valid) { LOG.error("invalid!"); return JavaResolveResult.EMPTY_ARRAY; } Project project = manager.getProject(); final ResolveCache resolveCache = ResolveCache.getInstance(project); final ResolveResult[] results = resolveCache.resolveWithCaching(this, OurGenericsResolver.INSTANCE, true, incompleteCode, file); return results.length == 0 ? JavaResolveResult.EMPTY_ARRAY : (JavaResolveResult[])results; }
@RequiredReadAction @Nullable @Override public PsiElement resolve() { return ResolveCache.getInstance(getProject()).resolveWithCaching(this, (expression, incompleteCode) -> { Ref<CSharpPreprocessorVariable> ref = Ref.create(); collect(it -> { if(Comparing.equal(it.getName(), getElement().getText())) { ref.set(it); return false; } return true; }); return ref.get(); }, true, true); }
@NotNull @Override public ResolveResult[] multiResolve(boolean incompleteCode) { return ResolveCache.getInstance(myElement.getProject()) .resolveWithCaching(this, (r, incomplete) -> { List<PsiElement> elements = r.resolveInner(); List<ResolveResult> resolveResults = new ArrayList<>(); ResolveResult[] result = new ResolveResult[elements.size()]; for (PsiElement e: elements) { resolveResults.add(new PsiElementResolveResult(e)); } return resolveResults.toArray(result); }, true, true); }
@Override @NotNull public JavaResolveResult[] multiResolve(boolean incompleteCode) { PsiFile file = getContainingFile(); final ResolveCache resolveCache = ResolveCache.getInstance(file.getProject()); ResolveResult[] results = resolveCache.resolveWithCaching(this, Resolver.INSTANCE, true, incompleteCode,file); if (results.length == 0) return JavaResolveResult.EMPTY_ARRAY; return (JavaResolveResult[])results; }
@Override @NotNull public JavaResolveResult[] multiResolve(boolean incompleteCode) { PsiFile file = getContainingFile(); final ResolveCache resolveCache = ResolveCache.getInstance(file.getProject()); final ResolveResult[] results = resolveCache.resolveWithCaching(this, OurGenericsResolver.INSTANCE, true, incompleteCode,file); return results instanceof JavaResolveResult[] ? (JavaResolveResult[])results : JavaResolveResult.EMPTY_ARRAY; }
@NotNull public static <T extends PsiJavaCodeReferenceElement> JavaResolveResult[] multiResolveImpl( @NotNull T element, boolean incompleteCode, @NotNull ResolveCache.PolyVariantContextResolver<? super T> resolver) { FileASTNode fileElement = SharedImplUtil.findFileElement(element.getNode()); if (fileElement == null) { PsiUtilCore.ensureValid(element); LOG.error("fileElement == null!"); return JavaResolveResult.EMPTY_ARRAY; } PsiFile psiFile = SharedImplUtil.getContainingFile(fileElement); PsiManager manager = psiFile == null ? null : psiFile.getManager(); if (manager == null) { PsiUtilCore.ensureValid(element); LOG.error("getManager() == null!"); return JavaResolveResult.EMPTY_ARRAY; } boolean valid = psiFile.isValid(); if (!valid) { PsiUtilCore.ensureValid(element); LOG.error("psiFile.isValid() == false!"); return JavaResolveResult.EMPTY_ARRAY; } if (element instanceof PsiMethodReferenceExpression) { // method refs: do not cache results during parent conflict resolving, acceptable checks, etc final Map<PsiElement, PsiType> map = LambdaUtil.ourFunctionTypes.get(); if (map != null && map.containsKey(element)) { return (JavaResolveResult[])resolver.resolve(element, psiFile, incompleteCode); } } return multiResolveImpl(manager.getProject(), psiFile, element, incompleteCode, resolver); }
public static <T extends PsiJavaCodeReferenceElement> JavaResolveResult[] multiResolveImpl( Project project, PsiFile psiFile, T element, boolean incompleteCode, ResolveCache.PolyVariantContextResolver<? super T> resolver) { ResolveResult[] results = ResolveCache.getInstance(project).resolveWithCaching(element, resolver, true, incompleteCode, psiFile); return results.length == 0 ? JavaResolveResult.EMPTY_ARRAY : (JavaResolveResult[])results; }
@Override @NotNull public JavaResolveResult advancedResolve(boolean incompleteCode) { PsiFile file = getJavaContextFile(); final ResolveCache resolveCache = ResolveCache.getInstance(file.getProject()); return (JavaResolveResult) resolveCache.resolveWithCaching(this, MyResolver.INSTANCE, false, false,file)[0]; }
@Override @NotNull public final ResolveResult[] multiResolve(boolean incompleteCode) { PsiElement element = getElement(); PsiFile file = element.getContainingFile(); return ResolveCache.getInstance(file.getProject()).resolveWithCaching(this, MyResolver.INSTANCE, true, incompleteCode,file); }
public CoreProjectEnvironment(@NotNull Disposable parentDisposable, @NotNull CoreApplicationEnvironment applicationEnvironment) { myParentDisposable = parentDisposable; myEnvironment = applicationEnvironment; myProject = createProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable); preregisterServices(); myFileIndexFacade = createFileIndexFacade(); myMessageBus = MessageBusFactory.newMessageBus("CoreProjectEnvironment"); PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject); myProject.registerService(PsiModificationTracker.class, modificationTracker); myProject.registerService(FileIndexFacade.class, myFileIndexFacade); myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus)); myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker); ((FileManagerImpl) myPsiManager.getFileManager()).markInitialized(); registerProjectComponent(PsiManager.class, myPsiManager); myProject.registerService(SmartPointerManager.class, SmartPointerManagerImpl.class); registerProjectComponent(PsiDocumentManager.class, new CorePsiDocumentManager(myProject, myPsiManager, myMessageBus, new MockDocumentCommitProcessor())); myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager)); myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager)); myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager))); myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager)); myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder()); myProject.registerService(DumbService.class, new MockDumbService(myProject)); myProject.registerService(CoreEncodingProjectManager.class, CoreEncodingProjectManager.class); }
/** * Resolves reference to possible referred elements. * First element is always what resolve() would return. * Imported module names: to module file, or {directory, '__init__.py}' for a qualifier. * todo Local identifiers: a list of definitions in the most recent compound statement * (e.g. <code>if X: a = 1; else: a = 2</code> has two definitions of <code>a</code>.). * todo Identifiers not found locally: similar definitions in imported files and builtins. * * @see com.intellij.psi.PsiPolyVariantReference#multiResolve(boolean) */ @Override @NotNull public ResolveResult[] multiResolve(final boolean incompleteCode) { if (USE_CACHE) { final ResolveCache cache = ResolveCache.getInstance(getElement().getProject()); return cache.resolveWithCaching(this, CachingResolver.INSTANCE, false, incompleteCode); } else { return multiResolveInner(); } }
@Override @Nullable public PsiElement resolve() { final PsiElement psiElement = ResolveCache .getInstance(getElement().getProject()).resolveWithCaching(this, MyResolver.INSTANCE, false, false); return psiElement != PsiUtilCore.NULL_PSI_ELEMENT ? psiElement:null; }
@Override public PsiElement resolve() { return ResolveCache.getInstance(myElement.getProject()).resolveWithCaching(this, new ResolveCache.Resolver() { @Nullable @Override public PsiElement resolve(@NotNull PsiReference reference, boolean incompleteCode) { return resolveInner(); } }, false, false); }
@Nullable @Override public PsiElement resolve() { return ResolveCache.getInstance(myElement.getProject()).resolveWithCaching(this, new ResolveCache.Resolver() { @Nullable @Override public PsiElement resolve(@NotNull PsiReference reference, boolean incompleteCode) { return resolveInner(); } }, false, false); }
@Nullable @Override public PsiElement resolve() { return ResolveCache.getInstance(myElement.getProject()) .resolveWithCaching(this, new ResolveCache.Resolver() { @Override public PsiElement resolve(@NotNull PsiReference reference, boolean incompleteCode) { return resolveInner(); } }, false, false); }
@Override public <T extends PsiPolyVariantReference> GroovyResolveResult[] multiResolve(@NotNull T ref, boolean incomplete, ResolveCache.PolyVariantResolver<T> resolver) { ResolveResult[] results = ResolveCache.getInstance(ref.getElement().getProject()).resolveWithCaching(ref, resolver, true, incomplete); return results.length == 0 ? GroovyResolveResult.EMPTY_ARRAY : (GroovyResolveResult[])results; }
@NotNull @Override public <T extends PsiPolyVariantReference> GroovyResolveResult[] multiResolve(@NotNull final T ref, final boolean incomplete, @NotNull final ResolveCache.PolyVariantResolver<T> resolver) { return _getCachedValue(ref.getElement(), new Computable<GroovyResolveResult[]>() { @Override public GroovyResolveResult[] compute() { return (GroovyResolveResult[])resolver.resolve(ref, incomplete); } }, Pair.create(incomplete, resolver.getClass())); }
@Nullable public final PsiElement resolve() { return ResolveCache.getInstance(myAttribute.getProject()).resolveWithCaching(this, new ResolveCache.Resolver() { @Nullable public PsiElement resolve(@NotNull PsiReference psiReference, boolean b) { return resolveImpl(); } }, false, false); }
@NotNull @Override public ResolveResult[] multiResolve(boolean incompleteCode) { final List<? extends PsiElement> elements = ResolveCache.getInstance(getProject()).resolveWithCaching(this, DLangResolver.INSTANCE, true, incompleteCode); return toCandidateInfoArray(elements); }
@NotNull @Override public JavaResolveResult[] multiResolve(final boolean incompleteCode) { FileElement fileElement = SharedImplUtil.findFileElement(this); if (fileElement == null) { LOG.error("fileElement == null!"); return JavaResolveResult.EMPTY_ARRAY; } final PsiManagerEx manager = fileElement.getManager(); if (manager == null) { LOG.error("getManager() == null!"); return JavaResolveResult.EMPTY_ARRAY; } PsiFile file = SharedImplUtil.getContainingFile(fileElement); boolean valid = file != null && file.isValid(); if (!valid) { LOG.error("invalid!"); return JavaResolveResult.EMPTY_ARRAY; } final MethodReferenceResolver resolver = new MethodReferenceResolver(); final Map<PsiMethodReferenceExpression, PsiType> map = PsiMethodReferenceUtil.ourRefs.get(); if (map != null && map.containsKey(this)) { return (JavaResolveResult[])resolver.resolve(this, incompleteCode); } ResolveResult[] results = ResolveCache.getInstance(getProject()).resolveWithCaching(this, resolver, true, incompleteCode,file); return results.length == 0 ? JavaResolveResult.EMPTY_ARRAY : (JavaResolveResult[])results; }
@Override @NotNull public JavaResolveResult advancedResolve(boolean incompleteCode) { PsiFile file = getElement().getContainingFile(); final ResolveCache resolveCache = ResolveCache.getInstance(file.getProject()); return (JavaResolveResult) resolveCache.resolveWithCaching(this, MyResolver.INSTANCE, false, false,file)[0]; }
public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) { myParentDisposable = parentDisposable; myEnvironment = applicationEnvironment; myProject = new MockProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable); preregisterServices(); myFileIndexFacade = createFileIndexFacade(); myMessageBus = new MessageBusImpl("CoreProjectEnvironment", null); PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject); myProject.registerService(PsiModificationTracker.class, modificationTracker); myProject.registerService(FileIndexFacade.class, myFileIndexFacade); myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus)); registerProjectExtensionPoint(PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class); myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker); ((FileManagerImpl) myPsiManager.getFileManager()).markInitialized(); registerProjectComponent(PsiManager.class, myPsiManager); myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager)); myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager)); myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager))); myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager)); myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder()); myProject.registerService(DumbService.class, new MockDumbService(myProject)); }
@RequiredReadAction @NotNull public static ResolveResult[] multiResolve(CSharpReferenceExpressionEx expression, final boolean incompleteCode, final boolean resolveFromParent) { if(!expression.isValid()) { return ResolveResult.EMPTY_ARRAY; } ResolveResult[] resolveResults; CSharpReferenceExpressionImplUtil.OurResolver resolver = CSharpReferenceExpressionImplUtil.OurResolver.INSTANCE; if(GenericInferenceUtil.isInsideGenericInferenceSession()) { resolveResults = resolver.resolve(expression, resolveFromParent); } else { resolveResults = ResolveCache.getInstance(expression.getProject()).resolveWithCaching(expression, resolver, false, resolveFromParent); } if(!incompleteCode) { return resolveResults; } else { return CSharpResolveUtil.filterValidResults(resolveResults); } }
@NotNull @Override @RequiredReadAction public ResolveResult[] multiResolve(boolean incompleteCode) { if(GenericInferenceUtil.isInsideGenericInferenceSession()) { return OurResolver.INSTANCE.resolve(this, incompleteCode); } return ResolveCache.getInstance(getProject()).resolveWithCaching(this, OurResolver.INSTANCE, true, incompleteCode); }
@RequiredReadAction @NotNull @Override public ResolveResult[] multiResolve(boolean incompleteCode) { return ResolveCache.getInstance(getProject()).resolveWithCaching(this, OurResolver.INSTANCE, false, incompleteCode); }
@NotNull @Override public ResolveResult[] multiResolve(boolean incompleteCode) { final List<? extends PsiElement> elements = ResolveCache.getInstance(getProject()).resolveWithCaching(this, HaxeResolver.INSTANCE, true, incompleteCode); return toCandidateInfoArray(elements); }
@Override @Nonnull public final ResolveResult[] multiResolve(boolean incompleteCode) { PsiElement element = getElement(); PsiFile file = element.getContainingFile(); return ResolveCache.getInstance(file.getProject()).resolveWithCaching(this, MyResolver.INSTANCE, true, incompleteCode,file); }
public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) { myParentDisposable = parentDisposable; myEnvironment = applicationEnvironment; myProject = new MockProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable); preregisterServices(); myFileIndexFacade = createFileIndexFacade(); myMessageBus = (MessageBusImpl)myProject.getMessageBus(); PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject); myProject.registerService(PsiModificationTracker.class, modificationTracker); myProject.registerService(FileIndexFacade.class, myFileIndexFacade); myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus)); registerProjectExtensionPoint(PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class); myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker); ((FileManagerImpl)myPsiManager.getFileManager()).markInitialized(); registerProjectComponent(PsiManager.class, myPsiManager); registerProjectComponent(PsiDocumentManager.class, new CorePsiDocumentManager(myProject, myPsiManager, myMessageBus, new MockDocumentCommitProcessor())); myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager)); myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager)); myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager))); myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder()); myProject.registerService(DumbService.class, new MockDumbService(myProject)); }
@Override @Nullable public PsiElement resolve() { final PsiElement psiElement = ResolveCache.getInstance(getElement().getProject()).resolveWithCaching(this, MyResolver.INSTANCE, false, false); return psiElement != PsiUtilCore.NULL_PSI_ELEMENT ? psiElement : null; }
@Override @NotNull @RequiredReadAction public ResolveResult[] multiResolve(final boolean incompleteCode) { PsiFile containingFile = element.getContainingFile(); if(containingFile == null) { return ResolveResult.EMPTY_ARRAY; } return ResolveCache.getInstance(containingFile.getProject()).resolveWithCaching(this, MyResolver.INSTANCE, true, incompleteCode, containingFile); }
@Override @NotNull public JavaResolveResult[] multiResolve(boolean incompleteCode) { PsiFile file = getContainingFile(); final ResolveCache resolveCache = ResolveCache.getInstance(file.getProject()); ResolveResult[] results = resolveCache.resolveWithCaching(this, Resolver.INSTANCE, true, incompleteCode, file); if(results.length == 0) { return JavaResolveResult.EMPTY_ARRAY; } return (JavaResolveResult[]) results; }