PsiPolyVariantCachingReference () { return CachedValuesManager.getCachedValue(this, () -> new CachedValueProvider.Result<>(new PsiPolyVariantCachingReference() { @Override public JavaResolveResult @NotNull [] resolveInner(boolean incompleteCode, @NotNull PsiFile containingFile) { ASTNode classRef = findChildByRole(ChildRole.TYPE_REFERENCE); if (classRef != null) { ASTNode argumentList = PsiImplUtil.skipWhitespaceAndComments(classRef.getTreeNext()); if (argumentList != null && argumentList.getElementType() == JavaElementType.EXPRESSION_LIST) { final JavaPsiFacade facade = JavaPsiFacade.getInstance(containingFile.getProject()); PsiClassType aClass = facade.getElementFactory().createType((PsiJavaCodeReferenceElement)SourceTreeToPsiMap.treeElementToPsi(classRef)); return facade.getResolveHelper().multiResolveConstructor(aClass, (PsiExpressionList)SourceTreeToPsiMap.treeElementToPsi(argumentList), PsiNewExpressionImpl.this); } } else{ ASTNode anonymousClassElement = findChildByType(JavaElementType.ANONYMOUS_CLASS); if (anonymousClassElement != null) { final JavaPsiFacade facade = JavaPsiFacade.getInstance(containingFile.getProject()); final PsiAnonymousClass anonymousClass = (PsiAnonymousClass)SourceTreeToPsiMap.treeElementToPsi(anonymousClassElement); PsiClassType aClass = anonymousClass.getBaseClassType(); ASTNode argumentList = anonymousClassElement.findChildByType(JavaElementType.EXPRESSION_LIST); return facade.getResolveHelper().multiResolveConstructor(aClass, (PsiExpressionList)SourceTreeToPsiMap.treeElementToPsi(argumentList), anonymousClass); } } return JavaResolveResult.EMPTY_ARRAY; } @NotNull @Override public PsiElement getElement() { return PsiNewExpressionImpl.this; } @NotNull @Override public TextRange getRangeInElement() { return null; } @Override @NotNull public String getCanonicalText() { throw new UnsupportedOperationException(); } @Override public PsiElement handleElementRename(@NotNull String newElementName) { return null; } @Override public PsiElement bindToElement(@NotNull PsiElement element) { return null; } @Override public int hashCode() { return getElement().hashCode(); } @Override public boolean equals(Object obj) { return obj instanceof PsiPolyVariantCachingReference && getElement() == ((PsiReference)obj).getElement(); } }, PsiModificationTracker.MODIFICATION_COUNT)); }