com.intellij.psi.impl.source.resolve.ResolveCache Java Examples
The following examples show how to use
com.intellij.psi.impl.source.resolve.ResolveCache.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSharpPreprocessorReferenceExpressionImpl.java From consulo-csharp with Apache License 2.0 | 6 votes |
@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); }
Example #2
Source File: FusionReferenceBase.java From intellij-neos with GNU General Public License v3.0 | 5 votes |
@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); }
Example #3
Source File: CSharpIndexAccessExpressionImpl.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nonnull @Override @RequiredReadAction public ResolveResult[] multiResolve(boolean incompleteCode) { if(CSharpReferenceExpressionImplUtil.isCacheDisabled(this)) { return OurResolver.INSTANCE.resolve(this, incompleteCode); } return ResolveCache.getInstance(getProject()).resolveWithCaching(this, OurResolver.INSTANCE, true, incompleteCode); }
Example #4
Source File: CSharpOperatorReferenceImpl.java From consulo-csharp with Apache License 2.0 | 5 votes |
@RequiredReadAction @Nonnull @Override public ResolveResult[] multiResolve(boolean incompleteCode) { if(CSharpReferenceExpressionImplUtil.isCacheDisabled(this)) { return OurResolver.INSTANCE.resolve(this, incompleteCode); } return ResolveCache.getInstance(getProject()).resolveWithCaching(this, OurResolver.INSTANCE, false, incompleteCode); }
Example #5
Source File: HaxeResolver.java From intellij-haxe with Apache License 2.0 | 5 votes |
@Override public List<? extends PsiElement> resolve(@NotNull HaxeReference reference, boolean incompleteCode) { // Set this true when debugging the resolver. boolean skipCachingForDebug = false; // Should always be false when checked in. // If we are in dumb mode (e.g. we are still indexing files and resolving may // fail until the indices are complete), we don't want to cache the (likely incorrect) // results. boolean isDumb = DumbService.isDumb(reference.getProject()); boolean skipCaching = skipCachingForDebug || isDumb; List<? extends PsiElement> elements = skipCaching ? doResolve(reference, incompleteCode) : ResolveCache.getInstance(reference.getProject()).resolveWithCaching( reference, this::doResolve,true, incompleteCode); if (reportCacheMetrics) { if (skipCachingForDebug) { LOG.debug("Resolve cache is disabled. No metrics computed."); reportCacheMetrics = false; } else { int dumb = isDumb ? dumbRequests.incrementAndGet() : dumbRequests.get(); int requestCount = isDumb ? requests.get() : requests.incrementAndGet(); if ((dumb + requestCount) % REPORT_FREQUENCY == 0) { int res = resolves.get(); Formatter formatter = new Formatter(); formatter.format("Resolve requests: %d; cache misses: %d; (%2.2f%% effective); Dumb requests: %d", requestCount, res, (1.0 - (Float.intBitsToFloat(res)/Float.intBitsToFloat(requestCount))) * 100, dumb); LOG.debug(formatter.toString()); } } } return elements; }
Example #6
Source File: PsiPolyVariantCachingReference.java From consulo with Apache License 2.0 | 5 votes |
@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); }
Example #7
Source File: CoreProjectEnvironment.java From consulo with Apache License 2.0 | 5 votes |
public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) { myParentDisposable = parentDisposable; myEnvironment = applicationEnvironment; myProject = new MockProject(myEnvironment.getApplication(), myParentDisposable); preregisterServices(); myFileIndexFacade = createFileIndexFacade(); myMessageBus = (MessageBusImpl)myProject.getMessageBus(); PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(applicationEnvironment.getApplication(), myProject); myProject.registerService(PsiModificationTracker.class, modificationTracker); myProject.registerService(FileIndexFacade.class, myFileIndexFacade); myProject.registerService(ResolveCache.class, new ResolveCache(myProject)); registerProjectExtensionPoint(PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class); myPsiManager = new PsiManagerImpl(myProject, () -> myFileIndexFacade, modificationTracker); ((FileManagerImpl)myPsiManager.getFileManager()).markInitialized(); registerProjectComponent(PsiManager.class, myPsiManager); registerProjectComponent(PsiDocumentManager.class, new CorePsiDocumentManager(myProject, 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)); }
Example #8
Source File: MyPsiPolyVariantReference.java From CppTools with Apache License 2.0 | 5 votes |
@NotNull public ResolveResult[] multiResolve(boolean b) { return ResolveCache.getInstance(psiElement.getProject()).resolveWithCaching( this, CppElement.MyResolver.INSTANCE, false, false ); }
Example #9
Source File: GraphQLCachingReference.java From js-graphql-intellij-plugin with MIT License | 4 votes |
@Nullable @Override public PsiElement resolve() { return ResolveCache.getInstance(getElement().getProject()).resolveWithCaching(this, GraphQLCachingReference.MyResolver.INSTANCE, false, false); }
Example #10
Source File: CSharpReferenceExpressionImplUtil.java From consulo-csharp with Apache License 2.0 | 4 votes |
@RequiredReadAction @Nonnull 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(isCacheDisabled(expression)) { resolveResults = resolver.resolve(expression, resolveFromParent); } else { resolveResults = ResolveCache.getInstance(expression.getProject()).resolveWithCaching(expression, resolver, false, resolveFromParent); } if(incompleteCode) { return resolveResults; } else { ResolveResult[] validResults = CSharpResolveUtil.filterValidResults(resolveResults); if(validResults.length > 0) { return validResults; } else if(resolveResults.length > 0) { ResolveToKind kind = expression.kind(); switch(kind) { case CONSTRUCTOR: case METHOD: return resolveResults; } } return ResolveResult.EMPTY_ARRAY; } }
Example #11
Source File: FileReference.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public ResolveResult[] multiResolve(final boolean incompleteCode) { PsiFile file = getElement().getContainingFile(); return ResolveCache.getInstance(file.getProject()).resolveWithCaching(this, MyResolver.INSTANCE, false, false, file); }
Example #12
Source File: CachingReference.java From consulo with Apache License 2.0 | 4 votes |
@Override public PsiElement resolve(){ return ResolveCache.getInstance(getElement().getProject()).resolveWithCaching(this, MyResolver.INSTANCE, false, false); }