anonymous classes converted to lambdas in core and java-psi modules
authornik <Nikolay.Chashnikov@jetbrains.com>
Thu, 16 Feb 2017 14:29:58 +0000 (17:29 +0300)
committernik <Nikolay.Chashnikov@jetbrains.com>
Thu, 16 Feb 2017 14:30:47 +0000 (17:30 +0300)
188 files changed:
java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java
java/java-psi-api/src/com/intellij/codeInsight/ConcurrencyAnnotationsManager.java
java/java-psi-api/src/com/intellij/codeInsight/NullableNotNullManager.java
java/java-psi-api/src/com/intellij/codeInsight/TestFrameworks.java
java/java-psi-api/src/com/intellij/patterns/PsiMethodPattern.java
java/java-psi-api/src/com/intellij/patterns/PsiModifierListOwnerPattern.java
java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
java/java-psi-api/src/com/intellij/psi/PsiAnnotation.java
java/java-psi-api/src/com/intellij/psi/PsiAnnotationMemberValue.java
java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java
java/java-psi-api/src/com/intellij/psi/PsiCatchSection.java
java/java-psi-api/src/com/intellij/psi/PsiClass.java
java/java-psi-api/src/com/intellij/psi/PsiClassInitializer.java
java/java-psi-api/src/com/intellij/psi/PsiClassType.java
java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java
java/java-psi-api/src/com/intellij/psi/PsiExpression.java
java/java-psi-api/src/com/intellij/psi/PsiField.java
java/java-psi-api/src/com/intellij/psi/PsiImportList.java
java/java-psi-api/src/com/intellij/psi/PsiImportStatementBase.java
java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java
java/java-psi-api/src/com/intellij/psi/PsiJavaCodeReferenceElement.java
java/java-psi-api/src/com/intellij/psi/PsiMethod.java
java/java-psi-api/src/com/intellij/psi/PsiNameValuePair.java
java/java-psi-api/src/com/intellij/psi/PsiParameter.java
java/java-psi-api/src/com/intellij/psi/PsiStatement.java
java/java-psi-api/src/com/intellij/psi/PsiType.java
java/java-psi-api/src/com/intellij/psi/PsiTypeElement.java
java/java-psi-api/src/com/intellij/psi/PsiTypeParameter.java
java/java-psi-api/src/com/intellij/psi/augment/PsiAugmentProvider.java
java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
java/java-psi-api/src/com/intellij/psi/util/ClassUtil.java
java/java-psi-api/src/com/intellij/psi/util/ImportsUtil.java
java/java-psi-api/src/com/intellij/psi/util/PsiClassUtil.java
java/java-psi-api/src/com/intellij/psi/util/PsiMethodUtil.java
java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java
java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java
java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java
java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java
java/java-psi-impl/src/com/intellij/codeInsight/JavaPsiEquivalenceUtil.java
java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/ClosureFolding.java
java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java
java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java
java/java-psi-impl/src/com/intellij/psi/NonClasspathClassFinder.java
java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowFactory.java
java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/ElementPresentationUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java
java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/ScopedClassHierarchy.java
java/java-psi-impl/src/com/intellij/psi/impl/TypeCorrector.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsMethodImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsPackageAccessibilityStatementImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsParameterImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java
java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiTypeParameterStubImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/light/LightJavaModule.java
java/java-psi-impl/src/com/intellij/psi/impl/light/LightParameterListWrapper.java
java/java-psi-impl/src/com/intellij/psi/impl/search/MethodSuperSearcher.java
java/java-psi-impl/src/com/intellij/psi/impl/smartPointers/SmartTypePointerManagerImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/ClassInnerStuffCache.java
java/java-psi-impl/src/com/intellij/psi/impl/source/FileLocalResolver.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportListImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStatementImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStaticStatementImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaModuleReference.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaModuleReferenceElementImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiMethodImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocCommentImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocMethodOrFieldRef.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/ProcessCandidateParameterTypeInferencePolicy.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSessionContainer.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariablesOrder.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/CheckedExceptionCompatibilityConstraint.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/LambdaExpressionCompatibilityConstraint.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaSharedImplUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiAnnotationImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBinaryExpressionImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCatchSectionImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPolyadicExpressionImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
java/java-psi-impl/src/com/intellij/refactoring/util/CanonicalTypes.java
platform/core-api/src/com/intellij/codeInsight/PsiEquivalenceUtil.java
platform/core-api/src/com/intellij/lang/LanguageUtil.java
platform/core-api/src/com/intellij/openapi/application/QueryExecutorBase.java
platform/core-api/src/com/intellij/openapi/application/ReadAction.java
platform/core-api/src/com/intellij/openapi/application/ReadActionProcessor.java
platform/core-api/src/com/intellij/openapi/application/WriteAction.java
platform/core-api/src/com/intellij/openapi/command/WriteCommandAction.java
platform/core-api/src/com/intellij/openapi/components/ServiceManager.java
platform/core-api/src/com/intellij/openapi/editor/event/DocumentListener.java
platform/core-api/src/com/intellij/openapi/progress/NonCancelableSection.java
platform/core-api/src/com/intellij/openapi/project/DumbService.java
platform/core-api/src/com/intellij/openapi/util/ActionCallback.java
platform/core-api/src/com/intellij/openapi/util/AsyncResult.java
platform/core-api/src/com/intellij/openapi/util/BusyObject.java
platform/core-api/src/com/intellij/openapi/util/TimedOutCallback.java
platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
platform/core-api/src/com/intellij/patterns/StandardPatterns.java
platform/core-api/src/com/intellij/psi/LanguageSubstitutors.java
platform/core-api/src/com/intellij/psi/PsiElement.java
platform/core-api/src/com/intellij/psi/PsiReference.java
platform/core-api/src/com/intellij/psi/PsiReferenceProviderBean.java
platform/core-api/src/com/intellij/psi/SyntaxTraverser.java
platform/core-api/src/com/intellij/psi/impl/ElementBase.java
platform/core-api/src/com/intellij/psi/search/GlobalSearchScope.java
platform/core-api/src/com/intellij/psi/search/LocalSearchScope.java
platform/core-api/src/com/intellij/psi/search/NonClasspathDirectoriesScope.java
platform/core-api/src/com/intellij/psi/search/ProjectScope.java
platform/core-api/src/com/intellij/psi/tree/IElementType.java
platform/core-api/src/com/intellij/psi/util/CachedValuesManager.java
platform/core-api/src/com/intellij/psi/util/PsiUtilCore.java
platform/core-api/src/com/intellij/util/FileContentUtilCore.java
platform/core-api/src/com/intellij/util/IconUtil.java
platform/core-api/src/com/intellij/util/PathsList.java
platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java
platform/core-impl/src/com/intellij/diagnostic/PerformanceWatcher.java
platform/core-impl/src/com/intellij/extapi/psi/ASTDelegatePsiElement.java
platform/core-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java
platform/core-impl/src/com/intellij/ide/plugins/PluginClassCache.java
platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
platform/core-impl/src/com/intellij/ide/plugins/PluginXmlPathResolver.java
platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java
platform/core-impl/src/com/intellij/mock/MockProject.java
platform/core-impl/src/com/intellij/openapi/application/TransactionGuardImpl.java
platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java
platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java
platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java
platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java
platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java
platform/core-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java
platform/core-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java
platform/core-impl/src/com/intellij/openapi/progress/impl/CoreProgressManager.java
platform/core-impl/src/com/intellij/openapi/vfs/impl/ZipEntryMap.java
platform/core-impl/src/com/intellij/pom/core/impl/PomModelImpl.java
platform/core-impl/src/com/intellij/psi/MultiplePsiFilesPerDocumentFileViewProvider.java
platform/core-impl/src/com/intellij/psi/PsiAnchor.java
platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java
platform/core-impl/src/com/intellij/psi/impl/DebugUtil.java
platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java
platform/core-impl/src/com/intellij/psi/impl/PsiCachedValue.java
platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
platform/core-impl/src/com/intellij/psi/impl/PsiModificationTrackerImpl.java
platform/core-impl/src/com/intellij/psi/impl/PsiToDocumentSynchronizer.java
platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java
platform/core-impl/src/com/intellij/psi/impl/meta/MetaRegistry.java
platform/core-impl/src/com/intellij/psi/impl/smartPointers/MarkerCache.java
platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java
platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerTracker.java
platform/core-impl/src/com/intellij/psi/impl/source/AstPathPsiMap.java
platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
platform/core-impl/src/com/intellij/psi/impl/source/resolve/ResolveCache.java
platform/core-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/PsiMultiReference.java
platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java
platform/core-impl/src/com/intellij/psi/impl/source/tree/LightTreeUtil.java
platform/core-impl/src/com/intellij/psi/stubs/StubTree.java
platform/core-impl/src/com/intellij/psi/stubs/StubTreeBuilder.java
platform/core-impl/src/com/intellij/psi/stubs/StubTreeLoader.java
platform/core-impl/src/com/intellij/util/CachedValueLeakChecker.java
platform/core-impl/src/com/intellij/util/DebugReflectionUtil.java
platform/core-impl/src/com/intellij/util/DocumentUtil.java
platform/core-impl/src/com/intellij/util/SofterReference.java
platform/core-impl/src/com/intellij/util/profiling/ProfileViewer.java
platform/core-impl/src/org/jetbrains/ide/script/Jsr223IdeScriptEngineManagerImpl.java
platform/extensions/src/com/intellij/openapi/extensions/SmartExtensionPoint.java
platform/extensions/src/com/intellij/openapi/extensions/SortingException.java
platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionsAreaImpl.java
platform/extensions/src/com/intellij/util/pico/CachingConstructorInjectionComponentAdapter.java

index 167fb4de8dc4782cbaad9d66eb3ab5007bc2b549..fe2c6f2efbc9a873855329bfd259d0a72cbfe848 100644 (file)
@@ -120,26 +120,22 @@ public class AnnotationUtil {
   private static PsiAnnotation findOwnAnnotation(final PsiModifierListOwner listOwner, Collection<String> annotationNames) {
     ConcurrentFactoryMap<Collection<String>, PsiAnnotation> map = CachedValuesManager.getCachedValue(
       listOwner,
-      new CachedValueProvider<ConcurrentFactoryMap<Collection<String>, PsiAnnotation>>() {
-        @Nullable
-        @Override
-        public Result<ConcurrentFactoryMap<Collection<String>, PsiAnnotation>> compute() {
-          ConcurrentFactoryMap<Collection<String>, PsiAnnotation> value = new ConcurrentFactoryMap<Collection<String>, PsiAnnotation>() {
-            @Nullable
-            @Override
-            protected PsiAnnotation create(Collection<String> annotationNames) {
-              final PsiModifierList list = listOwner.getModifierList();
-              if (list == null) return null;
-              for (PsiAnnotation annotation : list.getAnnotations()) {
-                if (annotationNames.contains(annotation.getQualifiedName())) {
-                  return annotation;
-                }
+      () -> {
+        ConcurrentFactoryMap<Collection<String>, PsiAnnotation> value = new ConcurrentFactoryMap<Collection<String>, PsiAnnotation>() {
+          @Nullable
+          @Override
+          protected PsiAnnotation create(Collection<String> annotationNames1) {
+            final PsiModifierList list = listOwner.getModifierList();
+            if (list == null) return null;
+            for (PsiAnnotation annotation : list.getAnnotations()) {
+              if (annotationNames1.contains(annotation.getQualifiedName())) {
+                return annotation;
               }
-              return null;
             }
-          };
-          return Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
-        }
+            return null;
+          }
+        };
+        return CachedValueProvider.Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
       });
     return map.get(annotationNames);
   }
@@ -147,35 +143,31 @@ public class AnnotationUtil {
   private static PsiAnnotation findNonCodeAnnotation(final PsiModifierListOwner listOwner, Collection<String> annotationNames) {
     ConcurrentFactoryMap<Collection<String>, PsiAnnotation> map = CachedValuesManager.getCachedValue(
       listOwner,
-      new CachedValueProvider<ConcurrentFactoryMap<Collection<String>, PsiAnnotation>>() {
-        @Nullable
-        @Override
-        public Result<ConcurrentFactoryMap<Collection<String>, PsiAnnotation>> compute() {
-          ConcurrentFactoryMap<Collection<String>, PsiAnnotation> value = new ConcurrentFactoryMap<Collection<String>, PsiAnnotation>() {
-            @Nullable
-            @Override
-            protected PsiAnnotation create(Collection<String> annotationNames) {
-              final Project project = listOwner.getProject();
-              final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
-              for (String annotationName : annotationNames) {
-                final PsiAnnotation annotation = annotationsManager.findExternalAnnotation(listOwner, annotationName);
-                if (annotation != null) {
-                  return annotation;
-                }
+      () -> {
+        ConcurrentFactoryMap<Collection<String>, PsiAnnotation> value = new ConcurrentFactoryMap<Collection<String>, PsiAnnotation>() {
+          @Nullable
+          @Override
+          protected PsiAnnotation create(Collection<String> annotationNames1) {
+            final Project project = listOwner.getProject();
+            final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
+            for (String annotationName : annotationNames1) {
+              final PsiAnnotation annotation = annotationsManager.findExternalAnnotation(listOwner, annotationName);
+              if (annotation != null) {
+                return annotation;
               }
-              final InferredAnnotationsManager inferredAnnotationsManager = InferredAnnotationsManager.getInstance(project);
-              for (String annotationName : annotationNames) {
-                final PsiAnnotation annotation = inferredAnnotationsManager.findInferredAnnotation(listOwner, annotationName);
-                if (annotation != null) {
-                  return annotation;
-                }
+            }
+            final InferredAnnotationsManager inferredAnnotationsManager = InferredAnnotationsManager.getInstance(project);
+            for (String annotationName : annotationNames1) {
+              final PsiAnnotation annotation = inferredAnnotationsManager.findInferredAnnotation(listOwner, annotationName);
+              if (annotation != null) {
+                return annotation;
               }
-              return null;
-
             }
-          };
-          return Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
-        }
+            return null;
+
+          }
+        };
+        return CachedValueProvider.Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
       });
     return map.get(annotationNames);
   }
@@ -197,29 +189,25 @@ public class AnnotationUtil {
   }
 
   public static <T extends PsiModifierListOwner> List<T> getSuperAnnotationOwners(final T element) {
-    return CachedValuesManager.getCachedValue(element, new CachedValueProvider<List<T>>() {
-      @Nullable
-      @Override
-      public Result<List<T>> compute() {
-        Set<PsiModifierListOwner> result = ContainerUtil.newLinkedHashSet();
-        if (element instanceof PsiMethod) {
-          collectSuperMethods(result, ((PsiMethod)element).getHierarchicalMethodSignature(), element,
-                              JavaPsiFacade.getInstance(element.getProject()).getResolveHelper());
-        }
-        else if (element instanceof PsiClass) {
-          //noinspection unchecked
-          InheritanceUtil.processSupers((PsiClass)element, false, (Processor)Processors.cancelableCollectProcessor(result));
-        }
-        else if (element instanceof PsiParameter) {
-          collectSuperParameters(result, (PsiParameter)element);
-        }
-
-        List<T> list = new ArrayList<T>();
+    return CachedValuesManager.getCachedValue(element, () -> {
+      Set<PsiModifierListOwner> result = ContainerUtil.newLinkedHashSet();
+      if (element instanceof PsiMethod) {
+        collectSuperMethods(result, ((PsiMethod)element).getHierarchicalMethodSignature(), element,
+                            JavaPsiFacade.getInstance(element.getProject()).getResolveHelper());
+      }
+      else if (element instanceof PsiClass) {
         //noinspection unchecked
-        list.addAll((Collection<? extends T>)result);
-        
-        return Result.create(list, PsiModificationTracker.MODIFICATION_COUNT);
+        InheritanceUtil.processSupers((PsiClass)element, false, (Processor)Processors.cancelableCollectProcessor(result));
       }
+      else if (element instanceof PsiParameter) {
+        collectSuperParameters(result, (PsiParameter)element);
+      }
+
+      List<T> list = new ArrayList<T>();
+      //noinspection unchecked
+      list.addAll((Collection<? extends T>)result);
+
+      return CachedValueProvider.Result.create(list, PsiModificationTracker.MODIFICATION_COUNT);
     });
   }
 
@@ -230,25 +218,21 @@ public class AnnotationUtil {
 
     ConcurrentFactoryMap<Set<String>, PsiAnnotation> map = CachedValuesManager.getCachedValue(
       listOwner,
-      new CachedValueProvider<ConcurrentFactoryMap<Set<String>, PsiAnnotation>>() {
-        @Nullable
-        @Override
-        public Result<ConcurrentFactoryMap<Set<String>, PsiAnnotation>> compute() {
-          ConcurrentFactoryMap<Set<String>, PsiAnnotation> value = new ConcurrentFactoryMap<Set<String>, PsiAnnotation>() {
-            @Nullable
-            @Override
-            protected PsiAnnotation create(Set<String> annotationNames) {
-              for (PsiModifierListOwner superOwner : getSuperAnnotationOwners(listOwner)) {
-                PsiAnnotation annotation = findAnnotation(superOwner, annotationNames);
-                if (annotation != null) {
-                  return annotation;
-                }
+      () -> {
+        ConcurrentFactoryMap<Set<String>, PsiAnnotation> value = new ConcurrentFactoryMap<Set<String>, PsiAnnotation>() {
+          @Nullable
+          @Override
+          protected PsiAnnotation create(Set<String> annotationNames1) {
+            for (PsiModifierListOwner superOwner : getSuperAnnotationOwners(listOwner)) {
+              PsiAnnotation annotation = findAnnotation(superOwner, annotationNames1);
+              if (annotation != null) {
+                return annotation;
               }
-              return null;
             }
-          };
-          return Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
-        }
+            return null;
+          }
+        };
+        return CachedValueProvider.Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
       });
     return map.get(annotationNames);
   }
@@ -259,13 +243,10 @@ public class AnnotationUtil {
       return;
     }
     final int index = ((PsiParameterList)parent).getParameterIndex(parameter);
-    Consumer<PsiMethod> forEachSuperMethod = new Consumer<PsiMethod>() {
-      @Override
-      public void consume(PsiMethod method) {
-        PsiParameter[] superParameters = method.getParameterList().getParameters();
-        if (index < superParameters.length) {
-          result.add(superParameters[index]);
-        }
+    Consumer<PsiMethod> forEachSuperMethod = method -> {
+      PsiParameter[] superParameters = method.getParameterList().getParameters();
+      if (index < superParameters.length) {
+        result.add(superParameters[index]);
       }
     };
 
index dc84164c2eb39fdaeddaa57a284165ca03f93ce0..244f8130d3f6230abbfd4341cb74e30f0a09654b 100644 (file)
@@ -45,12 +45,7 @@ public class ConcurrencyAnnotationsManager {
   }
 
   private static void fillDefaults(List<String> list, final String annoName) {
-    list.addAll(ContainerUtil.map(FRAMEWORKS, new Function<String, String>() {
-      @Override
-      public String fun(String framework) {
-        return framework + "." + annoName;
-      }
-    }));
+    list.addAll(ContainerUtil.map(FRAMEWORKS, framework -> framework + "." + annoName));
   }
 
   public static ConcurrencyAnnotationsManager getInstance(Project project) {
index 51e152ad6a6e02ce69d5183c1cb535a2ec4c8049..a76f94a18aae3eaea4a4b2bcd74227bdca60a09f 100644 (file)
@@ -230,15 +230,12 @@ public abstract class NullableNotNullManager {
   }
 
   private PsiAnnotation takeAnnotationFromSuperParameters(@NotNull PsiParameter owner, final List<PsiParameter> superOwners) {
-    return RecursionManager.doPreventingRecursion(owner, true, new Computable<PsiAnnotation>() {
-      @Override
-      public PsiAnnotation compute() {
-        for (PsiParameter superOwner : superOwners) {
-          PsiAnnotation anno = findNullabilityAnnotationWithDefault(superOwner, false, false);
-          if (anno != null) return anno;
-        }
-        return null;
+    return RecursionManager.doPreventingRecursion(owner, true, () -> {
+      for (PsiParameter superOwner : superOwners) {
+        PsiAnnotation anno = findNullabilityAnnotationWithDefault(superOwner, false, false);
+        if (anno != null) return anno;
       }
+      return null;
     });
   }
 
index f481de563b3be197cc33da2770be75d30e24cd02..45bd2c4c4bc097800abcb03f38ae9372909530bc 100644 (file)
@@ -56,13 +56,8 @@ public abstract class TestFrameworks {
   
   @Nullable
   public static TestFramework detectFramework(@NotNull final PsiClass psiClass) {
-    return CachedValuesManager.getCachedValue(psiClass, new CachedValueProvider<TestFramework>() {
-      @Nullable
-      @Override
-      public Result<TestFramework> compute() {
-        return Result.create(computeFramework(psiClass), PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
-      }
-    });
+    return CachedValuesManager.getCachedValue(psiClass, () -> CachedValueProvider.Result
+      .create(computeFramework(psiClass), PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT));
   }
 
   @Nullable
index cd62b8a3478d6c5029581d46e019b08b88f78fa3..1bbd32a9f62254161f249fe1b2e545fb87816c5c 100644 (file)
@@ -108,15 +108,12 @@ public class PsiMethodPattern extends PsiMemberPattern<PsiMethod,PsiMethodPatter
       public boolean processValues(PsiMethod t, final ProcessingContext context, final PairProcessor<PsiClass, ProcessingContext> processor) {
         if (!processor.process(t.getContainingClass(), context)) return false;
         final Ref<Boolean> result = Ref.create(Boolean.TRUE);
-        SuperMethodsSearch.search(t, null, true, false).forEach(new Processor<MethodSignatureBackedByPsiMethod>() {
-          @Override
-          public boolean process(final MethodSignatureBackedByPsiMethod signature) {
-            if (!processor.process(signature.getMethod().getContainingClass(), context)) {
-              result.set(Boolean.FALSE);
-              return false;
-            }
-            return true;
+        SuperMethodsSearch.search(t, null, true, false).forEach(signature -> {
+          if (!processor.process(signature.getMethod().getContainingClass(), context)) {
+            result.set(Boolean.FALSE);
+            return false;
           }
+          return true;
         });
         return result.get();
       }
index 4fd3ae1e6ce4442d708da97dca8188faa5321897..2e7927ef1afe722678e5a3350c794b4531378ff8 100644 (file)
@@ -39,11 +39,7 @@ public class PsiModifierListOwnerPattern<T extends PsiModifierListOwner, Self ex
   public Self withModifiers(final String... modifiers) {
     return with(new PatternCondition<T>("withModifiers") {
       public boolean accepts(@NotNull final T t, final ProcessingContext context) {
-        return ContainerUtil.and(modifiers, new Condition<String>() {
-          public boolean value(final String s) {
-            return t.hasModifierProperty(s);
-          }
-        });
+        return ContainerUtil.and(modifiers, s -> t.hasModifierProperty(s));
       }
     });
   }
@@ -51,11 +47,7 @@ public class PsiModifierListOwnerPattern<T extends PsiModifierListOwner, Self ex
   public Self withoutModifiers(final String... modifiers) {
     return with(new PatternCondition<T>("withoutModifiers") {
       public boolean accepts(@NotNull final T t, final ProcessingContext context) {
-        return ContainerUtil.and(modifiers, new Condition<String>() {
-          public boolean value(final String s) {
-            return !t.hasModifierProperty(s);
-          }
-        });
+        return ContainerUtil.and(modifiers, s -> !t.hasModifierProperty(s));
       }
     });
   }
index 45605b6c727df6c44bd577bfcab2a5e0dd28e637..4dbc2d7853d78fa1503272ab4de6d0a67fc5a7f3 100644 (file)
@@ -405,12 +405,7 @@ public class GenericsUtil {
     final List<PsiType> result = new ArrayList<PsiType>(substitutionMap.size());
     for (PsiTypeParameter typeParameter : psiClass.getTypeParameters()) {
       final String name = typeParameter.getName();
-      final PsiTypeParameter key = ContainerUtil.find(substitutionMap.keySet(), new Condition<PsiTypeParameter>() {
-        @Override
-        public boolean value(final PsiTypeParameter psiTypeParameter) {
-          return name.equals(psiTypeParameter.getName());
-        }
-      });
+      final PsiTypeParameter key = ContainerUtil.find(substitutionMap.keySet(), psiTypeParameter -> name.equals(psiTypeParameter.getName()));
       if (key != null) {
         result.add(substitutionMap.get(key));
       }
index 53530f2dc71c847286fe379c25549713c0f2cda3..a7c5d1a2fb8bb0cea859fcc58036fcf50028fa81 100644 (file)
@@ -170,12 +170,8 @@ public class LambdaUtil {
   @Nullable
   public static MethodSignature getFunction(final PsiClass psiClass) {
     if (isPlainInterface(psiClass)) {
-      return CachedValuesManager.getCachedValue(psiClass, new CachedValueProvider<MethodSignature>() {
-        @Override
-        public Result<MethodSignature> compute() {
-          return Result.create(calcFunction(psiClass), PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
-        }
-      });
+      return CachedValuesManager.getCachedValue(psiClass, () -> CachedValueProvider.Result
+        .create(calcFunction(psiClass), PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT));
     }
     return null;
   }
@@ -213,19 +209,16 @@ public class LambdaUtil {
   private static boolean hasManyInheritedAbstractMethods(@NotNull PsiClass psiClass) {
     final Set<String> abstractNames = ContainerUtil.newHashSet();
     final Set<String> defaultNames = ContainerUtil.newHashSet();
-    InheritanceUtil.processSupers(psiClass, true, new Processor<PsiClass>() {
-      @Override
-      public boolean process(PsiClass psiClass) {
-        for (PsiMethod method : psiClass.getMethods()) {
-          if (isDefinitelyAbstractInterfaceMethod(method)) {
-            abstractNames.add(method.getName());
-          }
-          else if (method.hasModifierProperty(PsiModifier.DEFAULT)) {
-            defaultNames.add(method.getName());
-          }
+    InheritanceUtil.processSupers(psiClass, true, psiClass1 -> {
+      for (PsiMethod method : psiClass1.getMethods()) {
+        if (isDefinitelyAbstractInterfaceMethod(method)) {
+          abstractNames.add(method.getName());
+        }
+        else if (method.hasModifierProperty(PsiModifier.DEFAULT)) {
+          defaultNames.add(method.getName());
         }
-        return true;
       }
+      return true;
     });
     abstractNames.removeAll(defaultNames);
     return abstractNames.size() > 1;
@@ -466,16 +459,13 @@ public class LambdaUtil {
       final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, (PsiMethod)resolve, parameters);
       if (finalLambdaIdx < parameters.length) {
         if (!tryToSubstitute) return getNormalizedType(parameters[finalLambdaIdx]);
-        return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, !MethodCandidateInfo.isOverloadCheck(), new Computable<PsiType>() {
-          @Override
-          public PsiType compute() {
-            final PsiType normalizedType = getNormalizedType(parameters[finalLambdaIdx]);
-            if (resolveResult instanceof MethodCandidateInfo && ((MethodCandidateInfo)resolveResult).isRawSubstitution()) {
-              return TypeConversionUtil.erasure(normalizedType);
-            }
-            else {
-              return resolveResult.getSubstitutor().substitute(normalizedType);
-            }
+        return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, !MethodCandidateInfo.isOverloadCheck(), () -> {
+          final PsiType normalizedType = getNormalizedType(parameters[finalLambdaIdx]);
+          if (resolveResult instanceof MethodCandidateInfo && ((MethodCandidateInfo)resolveResult).isRawSubstitution()) {
+            return TypeConversionUtil.erasure(normalizedType);
+          }
+          else {
+            return resolveResult.getSubstitutor().substitute(normalizedType);
           }
         });
       }
@@ -739,12 +729,7 @@ public class LambdaUtil {
     else if (functionalInterfaceReturnType != null) {
       final List<PsiExpression> returnExpressions = getReturnExpressions(lambdaExpression);
       for (final PsiExpression expression : returnExpressions) {
-        final PsiType expressionType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, true, new Computable<PsiType>() {
-          @Override
-          public PsiType compute() {
-            return expression.getType();
-          }
-        });
+        final PsiType expressionType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, true, () -> expression.getType());
         if (expressionType != null && !functionalInterfaceReturnType.isAssignableFrom(expressionType)) {
           errors.put(expression, "Bad return type in lambda expression: " + expressionType.getPresentableText() + " cannot be converted to " + functionalInterfaceReturnType.getPresentableText());
         }
@@ -888,12 +873,7 @@ public class LambdaUtil {
       for (PsiTypeParameter parameter : typeParameters) {
         final PsiClassType[] types = parameter.getExtendsListTypes();
         if (types.length > 0) {
-          final List<PsiType> conjuncts = ContainerUtil.map(types, new Function<PsiClassType, PsiType>() {
-            @Override
-            public PsiType fun(PsiClassType type) {
-              return substitutor.substitute(type);
-            }
-          });
+          final List<PsiType> conjuncts = ContainerUtil.map(types, type -> substitutor.substitute(type));
           //don't glb to avoid flattening = Object&Interface would be preserved
           //otherwise methods with different signatures could get same erasure
           final PsiType upperBound = PsiIntersectionType.createIntersection(false, conjuncts.toArray(new PsiType[conjuncts.size()]));
index 631b70802154ea4d3577c876a15885cd2020bbc8..c84f5080631b8d35e3bd9cc827a03ad5ad27f904 100644 (file)
@@ -32,13 +32,7 @@ public interface PsiAnnotation extends PsiAnnotationMemberValue, PsiMetaOwner {
    */
   PsiAnnotation[] EMPTY_ARRAY = new PsiAnnotation[0];
 
-  ArrayFactory<PsiAnnotation> ARRAY_FACTORY = new ArrayFactory<PsiAnnotation>() {
-    @NotNull
-    @Override
-    public PsiAnnotation[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiAnnotation[count];
-    }
-  };
+  ArrayFactory<PsiAnnotation> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiAnnotation[count];
 
   @NonNls String DEFAULT_REFERENCED_METHOD_NAME = "value";
 
index 0788fee661be02ab1e08525f4a405f35af39cb54..adec9ead9206260d8862d7f54683a40cb7f66d10 100644 (file)
@@ -29,11 +29,5 @@ public interface PsiAnnotationMemberValue extends PsiElement {
    */
   PsiAnnotationMemberValue[] EMPTY_ARRAY = new PsiAnnotationMemberValue[0];
 
-  ArrayFactory<PsiAnnotationMemberValue> ARRAY_FACTORY = new ArrayFactory<PsiAnnotationMemberValue>() {
-    @NotNull
-    @Override
-    public PsiAnnotationMemberValue[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiAnnotationMemberValue[count];
-    }
-  };
+  ArrayFactory<PsiAnnotationMemberValue> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiAnnotationMemberValue[count];
 }
index bc7d2c74ec5c65f2f95958e49ffc7f7ecda31eb2..bf3b6a65e519dda9a2257c57c3268021bf041752 100644 (file)
@@ -112,12 +112,8 @@ public class PsiCapturedWildcardType extends PsiType.Stub {
     }
 
     if (myParameter != null) {
-      final Boolean sameUpperBounds = guard.doPreventingRecursion(myContext, true, new Computable<Boolean>() {
-        @Override
-        public Boolean compute() {
-          return Comparing.equal(myUpperBound, captured.myUpperBound);
-        }
-      });
+      final Boolean sameUpperBounds = guard.doPreventingRecursion(myContext, true,
+                                                                  () -> Comparing.equal(myUpperBound, captured.myUpperBound));
 
       if (sameUpperBounds == null || sameUpperBounds) {
         return true;
index 9bf9f15c0473b2ed76dc8d1e4157dc606fed977a..37050da2914b0d381154b8aa56ac66a1ad228ac8 100644 (file)
@@ -32,13 +32,7 @@ public interface PsiCatchSection extends PsiElement {
    */
   PsiCatchSection[] EMPTY_ARRAY = new PsiCatchSection[0];
 
-  ArrayFactory<PsiCatchSection> ARRAY_FACTORY = new ArrayFactory<PsiCatchSection>() {
-    @NotNull
-    @Override
-    public PsiCatchSection[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiCatchSection[count];
-    }
-  };
+  ArrayFactory<PsiCatchSection> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiCatchSection[count];
 
   /**
    * Returns the variable in which the caught exception is captured.
index a60d56a725cdca5296962c6430a0950874b7a058..017f69a34747be351a0494fc5c67cb988facb55d 100644 (file)
@@ -38,13 +38,7 @@ public interface PsiClass
    */
   @NotNull PsiClass[] EMPTY_ARRAY = new PsiClass[0];
 
-  ArrayFactory<PsiClass> ARRAY_FACTORY = new ArrayFactory<PsiClass>() {
-    @NotNull
-    @Override
-    public PsiClass[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiClass[count];
-    }
-  };
+  ArrayFactory<PsiClass> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiClass[count];
 
   /**
    * Returns the fully qualified name of the class.
index 7fa1639cd4203d1e39b4bdc2b05d61ab4c1456f2..36354b6829d56c8a13debab9f1a3615f2005ae8a 100644 (file)
@@ -27,13 +27,7 @@ public interface PsiClassInitializer extends PsiMember {
    */
   PsiClassInitializer[] EMPTY_ARRAY = new PsiClassInitializer[0];
 
-  ArrayFactory<PsiClassInitializer> ARRAY_FACTORY = new ArrayFactory<PsiClassInitializer>() {
-    @NotNull
-    @Override
-    public PsiClassInitializer[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiClassInitializer[count];
-    }
-  };
+  ArrayFactory<PsiClassInitializer> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiClassInitializer[count];
 
   /**
    * Returns the contents of the class initializer block.
index 38c9978c7ad0a1af645aea09b4bbc84bcd6130ca..40715e11ffb9585f59ac14bfcc7557d65b9b45f3 100644 (file)
@@ -31,13 +31,7 @@ import org.jetbrains.annotations.Nullable;
  */
 public abstract class PsiClassType extends PsiType {
   public static final PsiClassType[] EMPTY_ARRAY = new PsiClassType[0];
-  public static final ArrayFactory<PsiClassType> ARRAY_FACTORY = new ArrayFactory<PsiClassType>() {
-    @NotNull
-    @Override
-    public PsiClassType[] create(int count) {
-      return new PsiClassType[count];
-    }
-  };
+  public static final ArrayFactory<PsiClassType> ARRAY_FACTORY = count -> new PsiClassType[count];
 
   protected final LanguageLevel myLanguageLevel;
 
index d09510d1cd26c5fe1a403ad8fdfbe80b48c55adc..922e88dbe497a22ac0e9e1d18e753f20b0d4ee4b 100644 (file)
@@ -44,19 +44,16 @@ public class PsiDisjunctionType extends PsiType.Stub {
     myManager = psiManager;
     myTypes = Collections.unmodifiableList(types);
 
-    myLubCache = CachedValuesManager.getManager(myManager.getProject()).createCachedValue(new CachedValueProvider<PsiType>() {
-      @Override
-      public Result<PsiType> compute() {
-        PsiType lub = myTypes.get(0);
-        for (int i = 1; i < myTypes.size(); i++) {
-          lub = GenericsUtil.getLeastUpperBound(lub, myTypes.get(i), myManager);
-          if (lub == null) {
-            lub = PsiType.getJavaLangObject(myManager, GlobalSearchScope.allScope(myManager.getProject()));
-            break;
-          }
+    myLubCache = CachedValuesManager.getManager(myManager.getProject()).createCachedValue(() -> {
+      PsiType lub = myTypes.get(0);
+      for (int i = 1; i < myTypes.size(); i++) {
+        lub = GenericsUtil.getLeastUpperBound(lub, myTypes.get(i), myManager);
+        if (lub == null) {
+          lub = PsiType.getJavaLangObject(myManager, GlobalSearchScope.allScope(myManager.getProject()));
+          break;
         }
-        return Result.create(lub, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
       }
+      return CachedValueProvider.Result.create(lub, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
     }, false);
   }
 
@@ -84,34 +81,19 @@ public class PsiDisjunctionType extends PsiType.Stub {
   @NotNull
   @Override
   public String getPresentableText(final boolean annotated) {
-    return StringUtil.join(myTypes, new Function<PsiType, String>() {
-      @Override
-      public String fun(PsiType psiType) {
-        return psiType.getPresentableText(annotated);
-      }
-    }, " | ");
+    return StringUtil.join(myTypes, psiType -> psiType.getPresentableText(annotated), " | ");
   }
 
   @NotNull
   @Override
   public String getCanonicalText(final boolean annotated) {
-    return StringUtil.join(myTypes, new Function<PsiType, String>() {
-      @Override
-      public String fun(PsiType psiType) {
-        return psiType.getCanonicalText(annotated);
-      }
-    }, " | ");
+    return StringUtil.join(myTypes, psiType -> psiType.getCanonicalText(annotated), " | ");
   }
 
   @NotNull
   @Override
   public String getInternalCanonicalText() {
-    return StringUtil.join(myTypes, new Function<PsiType, String>() {
-      @Override
-      public String fun(PsiType psiType) {
-        return psiType.getInternalCanonicalText();
-      }
-    }, " | ");
+    return StringUtil.join(myTypes, psiType -> psiType.getInternalCanonicalText(), " | ");
   }
 
   @Override
index 6f7fdf3eea8fbb48b57f962a6de066e184f81189..80dcd4d0699405a6389ac7ec48683c40801fdf2d 100644 (file)
@@ -30,20 +30,9 @@ public interface PsiExpression extends PsiAnnotationMemberValue {
    */
   PsiExpression[] EMPTY_ARRAY = new PsiExpression[0];
 
-  ArrayFactory<PsiExpression> ARRAY_FACTORY = new ArrayFactory<PsiExpression>() {
-    @NotNull
-    @Override
-    public PsiExpression[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiExpression[count];
-    }
-  };
+  ArrayFactory<PsiExpression> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiExpression[count];
 
-  Function<PsiExpression, PsiType> EXPRESSION_TO_TYPE = new NullableFunction<PsiExpression, PsiType>() {
-    @Override
-    public PsiType fun(final PsiExpression expression) {
-      return expression.getType();
-    }
-  };
+  Function<PsiExpression, PsiType> EXPRESSION_TO_TYPE = (NullableFunction<PsiExpression, PsiType>)expression -> expression.getType();
 
   /**
    * Returns the type of the expression.
index 01030e2fc5bc13fdb4221f66cdceb891a604c6f1..7a40d47408fd1e2e4242a7a669e0fad0576d03ac 100644 (file)
@@ -29,13 +29,7 @@ public interface PsiField extends PsiMember, PsiVariable, PsiDocCommentOwner {
    */
   PsiField[] EMPTY_ARRAY = new PsiField[0];
 
-  ArrayFactory<PsiField> ARRAY_FACTORY = new ArrayFactory<PsiField>() {
-    @NotNull
-    @Override
-    public PsiField[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiField[count];
-    }
-  };
+  ArrayFactory<PsiField> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiField[count];
 
   /**
    * Adds initializer to the field declaration or, if {@code initializer} parameter is null,
index 670f43556d62e037bd0d8c1ce7fc08dbd8b9025f..9d4964a66f959746e7dcd60a0f75fb5582eb9357 100644 (file)
@@ -27,13 +27,7 @@ import org.jetbrains.annotations.Nullable;
  */
 public interface PsiImportList extends PsiElement {
   PsiImportList[] EMPTY_ARRAY = new PsiImportList[0];
-  ArrayFactory<PsiImportList> ARRAY_FACTORY = new ArrayFactory<PsiImportList>() {
-    @NotNull
-    @Override
-    public PsiImportList[] create(int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiImportList[count];
-    }
-  };
+  ArrayFactory<PsiImportList> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiImportList[count];
 
   /**
    * Returns the non-static import statements contained in the list.
index bbf8a1595bd313fe45a3f49e53d6a975c1ebd150..e70d41e77a2832b249841f37833cece0ae46090b 100644 (file)
@@ -30,13 +30,7 @@ public interface PsiImportStatementBase extends PsiElement {
    */
   PsiImportStatementBase[] EMPTY_ARRAY = new PsiImportStatementBase[0];
 
-  ArrayFactory<PsiImportStatementBase> ARRAY_FACTORY = new ArrayFactory<PsiImportStatementBase>() {
-    @NotNull
-    @Override
-    public PsiImportStatementBase[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiImportStatementBase[count];
-    }
-  };
+  ArrayFactory<PsiImportStatementBase> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiImportStatementBase[count];
 
   /**
    * Checks if the statement represents a single element or on-demand import.
index 4968aa676b2d3057bb2ce5daa608abb7cb919dde..d92fba8c8b3b76b75cae3899536e888c7c676a6c 100644 (file)
@@ -61,12 +61,7 @@ public class PsiIntersectionType extends PsiType.Stub {
 
   private static PsiType[] flattenAndRemoveDuplicates(final PsiType[] conjuncts) {
     try {
-      final Set<PsiType> flattenConjuncts = PsiCapturedWildcardType.guard.doPreventingRecursion(conjuncts, true, new Computable<Set<PsiType>>() {
-        @Override
-        public Set<PsiType> compute() {
-          return flatten(conjuncts, ContainerUtil.<PsiType>newLinkedHashSet());
-        }
-      });
+      final Set<PsiType> flattenConjuncts = PsiCapturedWildcardType.guard.doPreventingRecursion(conjuncts, true, () -> flatten(conjuncts, ContainerUtil.<PsiType>newLinkedHashSet()));
       if (flattenConjuncts == null) {
         return conjuncts;
       }
@@ -117,12 +112,7 @@ public class PsiIntersectionType extends PsiType.Stub {
   @NotNull
   @Override
   public String getPresentableText(final boolean annotated) {
-    return StringUtil.join(myConjuncts, new Function<PsiType, String>() {
-      @Override
-      public String fun(PsiType psiType) {
-        return psiType.getPresentableText(annotated);
-      }
-    }, " & ");
+    return StringUtil.join(myConjuncts, psiType -> psiType.getPresentableText(annotated), " & ");
   }
 
   @NotNull
@@ -134,12 +124,7 @@ public class PsiIntersectionType extends PsiType.Stub {
   @NotNull
   @Override
   public String getInternalCanonicalText() {
-    return StringUtil.join(myConjuncts, new Function<PsiType, String>() {
-      @Override
-      public String fun(PsiType psiType) {
-        return psiType.getInternalCanonicalText();
-      }
-    }, " & ");
+    return StringUtil.join(myConjuncts, psiType -> psiType.getInternalCanonicalText(), " & ");
   }
 
   @Override
index f32eb81916bb2a2da95a1763891d44dff2e38fd0..e6d12fa41b9d4907310a6d58cf5422d484cf5d97 100644 (file)
@@ -29,13 +29,7 @@ public interface PsiJavaCodeReferenceElement extends PsiJavaReference, PsiQualif
    */
   PsiJavaCodeReferenceElement[] EMPTY_ARRAY = new PsiJavaCodeReferenceElement[0];
 
-  ArrayFactory<PsiJavaCodeReferenceElement> ARRAY_FACTORY = new ArrayFactory<PsiJavaCodeReferenceElement>() {
-    @NotNull
-    @Override
-    public PsiJavaCodeReferenceElement[] create(int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiJavaCodeReferenceElement[count];
-    }
-  };
+  ArrayFactory<PsiJavaCodeReferenceElement> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiJavaCodeReferenceElement[count];
 
   /**
    * Returns the element representing the name of the referenced element.
index 178c107a927894d80d520773d907e832509b84ab..adcdab5849a0cbac1ab474c0e7e27a51fad40976 100644 (file)
@@ -38,13 +38,7 @@ public interface PsiMethod extends PsiMember, PsiNameIdentifierOwner, PsiModifie
    */
   PsiMethod[] EMPTY_ARRAY = new PsiMethod[0];
 
-  ArrayFactory<PsiMethod> ARRAY_FACTORY = new ArrayFactory<PsiMethod>() {
-    @NotNull
-    @Override
-    public PsiMethod[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiMethod[count];
-    }
-  };
+  ArrayFactory<PsiMethod> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiMethod[count];
 
   /**
    * Returns the return type of the method.
index b1f7fcd7fe9e2b5ea31f2b9ac2966fce54ef970d..0af73d885fa5ee383a1b12bb034c5b5fdf49d764 100644 (file)
@@ -33,13 +33,7 @@ public interface PsiNameValuePair extends PsiElement {
    */
   PsiNameValuePair[] EMPTY_ARRAY = new PsiNameValuePair[0];
 
-  ArrayFactory<PsiNameValuePair> ARRAY_FACTORY = new ArrayFactory<PsiNameValuePair>() {
-    @NotNull
-    @Override
-    public PsiNameValuePair[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiNameValuePair[count];
-    }
-  };
+  ArrayFactory<PsiNameValuePair> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiNameValuePair[count];
 
   /**
    * Returns the identifier specifying the name of the element.
index b7ad72a17c29fa7442b7c6364a5ba47033d15bf6..a9c623e1d97feb866920461d2675d5c4a7aa46a5 100644 (file)
@@ -28,13 +28,7 @@ public interface PsiParameter extends PsiVariable {
    */
   PsiParameter[] EMPTY_ARRAY = new PsiParameter[0];
 
-  ArrayFactory<PsiParameter> ARRAY_FACTORY = new ArrayFactory<PsiParameter>() {
-    @NotNull
-    @Override
-    public PsiParameter[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiParameter[count];
-    }
-  };
+  ArrayFactory<PsiParameter> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiParameter[count];
 
   /**
    * Returns the element (method, lambda expression, foreach statement or catch block) in which the
index a26dfc2ca3bd5713baf592c271a9b33a5972231f..ef79cc1293c474986911f9b138cd6eea30ea5956 100644 (file)
@@ -27,11 +27,5 @@ public interface PsiStatement extends PsiElement {
    */
   PsiStatement[] EMPTY_ARRAY = new PsiStatement[0];
 
-  ArrayFactory<PsiStatement> ARRAY_FACTORY = new ArrayFactory<PsiStatement>() {
-    @NotNull
-    @Override
-    public PsiStatement[] create(final int count) {
-      return count == 0 ? PsiStatement.EMPTY_ARRAY : new PsiStatement[count];
-    }
-  };
+  ArrayFactory<PsiStatement> ARRAY_FACTORY = count -> count == 0 ? PsiStatement.EMPTY_ARRAY : new PsiStatement[count];
 }
index 9dd82854aa3c7437ecdb9c1bda238c8d5504fcae..ad35e2086d7413c9944df896d45fe229843cce2f 100644 (file)
@@ -38,13 +38,7 @@ public abstract class PsiType implements PsiAnnotationOwner, Cloneable {
   @SuppressWarnings("StaticInitializerReferencesSubClass") public static final PsiPrimitiveType NULL = new PsiPrimitiveType("null", (String)null);
 
   public static final PsiType[] EMPTY_ARRAY = new PsiType[0];
-  public static final ArrayFactory<PsiType> ARRAY_FACTORY = new ArrayFactory<PsiType>() {
-    @NotNull
-    @Override
-    public PsiType[] create(int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiType[count];
-    }
-  };
+  public static final ArrayFactory<PsiType> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiType[count];
 
   @NotNull
   public static PsiType[] createArray(int count) {
index 3decf6544bd1c8270c35fcbeeb77797bf9db7828..3b881ffef515ed4b9fc0a2ee5656d158bb9dc925 100644 (file)
@@ -29,13 +29,7 @@ public interface PsiTypeElement extends PsiElement, PsiAnnotationOwner {
    */
   PsiTypeElement[] EMPTY_ARRAY = new PsiTypeElement[0];
 
-  ArrayFactory<PsiTypeElement> ARRAY_FACTORY = new ArrayFactory<PsiTypeElement>() {
-    @NotNull
-    @Override
-    public PsiTypeElement[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiTypeElement[count];
-    }
-  };
+  ArrayFactory<PsiTypeElement> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiTypeElement[count];
 
   /**
    * Returns the type referenced by the type element.
index 9dcdbf3b55796bf585a2a53ca388ba01f744f238..f89b4184757bc709c6c7ba8bd101d3a9f15de68b 100644 (file)
@@ -30,13 +30,7 @@ public interface PsiTypeParameter extends PsiClass, PsiAnnotationOwner {
    */
   PsiTypeParameter[] EMPTY_ARRAY = new PsiTypeParameter[0];
 
-  ArrayFactory<PsiTypeParameter> ARRAY_FACTORY = new ArrayFactory<PsiTypeParameter>() {
-    @NotNull
-    @Override
-    public PsiTypeParameter[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiTypeParameter[count];
-    }
-  };
+  ArrayFactory<PsiTypeParameter> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiTypeParameter[count];
 
   /**
    * Returns the extends list of the type parameter.
index a3074e72a3a05d40a0a828e66ec2933bccb10644..81df05f0a3dfcfd95eafdb717919d3b3c5d8a781 100644 (file)
@@ -89,12 +89,9 @@ public abstract class PsiAugmentProvider {
   public static <Psi extends PsiElement> List<Psi> collectAugments(@NotNull final PsiElement element, @NotNull final Class<Psi> type) {
     final List<Psi> result = ContainerUtil.newSmartList();
 
-    forEach(element.getProject(), new Processor<PsiAugmentProvider>() {
-      @Override
-      public boolean process(PsiAugmentProvider provider) {
-        result.addAll(provider.getAugments(element, type));
-        return true;
-      }
+    forEach(element.getProject(), provider -> {
+      result.addAll(provider.getAugments(element, type));
+      return true;
     });
 
     return result;
@@ -104,17 +101,14 @@ public abstract class PsiAugmentProvider {
   public static PsiType getInferredType(@NotNull final PsiTypeElement typeElement) {
     final Ref<PsiType> result = Ref.create();
 
-    forEach(typeElement.getProject(), new Processor<PsiAugmentProvider>() {
-      @Override
-      public boolean process(PsiAugmentProvider provider) {
-        PsiType type = provider.inferType(typeElement);
-        if (type != null) {
-          result.set(type);
-          return false;
-        }
-        else {
-          return true;
-        }
+    forEach(typeElement.getProject(), provider -> {
+      PsiType type = provider.inferType(typeElement);
+      if (type != null) {
+        result.set(type);
+        return false;
+      }
+      else {
+        return true;
       }
     });
 
@@ -127,12 +121,9 @@ public abstract class PsiAugmentProvider {
                                                         @NotNull final Set<String> modifiers) {
     final Ref<Set<String>> result = Ref.create(modifiers);
 
-    forEach(project, new Processor<PsiAugmentProvider>() {
-      @Override
-      public boolean process(PsiAugmentProvider provider) {
-        result.set(provider.transformModifiers(modifierList, Collections.unmodifiableSet(result.get())));
-        return true;
-      }
+    forEach(project, provider -> {
+      result.set(provider.transformModifiers(modifierList, Collections.unmodifiableSet(result.get())));
+      return true;
     });
 
     return result.get();
index 13e3894493bbf36f6e00304ef1ff90b9587c609e..33a424e57cdda6637807c864c1d6dd6e7aa12fe5 100644 (file)
@@ -140,29 +140,21 @@ public class MethodCandidateInfo extends CandidateInfo{
     }
 
     final PsiSubstitutor substitutor = getSubstitutor(false);
-    @ApplicabilityLevelConstant int level = computeForOverloadedCandidate(new Computable<Integer>() {
-      @Override
-      public Integer compute() {
-        //arg types are calculated here without additional constraints:
-        //non-pertinent to applicability arguments of arguments would be skipped 
-        PsiType[] argumentTypes = getArgumentTypes();
-        if (argumentTypes == null) {
-          return ApplicabilityLevel.NOT_APPLICABLE;
-        }
+    @ApplicabilityLevelConstant int level = computeForOverloadedCandidate(() -> {
+      //arg types are calculated here without additional constraints:
+      //non-pertinent to applicability arguments of arguments would be skipped
+      PsiType[] argumentTypes = getArgumentTypes();
+      if (argumentTypes == null) {
+        return ApplicabilityLevel.NOT_APPLICABLE;
+      }
 
-        int level = PsiUtil.getApplicabilityLevel(method, substitutor, argumentTypes, myLanguageLevel);
-        if (!isVarargs() && level < ApplicabilityLevel.FIXED_ARITY) {
-          return ApplicabilityLevel.NOT_APPLICABLE;
-        }
-        return level;
+      int level1 = PsiUtil.getApplicabilityLevel(method, substitutor, argumentTypes, myLanguageLevel);
+      if (!isVarargs() && level1 < ApplicabilityLevel.FIXED_ARITY) {
+        return ApplicabilityLevel.NOT_APPLICABLE;
       }
+      return level1;
     }, substitutor, isVarargs(), true);
-    if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable(new Computable<PsiSubstitutor>() {
-      @Override
-      public PsiSubstitutor compute() {
-        return substitutor;
-      }
-    })) {
+    if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable(() -> substitutor)) {
       level = ApplicabilityLevel.NOT_APPLICABLE;
     }
     return level;
@@ -341,12 +333,7 @@ public class MethodCandidateInfo extends CandidateInfo{
 
 
   public boolean isTypeArgumentsApplicable() {
-    return isTypeArgumentsApplicable(new Computable<PsiSubstitutor>() {
-      @Override
-      public PsiSubstitutor compute() {
-        return getSubstitutor(false);
-      }
-    });
+    return isTypeArgumentsApplicable(() -> getSubstitutor(false));
   }
 
   private boolean isTypeArgumentsApplicable(Computable<PsiSubstitutor> computable) {
@@ -396,24 +383,21 @@ public class MethodCandidateInfo extends CandidateInfo{
   public PsiSubstitutor inferTypeArguments(@NotNull final ParameterTypeInferencePolicy policy,
                                            @NotNull final PsiExpression[] arguments,
                                            boolean includeReturnConstraint) {
-    return computeForOverloadedCandidate(new Computable<PsiSubstitutor>() {
-      @Override
-      public PsiSubstitutor compute() {
-        final PsiMethod method = MethodCandidateInfo.this.getElement();
-        PsiTypeParameter[] typeParameters = method.getTypeParameters();
-
-        if (MethodCandidateInfo.this.isRawSubstitution()) {
-          return JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createRawSubstitutor(mySubstitutor, typeParameters);
-        }
+    return computeForOverloadedCandidate(() -> {
+      final PsiMethod method = MethodCandidateInfo.this.getElement();
+      PsiTypeParameter[] typeParameters = method.getTypeParameters();
 
-        final PsiElement parent = MethodCandidateInfo.this.getParent();
-        if (parent == null) return PsiSubstitutor.EMPTY;
-        Project project = method.getProject();
-        JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
-        return javaPsiFacade.getResolveHelper()
-          .inferTypeArguments(typeParameters, method.getParameterList().getParameters(), arguments, mySubstitutor, parent, policy,
-                              myLanguageLevel);
+      if (MethodCandidateInfo.this.isRawSubstitution()) {
+        return JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createRawSubstitutor(mySubstitutor, typeParameters);
       }
+
+      final PsiElement parent = MethodCandidateInfo.this.getParent();
+      if (parent == null) return PsiSubstitutor.EMPTY;
+      Project project = method.getProject();
+      JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
+      return javaPsiFacade.getResolveHelper()
+        .inferTypeArguments(typeParameters, method.getParameterList().getParameters(), arguments, mySubstitutor, parent, policy,
+                            myLanguageLevel);
     }, super.getSubstitutor(), policy.isVarargsIgnored() || isVarargs(), !includeReturnConstraint);
   }
 
index bfa8006da329244220488c028d7fe1aec5529265..fc663ac47bdae4106a0add57b3f20f3882c5bd75 100644 (file)
@@ -81,19 +81,15 @@ public class ClassUtil {
 
   private static int getNonQualifiedClassIdx(@NotNull final PsiClass psiClass, @NotNull final PsiClass containingClass) {
     TObjectIntHashMap<PsiClass> indices =
-      CachedValuesManager.getCachedValue(containingClass, new CachedValueProvider<TObjectIntHashMap<PsiClass>>() {
-        @Nullable
-        @Override
-        public Result<TObjectIntHashMap<PsiClass>> compute() {
-          final TObjectIntHashMap<PsiClass> map = new TObjectIntHashMap<PsiClass>();
-          int index = 0;
-          for (PsiClass aClass : SyntaxTraverser.psiTraverser().withRoot(containingClass).postOrderDfsTraversal().filter(PsiClass.class)) {
-            if (aClass.getQualifiedName() == null) {
-              map.put(aClass, ++index);
-            }
+      CachedValuesManager.getCachedValue(containingClass, () -> {
+        final TObjectIntHashMap<PsiClass> map = new TObjectIntHashMap<PsiClass>();
+        int index = 0;
+        for (PsiClass aClass : SyntaxTraverser.psiTraverser().withRoot(containingClass).postOrderDfsTraversal().filter(PsiClass.class)) {
+          if (aClass.getQualifiedName() == null) {
+            map.put(aClass, ++index);
           }
-          return Result.create(map, containingClass);
         }
+        return CachedValueProvider.Result.create(map, containingClass);
       });
 
     return indices.get(psiClass);
index db4bc10200c16a9132d0e10265cd7b0578faa56f..60037f1fcf854d438b19c31108e7cde8dbc75cb9 100644 (file)
@@ -58,12 +58,7 @@ public class ImportsUtil {
     if (refExpr != null) {
       expressionToExpand.add(refExpr);
     }
-    Collections.sort(expressionToExpand, new Comparator<PsiJavaCodeReferenceElement>() {
-      @Override
-      public int compare(PsiJavaCodeReferenceElement o1, PsiJavaCodeReferenceElement o2) {
-        return o2.getTextOffset() - o1.getTextOffset();
-      }
-    });
+    Collections.sort(expressionToExpand, (o1, o2) -> o2.getTextOffset() - o1.getTextOffset());
     for (PsiJavaCodeReferenceElement expression : expressionToExpand) {
       expand(expression, staticImport);
     }
index 3966e39dece29ea79ad5af9b9a458d0a7e79178b..a9979577a155882f0980a921eaca5107b712b89a 100644 (file)
@@ -49,15 +49,12 @@ public class PsiClassUtil {
 
   @NotNull
   public static Comparator<PsiClass> createScopeComparator(@NotNull final GlobalSearchScope scope) {
-    return new Comparator<PsiClass>() {
-      @Override
-      public int compare(PsiClass c1, PsiClass c2) {
-        VirtualFile file1 = PsiUtilCore.getVirtualFile(c1);
-        VirtualFile file2 = PsiUtilCore.getVirtualFile(c2);
-        if (file1 == null) return file2 == null ? 0 : -1;
-        if (file2 == null) return 1;
-        return scope.compare(file2, file1);
-      }
+    return (c1, c2) -> {
+      VirtualFile file1 = PsiUtilCore.getVirtualFile(c1);
+      VirtualFile file2 = PsiUtilCore.getVirtualFile(c2);
+      if (file1 == null) return file2 == null ? 0 : -1;
+      if (file2 == null) return 1;
+      return scope.compare(file2, file1);
     };
   }
 }
index ccef1757f954ffc62a9003b8144f3bade8f07ece..adacb5bbfe4200be72618a01577b2ab08b9b400d 100644 (file)
@@ -27,13 +27,10 @@ import org.jetbrains.annotations.Nullable;
 public class PsiMethodUtil {
   private static final JavaMainMethodProvider[] myProviders = Extensions.getExtensions(JavaMainMethodProvider.EP_NAME);
 
-  public static final Condition<PsiClass> MAIN_CLASS = new Condition<PsiClass>() {
-    @Override
-    public boolean value(final PsiClass psiClass) {
-      if (psiClass instanceof PsiAnonymousClass) return false;
-      if (psiClass.isInterface() && !PsiUtil.isLanguageLevel8OrHigher(psiClass)) return false;
-      return psiClass.getContainingClass() == null || psiClass.hasModifierProperty(PsiModifier.STATIC);
-    }
+  public static final Condition<PsiClass> MAIN_CLASS = psiClass -> {
+    if (psiClass instanceof PsiAnonymousClass) return false;
+    if (psiClass.isInterface() && !PsiUtil.isLanguageLevel8OrHigher(psiClass)) return false;
+    return psiClass.getContainingClass() == null || psiClass.hasModifierProperty(PsiModifier.STATIC);
   };
 
   private PsiMethodUtil() { }
index d16641d1459b2f77ed3c481dd691eff0ebe36e02..821a7686615aab3a1d4367ad2ec1d93326a3c910 100644 (file)
@@ -1096,12 +1096,7 @@ public final class PsiUtil extends PsiUtilCore {
     return type;
   }
 
-  public static final Comparator<PsiElement> BY_POSITION = new Comparator<PsiElement>() {
-    @Override
-    public int compare(PsiElement o1, PsiElement o2) {
-      return compareElementsByPosition(o1, o2);
-    }
-  };
+  public static final Comparator<PsiElement> BY_POSITION = (o1, o2) -> compareElementsByPosition(o1, o2);
 
   public static void setModifierProperty(@NotNull PsiModifierListOwner owner, @NotNull @PsiModifier.ModifierConstant String property, boolean value) {
     final PsiModifierList modifierList = owner.getModifierList();
index 91643aeea96b1206e2f6be63a8e7aa09492bb955..356eb42c8882f6c92266bb887f06920031f34dd0 100644 (file)
@@ -423,34 +423,21 @@ public class RedundantCastUtil {
                 PsiExpression returnExpression = deparenthesizeExpression(expressions.get(returnExprIdx));
                 if (returnExpression instanceof PsiTypeCastExpression) {
                   processLambdaReturnExpression(expression, i, interfaceType, (PsiTypeCastExpression)returnExpression, returnExprIdx,
-                                                    new Function<PsiExpression, PsiTypeCastExpression>() {
-                                                      @Override
-                                                      public PsiTypeCastExpression fun(PsiExpression expression) {
-                                                        return (PsiTypeCastExpression)expression;
-                                                      }
-                                                    });
+                                                expression13 -> (PsiTypeCastExpression)expression13);
                 }
                 else if (returnExpression instanceof PsiConditionalExpression) {
                   final PsiExpression thenExpression = ((PsiConditionalExpression)returnExpression).getThenExpression();
                   if (thenExpression instanceof PsiTypeCastExpression) {
                     processLambdaReturnExpression(expression, i, interfaceType, (PsiTypeCastExpression)thenExpression,
-                                                  returnExprIdx, new Function<PsiExpression, PsiTypeCastExpression>() {
-                                                    @Override
-                                                    public PsiTypeCastExpression fun(PsiExpression expression) {
-                                                      return (PsiTypeCastExpression)((PsiConditionalExpression)expression).getThenExpression();
-                                                    }
-                                                  });
+                                                  returnExprIdx,
+                                                  expression12 -> (PsiTypeCastExpression)((PsiConditionalExpression)expression12).getThenExpression());
                   }
 
                   final PsiExpression elseExpression = ((PsiConditionalExpression)returnExpression).getElseExpression();
                   if (elseExpression instanceof PsiTypeCastExpression) {
                     processLambdaReturnExpression(expression, i, interfaceType, (PsiTypeCastExpression)elseExpression,
-                                                  returnExprIdx, new Function<PsiExpression, PsiTypeCastExpression>() {
-                                                    @Override
-                                                    public PsiTypeCastExpression fun(PsiExpression expression) {
-                                                      return (PsiTypeCastExpression)((PsiConditionalExpression)expression).getElseExpression();
-                                                    }
-                                                  });
+                                                  returnExprIdx,
+                                                  expression1 -> (PsiTypeCastExpression)((PsiConditionalExpression)expression1).getElseExpression());
                   }
                 }
               }
index 6d5b540be35fd92b1c4fd3d008278d1742be785b..3180c4cf58d9ecd51ef8c669c7683b150671a933 100644 (file)
@@ -933,24 +933,19 @@ public class TypeConversionUtil {
     final Project project = psiClass.getProject();
     CachedValue<Set<String>> boxedHolderTypes = project.getUserData(POSSIBLE_BOXED_HOLDER_TYPES);
     if (boxedHolderTypes == null) {
-      project.putUserData(POSSIBLE_BOXED_HOLDER_TYPES, boxedHolderTypes = CachedValuesManager.getManager(manager.getProject()).createCachedValue(new CachedValueProvider<Set<String>>() {
-        @Override
-        public Result<Set<String>> compute() {
+      project.putUserData(POSSIBLE_BOXED_HOLDER_TYPES, boxedHolderTypes = CachedValuesManager.getManager(manager.getProject()).createCachedValue(
+        () -> {
           final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
           final Set<String> set = new THashSet<String>();
           for (final String qname : PsiPrimitiveType.getAllBoxedTypeNames()) {
             final PsiClass boxedClass = facade.findClass(qname, GlobalSearchScope.allScope(project));
-            InheritanceUtil.processSupers(boxedClass, true, new Processor<PsiClass>() {
-              @Override
-              public boolean process(PsiClass psiClass) {
-                ContainerUtil.addIfNotNull(set, psiClass.getQualifiedName());
-                return true;
-              }
+            InheritanceUtil.processSupers(boxedClass, true, psiClass1 -> {
+              ContainerUtil.addIfNotNull(set, psiClass1.getQualifiedName());
+              return true;
             });
           }
-          return Result.create(set, ProjectRootModificationTracker.getInstance(project));
-        }
-      }, false));
+          return CachedValueProvider.Result.create(set, ProjectRootModificationTracker.getInstance(project));
+        }, false));
     }
 
     return boxedHolderTypes.getValue();
@@ -1031,13 +1026,8 @@ public class TypeConversionUtil {
         }
         else { //isSuper
           if (rightWildcard.isSuper()) {
-            final Boolean assignable = ourGuard.doPreventingRecursion(rightWildcard, true, new NotNullComputable<Boolean>() {
-              @NotNull
-              @Override
-              public Boolean compute() {
-                return isAssignable(rightWildcard.getBound(), leftBound, allowUncheckedConversion, false);
-              }
-            });
+            final Boolean assignable = ourGuard.doPreventingRecursion(rightWildcard, true,
+                                                                      (NotNullComputable<Boolean>)() -> isAssignable(rightWildcard.getBound(), leftBound, allowUncheckedConversion, false));
             if (assignable != null && assignable) {
               return true;
             }
@@ -1050,13 +1040,8 @@ public class TypeConversionUtil {
           return isAssignable(leftBound, typeRight, false, false);
         }
         else { // isSuper
-          final Boolean assignable = ourGuard.doPreventingRecursion(leftWildcard, true, new NotNullComputable<Boolean>() {
-            @NotNull
-            @Override
-            public Boolean compute() {
-              return isAssignable(typeRight, leftBound, false, false);
-            }
-          });
+          final Boolean assignable = ourGuard.doPreventingRecursion(leftWildcard, true,
+                                                                    (NotNullComputable<Boolean>)() -> isAssignable(typeRight, leftBound, false, false));
           return assignable == null || assignable.booleanValue(); 
         }
       }
@@ -1129,12 +1114,9 @@ public class TypeConversionUtil {
     }
     msg.append("isInheritor: " + InheritanceUtil.isInheritorOrSelf(derivedClass, superClass, true) + " " + derivedClass.isInheritor(superClass, true));
     msg.append("\nhierarchy:\n");
-    InheritanceUtil.processSupers(derivedClass, true, new Processor<PsiClass>() {
-      @Override
-      public boolean process(PsiClass psiClass) {
-        msg.append("each: " + classInfo(psiClass));
-        return true;
-      }
+    InheritanceUtil.processSupers(derivedClass, true, psiClass -> {
+      msg.append("each: " + classInfo(psiClass));
+      return true;
     });
     LOG.error(msg.toString());
   }
index 0de75592e6792f7ca121c03079e788489b9e6d65..74e23cf8194c19badcac02a0188212808abce890 100644 (file)
@@ -66,12 +66,7 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations
 
   public BaseExternalAnnotationsManager(@NotNull PsiManager psiManager) {
     myPsiManager = psiManager;
-    LowMemoryWatcher.register(new Runnable() {
-      @Override
-      public void run() {
-        dropCache();
-      }
-    }, psiManager.getProject());
+    LowMemoryWatcher.register(() -> dropCache(), psiManager.getProject());
   }
 
   @Nullable
@@ -102,24 +97,15 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations
   }
 
   private static AnnotationData findByFQN(@NotNull List<AnnotationData> map, @NotNull final String annotationFQN) {
-    return ContainerUtil.find(map, new Condition<AnnotationData>() {
-      @Override
-      public boolean value(AnnotationData data) {
-        return data.annotationClassFqName.equals(annotationFQN);
-      }
-    });
+    return ContainerUtil.find(map, data -> data.annotationClassFqName.equals(annotationFQN));
   }
 
   @Override
   @Nullable
   public PsiAnnotation[] findExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) {
     final List<AnnotationData> result = collectExternalAnnotations(listOwner);
-    return result.isEmpty() ? null : ContainerUtil.map2Array(result, PsiAnnotation.EMPTY_ARRAY, new Function<AnnotationData, PsiAnnotation>() {
-      @Override
-      public PsiAnnotation fun(AnnotationData data) {
-        return data.getAnnotation(BaseExternalAnnotationsManager.this);
-      }
-    });
+    return result.isEmpty() ? null : ContainerUtil.map2Array(result, PsiAnnotation.EMPTY_ARRAY,
+                                                             data -> data.getAnnotation(BaseExternalAnnotationsManager.this));
   }
 
   private static final List<AnnotationData> NO_DATA = new ArrayList<AnnotationData>(1);
@@ -262,13 +248,10 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations
 
     List<PsiFile> result = new SmartList<PsiFile>(possibleAnnotationXmls);
     // writable go first
-    Collections.sort(result, new Comparator<PsiFile>() {
-      @Override
-      public int compare(PsiFile f1, PsiFile f2) {
-        boolean w1 = f1.isWritable();
-        boolean w2 = f2.isWritable();
-        return w1 == w2 ? 0 : w1 ? -1 : 1;
-      }
+    Collections.sort(result, (f1, f2) -> {
+      boolean w1 = f1.isWritable();
+      boolean w2 = f2.isWritable();
+      return w1 == w2 ? 0 : w1 ? -1 : 1;
     });
     myExternalAnnotationsCache.put(virtualFile, result);
     return result;
index 95a4e0ff75bb4ee40b63fcd333172690b5a61f7b..ca2dba3ff8d0a18b3609966cf50aefe2416ed1a8 100644 (file)
@@ -103,12 +103,7 @@ public class ExceptionUtil {
       if (expr == null) return Collections.emptyList();
       final List<PsiType> types = getPreciseThrowTypes(expr);
       List<PsiClassType> classTypes =
-        new ArrayList<PsiClassType>(ContainerUtil.mapNotNull(types, new NullableFunction<PsiType, PsiClassType>() {
-          @Override
-          public PsiClassType fun(PsiType type) {
-            return type instanceof PsiClassType ? (PsiClassType)type : null;
-          }
-        }));
+        new ArrayList<PsiClassType>(ContainerUtil.mapNotNull(types, (NullableFunction<PsiType, PsiClassType>)type -> type instanceof PsiClassType ? (PsiClassType)type : null));
       addExceptions(classTypes, getThrownExceptions(expr));
       return classTypes;
     }
@@ -470,18 +465,15 @@ public class ExceptionUtil {
       try {
         PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false);
         final List<Pair<PsiMethod, PsiSubstitutor>> candidates = ContainerUtil.mapNotNull(
-          processor.getResults(), new Function<CandidateInfo, Pair<PsiMethod, PsiSubstitutor>>() {
-          @Override
-          public Pair<PsiMethod, PsiSubstitutor> fun(CandidateInfo info) {
-            PsiElement element = info.getElement();
+          processor.getResults(), info -> {
+            PsiElement element1 = info.getElement();
             if (info instanceof MethodCandidateInfo &&
-                MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element) &&
-                !MethodSignatureUtil.isSuperMethod((PsiMethod)element, method)) {
-              return Pair.create((PsiMethod)element, ((MethodCandidateInfo)info).getSubstitutor(false));
+                MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element1) &&
+                !MethodSignatureUtil.isSuperMethod((PsiMethod)element1, method)) {
+              return Pair.create((PsiMethod)element1, ((MethodCandidateInfo)info).getSubstitutor(false));
             }
             return null;
-          }
-        });
+          });
         if (candidates.size() > 1) {
           GlobalSearchScope scope = methodCall.getResolveScope();
           final List<PsiClassType> ex = collectSubstituted(substitutor, thrownExceptions, scope);
index 22e9452eb30fe57077c602a55577ed5ed8a2bfe1..cd75c28b90125e7a99b8ed45935fafba886ece35 100644 (file)
@@ -23,33 +23,27 @@ import java.util.Comparator;
 
 public class JavaPsiEquivalenceUtil {
   public static boolean areExpressionsEquivalent(PsiExpression expr1, PsiExpression expr2) {
-    return PsiEquivalenceUtil.areElementsEquivalent(expr1, expr2, new Comparator<PsiElement>() {
-      @Override
-      public int compare(PsiElement o1, PsiElement o2) {
-        if (o1 instanceof PsiParameter && o2 instanceof PsiParameter) {
-          final PsiElement scope1 = ((PsiParameter)o1).getDeclarationScope();
-          final PsiElement scope2 = ((PsiParameter)o2).getDeclarationScope();
-          if (scope1 instanceof PsiMethod && scope2 instanceof PsiMethod ||
-              scope1 instanceof PsiLambdaExpression && scope2 instanceof PsiLambdaExpression) {
-            if (!scope1.getTextRange().intersects(scope2.getTextRange())) {
-              return ((PsiParameter)o1).getName().compareTo(((PsiParameter)o2).getName());
-            }
+    return PsiEquivalenceUtil.areElementsEquivalent(expr1, expr2, (o1, o2) -> {
+      if (o1 instanceof PsiParameter && o2 instanceof PsiParameter) {
+        final PsiElement scope1 = ((PsiParameter)o1).getDeclarationScope();
+        final PsiElement scope2 = ((PsiParameter)o2).getDeclarationScope();
+        if (scope1 instanceof PsiMethod && scope2 instanceof PsiMethod ||
+            scope1 instanceof PsiLambdaExpression && scope2 instanceof PsiLambdaExpression) {
+          if (!scope1.getTextRange().intersects(scope2.getTextRange())) {
+            return ((PsiParameter)o1).getName().compareTo(((PsiParameter)o2).getName());
           }
         }
-        return 1;
       }
-    }, new Comparator<PsiElement>() {
-        @Override
-        public int compare(PsiElement o1, PsiElement o2) {
-          if (!o1.textMatches(o2)) return 1;
+      return 1;
+    }, (o1, o2) -> {
+      if (!o1.textMatches(o2)) return 1;
 
-          if (o1 instanceof PsiDiamondTypeElementImpl && o2 instanceof PsiDiamondTypeElementImpl) {
-            final PsiDiamondType.DiamondInferenceResult thisInferenceResult = new PsiDiamondTypeImpl(o1.getManager(), (PsiTypeElement)o1).resolveInferredTypes();
-            final PsiDiamondType.DiamondInferenceResult otherInferenceResult = new PsiDiamondTypeImpl(o2.getManager(), (PsiTypeElement)o2).resolveInferredTypes();
-            return thisInferenceResult.equals(otherInferenceResult) ? 0 : 1;
-          }
-          return 0;
-        }
-      });
+      if (o1 instanceof PsiDiamondTypeElementImpl && o2 instanceof PsiDiamondTypeElementImpl) {
+        final PsiDiamondType.DiamondInferenceResult thisInferenceResult = new PsiDiamondTypeImpl(o1.getManager(), (PsiTypeElement)o1).resolveInferredTypes();
+        final PsiDiamondType.DiamondInferenceResult otherInferenceResult = new PsiDiamondTypeImpl(o2.getManager(), (PsiTypeElement)o2).resolveInferredTypes();
+        return thisInferenceResult.equals(otherInferenceResult) ? 0 : 1;
+      }
+      return 0;
+    });
   }
 }
index 8d8408a6f12cc85d49b3d10a4ea5756919c5004a..80eb7aab54ba708e0c537497d73e874bac2680f0 100644 (file)
@@ -149,12 +149,7 @@ class ClosureFolding {
   private String getFoldingHeader() {
     String methodName = shouldShowMethodName() ? myMethod.getName() : "";
     String type = myQuick ? "" : getOptionalLambdaType();
-    String params = StringUtil.join(myMethod.getParameterList().getParameters(), new Function<PsiParameter, String>() {
-      @Override
-      public String fun(PsiParameter psiParameter) {
-        return psiParameter.getName();
-      }
-    }, ", ");
+    String params = StringUtil.join(myMethod.getParameterList().getParameters(), psiParameter -> psiParameter.getName(), ", ");
     return type + methodName + "(" + params + ") " + myBuilder.rightArrow() + " {";
   }
 
index 5742a1407a49e0d268e7f84ccc595d5354fa3e24..65ce1e46c9d3d07d455969ac5761159fb327819c 100644 (file)
@@ -928,11 +928,7 @@ public class DeclarationParser {
 
   @NotNull
   private PsiBuilder.Marker parseAnnotationArrayInitializer(PsiBuilder builder) {
-    return myParser.getExpressionParser().parseArrayInitializer(builder, JavaElementType.ANNOTATION_ARRAY_INITIALIZER, new Function<PsiBuilder, Boolean>() {
-      @Override
-      public Boolean fun(PsiBuilder builder) {
-        return doParseAnnotationValue(builder) != null;
-      }
-    }, "expected.value");
+    return myParser.getExpressionParser().parseArrayInitializer(builder, JavaElementType.ANNOTATION_ARRAY_INITIALIZER,
+                                                                builder1 -> doParseAnnotationValue(builder1) != null, "expected.value");
   }
 }
\ No newline at end of file
index 5690638c55eafa5391f94e489db96189f103a077..da0568517ff3126fc48d4682ac070e08dfe59470 100644 (file)
@@ -612,12 +612,7 @@ public class ExpressionParser {
 
   @NotNull
   private PsiBuilder.Marker parseArrayInitializer(PsiBuilder builder) {
-    return parseArrayInitializer(builder, JavaElementType.ARRAY_INITIALIZER_EXPRESSION, new Function<PsiBuilder, Boolean>() {
-      @Override
-      public Boolean fun(PsiBuilder builder) {
-        return parse(builder) != null;
-      }
-    }, "expected.expression");
+    return parseArrayInitializer(builder, JavaElementType.ARRAY_INITIALIZER_EXPRESSION, builder1 -> parse(builder1) != null, "expected.expression");
   }
 
   @NotNull
index 569f86691a9c59dd5a6b6d1bad5e1f60adc87419..c976ba413966ee1acfd114839f1a0962a52c3334 100644 (file)
@@ -64,12 +64,7 @@ public abstract class NonClasspathClassFinder extends PsiElementFinder {
         clearCache();
       }
     });
-    LowMemoryWatcher.register(new Runnable() {
-      @Override
-      public void run() {
-        clearCache();
-      }
-    }, project);
+    LowMemoryWatcher.register(() -> clearCache(), project);
   }
 
   @NotNull 
@@ -103,20 +98,17 @@ public abstract class NonClasspathClassFinder extends PsiElementFinder {
   @Override
   public PsiClass findClass(@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope) {
     final Ref<PsiClass> result = Ref.create();
-    processDirectories(StringUtil.getPackageName(qualifiedName), scope, new Processor<VirtualFile>() {
-      @Override
-      public boolean process(VirtualFile dir) {
-        VirtualFile virtualFile = findChild(dir, StringUtil.getShortName(qualifiedName), myFileExtensions);
-        final PsiFile file = virtualFile == null ? null : myManager.findFile(virtualFile);
-        if (file instanceof PsiClassOwner) {
-          final PsiClass[] classes = ((PsiClassOwner)file).getClasses();
-          if (classes.length == 1) {
-            result.set(classes[0]);
-            return false;
-          }
+    processDirectories(StringUtil.getPackageName(qualifiedName), scope, dir -> {
+      VirtualFile virtualFile = findChild(dir, StringUtil.getShortName(qualifiedName), myFileExtensions);
+      final PsiFile file = virtualFile == null ? null : myManager.findFile(virtualFile);
+      if (file instanceof PsiClassOwner) {
+        final PsiClass[] classes = ((PsiClassOwner)file).getClasses();
+        if (classes.length == 1) {
+          result.set(classes[0]);
+          return false;
         }
-        return true;
       }
+      return true;
     });
     return result.get();
   }
@@ -127,19 +119,16 @@ public abstract class NonClasspathClassFinder extends PsiElementFinder {
   @Override
   public PsiClass[] getClasses(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
     final List<PsiClass> result = ContainerUtil.newArrayList();
-    processDirectories(psiPackage.getQualifiedName(), scope, new Processor<VirtualFile>() {
-      @Override
-      public boolean process(VirtualFile dir) {
-        for (final VirtualFile file : dir.getChildren()) {
-          if (!file.isDirectory() && ArrayUtil.contains(file.getExtension(), myFileExtensions)) {
-            final PsiFile psi = myManager.findFile(file);
-            if (psi instanceof PsiClassOwner) {
-              ContainerUtil.addAll(result, ((PsiClassOwner)psi).getClasses());
-            }
+    processDirectories(psiPackage.getQualifiedName(), scope, dir -> {
+      for (final VirtualFile file : dir.getChildren()) {
+        if (!file.isDirectory() && ArrayUtil.contains(file.getExtension(), myFileExtensions)) {
+          final PsiFile psi = myManager.findFile(file);
+          if (psi instanceof PsiClassOwner) {
+            ContainerUtil.addAll(result, ((PsiClassOwner)psi).getClasses());
           }
         }
-        return true;
       }
+      return true;
     });
     return result.toArray(new PsiClass[result.size()]);
   }
@@ -149,16 +138,13 @@ public abstract class NonClasspathClassFinder extends PsiElementFinder {
   @Override
   public Set<String> getClassNames(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
     final Set<String> result = new HashSet<String>();
-    processDirectories(psiPackage.getQualifiedName(), scope, new Processor<VirtualFile>() {
-      @Override
-      public boolean process(VirtualFile dir) {
-        for (final VirtualFile file : dir.getChildren()) {
-          if (!file.isDirectory() && ArrayUtil.contains(file.getExtension(), myFileExtensions)) {
-            result.add(file.getNameWithoutExtension());
-          }
+    processDirectories(psiPackage.getQualifiedName(), scope, dir -> {
+      for (final VirtualFile file : dir.getChildren()) {
+        if (!file.isDirectory() && ArrayUtil.contains(file.getExtension(), myFileExtensions)) {
+          result.add(file.getNameWithoutExtension());
         }
-        return true;
       }
+      return true;
     });
     return result;
   }
@@ -179,24 +165,17 @@ public abstract class NonClasspathClassFinder extends PsiElementFinder {
                                            @NotNull GlobalSearchScope scope,
                                            @NotNull final Processor<PsiDirectory> consumer,
                                            boolean includeLibrarySources) {
-    return processDirectories(psiPackage.getQualifiedName(), scope, new Processor<VirtualFile>() {
-      @Override
-      public boolean process(VirtualFile dir) {
-        final PsiDirectory psiDirectory = psiPackage.getManager().findDirectory(dir);
-        return psiDirectory == null || consumer.process(psiDirectory);
-      }
+    return processDirectories(psiPackage.getQualifiedName(), scope, dir -> {
+      final PsiDirectory psiDirectory = psiPackage.getManager().findDirectory(dir);
+      return psiDirectory == null || consumer.process(psiDirectory);
     });
   }
 
   private boolean processDirectories(@NotNull String qualifiedName,
                                      @NotNull final GlobalSearchScope scope,
                                      @NotNull final Processor<VirtualFile> processor) {
-    return ContainerUtil.process(getCache(scope).getDirectoriesByPackageName(qualifiedName), new Processor<VirtualFile>() {
-      @Override
-      public boolean process(VirtualFile file) {
-        return !scope.contains(file) || processor.process(file);
-      }
-    });
+    return ContainerUtil.process(getCache(scope).getDirectoriesByPackageName(qualifiedName),
+                                 file -> !scope.contains(file) || processor.process(file));
   }
 
   @NotNull
index 06ac9c07309a52950230f9a2418ab9e96de23a33..d5ed08d422a07b05824b0f04774d9cd713ddc035 100644 (file)
@@ -156,14 +156,9 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
 
   private static JavaResolveResult getStaticFactory(final PsiNewExpression newExpression, final PsiElement context) {
     return context == newExpression
-           ? CachedValuesManager.getCachedValue(newExpression, new CachedValueProvider<JavaResolveResult>() {
-                @Nullable
-                @Override
-                public Result<JavaResolveResult> compute() {
-                  return new Result<JavaResolveResult>(getStaticFactoryCandidateInfo(newExpression, newExpression),
-                                                       PsiModificationTracker.MODIFICATION_COUNT);
-                }
-              })
+           ? CachedValuesManager.getCachedValue(newExpression,
+                                                () -> new CachedValueProvider.Result<JavaResolveResult>(getStaticFactoryCandidateInfo(newExpression, newExpression),
+                                                                                                        PsiModificationTracker.MODIFICATION_COUNT))
            : getStaticFactoryCandidateInfo(newExpression, context);
   }
 
@@ -172,14 +167,11 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
     if (staticFactoryCandidateInfo == null) {
       return DiamondInferenceResult.NULL_RESULT;
     }
-    final PsiSubstitutor inferredSubstitutor = ourDiamondGuard.doPreventingRecursion(context, false, new Computable<PsiSubstitutor>() {
-      @Override
-      public PsiSubstitutor compute() {
-        PsiSubstitutor substitutor = staticFactoryCandidateInfo.getSubstitutor();
-        return staticFactoryCandidateInfo instanceof MethodCandidateInfo &&
-               ((MethodCandidateInfo)staticFactoryCandidateInfo).getInferenceErrorMessage() != null
-               ? null : substitutor;
-      }
+    final PsiSubstitutor inferredSubstitutor = ourDiamondGuard.doPreventingRecursion(context, false, () -> {
+      PsiSubstitutor substitutor = staticFactoryCandidateInfo.getSubstitutor();
+      return staticFactoryCandidateInfo instanceof MethodCandidateInfo &&
+             ((MethodCandidateInfo)staticFactoryCandidateInfo).getInferenceErrorMessage() != null
+             ? null : substitutor;
     });
     if (inferredSubstitutor == null) {
       return DiamondInferenceResult.NULL_RESULT;
@@ -231,34 +223,31 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
 
   private static JavaResolveResult getStaticFactoryCandidateInfo(final PsiNewExpression newExpression,
                                                                  final PsiElement context) {
-    return ourDiamondGuard.doPreventingRecursion(context, false, new Computable<JavaResolveResult>() {
-      @Override
-      public JavaResolveResult compute() {
-
-        final PsiExpressionList argumentList = newExpression.getArgumentList();
-        if (argumentList == null) {
-          //token expected diagnostic is provided by parser
-          return null;
-        }
+    return ourDiamondGuard.doPreventingRecursion(context, false, () -> {
 
-        final JavaMethodsConflictResolver resolver = new JavaMethodsConflictResolver(argumentList, PsiUtil.getLanguageLevel(newExpression));
-        final JavaResolveResult[] result = collectStaticFactories(newExpression, resolver);
-        final PsiMethod staticFactory = result != null && result.length == 1 ? (PsiMethod)result[0].getElement() : null;
-        if (staticFactory == null) {
-          //additional diagnostics: inference fails due to unresolved constructor
-          return JavaResolveResult.EMPTY;
-        }
+      final PsiExpressionList argumentList = newExpression.getArgumentList();
+      if (argumentList == null) {
+        //token expected diagnostic is provided by parser
+        return null;
+      }
 
-        final MethodCandidateInfo staticFactoryCandidateInfo = createMethodCandidate(staticFactory, context, false, argumentList);
-        if (!staticFactory.isVarArgs()) {
-          return staticFactoryCandidateInfo;
-        }
+      final JavaMethodsConflictResolver resolver = new JavaMethodsConflictResolver(argumentList, PsiUtil.getLanguageLevel(newExpression));
+      final JavaResolveResult[] result = collectStaticFactories(newExpression, resolver);
+      final PsiMethod staticFactory = result != null && result.length == 1 ? (PsiMethod)result[0].getElement() : null;
+      if (staticFactory == null) {
+        //additional diagnostics: inference fails due to unresolved constructor
+        return JavaResolveResult.EMPTY;
+      }
 
-        final ArrayList<CandidateInfo> conflicts = new ArrayList<CandidateInfo>();
-        conflicts.add(staticFactoryCandidateInfo);
-        conflicts.add(createMethodCandidate(staticFactory, context, true, argumentList));
-        return resolver.resolveConflict(conflicts);
+      final MethodCandidateInfo staticFactoryCandidateInfo = createMethodCandidate(staticFactory, context, false, argumentList);
+      if (!staticFactory.isVarArgs()) {
+        return staticFactoryCandidateInfo;
       }
+
+      final ArrayList<CandidateInfo> conflicts = new ArrayList<CandidateInfo>();
+      conflicts.add(staticFactoryCandidateInfo);
+      conflicts.add(createMethodCandidate(staticFactory, context, true, argumentList));
+      return resolver.resolveConflict(conflicts);
     });
   }
 
@@ -356,24 +345,16 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
     //it's important that class type parameters names are preserved(they are first in the list),
     //though constructor parameters would be renamed in case of conflicts
     final UniqueNameGenerator generator = new UniqueNameGenerator();
-    buf.append(StringUtil.join(params, new Function<PsiTypeParameter, String>() {
-      @Override
-      public String fun(PsiTypeParameter psiTypeParameter) {
-        String extendsList = "";
-        if (psiTypeParameter.getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
-          final PsiClassType[] extendsListTypes = psiTypeParameter.getExtendsListTypes();
-          if (extendsListTypes.length > 0) {
-            final Function<PsiClassType, String> canonicalTypePresentationFun = new Function<PsiClassType, String>() {
-              @Override
-              public String fun(PsiClassType type) {
-                return type.getCanonicalText();
-              }
-            };
-            extendsList = " extends " + StringUtil.join(extendsListTypes, canonicalTypePresentationFun, "&");
-          }
+    buf.append(StringUtil.join(params, psiTypeParameter -> {
+      String extendsList = "";
+      if (psiTypeParameter.getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
+        final PsiClassType[] extendsListTypes = psiTypeParameter.getExtendsListTypes();
+        if (extendsListTypes.length > 0) {
+          final Function<PsiClassType, String> canonicalTypePresentationFun = type -> type.getCanonicalText();
+          extendsList = " extends " + StringUtil.join(extendsListTypes, canonicalTypePresentationFun, "&");
         }
-        return generator.generateUniqueName(psiTypeParameter.getName()) + extendsList;
       }
+      return generator.generateUniqueName(psiTypeParameter.getName()) + extendsList;
     }, ", "));
     buf.append(">");
 
@@ -397,12 +378,7 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
     buf.append(qualifiedName != null ? qualifiedName : containingClass.getName());
     final PsiTypeParameter[] parameters = containingClass.getTypeParameters();
     buf.append("<");
-    buf.append(StringUtil.join(parameters, new Function<PsiTypeParameter, String>() {
-      @Override
-      public String fun(PsiTypeParameter psiTypeParameter) {
-        return psiTypeParameter.getName();
-      }
-    }, ", "));
+    buf.append(StringUtil.join(parameters, psiTypeParameter -> psiTypeParameter.getName(), ", "));
     buf.append("> ");
 
     String staticFactoryName = "staticFactory";
index e3c6a396c9ad3bcfcfc5efade9884209549139ff..ba9a4be989d8bc4d0185c6ae2cd28fac549556fe 100644 (file)
@@ -47,12 +47,7 @@ public class ControlFlowFactory {
 
 
   public ControlFlowFactory(PsiManagerEx psiManager) {
-    psiManager.registerRunnableToRunOnChange(new Runnable(){
-      @Override
-      public void run() {
-        clearCache();
-      }
-    });
+    psiManager.registerRunnableToRunOnChange(() -> clearCache());
   }
 
   private void clearCache() {
index 356ce61b53fc550eeabe5c512fed2e0597a840d4..225f111ed06e0044bde9d9f84fcf4eb253951fd9 100644 (file)
@@ -597,13 +597,10 @@ public class ControlFlowUtil {
         };
         graph.buildFrom(flow);
 
-        return new Function<Integer, BitSet>() {
-          @Override
-          public BitSet fun(Integer startOffset) {
-            BitSet visitedOffsets = new BitSet(flowEnd);
-            graph.depthFirstSearch(startOffset, visitedOffsets);
-            return visitedOffsets;
-          }
+        return startOffset -> {
+          BitSet visitedOffsets = new BitSet(flowEnd);
+          graph.depthFirstSearch(startOffset, visitedOffsets);
+          return visitedOffsets;
         };
       }
     }
index c5b27bfcb5a8769221bacf1a0b54904e9c4ae84b..61b0a7e7dd5856218f182a0020e604be9e748e44 100644 (file)
@@ -102,12 +102,8 @@ public class ElementPresentationUtil implements PlatformIcons {
 
     CachedValue<Integer> value = aClass.getUserData(CLASS_KIND_KEY);
     if (value == null) {
-      value = CachedValuesManager.getManager(aClass.getProject()).createCachedValue(new CachedValueProvider<Integer>() {
-        @Override
-        public Result<Integer> compute() {
-          return Result.createSingleDependency(Integer.valueOf(getClassKindImpl(aClass)), aClass);
-        }
-      }, false);
+      value = CachedValuesManager.getManager(aClass.getProject()).createCachedValue(
+        () -> CachedValueProvider.Result.createSingleDependency(Integer.valueOf(getClassKindImpl(aClass)), aClass), false);
       aClass.putUserData(CLASS_KIND_KEY, value);
     }
     return value.getValue().intValue();
index 73b72a0943b0308cf402cfc93b38c93ee9047acf..4d82d0195fc21efd4cb91c879214ed6289221a6f 100644 (file)
@@ -52,12 +52,7 @@ public class JavaConstantExpressionEvaluator extends JavaRecursiveElementWalking
           throwExceptionOnOverflow ? CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY : CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY;
         return CachedValuesManager.getManager(myProject).getCachedValue(myProject, key, PROVIDER, false);
       }
-    } : new Factory<ConcurrentMap<PsiElement, Object>>() {
-      @Override
-      public ConcurrentMap<PsiElement, Object> create() {
-        return auxEvaluator.getCacheMap(throwExceptionOnOverflow);
-      }
-    };
+    } : () -> auxEvaluator.getCacheMap(throwExceptionOnOverflow);
     myProject = project;
     myConstantExpressionVisitor = new ConstantExpressionVisitor(visitedVars, throwExceptionOnOverflow, auxEvaluator);
   }
@@ -83,12 +78,9 @@ public class JavaConstantExpressionEvaluator extends JavaRecursiveElementWalking
     }
   }
 
-  private static final CachedValueProvider<ConcurrentMap<PsiElement,Object>> PROVIDER = new CachedValueProvider<ConcurrentMap<PsiElement,Object>>() {
-    @Override
-    public Result<ConcurrentMap<PsiElement,Object>> compute() {
-      ConcurrentMap<PsiElement, Object> value = ContainerUtil.createConcurrentSoftMap();
-      return Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
-    }
+  private static final CachedValueProvider<ConcurrentMap<PsiElement,Object>> PROVIDER = () -> {
+    ConcurrentMap<PsiElement, Object> value = ContainerUtil.createConcurrentSoftMap();
+    return CachedValueProvider.Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
   };
 
   private Object getCached(@NotNull PsiElement element) {
index 8129627033e51ab43f84d8a2047f65f537b8c958..c1ecde92125bc6118e64f3b76d8dc5b2f69e8611 100644 (file)
@@ -250,20 +250,17 @@ public class PsiClassImplUtil {
     }
   }
 
-  private static final Function<ClassIconRequest, Icon> FULL_ICON_EVALUATOR = new NullableFunction<ClassIconRequest, Icon>() {
-    @Override
-    public Icon fun(ClassIconRequest r) {
-      if (!r.psiClass.isValid() || r.psiClass.getProject().isDisposed()) return null;
-
-      final boolean isLocked = BitUtil.isSet(r.flags, Iconable.ICON_FLAG_READ_STATUS) && !r.psiClass.isWritable();
-      Icon symbolIcon = r.symbolIcon != null
-                        ? r.symbolIcon
-                        : ElementPresentationUtil.getClassIconOfKind(r.psiClass, ElementPresentationUtil.getClassKind(r.psiClass));
-      RowIcon baseIcon = ElementPresentationUtil.createLayeredIcon(symbolIcon, r.psiClass, isLocked);
-      Icon result = ElementPresentationUtil.addVisibilityIcon(r.psiClass, r.flags, baseIcon);
-      Iconable.LastComputedIcon.put(r.psiClass, result, r.flags);
-      return result;
-    }
+  private static final Function<ClassIconRequest, Icon> FULL_ICON_EVALUATOR = (NullableFunction<ClassIconRequest, Icon>)r -> {
+    if (!r.psiClass.isValid() || r.psiClass.getProject().isDisposed()) return null;
+
+    final boolean isLocked = BitUtil.isSet(r.flags, Iconable.ICON_FLAG_READ_STATUS) && !r.psiClass.isWritable();
+    Icon symbolIcon = r.symbolIcon != null
+                      ? r.symbolIcon
+                      : ElementPresentationUtil.getClassIconOfKind(r.psiClass, ElementPresentationUtil.getClassKind(r.psiClass));
+    RowIcon baseIcon = ElementPresentationUtil.createLayeredIcon(symbolIcon, r.psiClass, isLocked);
+    Icon result = ElementPresentationUtil.addVisibilityIcon(r.psiClass, r.flags, baseIcon);
+    Iconable.LastComputedIcon.put(r.psiClass, result, r.flags);
+    return result;
   };
 
   public static Icon getClassIcon(final int flags, @NotNull PsiClass aClass) {
@@ -718,13 +715,9 @@ public class PsiClassImplUtil {
     if (last instanceof PsiReferenceList) return true;
 
     final Set<PsiClass> visited1 = visited;
-    return processSuperTypes(aClass, state.get(PsiSubstitutor.KEY), factory, languageLevel, resolveScope, new PairProcessor<PsiClass, PsiSubstitutor>() {
-      @Override
-      public boolean process(PsiClass superClass, PsiSubstitutor finalSubstitutor) {
-        return processDeclarationsInClass(superClass, processor, state.put(PsiSubstitutor.KEY, finalSubstitutor), visited1, last, place,
-                                          languageLevel, isRaw, resolveScope);
-      }
-    });
+    return processSuperTypes(aClass, state.get(PsiSubstitutor.KEY), factory, languageLevel, resolveScope,
+                             (superClass, finalSubstitutor) -> processDeclarationsInClass(superClass, processor, state.put(PsiSubstitutor.KEY, finalSubstitutor), visited1, last, place,
+                                                                                                               languageLevel, isRaw, resolveScope));
   }
 
   @Nullable
@@ -990,14 +983,11 @@ public class PsiClassImplUtil {
   private static <T extends PsiMember> List<Pair<T, PsiSubstitutor>> withSubstitutors(@NotNull final PsiClass psiClass, PsiMember[] members) {
     final ScopedClassHierarchy hierarchy = ScopedClassHierarchy.getHierarchy(psiClass, psiClass.getResolveScope());
     final LanguageLevel level = PsiUtil.getLanguageLevel(psiClass);
-    return ContainerUtil.map(members, new Function<PsiMember, Pair<T, PsiSubstitutor>>() {
-      @Override
-      public Pair<T, PsiSubstitutor> fun(PsiMember member) {
-        PsiClass containingClass = member.getContainingClass();
-        PsiSubstitutor substitutor = containingClass == null ? null : hierarchy.getSuperMembersSubstitutor(containingClass, level);
-        //noinspection unchecked
-        return Pair.create((T)member, substitutor == null ? PsiSubstitutor.EMPTY : substitutor);
-      }
+    return ContainerUtil.map(members, member -> {
+      PsiClass containingClass = member.getContainingClass();
+      PsiSubstitutor substitutor = containingClass == null ? null : hierarchy.getSuperMembersSubstitutor(containingClass, level);
+      //noinspection unchecked
+      return Pair.create((T)member, substitutor == null ? PsiSubstitutor.EMPTY : substitutor);
     });
   }
 
index 5bb044c3ffabe45195f51fe8d4f7b0d367269c44..b9ac0fc4ae121b395102870112b950913dc790a9 100644 (file)
@@ -116,12 +116,7 @@ public class PsiDiamondTypeUtil {
     text.append('<');
     final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class);
     final PsiDiamondType.DiamondInferenceResult result = PsiDiamondTypeImpl.resolveInferredTypesNoCheck(newExpression, newExpression);
-    text.append(StringUtil.join(result.getInferredTypes(), new Function<PsiType, String>() {
-      @Override
-      public String fun(PsiType psiType) {
-        return psiType.getCanonicalText();
-      }
-    }, ","));
+    text.append(StringUtil.join(result.getInferredTypes(), psiType -> psiType.getCanonicalText(), ","));
     text.append('>');
     final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(element.getProject());
     final PsiJavaCodeReferenceElement newReference = elementFactory.createReferenceFromText(text.toString(), element);
index 85da19dde5a971d4c8ea3873461c9d3e37ca5b4e..ecf56dfa55bf392383ad8c38ca2f6f0b4fafbbc3 100644 (file)
@@ -70,12 +70,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
 
   public PsiElementFactoryImpl(final PsiManagerEx manager) {
     super(manager);
-    manager.registerRunnableToRunOnChange(new Runnable() {
-      @Override
-      public void run() {
-        myCachedObjectType.clear();
-      }
-    });
+    manager.registerRunnableToRunOnChange(() -> myCachedObjectType.clear());
   }
 
   @NotNull
index 29cc8832feb7bc92a07ffd16e86ecd86bae99b7e..6e3413af74f808c50f0fc2d277c4faa4006f9b4d 100644 (file)
@@ -149,12 +149,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
     final PsiClassType[] extendsTypes = typeParameter.getExtendsListTypes();
     if (extendsTypes.length > 0) {
       // First bound
-      return ourGuard.doPreventingRecursion(extendsTypes[0], true, new Computable<PsiType>() {
-        @Override
-        public PsiType compute() {
-          return substitute(extendsTypes[0]);
-        }
-      });
+      return ourGuard.doPreventingRecursion(extendsTypes[0], true, () -> substitute(extendsTypes[0]));
     }
     // Object
     return PsiType.getJavaLangObject(typeParameter.getManager(), typeParameter.getResolveScope());
index e862ea99aff14df4350becc583e36afdb56286b7..f677540e73e6c84ab86727a0b9d942389f357aa3 100644 (file)
@@ -44,24 +44,14 @@ import java.util.*;
 public class PsiSuperMethodImplUtil {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiSuperMethodImplUtil");
   private static final PsiCacheKey<Map<MethodSignature, HierarchicalMethodSignature>, PsiClass> SIGNATURES_FOR_CLASS_KEY = PsiCacheKey
-    .create("SIGNATURES_FOR_CLASS_KEY", new NotNullFunction<PsiClass, Map<MethodSignature, HierarchicalMethodSignature>>() {
-      @NotNull
-      @Override
-      public Map<MethodSignature, HierarchicalMethodSignature> fun(PsiClass dom) {
-        return buildMethodHierarchy(dom, null, PsiSubstitutor.EMPTY, true, new THashSet<PsiClass>(), false, dom.getResolveScope());
-      }
-    });
+    .create("SIGNATURES_FOR_CLASS_KEY",
+            (NotNullFunction<PsiClass, Map<MethodSignature, HierarchicalMethodSignature>>)dom -> buildMethodHierarchy(dom, null, PsiSubstitutor.EMPTY, true, new THashSet<PsiClass>(), false, dom.getResolveScope()));
   private static final PsiCacheKey<FactoryMap<String, Map<MethodSignature, HierarchicalMethodSignature>>, PsiClass> SIGNATURES_BY_NAME_KEY = PsiCacheKey
-    .create("SIGNATURES_BY_NAME_KEY", new Function<PsiClass, FactoryMap<String, Map<MethodSignature, HierarchicalMethodSignature>>>() {
+    .create("SIGNATURES_BY_NAME_KEY", psiClass -> new ConcurrentFactoryMap<String, Map<MethodSignature, HierarchicalMethodSignature>>() {
+      @Nullable
       @Override
-      public FactoryMap<String, Map<MethodSignature, HierarchicalMethodSignature>> fun(final PsiClass psiClass) {
-        return new ConcurrentFactoryMap<String, Map<MethodSignature, HierarchicalMethodSignature>>() {
-          @Nullable
-          @Override
-          protected Map<MethodSignature, HierarchicalMethodSignature> create(String methodName) {
-            return buildMethodHierarchy(psiClass, methodName, PsiSubstitutor.EMPTY, true, new THashSet<PsiClass>(), false, psiClass.getResolveScope());
-          }
-        };
+      protected Map<MethodSignature, HierarchicalMethodSignature> create(String methodName) {
+        return buildMethodHierarchy(psiClass, methodName, PsiSubstitutor.EMPTY, true, new THashSet<PsiClass>(), false, psiClass.getResolveScope());
       }
     });
 
index 74168755e6a704e5cb719e13663c87f2e7fbc318..5172d0eb06f3900663bdce3bd139786cbebd5592 100644 (file)
@@ -109,19 +109,15 @@ class ScopedClassHierarchy {
 
   @NotNull
   static ScopedClassHierarchy getHierarchy(@NotNull final PsiClass psiClass, @NotNull final GlobalSearchScope resolveScope) {
-    return CachedValuesManager.getCachedValue(psiClass, new CachedValueProvider<Map<GlobalSearchScope, ScopedClassHierarchy>>() {
-      @Nullable
-      @Override
-      public Result<Map<GlobalSearchScope, ScopedClassHierarchy>> compute() {
-        Map<GlobalSearchScope, ScopedClassHierarchy> result = new ConcurrentFactoryMap<GlobalSearchScope, ScopedClassHierarchy>() {
-          @Nullable
-          @Override
-          protected ScopedClassHierarchy create(GlobalSearchScope resolveScope) {
-            return new ScopedClassHierarchy(psiClass, resolveScope);
-          }
-        };
-        return Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
-      }
+    return CachedValuesManager.getCachedValue(psiClass, () -> {
+      Map<GlobalSearchScope, ScopedClassHierarchy> result = new ConcurrentFactoryMap<GlobalSearchScope, ScopedClassHierarchy>() {
+        @Nullable
+        @Override
+        protected ScopedClassHierarchy create(GlobalSearchScope resolveScope1) {
+          return new ScopedClassHierarchy(psiClass, resolveScope1);
+        }
+      };
+      return CachedValueProvider.Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
     }).get(resolveScope);
   }
 
@@ -165,12 +161,7 @@ class ScopedClassHierarchy {
     List<PsiClassType.ClassResolveResult> list = myImmediateSupersWithCapturing;
     if (list == null) {
       RecursionGuard.StackStamp stamp = ourGuard.markStack();
-      list = ourGuard.doPreventingRecursion(this, true, new Computable<List<PsiClassType.ClassResolveResult>>() {
-        @Override
-        public List<PsiClassType.ClassResolveResult> compute() {
-          return calcImmediateSupersWithCapturing();
-        }
-      });
+      list = ourGuard.doPreventingRecursion(this, true, () -> calcImmediateSupersWithCapturing());
       if (list == null) {
         return Collections.emptyList();
       }
index 952c744e685ce2ae54ed217381a7764a69f6c6e8..cc4ad2f676bfd407a5e37196e8b8afea31c7e052 100644 (file)
@@ -167,15 +167,12 @@ class TypeCorrector extends PsiTypeMapper {
     @NotNull
     @Override
     public PsiType[] getParameters() {
-      return ContainerUtil.map2Array(myDelegate.getParameters(), PsiType.class, new Function<PsiType, PsiType>() {
-        @Override
-        public PsiType fun(PsiType type) {
-          if (type == null) {
-            LOG.error(myDelegate + " of " + myDelegate.getClass() + "; substitutor=" + myDelegate.resolveGenerics().getSubstitutor());
-            return null;
-          }
-          return mapType(type);
+      return ContainerUtil.map2Array(myDelegate.getParameters(), PsiType.class, type -> {
+        if (type == null) {
+          LOG.error(myDelegate + " of " + myDelegate.getClass() + "; substitutor=" + myDelegate.resolveGenerics().getSubstitutor());
+          return null;
         }
+        return mapType(type);
       });
     }
 
index 3416b85c479f4ccfbb0f32d284a5a0356fbc6e38..6c0d3e2006cdb036ca98b8b137be68fb17576b3f 100644 (file)
@@ -82,12 +82,7 @@ public class ClassFileStubBuilder implements BinaryFileStubBuilder {
     return null;
   }
 
-  private static final Comparator<Object> CLASS_NAME_COMPARATOR = new Comparator<Object>() {
-    @Override
-    public int compare(Object o1, Object o2) {
-      return o1.getClass().getName().compareTo(o2.getClass().getName());
-    }
-  };
+  private static final Comparator<Object> CLASS_NAME_COMPARATOR = (o1, o2) -> o1.getClass().getName().compareTo(o2.getClass().getName());
 
   @Override
   public int getStubVersion() {
index 51f54e7746d45980818e0d084e251b77b1d3b851..868334458964eda08f76f0802c1e603c918f4cfc 100644 (file)
@@ -369,13 +369,10 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
       }
     }
 
-    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiElement>() {
-      @Override
-      public Result<PsiElement> compute() {
-        PsiElement target = JavaPsiImplementationHelper.getInstance(getProject()).getClsFileNavigationElement(ClsFileImpl.this);
-        ModificationTracker tracker = FileIndexFacade.getInstance(getProject()).getRootModificationTracker();
-        return Result.create(target, ClsFileImpl.this, target.getContainingFile(), tracker);
-      }
+    return CachedValuesManager.getCachedValue(this, () -> {
+      PsiElement target = JavaPsiImplementationHelper.getInstance(getProject()).getClsFileNavigationElement(ClsFileImpl.this);
+      ModificationTracker tracker = FileIndexFacade.getInstance(getProject()).getRootModificationTracker();
+      return CachedValueProvider.Result.create(target, ClsFileImpl.this, target.getContainingFile(), tracker);
     });
   }
 
@@ -402,12 +399,9 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
           mirrorTreeElement = SourceTreeToPsiMap.psiToTreeNotNull(mirror);
           try {
             final TreeElement finalMirrorTreeElement = mirrorTreeElement;
-            ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
-              @Override
-              public void run() {
-                setMirror(finalMirrorTreeElement);
-                putUserData(CLS_DOCUMENT_LINK_KEY, document);
-              }
+            ProgressManager.getInstance().executeNonCancelableSection(() -> {
+              setMirror(finalMirrorTreeElement);
+              putUserData(CLS_DOCUMENT_LINK_KEY, document);
             });
           }
           catch (InvalidMirrorException e) {
@@ -626,12 +620,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
     PsiManager manager = PsiManager.getInstance(DefaultProjectFactory.getInstance().getDefaultProject());
     final ClsFileImpl clsFile = new ClsFileImpl(new ClassFileViewProvider(manager, file), true);
     final StringBuilder buffer = new StringBuilder();
-    ApplicationManager.getApplication().runReadAction(new Runnable() {
-      @Override
-      public void run() {
-        clsFile.appendMirrorText(0, buffer);
-      }
-    });
+    ApplicationManager.getApplication().runReadAction(() -> clsFile.appendMirrorText(0, buffer));
     return buffer;
   }
 
index 84157c5dcdf0d1d26b6722f0e47caeef3d92eb19..747503de8275301e568ce438f608b7f4c9c3af3e 100644 (file)
@@ -280,16 +280,10 @@ public class ClsMethodImpl extends ClsMemberImpl<PsiMethodStub> implements PsiAn
 
   @Nullable
   public PsiMethod getSourceMirrorMethod() {
-    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiMethod>() {
-      @Nullable
-      @Override
-      public Result<PsiMethod> compute() {
-        return Result.create(calcSourceMirrorMethod(),
-                             getContainingFile(),
-                             getContainingFile().getNavigationElement(),
-                             FileIndexFacade.getInstance(getProject()).getRootModificationTracker());
-      }
-    });
+    return CachedValuesManager.getCachedValue(this, () -> CachedValueProvider.Result.create(calcSourceMirrorMethod(),
+                                                                                            getContainingFile(),
+                                                                                            getContainingFile().getNavigationElement(),
+                                                                                            FileIndexFacade.getInstance(getProject()).getRootModificationTracker()));
   }
 
   @Nullable
index bc54704f6426c5f6b1c247bb2707caea080379a2..b626ae6630f66484e9a60184754a8884a77eaae9 100644 (file)
@@ -52,12 +52,8 @@ public class ClsPackageAccessibilityStatementImpl extends ClsRepositoryPsiElemen
       @NotNull
       @Override
       protected Iterable<PsiJavaModuleReferenceElement> compute() {
-        return ContainerUtil.map(getStub().getTargets(), new Function<String, PsiJavaModuleReferenceElement>() {
-          @Override
-          public PsiJavaModuleReferenceElement fun(String target) {
-            return new ClsJavaModuleReferenceElementImpl(ClsPackageAccessibilityStatementImpl.this, target);
-          }
-        });
+        return ContainerUtil.map(getStub().getTargets(),
+                                 target -> new ClsJavaModuleReferenceElementImpl(ClsPackageAccessibilityStatementImpl.this, target));
       }
     };
   }
index 4482da8db602e5d45e628cd266ab9387236ba3ce..70a98eabc7ed8e588af50fa95469712758f02338 100644 (file)
@@ -66,17 +66,11 @@ public class ClsParameterImpl extends ClsRepositoryPsiElement<PsiParameterStub>
 
   @Override
   public String getName() {
-    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<String>() {
-      @Nullable
-      @Override
-      public Result<String> compute() {
-        return Result.create(calcName(), 
-                             getContainingFile(),
-                             getContainingFile().getNavigationElement(),
-                             FileIndexFacade.getInstance(getProject()).getRootModificationTracker(),
-                             DumbService.getInstance(getProject()).getModificationTracker());
-      }
-    });
+    return CachedValuesManager.getCachedValue(this, () -> CachedValueProvider.Result.create(calcName(),
+                                                                                            getContainingFile(),
+                                                                                            getContainingFile().getNavigationElement(),
+                                                                                            FileIndexFacade.getInstance(getProject()).getRootModificationTracker(),
+                                                                                            DumbService.getInstance(getProject()).getModificationTracker()));
   }
 
   @Nullable 
index acb3f2b42ac7ae87de7f4dd55185dcdadb1e307e..b0f62c29d636e9eace1c3d41bae5c7ab5d96fba8 100644 (file)
@@ -177,12 +177,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
     ClassInfo result = new ClassInfo();
     result.typeParameters = ContainerUtil.emptyList();
     result.superName = superClass != null ? myMapping.fun(superClass) : null;
-    result.interfaceNames = superInterfaces == null ? null : ContainerUtil.map(superInterfaces, new Function<String, String>() {
-      @Override
-      public String fun(String name) {
-        return myMapping.fun(name);
-      }
-    });
+    result.interfaceNames = superInterfaces == null ? null : ContainerUtil.map(superInterfaces, name -> myMapping.fun(name));
     return result;
   }
 
@@ -244,12 +239,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
 
   @Override
   public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
-    return new AnnotationTextCollector(desc, myMapping, new Consumer<String>() {
-      @Override
-      public void consume(String text) {
-        new PsiAnnotationStubImpl(myModList, text);
-      }
-    });
+    return new AnnotationTextCollector(desc, myMapping, text -> new PsiAnnotationStubImpl(myModList, text));
   }
 
   @Override
@@ -420,12 +410,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
     }
     if (exceptions != null && (result.throwTypes == null || exceptions.length > result.throwTypes.size())) {
       // a signature may be inconsistent with exception list - in this case, the more complete list takes precedence
-      result.throwTypes = ContainerUtil.map(exceptions, new Function<String, String>() {
-        @Override
-        public String fun(String name) {
-          return myMapping.fun(name);
-        }
-      });
+      result.throwTypes = ContainerUtil.map(exceptions, name -> myMapping.fun(name));
     }
 
     return result;
@@ -435,18 +420,8 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
     MethodInfo result = new MethodInfo();
     result.typeParameters = ContainerUtil.emptyList();
     result.returnType = toJavaType(Type.getReturnType(desc), myMapping);
-    result.argTypes = ContainerUtil.map(Type.getArgumentTypes(desc), new Function<Type, String>() {
-      @Override
-      public String fun(Type type) {
-        return toJavaType(type, myMapping);
-      }
-    });
-    result.throwTypes = exceptions == null ? null : ContainerUtil.map(exceptions, new Function<String, String>() {
-      @Override
-      public String fun(String name) {
-        return myMapping.fun(name);
-      }
-    });
+    result.argTypes = ContainerUtil.map(Type.getArgumentTypes(desc), type -> toJavaType(type, myMapping));
+    result.throwTypes = exceptions == null ? null : ContainerUtil.map(exceptions, name -> myMapping.fun(name));
     return result;
   }
 
@@ -513,24 +488,14 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
     @Override
     public AnnotationVisitor visitAnnotation(String name, String desc) {
       valuePairPrefix(name);
-      return new AnnotationTextCollector(desc, myMapping, new Consumer<String>() {
-        @Override
-        public void consume(String text) {
-          myBuilder.append(text);
-        }
-      });
+      return new AnnotationTextCollector(desc, myMapping, text -> myBuilder.append(text));
     }
 
     @Override
     public AnnotationVisitor visitArray(String name) {
       valuePairPrefix(name);
       myBuilder.append('{');
-      return new AnnotationTextCollector(null, myMapping, new Consumer<String>() {
-        @Override
-        public void consume(String text) {
-          myBuilder.append(text).append('}');
-        }
-      });
+      return new AnnotationTextCollector(null, myMapping, text -> myBuilder.append(text).append('}'));
     }
 
     @Override
@@ -555,24 +520,18 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
 
     @Override
     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
-      return new AnnotationTextCollector(desc, myMapping, new Consumer<String>() {
-        @Override
-        public void consume(String text) {
-          if (myFilter == null) myFilter = ContainerUtil.newTroveSet();
-          myFilter.add(text);
-          new PsiAnnotationStubImpl(myModList, text);
-        }
+      return new AnnotationTextCollector(desc, myMapping, text -> {
+        if (myFilter == null) myFilter = ContainerUtil.newTroveSet();
+        myFilter.add(text);
+        new PsiAnnotationStubImpl(myModList, text);
       });
     }
 
     @Override
     public AnnotationVisitor visitTypeAnnotation(int typeRef, final TypePath typePath, String desc, boolean visible) {
-      return new AnnotationTextCollector(desc, myMapping, new Consumer<String>() {
-        @Override
-        public void consume(String text) {
-          if (typePath == null && (myFilter == null || !myFilter.contains(text))) {
-            new PsiAnnotationStubImpl(myModList, text);
-          }
+      return new AnnotationTextCollector(desc, myMapping, text -> {
+        if (typePath == null && (myFilter == null || !myFilter.contains(text))) {
+          new PsiAnnotationStubImpl(myModList, text);
         }
       });
     }
@@ -609,42 +568,33 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
 
     @Override
     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
-      return new AnnotationTextCollector(desc, myMapping, new Consumer<String>() {
-        @Override
-        public void consume(String text) {
-          filter(0, text);
-          new PsiAnnotationStubImpl(myModList, text);
-        }
+      return new AnnotationTextCollector(desc, myMapping, text -> {
+        filter(0, text);
+        new PsiAnnotationStubImpl(myModList, text);
       });
     }
 
     @Override
     @Nullable
     public AnnotationVisitor visitParameterAnnotation(final int parameter, String desc, boolean visible) {
-      return parameter < myParamIgnoreCount ? null : new AnnotationTextCollector(desc, myMapping, new Consumer<String>() {
-        @Override
-        public void consume(String text) {
-          int idx = parameter - myParamIgnoreCount;
-          filter(idx + 1, text);
-          new PsiAnnotationStubImpl(myOwner.findParameter(idx).getModList(), text);
-        }
+      return parameter < myParamIgnoreCount ? null : new AnnotationTextCollector(desc, myMapping, text -> {
+        int idx = parameter - myParamIgnoreCount;
+        filter(idx + 1, text);
+        new PsiAnnotationStubImpl(myOwner.findParameter(idx).getModList(), text);
       });
     }
 
     @Override
     public AnnotationVisitor visitTypeAnnotation(int typeRef, final TypePath typePath, String desc, boolean visible) {
       final TypeReference ref = new TypeReference(typeRef);
-      return new AnnotationTextCollector(desc, myMapping, new Consumer<String>() {
-        @Override
-        public void consume(String text) {
-          if (ref.getSort() == TypeReference.METHOD_RETURN && typePath == null && !filtered(0, text)) {
-            new PsiAnnotationStubImpl(myModList, text);
-          }
-          else if (ref.getSort() == TypeReference.METHOD_FORMAL_PARAMETER && typePath == null) {
-            int idx = ref.getFormalParameterIndex();
-            if (!filtered(idx + 1, text)) {
-              new PsiAnnotationStubImpl(myOwner.findParameter(idx).getModList(), text);
-            }
+      return new AnnotationTextCollector(desc, myMapping, text -> {
+        if (ref.getSort() == TypeReference.METHOD_RETURN && typePath == null && !filtered(0, text)) {
+          new PsiAnnotationStubImpl(myModList, text);
+        }
+        else if (ref.getSort() == TypeReference.METHOD_FORMAL_PARAMETER && typePath == null) {
+          int idx = ref.getFormalParameterIndex();
+          if (!filtered(idx + 1, text)) {
+            new PsiAnnotationStubImpl(myOwner.findParameter(idx).getModList(), text);
           }
         }
       });
@@ -652,12 +602,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
 
     @Override
     public AnnotationVisitor visitAnnotationDefault() {
-      return new AnnotationTextCollector(null, myMapping, new Consumer<String>() {
-        @Override
-        public void consume(String text) {
-          ((PsiMethodStubImpl)myOwner).setDefaultValueText(text);
-        }
-      });
+      return new AnnotationTextCollector(null, myMapping, text -> ((PsiMethodStubImpl)myOwner).setDefaultValueText(text));
     }
 
     @Override
@@ -841,28 +786,25 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
     return null;
   }
 
-  public static final Function<String, String> GUESSING_MAPPER = new Function<String, String>() {
-    @Override
-    public String fun(String internalName) {
-      String canonicalText = internalName;
-
-      if (canonicalText.indexOf('$') >= 0) {
-        StringBuilder sb = new StringBuilder(canonicalText);
-        boolean updated = false;
-        for (int p = 0; p < sb.length(); p++) {
-          char c = sb.charAt(p);
-          if (c == '$' && p > 0 && sb.charAt(p - 1) != '/' && p < sb.length() - 1 && sb.charAt(p + 1) != '$') {
-            sb.setCharAt(p, '.');
-            updated = true;
-          }
-        }
-        if (updated) {
-          canonicalText = sb.toString();
+  public static final Function<String, String> GUESSING_MAPPER = internalName -> {
+    String canonicalText = internalName;
+
+    if (canonicalText.indexOf('$') >= 0) {
+      StringBuilder sb = new StringBuilder(canonicalText);
+      boolean updated = false;
+      for (int p = 0; p < sb.length(); p++) {
+        char c = sb.charAt(p);
+        if (c == '$' && p > 0 && sb.charAt(p - 1) != '/' && p < sb.length() - 1 && sb.charAt(p + 1) != '$') {
+          sb.setCharAt(p, '.');
+          updated = true;
         }
       }
-
-      return canonicalText.replace('/', '.');
+      if (updated) {
+        canonicalText = sb.toString();
+      }
     }
+
+    return canonicalText.replace('/', '.');
   };
 
   public static AnnotationVisitor getAnnotationTextCollector(String desc, Consumer<String> consumer) {
index 942a9e5cfd48813ad4e97da680b3aa1f127c1dc0..8c62b2c5c8188d59e40d157ae85dd03d925991d7 100644 (file)
@@ -82,14 +82,12 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
 
   @NotNull
   private CachedValue<Collection<PsiDirectory>> createCachedDirectories(final boolean includeLibrarySources) {
-    return CachedValuesManager.getManager(myManager.getProject()).createCachedValue(new CachedValueProvider<Collection<PsiDirectory>>() {
-      @Override
-      public Result<Collection<PsiDirectory>> compute() {
-        Collection<PsiDirectory> result = new ArrayList<PsiDirectory>();
-        Processor<PsiDirectory> processor = Processors.cancelableCollectProcessor(result);
-        getFacade().processPackageDirectories(PsiPackageImpl.this, allScope(), processor, includeLibrarySources);
-        return Result.create(result, PsiPackageImplementationHelper.getInstance().getDirectoryCachedValueDependencies(PsiPackageImpl.this));
-      }
+    return CachedValuesManager.getManager(myManager.getProject()).createCachedValue(() -> {
+      Collection<PsiDirectory> result = new ArrayList<PsiDirectory>();
+      Processor<PsiDirectory> processor = Processors.cancelableCollectProcessor(result);
+      getFacade().processPackageDirectories(PsiPackageImpl.this, allScope(), processor, includeLibrarySources);
+      return CachedValueProvider.Result
+        .create(result, PsiPackageImplementationHelper.getInstance().getDirectoryCachedValueDependencies(PsiPackageImpl.this));
     }, false);
   }
 
@@ -252,12 +250,7 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
     if (result == null) {
       List<PsiClass> fastClasses = ContainerUtil.newArrayList();
       for (PsiDirectory directory : getDirectories(scope)) {
-        List<PsiFile> sameNamed = ContainerUtil.filter(directory.getFiles(), new Condition<PsiFile>() {
-          @Override
-          public boolean value(PsiFile file) {
-            return file.getName().contains(name);
-          }
-        });
+        List<PsiFile> sameNamed = ContainerUtil.filter(directory.getFiles(), file -> file.getName().contains(name));
         Collections.addAll(fastClasses, CoreJavaDirectoryService.getPsiClasses(directory, sameNamed.toArray(new PsiFile[sameNamed.size()])));
       }
       if (!fastClasses.isEmpty()) {
@@ -280,12 +273,7 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
     if (allClasses.length == 1) {
       return PsiSearchScopeUtil.isInScope(scope, allClasses[0]) ? allClasses : PsiClass.EMPTY_ARRAY;
     }
-    PsiClass[] array = ContainerUtil.findAllAsArray(allClasses, new Condition<PsiClass>() {
-      @Override
-      public boolean value(PsiClass aClass) {
-        return PsiSearchScopeUtil.isInScope(scope, aClass);
-      }
-    });
+    PsiClass[] array = ContainerUtil.findAllAsArray(allClasses, aClass -> PsiSearchScopeUtil.isInScope(scope, aClass));
     Arrays.sort(array, PsiClassUtil.createScopeComparator(scope));
     return array;
   }
index a315c3ad4ac6ac39b412bc96028eac632688ee99..c0714a24a79948d4ef337e575cbfd2e692e7ed2c 100644 (file)
@@ -54,11 +54,7 @@ public class PsiTypeParameterStubImpl extends StubBase<PsiTypeParameter> impleme
   public List<PsiAnnotationStub> getAnnotations() {
     List<StubElement> children = getChildrenStubs();
 
-    return ContainerUtil.mapNotNull(children, new Function<StubElement, PsiAnnotationStub>() {
-      @Override
-      public PsiAnnotationStub fun(StubElement stubElement) {
-        return stubElement instanceof PsiAnnotationStub ? (PsiAnnotationStub)stubElement : null;
-      }
-    });
+    return ContainerUtil.mapNotNull(children,
+                                    stubElement -> stubElement instanceof PsiAnnotationStub ? (PsiAnnotationStub)stubElement : null);
   }
 }
\ No newline at end of file
index 54f16a7616f8590003ad5b989082271c3f5bef1a..a436d8672e11320d0107230d27dad77aa0fd4ad0 100644 (file)
@@ -168,12 +168,9 @@ public class LightJavaModule extends LightElement implements PsiJavaModule {
   public static LightJavaModule getModule(@NotNull final PsiManager manager, @NotNull final VirtualFile jarRoot) {
     final PsiDirectory directory = manager.findDirectory(jarRoot);
     assert directory != null : jarRoot;
-    return CachedValuesManager.getCachedValue(directory, new CachedValueProvider<LightJavaModule>() {
-      @Override
-      public Result<LightJavaModule> compute() {
-        LightJavaModule module = new LightJavaModule(manager, jarRoot);
-        return Result.create(module, directory);
-      }
+    return CachedValuesManager.getCachedValue(directory, () -> {
+      LightJavaModule module = new LightJavaModule(manager, jarRoot);
+      return CachedValueProvider.Result.create(module, directory);
     });
   }
 
index 0554e9b81c924e9c9a718a12497ebb902a85760e..384683aeb58c8ab71b332a14e3bf5e6d438c06df 100644 (file)
@@ -45,12 +45,8 @@ public class LightParameterListWrapper extends LightElement implements PsiParame
   public PsiParameter[] getParameters() {
     return mySubstitutor == PsiSubstitutor.EMPTY
            ? myDelegate.getParameters()
-           : ContainerUtil.map2Array(myDelegate.getParameters(), PsiParameter.class, new Function<PsiParameter, PsiParameter>() {
-             @Override
-             public PsiParameter fun(PsiParameter parameter) {
-               return new LightParameterWrapper(parameter, mySubstitutor);
-             }
-           });
+           : ContainerUtil.map2Array(myDelegate.getParameters(), PsiParameter.class,
+                                     (Function<PsiParameter, PsiParameter>)parameter -> new LightParameterWrapper(parameter, mySubstitutor));
   }
 
   @Override
index d19b54fdd75c35c86f7f9164316c808a6e5d115a..dce0fa937073248d5100da1f1b994c88992efcda 100644 (file)
@@ -39,22 +39,19 @@ public class MethodSuperSearcher implements QueryExecutor<MethodSignatureBackedB
   public boolean execute(@NotNull final SuperMethodsSearch.SearchParameters queryParameters, @NotNull final Processor<MethodSignatureBackedByPsiMethod> consumer) {
     final PsiClass parentClass = queryParameters.getPsiClass();
     final PsiMethod method = queryParameters.getMethod();
-    return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
-      @Override
-      public Boolean compute() {
-        HierarchicalMethodSignature signature = method.getHierarchicalMethodSignature();
+    return ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> {
+      HierarchicalMethodSignature signature = method.getHierarchicalMethodSignature();
 
-        final boolean checkBases = queryParameters.isCheckBases();
-        final boolean allowStaticMethod = queryParameters.isAllowStaticMethod();
-        final List<HierarchicalMethodSignature> supers = signature.getSuperSignatures();
-        for (HierarchicalMethodSignature superSignature : supers) {
-          if (MethodSignatureUtil.isSubsignature(superSignature, signature)) {
-            if (!addSuperMethods(superSignature, method, parentClass, allowStaticMethod, checkBases, consumer)) return false;
-          }
+      final boolean checkBases = queryParameters.isCheckBases();
+      final boolean allowStaticMethod = queryParameters.isAllowStaticMethod();
+      final List<HierarchicalMethodSignature> supers = signature.getSuperSignatures();
+      for (HierarchicalMethodSignature superSignature : supers) {
+        if (MethodSignatureUtil.isSubsignature(superSignature, signature)) {
+          if (!addSuperMethods(superSignature, method, parentClass, allowStaticMethod, checkBases, consumer)) return false;
         }
-
-        return true;
       }
+
+      return true;
     });
   }
 
index 8da119a067a2cd6f6820faaefea4c3e484d7acc3..1b3d740c7986b5235a7d9486debca82e02d13724 100644 (file)
@@ -151,19 +151,13 @@ public class SmartTypePointerManagerImpl extends SmartTypePointerManager {
 
     private DisjunctionTypePointer(@NotNull PsiDisjunctionType type) {
       super(type);
-      myPointers = ContainerUtil.map(type.getDisjunctions(), new Function<PsiType, SmartTypePointer>() {
-        @Override
-        public SmartTypePointer fun(PsiType psiType) {
-          return createSmartTypePointer(psiType);
-        }
-      });
+      myPointers = ContainerUtil.map(type.getDisjunctions(), psiType -> createSmartTypePointer(psiType));
     }
 
     @Override
     protected PsiDisjunctionType calcType() {
-      final List<PsiType> types = ContainerUtil.map(myPointers, new NullableFunction<SmartTypePointer, PsiType>() {
-        @Override public PsiType fun(SmartTypePointer typePointer) { return typePointer.getType(); }
-      });
+      final List<PsiType> types = ContainerUtil.map(myPointers,
+                                                    (NullableFunction<SmartTypePointer, PsiType>)typePointer -> typePointer.getType());
       return new PsiDisjunctionType(types, PsiManager.getInstance(myProject));
     }
   }
index 93e40991aea7981014f9012a35550eecb1b0f203..529c3f5fd60235b307b9a599f511b353880beee7 100644 (file)
@@ -50,46 +50,26 @@ public class ClassInnerStuffCache {
 
   @NotNull
   public PsiMethod[] getConstructors() {
-    return copy(CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiMethod[]>() {
-      @Nullable
-      @Override
-      public Result<PsiMethod[]> compute() {
-        return Result.create(PsiImplUtil.getConstructors(myClass), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
-      }
-    }));
+    return copy(CachedValuesManager.getCachedValue(myClass, () -> CachedValueProvider.Result
+      .create(PsiImplUtil.getConstructors(myClass), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker)));
   }
 
   @NotNull
   public PsiField[] getFields() {
-    return copy(CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiField[]>() {
-      @Nullable
-      @Override
-      public Result<PsiField[]> compute() {
-        return Result.create(getAllFields(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
-      }
-    }));
+    return copy(CachedValuesManager.getCachedValue(myClass, () -> CachedValueProvider.Result
+      .create(getAllFields(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker)));
   }
 
   @NotNull
   public PsiMethod[] getMethods() {
-    return copy(CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiMethod[]>() {
-      @Nullable
-      @Override
-      public Result<PsiMethod[]> compute() {
-        return Result.create(getAllMethods(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
-      }
-    }));
+    return copy(CachedValuesManager.getCachedValue(myClass, () -> CachedValueProvider.Result
+      .create(getAllMethods(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker)));
   }
 
   @NotNull
   public PsiClass[] getInnerClasses() {
-    return copy(CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiClass[]>() {
-      @Nullable
-      @Override
-      public Result<PsiClass[]> compute() {
-        return Result.create(getAllInnerClasses(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
-      }
-    }));
+    return copy(CachedValuesManager.getCachedValue(myClass, () -> CachedValueProvider.Result
+      .create(getAllInnerClasses(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker)));
   }
 
   @Nullable
@@ -97,13 +77,9 @@ public class ClassInnerStuffCache {
     if (checkBases) {
       return PsiClassImplUtil.findFieldByName(myClass, name, true);
     }
-    return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiField>>() {
-      @Nullable
-      @Override
-      public Result<Map<String, PsiField>> compute() {
-        return Result.create(getFieldsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
-      }
-    }).get(name);
+    return CachedValuesManager.getCachedValue(myClass,
+                                              () -> CachedValueProvider.Result
+                                                .create(getFieldsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker)).get(name);
   }
 
   @NotNull
@@ -111,13 +87,8 @@ public class ClassInnerStuffCache {
     if (checkBases) {
       return PsiClassImplUtil.findMethodsByName(myClass, name, true);
     }
-    PsiMethod[] methods = CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiMethod[]>>() {
-      @Nullable
-      @Override
-      public Result<Map<String, PsiMethod[]>> compute() {
-        return Result.create(getMethodsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
-      }
-    }).get(name);
+    PsiMethod[] methods = CachedValuesManager.getCachedValue(myClass, () -> CachedValueProvider.Result
+      .create(getMethodsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker)).get(name);
     return methods == null ? PsiMethod.EMPTY_ARRAY : methods.clone();
   }
 
@@ -127,37 +98,24 @@ public class ClassInnerStuffCache {
       return PsiClassImplUtil.findInnerByName(myClass, name, true);
     }
     else {
-      return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiClass>>() {
-        @Nullable
-        @Override
-        public Result<Map<String, PsiClass>> compute() {
-          return Result.create(getInnerClassesMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
-        }
-      }).get(name);
+      return CachedValuesManager.getCachedValue(myClass, () -> CachedValueProvider.Result
+        .create(getInnerClassesMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker)).get(name);
     }
   }
 
   @Nullable
   public PsiMethod getValuesMethod() {
-    return !myClass.isEnum() || myClass.getName() == null ? null : CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiMethod>() {
-      @Nullable
-      @Override
-      public Result<PsiMethod> compute() {
-        String text = "public static " + myClass.getName() + "[] values() { }";
-        return new Result<PsiMethod>(getSyntheticMethod(text), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
-      }
+    return !myClass.isEnum() || myClass.getName() == null ? null : CachedValuesManager.getCachedValue(myClass, () -> {
+      String text = "public static " + myClass.getName() + "[] values() { }";
+      return new CachedValueProvider.Result<PsiMethod>(getSyntheticMethod(text), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
     });
   }
 
   @Nullable
   public PsiMethod getValueOfMethod() {
-    return !myClass.isEnum() || myClass.getName() == null ? null : CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiMethod>() {
-      @Nullable
-      @Override
-      public Result<PsiMethod> compute() {
-        String text = "public static " + myClass.getName() + " valueOf(java.lang.String name) throws java.lang.IllegalArgumentException { }";
-        return new Result<PsiMethod>(getSyntheticMethod(text), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
-      }
+    return !myClass.isEnum() || myClass.getName() == null ? null : CachedValuesManager.getCachedValue(myClass, () -> {
+      String text = "public static " + myClass.getName() + " valueOf(java.lang.String name) throws java.lang.IllegalArgumentException { }";
+      return new CachedValueProvider.Result<PsiMethod>(getSyntheticMethod(text), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
     });
   }
 
index 6d2fae3e84c6022a6775f1bd40b2b3a5f5bf882f..594c76108751329e45fb2e5120b027bb0b0b45cb 100644 (file)
@@ -118,22 +118,12 @@ public class FileLocalResolver {
 
   @NotNull
   private JBIterable<LighterASTNode> walkChildrenScopes(JBIterable<LighterASTNode> children) {
-    return children.flatMap(new Function<LighterASTNode, Iterable<? extends LighterASTNode>>() {
-      @Override
-      public Iterable<? extends LighterASTNode> fun(LighterASTNode child) {
-        return getDeclarations(child, null);
-      }
-    });
+    return children.flatMap(child -> getDeclarations(child, null));
   }
 
   @NotNull
   private static JBIterable<LighterASTNode> before(List<LighterASTNode> children, @Nullable final LighterASTNode lastParent) {
-    return JBIterable.from(children).filter(new Condition<LighterASTNode>() {
-      @Override
-      public boolean value(LighterASTNode node) {
-        return lastParent == null || node.getStartOffset() < lastParent.getStartOffset();
-      }
-    });
+    return JBIterable.from(children).filter(node -> lastParent == null || node.getStartOffset() < lastParent.getStartOffset());
   }
 
   /**
index 2de0d95e2d3424ea8023e248d95c7b522354f733..544ee49d8a0eeab6bbea76bef558be5406ea161a 100644 (file)
@@ -106,14 +106,10 @@ public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements
 
   @Override
   public PsiElement getOriginalElement() {
-    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiClass>() {
-      @Nullable
-      @Override
-      public Result<PsiClass> compute() {
-        final JavaPsiImplementationHelper helper = JavaPsiImplementationHelper.getInstance(getProject());
-        final PsiClass result = helper != null ? helper.getOriginalClass(PsiClassImpl.this) : PsiClassImpl.this;
-        return Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
-      }
+    return CachedValuesManager.getCachedValue(this, () -> {
+      final JavaPsiImplementationHelper helper = JavaPsiImplementationHelper.getInstance(getProject());
+      final PsiClass result = helper != null ? helper.getOriginalClass(PsiClassImpl.this) : PsiClassImpl.this;
+      return CachedValueProvider.Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
     });
   }
 
index 43bf3349a17e3abaaa82517a624f59a5a46eafd7..b0bf2bb920727ed9e62f69114d17e51781b4fb2d 100644 (file)
@@ -33,13 +33,8 @@ public class PsiImportListImpl extends JavaStubPsiElement<PsiImportListStub> imp
   private volatile Map<String,PsiImportStatement> myPackageNameToImportMap;
   private volatile Map<String,PsiImportStatementBase> myNameToSingleImportMap;
   private static final PsiImportStatementBase[] EMPTY_ARRAY = PsiImportStatementBase.EMPTY_ARRAY;
-  private static final ArrayFactory<PsiImportStatementBase> ARRAY_FACTORY = new ArrayFactory<PsiImportStatementBase>() {
-    @NotNull
-    @Override
-    public PsiImportStatementBase[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiImportStatementBase[count];
-    }
-  };
+  private static final ArrayFactory<PsiImportStatementBase> ARRAY_FACTORY =
+    count -> count == 0 ? EMPTY_ARRAY : new PsiImportStatementBase[count];
 
   public PsiImportListImpl(final PsiImportListStub stub) {
     super(stub, JavaStubElementTypes.IMPORT_LIST);
index 7557e97b7c3c8c29ee89c33726ddde1bad6ce04b..4a91d940e3567f572c13b411be4bbb7cc318c630 100644 (file)
@@ -24,13 +24,8 @@ import org.jetbrains.annotations.NotNull;
 
 public class PsiImportStatementImpl extends PsiImportStatementBaseImpl implements PsiImportStatement {
   public static final PsiImportStatementImpl[] EMPTY_ARRAY = new PsiImportStatementImpl[0];
-  public static final ArrayFactory<PsiImportStatementImpl> ARRAY_FACTORY = new ArrayFactory<PsiImportStatementImpl>() {
-    @NotNull
-    @Override
-    public PsiImportStatementImpl[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiImportStatementImpl[count];
-    }
-  };
+  public static final ArrayFactory<PsiImportStatementImpl> ARRAY_FACTORY =
+    count -> count == 0 ? EMPTY_ARRAY : new PsiImportStatementImpl[count];
 
   public PsiImportStatementImpl(final PsiImportStatementStub stub) {
     super(stub, JavaStubElementTypes.IMPORT_STATEMENT);
index 9286673b8eba0c7752e256847d29e3b6f595cba9..30c4966bb1998c3e4503dd8bacad9f2ac73cc039 100644 (file)
@@ -25,13 +25,8 @@ import org.jetbrains.annotations.Nullable;
 
 public class PsiImportStaticStatementImpl extends PsiImportStatementBaseImpl implements PsiImportStaticStatement {
   public static final PsiImportStaticStatementImpl[] EMPTY_ARRAY = new PsiImportStaticStatementImpl[0];
-  public static final ArrayFactory<PsiImportStaticStatementImpl> ARRAY_FACTORY = new ArrayFactory<PsiImportStaticStatementImpl>() {
-    @NotNull
-    @Override
-    public PsiImportStaticStatementImpl[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiImportStaticStatementImpl[count];
-    }
-  };
+  public static final ArrayFactory<PsiImportStaticStatementImpl> ARRAY_FACTORY =
+    count -> count == 0 ? EMPTY_ARRAY : new PsiImportStaticStatementImpl[count];
 
   public PsiImportStaticStatementImpl(final PsiImportStatementStub stub) {
     super(stub, JavaStubElementTypes.IMPORT_STATIC_STATEMENT);
index d180a4045f51fa3f27484e129147d9fe731b5d21..0c1f7e0a36719f50df05fd78c5f79eb28d146703 100644 (file)
@@ -479,13 +479,8 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava
     return JavaCodeStyleManager.getInstance(getProject()).addImport(this, aClass);
   }
 
-  private static final NotNullLazyKey<LanguageLevel, PsiJavaFileBaseImpl> LANGUAGE_LEVEL_KEY = NotNullLazyKey.create("LANGUAGE_LEVEL", new NotNullFunction<PsiJavaFileBaseImpl, LanguageLevel>() {
-    @Override
-    @NotNull
-    public LanguageLevel fun(PsiJavaFileBaseImpl file) {
-      return file.getLanguageLevelInner();
-    }
-  });
+  private static final NotNullLazyKey<LanguageLevel, PsiJavaFileBaseImpl> LANGUAGE_LEVEL_KEY = NotNullLazyKey.create("LANGUAGE_LEVEL",
+                                                                                                                     file -> file.getLanguageLevelInner());
 
   @Override
   @NotNull
index 95d606d4dbef6741336295ebd3b07732b0d0b6fb..6a9d9648f83e01ae6d0672c256a4f43a45865310 100644 (file)
@@ -116,12 +116,9 @@ public class PsiJavaModuleReference extends PsiReferenceBase.Poly<PsiJavaModuleR
     if (StringUtil.isEmpty(refText)) return Collections.emptyList();
     CachedValuesManager manager = CachedValuesManager.getManager(refOwner.getProject());
     Key<CachedValue<Collection<PsiJavaModule>>> key = incompleteCode ? K_INCOMPLETE : K_COMPLETE;
-    return manager.getCachedValue(refOwner, key, new CachedValueProvider<Collection<PsiJavaModule>>() {
-      @Override
-      public Result<Collection<PsiJavaModule>> compute() {
-        Collection<PsiJavaModule> modules = Resolver.findModules(refOwner.getContainingFile(), refText, incompleteCode);
-        return Result.create(modules, OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
-      }
+    return manager.getCachedValue(refOwner, key, () -> {
+      Collection<PsiJavaModule> modules = Resolver.findModules(refOwner.getContainingFile(), refText, incompleteCode);
+      return CachedValueProvider.Result.create(modules, OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
     }, false);
   }
 }
\ No newline at end of file
index 82d2a9d30334d895082cfec787ededf37caa07df..954a81ba339242c67967fc6bcc5075fc9ac16c5d 100644 (file)
@@ -42,14 +42,10 @@ public class PsiJavaModuleReferenceElementImpl extends CompositePsiElement imple
 
   @Override
   public PsiPolyVariantReference getReference() {
-    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiJavaModuleReference>() {
-      @Nullable
-      @Override
-      public Result<PsiJavaModuleReference> compute() {
-        PsiJavaModuleReferenceElementImpl refElement = PsiJavaModuleReferenceElementImpl.this;
-        PsiJavaModuleReference ref = refElement.getParent() instanceof PsiJavaModule ? null : new PsiJavaModuleReference(refElement);
-        return Result.create(ref, refElement);
-      }
+    return CachedValuesManager.getCachedValue(this, () -> {
+      PsiJavaModuleReferenceElementImpl refElement = PsiJavaModuleReferenceElementImpl.this;
+      PsiJavaModuleReference ref = refElement.getParent() instanceof PsiJavaModule ? null : new PsiJavaModuleReference(refElement);
+      return CachedValueProvider.Result.create(ref, refElement);
     });
   }
 
index e9e08148a1faf819027b33e1fba15ee523ebf908..78a7b1b60b47630f1b60d0d1e7ea8899109549e8 100644 (file)
@@ -303,13 +303,9 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
   @NotNull
   public MethodSignature getSignature(@NotNull PsiSubstitutor substitutor) {
     if (substitutor == PsiSubstitutor.EMPTY) {
-      return CachedValuesManager.getCachedValue(this, new CachedValueProvider<MethodSignature>() {
-        @Nullable
-        @Override
-        public Result<MethodSignature> compute() {
-          MethodSignature signature = MethodSignatureBackedByPsiMethod.create(PsiMethodImpl.this, PsiSubstitutor.EMPTY);
-          return Result.create(signature, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
-        }
+      return CachedValuesManager.getCachedValue(this, () -> {
+        MethodSignature signature = MethodSignatureBackedByPsiMethod.create(PsiMethodImpl.this, PsiSubstitutor.EMPTY);
+        return CachedValueProvider.Result.create(signature, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
       });
     }
     return MethodSignatureBackedByPsiMethod.create(this, substitutor);
@@ -350,12 +346,8 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
   @Override
   @NotNull
   public SearchScope getUseScope() {
-    return ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
-      @Override
-      public SearchScope compute() {
-        return PsiImplUtil.getMemberUseScope(PsiMethodImpl.this);
-      }
-    });
+    return ApplicationManager.getApplication().runReadAction(
+      (Computable<SearchScope>)() -> PsiImplUtil.getMemberUseScope(PsiMethodImpl.this));
   }
 
   @Override
index e7da8743175e32a17b226193e2ce8a4d90199506..f4fe5bd3cbd27b9161661b1a58859e2f2cfcfad8 100644 (file)
@@ -140,12 +140,7 @@ public class PsiModifierListImpl extends JavaStubPsiElement<PsiModifierListStub>
         }
         List<PsiField> fields = parent instanceof PsiExtensibleClass ? ((PsiExtensibleClass)parent).getOwnFields()
                                                                      : Arrays.asList(((PsiClass)parent).getFields());
-        boolean hasSubClass = ContainerUtil.find(fields, new Condition<PsiField>() {
-          @Override
-          public boolean value(PsiField field) {
-            return field instanceof PsiEnumConstant && ((PsiEnumConstant)field).getInitializingClass() != null;
-          }
-        }) != null;
+        boolean hasSubClass = ContainerUtil.find(fields, field -> field instanceof PsiEnumConstant && ((PsiEnumConstant)field).getInitializingClass() != null) != null;
         if (!hasSubClass) {
           implicitModifiers.add(FINAL);
         }
@@ -286,12 +281,9 @@ public class PsiModifierListImpl extends JavaStubPsiElement<PsiModifierListStub>
   @NotNull
   public PsiAnnotation[] getApplicableAnnotations() {
     final PsiAnnotation.TargetType[] targets = AnnotationTargetUtil.getTargetsForLocation(this);
-    List<PsiAnnotation> filtered = ContainerUtil.findAll(getAnnotations(), new Condition<PsiAnnotation>() {
-      @Override
-      public boolean value(PsiAnnotation annotation) {
-        PsiAnnotation.TargetType target = AnnotationTargetUtil.findAnnotationTarget(annotation, targets);
-        return target != null && target != PsiAnnotation.TargetType.UNKNOWN;
-      }
+    List<PsiAnnotation> filtered = ContainerUtil.findAll(getAnnotations(), annotation -> {
+      PsiAnnotation.TargetType target = AnnotationTargetUtil.findAnnotationTarget(annotation, targets);
+      return target != null && target != PsiAnnotation.TargetType.UNKNOWN;
     });
 
     return filtered.toArray(new PsiAnnotation[filtered.size()]);
index c9cc626e371bf903d02147ffc015739652c1c47c..ec789a9482f7d625b55c0bc3bbd1dc718b8c718b 100644 (file)
@@ -69,12 +69,7 @@ public class PsiParameterImpl extends JavaStubPsiElement<PsiParameterStub> imple
         final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(param, PsiLambdaExpression.class);
         if (lambdaExpression != null) {
           final PsiType functionalInterfaceType = LambdaUtil.ourParameterGuard.doPreventingRecursion(param, false,
-                                                                                                     new Computable<PsiType>() {
-                                                                                                         @Override
-                                                                                                         public PsiType compute() {
-                                                                                                           return LambdaUtil.getFunctionalInterfaceType(lambdaExpression, true);
-                                                                                                         }
-                                                                                                       });
+                                                                                                     () -> LambdaUtil.getFunctionalInterfaceType(lambdaExpression, true));
           PsiType type = FunctionalInterfaceParameterizationUtil.getGroundTargetType(functionalInterfaceType, lambdaExpression);
           if (type instanceof PsiIntersectionType) {
             final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts();
index 1b7c3ede8466976da02286cc9e2218d4d19f3064..74be88956f46e71b71b81f07232d685abbe8d450 100644 (file)
@@ -62,13 +62,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
   @Override
   @NotNull
   public PsiType getType() {
-    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiType>() {
-      @Nullable
-      @Override
-      public Result<PsiType> compute() {
-        return Result.create(calculateType(), PsiModificationTracker.MODIFICATION_COUNT);
-      }
-    });
+    return CachedValuesManager.getCachedValue(this, () -> CachedValueProvider.Result.create(calculateType(), PsiModificationTracker.MODIFICATION_COUNT));
   }
 
   private PsiType calculateType() {
@@ -196,12 +190,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
 
   private List<PsiType> collectTypes() {
     List<PsiTypeElement> typeElements = PsiTreeUtil.getChildrenOfTypeAsList(this, PsiTypeElement.class);
-    return ContainerUtil.map(typeElements, new Function<PsiTypeElement, PsiType>() {
-      @Override
-      public PsiType fun(PsiTypeElement typeElement) {
-        return typeElement.getType();
-      }
-    });
+    return ContainerUtil.map(typeElements, typeElement -> typeElement.getType());
   }
 
   @Override
index 80d7ffcd80dab7d253f49764022bfe7de7c8c108..72b0b7a11f123b7b6fee41bd67cb5a85a5b3d871 100644 (file)
@@ -42,13 +42,7 @@ public class PsiDocCommentImpl extends LazyParseablePsiElement implements PsiDoc
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.javadoc.PsiDocCommentImpl");
 
   private static final TokenSet TAG_BIT_SET = TokenSet.create(DOC_TAG);
-  private static final ArrayFactory<PsiDocTag> ARRAY_FACTORY = new ArrayFactory<PsiDocTag>() {
-    @NotNull
-    @Override
-    public PsiDocTag[] create(final int count) {
-      return count == 0 ? PsiDocTag.EMPTY_ARRAY : new PsiDocTag[count];
-    }
-  };
+  private static final ArrayFactory<PsiDocTag> ARRAY_FACTORY = count -> count == 0 ? PsiDocTag.EMPTY_ARRAY : new PsiDocTag[count];
 
   @SuppressWarnings({"HardCodedStringLiteral"})
   private static final Pattern WS_PATTERN = Pattern.compile("\\s*");
index 211893ceb737a4393d7dfaa80b37a4b8eee03a6b..026f7dff780a8d3cb0c557d0b0f1aa9c7460537f 100644 (file)
@@ -342,12 +342,7 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo
         if (hasSignature) {
           newText.append('(');
           PsiParameter[] parameters = method.getParameterList().getParameters();
-          newText.append(StringUtil.join(parameters, new Function<PsiParameter, String>() {
-            @Override
-            public String fun(PsiParameter parameter) {
-              return TypeConversionUtil.erasure(parameter.getType()).getCanonicalText();
-            }
-          }, ","));
+          newText.append(StringUtil.join(parameters, parameter -> TypeConversionUtil.erasure(parameter.getType()).getCanonicalText(), ","));
           newText.append(')');
         }
         newText.append("*/");
index 96b6f4b19271862288a07508d43bb70ef800e4fe..acc3cce05064c727724c48c5b9833bbdfe217625 100644 (file)
@@ -103,12 +103,8 @@ public class ProcessCandidateParameterTypeInferencePolicy extends DefaultParamet
       }
       if (parameter != null) {
         final PsiParameter finalParameter = parameter;
-        PsiType type = PsiResolveHelper.ourGuard.doPreventingRecursion(innerMethodCall, true, new Computable<PsiType>() {
-          @Override
-          public PsiType compute() {
-            return substitutor.substitute(finalParameter.getType());
-          }
-        });
+        PsiType type = PsiResolveHelper.ourGuard.doPreventingRecursion(innerMethodCall, true,
+                                                                       () -> substitutor.substitute(finalParameter.getType()));
         final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(finalParameter);
         final Pair<PsiType, ConstraintType> constraint =
           new PsiOldInferenceHelper(element.getManager()).getSubstitutionForTypeParameterConstraint(typeParameter, innerReturnType, type, false, languageLevel);
index 9b9cfa6b31d4bcb38eed8190763a1c8a5c33fc75..a167a0ac4ee451c8b3b296f24bf237a9f8a70923 100644 (file)
@@ -355,16 +355,13 @@ public class InferenceIncorporationPhase {
    * then for all i, 1 ≤ i ≤ n, if Si and Ti are types (not wildcards), the constraint ⟨Si = Ti⟩ is implied.
    */
   private boolean upUp(List<PsiType> upperBounds) {
-    return InferenceSession.findParameterizationOfTheSameGenericClass(upperBounds, new Processor<Pair<PsiType, PsiType>>() {
-      @Override
-      public boolean process(Pair<PsiType, PsiType> pair) {
-        final PsiType sType = pair.first;
-        final PsiType tType = pair.second;
-        if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) {
-          addConstraint(new TypeEqualityConstraint(sType, tType));
-        }
-        return false;
+    return InferenceSession.findParameterizationOfTheSameGenericClass(upperBounds, pair -> {
+      final PsiType sType = pair.first;
+      final PsiType tType = pair.second;
+      if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) {
+        addConstraint(new TypeEqualityConstraint(sType, tType));
       }
+      return false;
     }) != null;
   }
 
index c52c0dab74803ef045563ea23bef935f22eb6e3a..b69625c1f4159f69d3af36749f1e46c5cb15ffbe 100644 (file)
@@ -597,29 +597,25 @@ public class InferenceSession {
   public static JavaResolveResult getResolveResult(final PsiCall callExpression) {
     if (callExpression instanceof PsiNewExpression && PsiDiamondType.hasDiamond((PsiNewExpression)callExpression)) {
       PsiUtilCore.ensureValid(callExpression);
-      return CachedValuesManager.getCachedValue(callExpression, new CachedValueProvider<JavaResolveResult>() {
-        @Nullable
-        @Override
-        public Result<JavaResolveResult> compute() {
-          final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)callExpression).getClassOrAnonymousClassReference();
-          JavaResolveResult constructor = JavaResolveResult.EMPTY;
-          JavaResolveResult resolveResult = null;
-          if (classReference != null) {
-            resolveResult = classReference.advancedResolve(false);
-            final PsiElement psiClass = resolveResult.getElement();
-            if (psiClass != null) {
-              final JavaPsiFacade facade = JavaPsiFacade.getInstance(callExpression.getProject());
-              final PsiExpressionList argumentList = callExpression.getArgumentList();
-              if (argumentList != null) {
-                constructor = facade.getResolveHelper().resolveConstructor(facade.getElementFactory().createType((PsiClass)psiClass).rawType(),
-                                                                           argumentList,
-                                                                           callExpression);
-              }
+      return CachedValuesManager.getCachedValue(callExpression, () -> {
+        final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)callExpression).getClassOrAnonymousClassReference();
+        JavaResolveResult constructor = JavaResolveResult.EMPTY;
+        JavaResolveResult resolveResult = null;
+        if (classReference != null) {
+          resolveResult = classReference.advancedResolve(false);
+          final PsiElement psiClass = resolveResult.getElement();
+          if (psiClass != null) {
+            final JavaPsiFacade facade = JavaPsiFacade.getInstance(callExpression.getProject());
+            final PsiExpressionList argumentList = callExpression.getArgumentList();
+            if (argumentList != null) {
+              constructor = facade.getResolveHelper().resolveConstructor(facade.getElementFactory().createType((PsiClass)psiClass).rawType(),
+                                                                         argumentList,
+                                                                         callExpression);
             }
           }
-          return new Result<JavaResolveResult>(constructor.getElement() == null && resolveResult != null ? resolveResult : constructor,
-                                               PsiModificationTracker.MODIFICATION_COUNT);
         }
+        return new CachedValueProvider.Result<JavaResolveResult>(constructor.getElement() == null && resolveResult != null ? resolveResult : constructor,
+                                                                 PsiModificationTracker.MODIFICATION_COUNT);
       });
     }
     return callExpression.resolveMethodGenerics();
@@ -848,12 +844,8 @@ public class InferenceSession {
   private static boolean hasWildcardParameterization(InferenceVariable inferenceVariable, PsiClassType targetType) {
     if (!FunctionalInterfaceParameterizationUtil.isWildcardParameterized(targetType)) {
       final List<PsiType> bounds = inferenceVariable.getBounds(InferenceBound.LOWER);
-      final Processor<Pair<PsiType, PsiType>> differentParameterizationProcessor = new Processor<Pair<PsiType, PsiType>>() {
-        @Override
-        public boolean process(Pair<PsiType, PsiType> pair) {
-          return pair.first == null || pair.second == null || !TypesDistinctProver.provablyDistinct(pair.first, pair.second);
-        }
-      };
+      final Processor<Pair<PsiType, PsiType>> differentParameterizationProcessor =
+        pair -> pair.first == null || pair.second == null || !TypesDistinctProver.provablyDistinct(pair.first, pair.second);
       if (findParameterizationOfTheSameGenericClass(bounds, differentParameterizationProcessor) != null) return true;
       final List<PsiType> eqBounds = inferenceVariable.getBounds(InferenceBound.EQ);
       final List<PsiType> boundsToCheck = new ArrayList<PsiType>(bounds);
@@ -978,12 +970,7 @@ public class InferenceSession {
 
   public boolean collectDependencies(@Nullable PsiType type,
                                      @Nullable final Set<InferenceVariable> dependencies) {
-    return collectDependencies(type, dependencies, new Function<PsiClassType, InferenceVariable>() {
-      @Override
-      public InferenceVariable fun(PsiClassType classType) {
-        return getInferenceVariable(classType);
-      }
-    });
+    return collectDependencies(type, dependencies, classType -> getInferenceVariable(classType));
   }
 
   public static boolean collectDependencies(@Nullable PsiType type,
@@ -1307,18 +1294,8 @@ public class InferenceSession {
 
   public void registerIncompatibleErrorMessage(Collection<InferenceVariable> variables, String incompatibleTypesMessage) {
     variables = new ArrayList<InferenceVariable>(variables);
-    Collections.sort((ArrayList<InferenceVariable>)variables, new Comparator<InferenceVariable>() {
-      @Override
-      public int compare(InferenceVariable v1, InferenceVariable v2) {
-        return Comparing.compare(v1.getName(), v2.getName());
-      }
-    });
-    final String variablesEnumeration = StringUtil.join(variables, new Function<InferenceVariable, String>() {
-      @Override
-      public String fun(InferenceVariable variable) {
-        return variable.getParameter().getName();
-      }
-    }, ", ");
+    Collections.sort((ArrayList<InferenceVariable>)variables, (v1, v2) -> Comparing.compare(v1.getName(), v2.getName()));
+    final String variablesEnumeration = StringUtil.join(variables, variable -> variable.getParameter().getName(), ", ");
     registerIncompatibleErrorMessage("no instance(s) of type variable(s) " + variablesEnumeration + " exist so that " + incompatibleTypesMessage);
   }
   
@@ -1337,12 +1314,9 @@ public class InferenceSession {
                                                   final String lowBoundName,
                                                   final InferenceBound upperBound,
                                                   final String upperBoundName) {
-    final Function<PsiType, String> typePresentation = new Function<PsiType, String>() {
-      @Override
-      public String fun(PsiType type) {
-        final PsiType substituted = substituteNonProperBound(type, substitutor);
-        return getPresentableText(substituted != null ? substituted : type);
-      }
+    final Function<PsiType, String> typePresentation = type -> {
+      final PsiType substituted = substituteNonProperBound(type, substitutor);
+      return getPresentableText(substituted != null ? substituted : type);
     };
     return "inference variable " + var.getParameter().getName() + " has incompatible bounds:\n " + 
            lowBoundName  + ": " + StringUtil.join(var.getBounds(lowBound), typePresentation, ", ") + "\n" + 
@@ -1350,12 +1324,7 @@ public class InferenceSession {
   }
 
   private PsiType getLowerBound(InferenceVariable var, PsiSubstitutor substitutor) {
-    return composeBound(var, InferenceBound.LOWER, new Function<Pair<PsiType, PsiType>, PsiType>() {
-      @Override
-      public PsiType fun(Pair<PsiType, PsiType> pair) {
-        return GenericsUtil.getLeastUpperBound(pair.first, pair.second, myManager);
-      }
-    }, substitutor);
+    return composeBound(var, InferenceBound.LOWER, pair -> GenericsUtil.getLeastUpperBound(pair.first, pair.second, myManager), substitutor);
   }
 
   private PsiType getUpperBound(InferenceVariable var, PsiSubstitutor substitutor) {
@@ -1363,12 +1332,7 @@ public class InferenceSession {
   }
 
   public PsiType getEqualsBound(InferenceVariable var, PsiSubstitutor substitutor) {
-    return composeBound(var, InferenceBound.EQ, new Function<Pair<PsiType, PsiType>, PsiType>() {
-      @Override
-      public PsiType fun(Pair<PsiType, PsiType> pair) {
-        return !Comparing.equal(pair.first, pair.second) ? null : pair.first;
-      }
-    }, substitutor);
+    return composeBound(var, InferenceBound.EQ, pair -> !Comparing.equal(pair.first, pair.second) ? null : pair.first, substitutor);
   }
 
   private PsiType composeBound(InferenceVariable variable,
@@ -1704,13 +1668,8 @@ public class InferenceSession {
                                        final PsiExpression[] args,
                                        final PsiElement context,
                                        final boolean varargs) {
-    return LambdaUtil.performWithSubstitutedParameterBounds(m1.getTypeParameters(), siteSubstitutor1, new Producer<Boolean>() {
-      @Nullable
-      @Override
-      public Boolean produce() {
-        return isMoreSpecificInternal(m1, m2, siteSubstitutor1, args, context, varargs);
-      }
-    });
+    return LambdaUtil.performWithSubstitutedParameterBounds(m1.getTypeParameters(), siteSubstitutor1,
+                                                            () -> isMoreSpecificInternal(m1, m2, siteSubstitutor1, args, context, varargs));
   }
 
   private static boolean isMoreSpecificInternal(PsiMethod m1,
index 85a3ab20ce95532adf1373919c87f3e39697197f..7311d752845287f241225745225896fc1a3d7546 100644 (file)
@@ -78,14 +78,11 @@ public class InferenceSessionContainer {
           //traversing down would stop at lambda level and won't take into account overloaded method
           !MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argumentList)) {
         final PsiCall topLevelCall = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(parent, false,
-                                                                                          new Computable<PsiCall>() {
-                                                                                            @Override
-                                                                                            public PsiCall compute() {
-                                                                                              if (parent instanceof PsiExpression && !PsiPolyExpressionUtil.isPolyExpression((PsiExpression)parent)) {
-                                                                                                return null;
-                                                                                              }
-                                                                                              return LambdaUtil.treeWalkUp(parent);
+                                                                                          () -> {
+                                                                                            if (parent instanceof PsiExpression && !PsiPolyExpressionUtil.isPolyExpression((PsiExpression)parent)) {
+                                                                                              return null;
                                                                                             }
+                                                                                            return LambdaUtil.treeWalkUp(parent);
                                                                                           });
         if (topLevelCall != null) {
 
@@ -94,13 +91,8 @@ public class InferenceSessionContainer {
             session = startTopLevelInference(topLevelCall, policy);
           }
           else {
-            session = CachedValuesManager.getCachedValue(topLevelCall, new CachedValueProvider<InferenceSession>() {
-              @Nullable
-              @Override
-              public Result<InferenceSession> compute() {
-                return new Result<InferenceSession>(startTopLevelInference(topLevelCall, policy), PsiModificationTracker.MODIFICATION_COUNT);
-              }
-            });
+            session = CachedValuesManager.getCachedValue(topLevelCall,
+                                                         () -> new CachedValueProvider.Result<InferenceSession>(startTopLevelInference(topLevelCall, policy), PsiModificationTracker.MODIFICATION_COUNT));
 
             if (session != null) {
               //reject cached top level session if it was based on wrong candidate: check nested session if candidate (it's type parameters) are the same
@@ -186,16 +178,14 @@ public class InferenceSessionContainer {
                 final PsiType parameterTypeInTermsOfSession = initialInferenceState.getInferenceSubstitutor().substitute(parameterType);
                 final PsiType lambdaTargetType = compoundInitialState.getInitialSubstitutor().substitute(parameterTypeInTermsOfSession);
                 if (call.equals(PsiTreeUtil.getParentOfType(parent, PsiCall.class, true))) {
-                  return LambdaUtil.performWithLambdaTargetType((PsiLambdaExpression)gParent, partialSubstitutor.substitute(lambdaTargetType), new Producer<PsiSubstitutor>() {
-                    @Override
-                    public PsiSubstitutor produce() {
-                        //parent was mentioned in the top inference session
-                        //just proceed with the target type
-                        final InferenceSession inferenceSession = new InferenceSession(typeParameters, partialSubstitutor, parent.getManager(), parent, policy);
-                        inferenceSession.initExpressionConstraints(parameters, arguments, parent);
-                        return inferenceSession.infer(parameters, arguments, parent);
-                    }
-                  });
+                  return LambdaUtil.performWithLambdaTargetType((PsiLambdaExpression)gParent, partialSubstitutor.substitute(lambdaTargetType),
+                                                                () -> {
+                                                                    //parent was mentioned in the top inference session
+                                                                    //just proceed with the target type
+                                                                    final InferenceSession inferenceSession = new InferenceSession(typeParameters, partialSubstitutor, parent.getManager(), parent, policy);
+                                                                    inferenceSession.initExpressionConstraints(parameters, arguments, parent);
+                                                                    return inferenceSession.infer(parameters, arguments, parent);
+                                                                });
                 }
 
                 //one of the grand parents were found in the top inference session
@@ -268,15 +258,12 @@ public class InferenceSessionContainer {
       final PsiExpressionList topLevelCallArgumentList = topLevelCall.getArgumentList();
       LOG.assertTrue(topLevelCallArgumentList != null, topLevelCall);
       final PsiExpression[] topLevelArguments = topLevelCallArgumentList.getExpressions();
-      return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(topLevelCall, true, new Computable<InferenceSession>() {
-        @Override
-        public InferenceSession compute() {
-          final InferenceSession topLevelSession =
-            new InferenceSession(method.getTypeParameters(), ((MethodCandidateInfo)result).getSiteSubstitutor(), topLevelCall.getManager(), topLevelCall, policy);
-          topLevelSession.initExpressionConstraints(topLevelParameters, topLevelArguments, topLevelCall, method, ((MethodCandidateInfo)result).isVarargs());
-          topLevelSession.infer(topLevelParameters, topLevelArguments, topLevelCall, ((MethodCandidateInfo)result).createProperties());
-          return topLevelSession;
-        }
+      return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(topLevelCall, true, () -> {
+        final InferenceSession topLevelSession =
+          new InferenceSession(method.getTypeParameters(), ((MethodCandidateInfo)result).getSiteSubstitutor(), topLevelCall.getManager(), topLevelCall, policy);
+        topLevelSession.initExpressionConstraints(topLevelParameters, topLevelArguments, topLevelCall, method, ((MethodCandidateInfo)result).isVarargs());
+        topLevelSession.infer(topLevelParameters, topLevelArguments, topLevelCall, ((MethodCandidateInfo)result).createProperties());
+        return topLevelSession;
       });
     }
     return null;
index 65bcac7e6e804c67921296abc410f52a073b83ee..d41f4a3f921ae8236939c0822bf0a252b63f37d0 100644 (file)
@@ -50,12 +50,7 @@ public class InferenceVariablesOrder {
       }
     }
     final ArrayList<InferenceGraphNode<InferenceVariable>> acyclicNodes = initNodes(nodes.values());
-    return ContainerUtil.map(acyclicNodes, new Function<InferenceGraphNode<InferenceVariable>, List<InferenceVariable>>() {
-      @Override
-      public List<InferenceVariable> fun(InferenceGraphNode<InferenceVariable> node) {
-        return node.getValue();
-      }
-    }).iterator();
+    return ContainerUtil.map(acyclicNodes, node -> node.getValue()).iterator();
   }
 
   public static <T> List<List<InferenceGraphNode<T>>> tarjan(Collection<InferenceGraphNode<T>> nodes) {
index 0ebb4677986fbd4315f7365a2c27a567a8dd5895..1ac2b00e38f1c27b673e50e3b15424293db25ceb 100644 (file)
@@ -101,12 +101,8 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
       }
 
       final List<PsiType>
-        expectedThrownTypes = ContainerUtil.map(interfaceMethod.getThrowsList().getReferencedTypes(), new Function<PsiType, PsiType>() {
-        @Override
-        public PsiType fun(PsiType type) {
-          return session.substituteWithInferenceVariables(substitutor.substitute(type));
-        }
-      });
+        expectedThrownTypes = ContainerUtil.map(interfaceMethod.getThrowsList().getReferencedTypes(),
+                                                (Function<PsiType, PsiType>)type -> session.substituteWithInferenceVariables(substitutor.substitute(type)));
       final List<PsiType> expectedNonProperThrownTypes = new ArrayList<PsiType>();
       for (PsiType type : expectedThrownTypes) {
         if (!session.isProperType(type)) {
@@ -119,12 +115,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
       if (body != null) {
         final List<PsiClassType> exceptions =  ExceptionUtil.getUnhandledExceptions(new PsiElement[] {body});
         if (exceptions != null) {
-          thrownTypes.addAll(ContainerUtil.filter(exceptions, new Condition<PsiClassType>() {
-            @Override
-            public boolean value(PsiClassType type) {
-              return !ExceptionUtil.isUncheckedException(type);
-            }
-          }));
+          thrownTypes.addAll(ContainerUtil.filter(exceptions, type -> !ExceptionUtil.isUncheckedException(type)));
         }
       }
 
index a42d3ba8b38992e2f627cb2d5a01293a524c8295..3e40ed78d134d7cbf60590dbd837d83807aa2434 100644 (file)
@@ -80,12 +80,9 @@ public class LambdaExpressionCompatibilityConstraint implements ConstraintFormul
         }
         final PsiSubstitutor nestedSubstitutor = session.getInferenceSessionContainer().findNestedSubstitutor(myExpression, session.getInferenceSubstitution());
         returnType = nestedSubstitutor.substitute(substitutor.substitute(returnType));
-        boolean isProperType = InferenceSession.collectDependencies(returnType, null, new Function<PsiClassType, InferenceVariable>() {
-          @Override
-          public InferenceVariable fun(PsiClassType type) {
-            final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(type);
-            return psiClass instanceof InferenceVariable && nestedSubstitutor.getSubstitutionMap().containsValue(type) ? (InferenceVariable)psiClass : null;
-          }
+        boolean isProperType = InferenceSession.collectDependencies(returnType, null, type -> {
+          final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(type);
+          return psiClass instanceof InferenceVariable && nestedSubstitutor.getSubstitutionMap().containsValue(type) ? (InferenceVariable)psiClass : null;
         });
         if (!isProperType) {
           for (PsiExpression returnExpression : returnExpressions) {
index 1cf442943e97aa4e40d6e53baef09aa9efa36cda..ebb0090e937f32730f1f1e511eea476a5b384e15 100644 (file)
@@ -213,12 +213,7 @@ public class JavaSharedImplUtil {
       PsiAnnotation[] result = myCache;
       if (result == null) {
         List<PsiAnnotation> filtered = JBIterable.of(myCandidates)
-          .filter(new Condition<PsiAnnotation>() {
-            @Override
-            public boolean value(PsiAnnotation annotation) {
-              return AnnotationTargetUtil.isTypeAnnotation(annotation);
-            }
-          })
+          .filter(annotation -> AnnotationTargetUtil.isTypeAnnotation(annotation))
           .append(myOriginalProvider.getAnnotations())
           .toList();
         myCache = result = filtered.isEmpty() ? PsiAnnotation.EMPTY_ARRAY : filtered.toArray(new PsiAnnotation[filtered.size()]);
index 0bf1753614254befa20a944e858e0f5a6f6aa978..54142d9400fe336f16bac9f61606706e3519c6ad 100644 (file)
@@ -36,12 +36,8 @@ import org.jetbrains.annotations.Nullable;
  * @author ven
  */
 public class PsiAnnotationImpl extends JavaStubPsiElement<PsiAnnotationStub> implements PsiAnnotation {
-  private static final PairFunction<Project, String, PsiAnnotation> ANNOTATION_CREATOR = new PairFunction<Project, String, PsiAnnotation>() {
-    @Override
-    public PsiAnnotation fun(Project project, String text) {
-      return JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText(text, null);
-    }
-  };
+  private static final PairFunction<Project, String, PsiAnnotation> ANNOTATION_CREATOR =
+    (project, text) -> JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText(text, null);
 
   public PsiAnnotationImpl(final PsiAnnotationStub stub) {
     super(stub, JavaStubElementTypes.ANNOTATION);
index 561b545602633227ac655b75dd2a23f92586ed64..74eefc7a5f4c630584c820554ea51ac6450b08b3 100644 (file)
@@ -84,12 +84,7 @@ public class PsiBinaryExpressionImpl extends ExpressionPsiElement implements Psi
     return TypeConversionUtil.calcTypeForBinaryExpression(lType, rType, sign, true);
   }
 
-  private static final Function<PsiBinaryExpressionImpl,PsiType> MY_TYPE_EVALUATOR = new Function<PsiBinaryExpressionImpl, PsiType>() {
-    @Override
-    public PsiType fun(PsiBinaryExpressionImpl expression) {
-      return doGetType(expression);
-    }
-  };
+  private static final Function<PsiBinaryExpressionImpl,PsiType> MY_TYPE_EVALUATOR = expression -> doGetType(expression);
   @Override
   public PsiType getType() {
     return JavaResolveCache.getInstance(getProject()).getType(this, MY_TYPE_EVALUATOR);
index f5c8d30dcf6669b4fcc9d59b5e756649a92284eb..69a39cc6490194e2cfa5aeac40d5fc22d29fe4fd 100644 (file)
@@ -89,12 +89,10 @@ public class PsiCatchSectionImpl extends CompositePsiElement implements PsiCatch
     synchronized (myTypesCacheLock) {
       if (myTypesCache == null) {
         final CachedValuesManager cacheManager = CachedValuesManager.getManager(getProject());
-        myTypesCache = cacheManager.createCachedValue(new CachedValueProvider<List<PsiType>>() {
-            @Override public Result<List<PsiType>> compute() {
-              final List<PsiType> types = computePreciseCatchTypes(getParameter());
-              return Result.create(types, PsiModificationTracker.MODIFICATION_COUNT);
-            }
-          }, false);
+        myTypesCache = cacheManager.createCachedValue(() -> {
+          final List<PsiType> types = computePreciseCatchTypes(getParameter());
+          return CachedValueProvider.Result.create(types, PsiModificationTracker.MODIFICATION_COUNT);
+        }, false);
       }
       return myTypesCache;
     }
@@ -118,15 +116,12 @@ public class PsiCatchSectionImpl extends CompositePsiElement implements PsiCatch
       //     declared to the left of Cj for the same try statement, T is not assignable to Ei ...
       final PsiParameter[] parameters = statement.getCatchBlockParameters();
       final int currentIdx = ArrayUtil.find(parameters, parameter);
-      List<PsiType> uncaughtTypes = ContainerUtil.mapNotNull(thrownTypes, new NullableFunction<PsiClassType, PsiType>() {
-        @Override
-        public PsiType fun(final PsiClassType thrownType) {
-          for (int i = 0; i < currentIdx; i++) {
-            final PsiType catchType = parameters[i].getType();
-            if (catchType.isAssignableFrom(thrownType)) return null;
-          }
-          return thrownType;
+      List<PsiType> uncaughtTypes = ContainerUtil.mapNotNull(thrownTypes, (NullableFunction<PsiClassType, PsiType>)thrownType -> {
+        for (int i = 0; i < currentIdx; i++) {
+          final PsiType catchType = parameters[i].getType();
+          if (catchType.isAssignableFrom(thrownType)) return null;
         }
+        return thrownType;
       });
       // ... and T is assignable to Ej ...
       boolean passed = true;
index 9c4810967678fa65afcd3bfc3c488ad0c9254775..a4eb457fef9a637a37f8c6ffdd9bc1c9f5db54ee 100644 (file)
@@ -101,12 +101,7 @@ public class PsiLambdaExpressionImpl extends JavaStubPsiElement<FunctionalExpres
   public boolean isValueCompatible() {
     //it could be called when functional type of lambda expression is not yet defined (during lambda expression compatibility constraint reduction)
     //thus inferred results for calls inside could be wrong and should not be cached
-    final Boolean result = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(this, false, new Computable<Boolean>() {
-      @Override
-      public Boolean compute() {
-        return isValueCompatibleNoCache();
-      }
-    });
+    final Boolean result = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(this, false, () -> isValueCompatibleNoCache());
     return result != null && result;
   }
 
index 18ed26bd5e43fd6666cbe05422fad0c427dd45e7..6e91c8a1345c3220354c3f35d29c41665eb87133 100644 (file)
@@ -209,12 +209,7 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements
 
       boolean is15OrHigher = languageLevel.compareTo(LanguageLevel.JDK_1_5) >= 0;
       final PsiType getClassReturnType = PsiTypesUtil.patchMethodGetClassReturnType(call, methodExpression, method,
-                                                                                    new Condition<IElementType>() {
-                                                                                      @Override
-                                                                                      public boolean value(IElementType type) {
-                                                                                        return type != JavaElementType.CLASS;
-                                                                                      }
-                                                                                    }, languageLevel);
+                                                                                    type -> type != JavaElementType.CLASS, languageLevel);
 
       if (getClassReturnType != null) {
         return getClassReturnType;
index bb70ced2ef0cee5e498683168610ae91eb3375fc..deefabce78df609f4a39390390831f22b57811e2 100644 (file)
@@ -134,13 +134,8 @@ public class PsiMethodReferenceExpressionImpl extends JavaStubPsiElement<Functio
 
   @Override
   public PsiMember getPotentiallyApplicableMember() {
-    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiMember>() {
-      @Nullable
-      @Override
-      public Result<PsiMember> compute() {
-        return Result.create(getPotentiallyApplicableMemberInternal(), PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT, PsiMethodReferenceExpressionImpl.this);
-      }
-    });
+    return CachedValuesManager.getCachedValue(this, () -> CachedValueProvider.Result
+      .create(getPotentiallyApplicableMemberInternal(), PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT, PsiMethodReferenceExpressionImpl.this));
   }
 
   private PsiMember getPotentiallyApplicableMemberInternal() {
index d5a22919b586eaae7f3f3e7719f86986e93f8324..d0ea45221443b6ecb855b2487abd859b52d677c0 100644 (file)
@@ -59,12 +59,8 @@ public class PsiPolyadicExpressionImpl extends ExpressionPsiElement implements P
     return JavaResolveCache.getInstance(getProject()).getType(this, MY_TYPE_EVALUATOR);
   }
 
-  private static final Function<PsiPolyadicExpressionImpl,PsiType> MY_TYPE_EVALUATOR = new NullableFunction<PsiPolyadicExpressionImpl, PsiType>() {
-    @Override
-    public PsiType fun(PsiPolyadicExpressionImpl expression) {
-      return doGetType(expression);
-    }
-  };
+  private static final Function<PsiPolyadicExpressionImpl,PsiType> MY_TYPE_EVALUATOR =
+    (NullableFunction<PsiPolyadicExpressionImpl, PsiType>)expression -> doGetType(expression);
 
   @Nullable
   private static PsiType doGetType(PsiPolyadicExpressionImpl param) {
index 5b0b5d55522283cdc084a7214e42c5d565987b3c..bab9d4cfc2caaf96c8f9ec3cb121138fc8f6bed2 100644 (file)
@@ -519,19 +519,9 @@ public class PsiReferenceExpressionImpl extends PsiReferenceExpressionBase imple
     }
 
     if (seemsScrambled(aClass.getName())) {
-      List<PsiMethod> methods = ContainerUtil.filter(aClass.getMethods(), new Condition<PsiMethod>() {
-        @Override
-        public boolean value(PsiMethod method) {
-          return !method.hasModifierProperty(PsiModifier.PRIVATE);
-        }
-      });
+      List<PsiMethod> methods = ContainerUtil.filter(aClass.getMethods(), method -> !method.hasModifierProperty(PsiModifier.PRIVATE));
 
-      return !methods.isEmpty() && ContainerUtil.and(methods, new Condition<PsiMethod>() {
-        @Override
-        public boolean value(PsiMethod method) {
-          return seemsScrambled(method.getName());
-        }
-      });
+      return !methods.isEmpty() && ContainerUtil.and(methods, method -> seemsScrambled(method.getName()));
     }
 
     return false;
index 36593237c5fb577b50755a22323cce076798cd06..e845852d7506fb0a2e3148635f00312c3a03be1d 100644 (file)
@@ -78,12 +78,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
                 myArgumentsList.getText() + "; " +
                 "file=" + (method == null ? "<unknown>" : method.getContainingFile()));
     }
-    return MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(myArgumentsList, false, new Computable<CandidateInfo>() {
-      @Override
-      public CandidateInfo compute() {
-        return guardedOverloadResolution(conflicts);
-      }
-    });
+    return MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(myArgumentsList, false, () -> guardedOverloadResolution(conflicts));
   }
 
   @Nullable
index 4cc44f216592c112f2726fa1c4a1923a94dff39c..5cf3699caabe0b623fb3be6c5f0e108133b2192e 100644 (file)
@@ -58,12 +58,7 @@ public class CanonicalTypes {
     protected final TypeAnnotationProvider myProvider;
 
     public AnnotatedType(@NotNull TypeAnnotationProvider provider) {
-      PsiAnnotation[] annotations = ContainerUtil.map(provider.getAnnotations(), new Function<PsiAnnotation, PsiAnnotation>() {
-        @Override
-        public PsiAnnotation fun(PsiAnnotation annotation) {
-          return (PsiAnnotation)annotation.copy();
-        }
-      }, PsiAnnotation.EMPTY_ARRAY);
+      PsiAnnotation[] annotations = ContainerUtil.map(provider.getAnnotations(), annotation -> (PsiAnnotation)annotation.copy(), PsiAnnotation.EMPTY_ARRAY);
       myProvider = TypeAnnotationProvider.Static.create(annotations);
     }
   }
@@ -269,23 +264,13 @@ public class CanonicalTypes {
     @NotNull
     @Override
     public PsiType getType(final PsiElement context, final PsiManager manager) throws IncorrectOperationException {
-      List<PsiType> types = ContainerUtil.map(myTypes, new Function<Type, PsiType>() {
-        @Override
-        public PsiType fun(Type type) {
-          return type.getType(context, manager);
-        }
-      });
+      List<PsiType> types = ContainerUtil.map(myTypes, type -> type.getType(context, manager));
       return myDisjunction ? new PsiDisjunctionType(types, manager) : PsiIntersectionType.createIntersection(types);
     }
 
     @Override
     public String getTypeText() {
-      return StringUtil.join(myTypes, new Function<Type, String>() {
-        @Override
-        public String fun(Type type) {
-          return type.getTypeText();
-        }
-      }, myDisjunction ? "|" : "&");
+      return StringUtil.join(myTypes, type -> type.getTypeText(), myDisjunction ? "|" : "&");
     }
 
     @Override
@@ -353,24 +338,14 @@ public class CanonicalTypes {
 
     @Override
     public Type visitDisjunctionType(PsiDisjunctionType type) {
-      List<Type> types = ContainerUtil.map(type.getDisjunctions(), new Function<PsiType, Type>() {
-        @Override
-        public Type fun(PsiType type) {
-          return type.accept(Creator.this);
-        }
-      });
+      List<Type> types = ContainerUtil.map(type.getDisjunctions(), type1 -> type1.accept(Creator.this));
       return new LogicalOperationType(types, true);
     }
 
     @Nullable
     @Override
     public Type visitIntersectionType(PsiIntersectionType type) {
-      List<Type> types = ContainerUtil.map(type.getConjuncts(), new Function<PsiType, Type>() {
-        @Override
-        public Type fun(PsiType type) {
-          return type.accept(Creator.this);
-        }
-      });
+      List<Type> types = ContainerUtil.map(type.getConjuncts(), type1 -> type1.accept(Creator.this));
       return new LogicalOperationType(types, false);
     }
   }
index 145540f506a270e2c240640e687e15fd8a5fa7b0..0db4bd427e8aab324cac85a01d942dbc123104eb 100644 (file)
@@ -134,12 +134,7 @@ public class PsiEquivalenceUtil {
   public static void findChildRangeDuplicates(PsiElement first, PsiElement last,
                                               final List<Couple<PsiElement>> result,
                                               PsiElement scope) {
-    findChildRangeDuplicates(first, last, scope, new PairConsumer<PsiElement, PsiElement>() {
-      @Override
-      public void consume(final PsiElement start, final PsiElement end) {
-        result.add(Couple.of(start, end));
-      }
-    });
+    findChildRangeDuplicates(first, last, scope, (start, end) -> result.add(Couple.of(start, end)));
   }
 
   public static void findChildRangeDuplicates(PsiElement first, PsiElement last, PsiElement scope,
index cb4b5f60a761e0390b58b4e56d3520cf5e15386e..6e60c3913c05f155c5fd282b8e799b1f4b594374 100644 (file)
@@ -42,12 +42,8 @@ public final class LanguageUtil {
   private LanguageUtil() {
   }
 
-  public static final Comparator<Language> LANGUAGE_COMPARATOR = new Comparator<Language>() {
-    @Override
-    public int compare(Language o1, Language o2) {
-      return StringUtil.naturalCompare(o1.getDisplayName(), o2.getDisplayName());
-    }
-  };
+  public static final Comparator<Language> LANGUAGE_COMPARATOR =
+    (o1, o2) -> StringUtil.naturalCompare(o1.getDisplayName(), o2.getDisplayName());
 
 
   @Nullable
@@ -88,12 +84,7 @@ public final class LanguageUtil {
 
   @NotNull
   public static Language[] getLanguageDialects(@NotNull final Language base) {
-    final List<Language> list = ContainerUtil.findAll(Language.getRegisteredLanguages(), new Condition<Language>() {
-      @Override
-      public boolean value(final Language language) {
-        return language.getBaseLanguage() == base;
-      }
-    });
+    final List<Language> list = ContainerUtil.findAll(Language.getRegisteredLanguages(), language -> language.getBaseLanguage() == base);
     return list.toArray(new Language[list.size()]);
   }
 
index 73d862ad4a2e74131c7331da32fd52cc98d8dd43..d3ed4d462230d5edade05698cc597b46a0f260ca 100644 (file)
@@ -57,28 +57,20 @@ public abstract class QueryExecutorBase<Result, Params> implements QueryExecutor
   @Override
   public final boolean execute(@NotNull final Params queryParameters, @NotNull final Processor<Result> consumer) {
     final AtomicBoolean toContinue = new AtomicBoolean(true);
-    final Processor<Result> wrapper = new Processor<Result>() {
-      @Override
-      public boolean process(Result result) {
-        if (!toContinue.get()) {
-          return false;
-        }
+    final Processor<Result> wrapper = result -> {
+      if (!toContinue.get()) {
+        return false;
+      }
 
-        if (!consumer.process(result)) {
-          toContinue.set(false);
-          return false;
-        }
-        return true;
+      if (!consumer.process(result)) {
+        toContinue.set(false);
+        return false;
       }
+      return true;
     };
 
     if (myRequireReadAction && !ApplicationManager.getApplication().isReadAccessAllowed()) {
-      Runnable runnable = new Runnable() {
-        @Override
-        public void run() {
-          processQuery(queryParameters, wrapper);
-        }
-      };
+      Runnable runnable = () -> processQuery(queryParameters, wrapper);
       
       if (!DumbService.isDumbAware(this)) {
         Project project = queryParameters instanceof DumbAwareSearchParameters ? ((DumbAwareSearchParameters)queryParameters).getProject()
index 1738cd4c48cc411e2be956a15898df661229d75e..19ed653bb41fcad370d2feb9571f5efd8ef8878f 100644 (file)
@@ -25,12 +25,7 @@ public abstract class ReadAction<T> extends BaseActionRunnable<T> {
   @Override
   public RunResult<T> execute() {
     final RunResult<T> result = new RunResult<T>(this);
-    return ApplicationManager.getApplication().runReadAction(new Computable<RunResult<T>>() {
-      @Override
-      public RunResult<T> compute() {
-        return result.run();
-      }
-    });
+    return ApplicationManager.getApplication().runReadAction((Computable<RunResult<T>>)() -> result.run());
   }
 
   public static AccessToken start() {
index ba765566c042e19fa4460b078f1bd15f6a04c1c1..6219b24217181d36ef7b3db1edf665ad75af6c9b 100644 (file)
@@ -26,27 +26,12 @@ import org.jetbrains.annotations.NotNull;
 public abstract class ReadActionProcessor<T> implements Processor<T> {
   @Override
   public boolean process(final T t) {
-    return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>(){
-      @Override
-      public Boolean compute() {
-        return processInReadAction(t);
-      }
-    });
+    return ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> processInReadAction(t));
   }
   public abstract boolean processInReadAction(T t);
 
   @NotNull
   public static <T> Processor<T> wrapInReadAction(@NotNull final Processor<T> processor) {
-    return new Processor<T>() {
-      @Override
-      public boolean process(final T t) {
-        return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
-          @Override
-          public Boolean compute() {
-            return processor.process(t);
-          }
-        });
-      }
-    };
+    return t -> ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> processor.process(t));
   }
 }
index 90806e9a173f6b19e28db5d2c9363915e9ef8354..e458ca9100a32a26b21bfb22af4acf9e996fa6cc 100644 (file)
@@ -47,16 +47,13 @@ public abstract class WriteAction<T> extends BaseActionRunnable<T> {
       LOG.error("Must not start write action from within read action in the other thread - deadlock is coming");
     }
 
-    TransactionGuard.getInstance().submitTransactionAndWait(new Runnable() {
-      @Override
-      public void run() {
-        AccessToken token = start(WriteAction.this.getClass());
-        try {
-          result.run();
-        }
-        finally {
-          token.finish();
-        }
+    TransactionGuard.getInstance().submitTransactionAndWait(() -> {
+      AccessToken token = start(WriteAction.this.getClass());
+      try {
+        result.run();
+      }
+      finally {
+        token.finish();
       }
     });
 
index 3bd15a607bc6d5196df0fbfeae73da44f940ab39..4e828fe3ee946fa894ed214b0d9c42e2614ae994 100644 (file)
@@ -152,12 +152,7 @@ public abstract class WriteCommandAction<T> extends BaseActionRunnable<T> {
     }
     else {
       try {
-        TransactionGuard.getInstance().submitTransactionAndWait(new Runnable() {
-          @Override
-          public void run() {
-            performWriteCommandAction(result);
-          }
-        });
+        TransactionGuard.getInstance().submitTransactionAndWait(() -> performWriteCommandAction(result));
       }
       catch (ProcessCanceledException ignored) { }
     }
@@ -170,18 +165,12 @@ public abstract class WriteCommandAction<T> extends BaseActionRunnable<T> {
     // this is needed to prevent memory leak, since the command is put into undo queue
     final RunResult[] results = {result};
 
-    doExecuteCommand(new Runnable() {
-      @Override
-      public void run() {
-        //noinspection deprecation
-        ApplicationManager.getApplication().runWriteAction(new Runnable() {
-          @Override
-          public void run() {
-            results[0].run();
-            results[0] = null;
-          }
-        });
-      }
+    doExecuteCommand(() -> {
+      //noinspection deprecation
+      ApplicationManager.getApplication().runWriteAction(() -> {
+        results[0].run();
+        results[0] = null;
+      });
     });
   }
 
@@ -206,12 +195,9 @@ public abstract class WriteCommandAction<T> extends BaseActionRunnable<T> {
     final RunResult[] results = {new RunResult<T>(this)};
     final Ref<Throwable> exception = new Ref<Throwable>();
 
-    doExecuteCommand(new Runnable() {
-      @Override
-      public void run() {
-        exception.set(results[0].run().getThrowable());
-        results[0] = null;
-      }
+    doExecuteCommand(() -> {
+      exception.set(results[0].run().getThrowable());
+      results[0] = null;
     });
 
     Throwable throwable = exception.get();
@@ -219,12 +205,9 @@ public abstract class WriteCommandAction<T> extends BaseActionRunnable<T> {
   }
 
   private void doExecuteCommand(final Runnable runnable) {
-    Runnable wrappedRunnable = new Runnable() {
-      @Override
-      public void run() {
-        if (isGlobalUndoAction()) CommandProcessor.getInstance().markCurrentCommandAsGlobal(getProject());
-        runnable.run();
-      }
+    Runnable wrappedRunnable = () -> {
+      if (isGlobalUndoAction()) CommandProcessor.getInstance().markCurrentCommandAsGlobal(getProject());
+      runnable.run();
     };
     CommandProcessor.getInstance().executeCommand(getProject(), wrappedRunnable, getCommandName(), getGroupID(),
                                                   getUndoConfirmationPolicy(), shouldRecordActionForActiveDocument());
index 8fe067f7d7f449b18bd3ee6a10414f42b97ef29c..3f847722ef65cd9922ffb325462abb63b8492904 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.NotNullLazyKey;
-import com.intellij.util.NotNullFunction;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.picocontainer.PicoContainer;
@@ -72,12 +71,6 @@ public class ServiceManager {
    * @return Key instance.
    */
   public static <T> NotNullLazyKey<T, Project> createLazyKey(@NotNull final Class<T> serviceClass) {
-    return NotNullLazyKey.create("Service: " + serviceClass.getName(), new NotNullFunction<Project, T>() {
-      @Override
-      @NotNull
-      public T fun(Project project) {
-        return getService(project, serviceClass);
-      }
-    });
+    return NotNullLazyKey.create("Service: " + serviceClass.getName(), project -> getService(project, serviceClass));
   }
 }
index 18e23a005a053a2e6149bc0a2f1e3c50c016fd2c..e19d027f37878c7df40edfdfa812339ae55119a3 100644 (file)
@@ -16,7 +16,6 @@
 package com.intellij.openapi.editor.event;
 
 import com.intellij.util.ArrayFactory;
-import org.jetbrains.annotations.NotNull;
 
 import java.util.EventListener;
 
@@ -30,13 +29,7 @@ import java.util.EventListener;
 @SuppressWarnings("JavadocReference")
 public interface DocumentListener extends EventListener{
   DocumentListener[] EMPTY_ARRAY = new DocumentListener[0];
-  ArrayFactory<DocumentListener> ARRAY_FACTORY = new ArrayFactory<DocumentListener>() {
-    @NotNull
-    @Override
-    public DocumentListener[] create(int count) {
-      return count == 0 ? EMPTY_ARRAY : new DocumentListener[count];
-    }
-  };
+  ArrayFactory<DocumentListener> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new DocumentListener[count];
 
   /**
    * Called before the text of the document is changed.
index a168fdaec779e053dcdae2e708c38a37eab24b44..7cc84c75d20dc02926c3477d7c16a39781b81448 100644 (file)
@@ -25,10 +25,7 @@ public interface NonCancelableSection {
   void done();
 
   @NotNull
-  NonCancelableSection EMPTY = new NonCancelableSection() {
-    @Override
-    public void done() {
-      // do nothing
-    }
+  NonCancelableSection EMPTY = () -> {
+    // do nothing
   };
 }
index 364358922427d002487cf15745de46e55d3dbf45..a8a26a5943cfd8be2ba84467b2bde0dd8d5581e3 100644 (file)
@@ -89,12 +89,7 @@ public abstract class DumbService {
    */
   public <T> T runReadActionInSmartMode(@NotNull final Computable<T> r) {
     final Ref<T> result = new Ref<T>();
-    runReadActionInSmartMode(new Runnable() {
-      @Override
-      public void run() {
-        result.set(r.compute());
-      }
-    });
+    runReadActionInSmartMode(() -> result.set(r.compute()));
     return result.get();
   }
 
@@ -128,15 +123,12 @@ public abstract class DumbService {
 
     while (true) {
       waitForSmartMode();
-      boolean success = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
-        @Override
-        public Boolean compute() {
-          if (isDumb()) {
-            return false;
-          }
-          r.run();
-          return true;
+      boolean success = ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> {
+        if (isDumb()) {
+          return false;
         }
+        r.run();
+        return true;
       });
       if (success) break;
     }
index 44a4002c58154a8592209bba37c557db3d57071d..61d8b323ea5635ad562af27b9967613ed7bac3dd 100644 (file)
@@ -120,12 +120,7 @@ public class ActionCallback implements Disposable {
 
   @NotNull
   public final ActionCallback doWhenRejected(@NotNull final Consumer<String> consumer) {
-    myRejected.doWhenExecuted(new Runnable() {
-      @Override
-      public void run() {
-        consumer.consume(myError);
-      }
-    });
+    myRejected.doWhenExecuted(() -> consumer.consume(myError));
     return this;
   }
 
@@ -143,12 +138,7 @@ public class ActionCallback implements Disposable {
 
   @NotNull
   public final ActionCallback notifyWhenRejected(@NotNull final ActionCallback child) {
-    return doWhenRejected(new Runnable() {
-      @Override
-      public void run() {
-        child.reject(myError);
-      }
-    });
+    return doWhenRejected(() -> child.reject(myError));
   }
 
   @NotNull
@@ -269,12 +259,7 @@ public class ActionCallback implements Disposable {
 
   @NotNull
   public Runnable createSetDoneRunnable() {
-    return new Runnable() {
-      @Override
-      public void run() {
-        setDone();
-      }
-    };
+    return () -> setDone();
   }
 
   /**
@@ -283,12 +268,7 @@ public class ActionCallback implements Disposable {
   @NotNull
   @Deprecated
   public Runnable createSetRejectedRunnable() {
-    return new Runnable() {
-      @Override
-      public void run() {
-        setRejected();
-      }
-    };
+    return () -> setRejected();
   }
 
   public boolean waitFor(long msTimeout) {
@@ -298,12 +278,7 @@ public class ActionCallback implements Disposable {
 
     final Semaphore semaphore = new Semaphore();
     semaphore.down();
-    doWhenProcessed(new Runnable() {
-      @Override
-      public void run() {
-        semaphore.up();
-      }
-    });
+    doWhenProcessed(() -> semaphore.up());
 
     try {
       if (msTimeout == -1) {
index 253910e5adf953cea78d729cf0235f3156f115c2..f912aa274ecf2fad2809319561175d4dd323ff8d 100644 (file)
@@ -68,34 +68,19 @@ public class AsyncResult<T> extends ActionCallback {
   @NotNull
   @Deprecated
   public AsyncResult<T> doWhenDone(@SuppressWarnings("deprecation") @NotNull final Handler<T> handler) {
-    doWhenDone(new Runnable() {
-      @Override
-      public void run() {
-        handler.run(myResult);
-      }
-    });
+    doWhenDone(() -> handler.run(myResult));
     return this;
   }
 
   @NotNull
   public AsyncResult<T> doWhenDone(@NotNull final Consumer<T> consumer) {
-    doWhenDone(new Runnable() {
-      @Override
-      public void run() {
-        consumer.consume(myResult);
-      }
-    });
+    doWhenDone(() -> consumer.consume(myResult));
     return this;
   }
 
   @NotNull
   public AsyncResult<T> doWhenRejected(@NotNull final PairConsumer<T, String> consumer) {
-    doWhenRejected(new Runnable() {
-      @Override
-      public void run() {
-        consumer.consume(myResult, myError);
-      }
-    });
+    doWhenRejected(() -> consumer.consume(myResult, myError));
     return this;
   }
 
@@ -123,12 +108,7 @@ public class AsyncResult<T> extends ActionCallback {
   @NotNull
   public final ActionCallback doWhenProcessed(@NotNull final Consumer<T> consumer) {
     doWhenDone(consumer);
-    doWhenRejected(new PairConsumer<T, String>() {
-      @Override
-      public void consume(T result, String error) {
-        consumer.consume(result);
-      }
-    });
+    doWhenRejected((result, error) -> consumer.consume(result));
     return this;
   }
 
index 7bc3f69a2360cae07cc3695f9eacf660d5d5c3f0..e747a0193090bc173f74fe91e5136b1846a3325e 100644 (file)
@@ -121,13 +121,10 @@ public interface BusyObject {
       public ActionCallback execute(@NotNull ActiveRunnable runnable) {
         myBusyCount.addAndGet(1);
         ActionCallback cb = runnable.run();
-        cb.doWhenProcessed(new Runnable() {
-          @Override
-          public void run() {
-            myBusyCount.addAndGet(-1);
-            if (isReady()) {
-              onReady();
-            }
+        cb.doWhenProcessed(() -> {
+          myBusyCount.addAndGet(-1);
+          if (isReady()) {
+            onReady();
           }
         });
         return cb;
index 9a4119932e6ff63e3995a9e3aa4cc6a3fd1d6ad6..b0db1384bdefcc217893a854331af3cd9994a8d7 100644 (file)
@@ -45,15 +45,12 @@ public class TimedOutCallback extends ActionCallback implements Runnable {
     myMessage = message;
     myAllocation = allocation;
     final long current = System.currentTimeMillis();
-    myTask = SimpleTimer.getInstance().setUp(new Runnable() {
-      @Override
-      public void run() {
-        myShouldDumpError = System.currentTimeMillis() - current > timeOut; //double check is necessary :-(
-        if (isEdt) {
-          SwingUtilities.invokeLater(TimedOutCallback.this);
-        } else {
-          TimedOutCallback.this.run();
-        }
+    myTask = SimpleTimer.getInstance().setUp(() -> {
+      myShouldDumpError = System.currentTimeMillis() - current > timeOut; //double check is necessary :-(
+      if (isEdt) {
+        SwingUtilities.invokeLater(TimedOutCallback.this);
+      } else {
+        TimedOutCallback.this.run();
       }
     }, timeOut);
   }
index 61cce2b0d7d5d2c099d544048939775003d45258..c41661847c92a9f298bfe7a3454f9d2968d2e4da 100644 (file)
@@ -24,7 +24,6 @@ import com.intellij.openapi.util.SystemInfoRt;
 import com.intellij.openapi.util.io.BufferExposingByteArrayInputStream;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.Function;
 import com.intellij.util.PathUtil;
 import com.intellij.util.Processor;
 import com.intellij.util.containers.ContainerUtil;
@@ -388,12 +387,7 @@ public class VfsUtilCore {
   }
 
   public static List<File> virtualToIoFiles(@NotNull Collection<VirtualFile> scope) {
-    return ContainerUtil.map2List(scope, new Function<VirtualFile, File>() {
-      @Override
-      public File fun(VirtualFile file) {
-        return virtualToIoFile(file);
-      }
-    });
+    return ContainerUtil.map2List(scope, file -> virtualToIoFile(file));
   }
 
   @NotNull
index 0a1d7ebb42460e5e6ccd73ff532efaa926db422c..d15140c9b4de632a19ae314aa5cb4906d6628095 100644 (file)
@@ -53,12 +53,7 @@ public class StandardPatterns {
 
   @NotNull
   public static <T> ElementPattern<T> instanceOf(@NotNull Class<T>... classes) {
-    ElementPattern[] patterns = ContainerUtil.map(classes, new Function<Class<T>, ElementPattern>() {
-      @Override
-      public ElementPattern fun(Class<T> aClass) {
-        return instanceOf(aClass);
-      }
-    }, new ElementPattern[0]);
+    ElementPattern[] patterns = ContainerUtil.map(classes, aClass -> instanceOf(aClass), new ElementPattern[0]);
     return or(patterns);
   }
 
index a2d672fa3bf48b5f273df451b1ae30b375f953c8..03bcc7b740cfe0b40432744c68fba80f8d89692b 100644 (file)
@@ -103,27 +103,24 @@ public final class LanguageSubstitutors extends LanguageExtension<LanguageSubsti
   private static void requestReparsing(@NotNull VirtualFile file, @NotNull Language prevLang, @NotNull Language substitutedLang) {
     ourReparsingRequests.put(file, new SubstitutionInfo(prevLang, substitutedLang));
     if (REQUESTS_DRAIN_NEEDED.compareAndSet(true, false)) {
-      ApplicationManager.getApplication().invokeLater(new Runnable() {
-        @Override
-        public void run() {
-          REQUESTS_DRAIN_NEEDED.set(true);
-          List<Map.Entry<VirtualFile, SubstitutionInfo>> set = ContainerUtil.newArrayList(ourReparsingRequests.entrySet());
-          List<VirtualFile> files = ContainerUtil.newArrayListWithCapacity(set.size());
-          int id = 1;
-          for (Map.Entry<VirtualFile, SubstitutionInfo> entry : set) {
-            VirtualFile f = entry.getKey();
-            SubstitutionInfo info = entry.getValue();
-            ourReparsingRequests.remove(f);
-            if (f.isValid()) {
-              LOG.info("Reparsing " + f.getPath() + " because of language substitution " +
-                       info.myPrevLang.getID() + "->" + info.mySubstitutedLang.getID() + ", #" + (id++));
-              files.add(f);
-            }
-          }
-          if (files.size() > 0) {
-            FileContentUtilCore.reparseFiles(files);
+      ApplicationManager.getApplication().invokeLater(() -> {
+        REQUESTS_DRAIN_NEEDED.set(true);
+        List<Map.Entry<VirtualFile, SubstitutionInfo>> set = ContainerUtil.newArrayList(ourReparsingRequests.entrySet());
+        List<VirtualFile> files = ContainerUtil.newArrayListWithCapacity(set.size());
+        int id = 1;
+        for (Map.Entry<VirtualFile, SubstitutionInfo> entry : set) {
+          VirtualFile f = entry.getKey();
+          SubstitutionInfo info = entry.getValue();
+          ourReparsingRequests.remove(f);
+          if (f.isValid()) {
+            LOG.info("Reparsing " + f.getPath() + " because of language substitution " +
+                     info.myPrevLang.getID() + "->" + info.mySubstitutedLang.getID() + ", #" + (id++));
+            files.add(f);
           }
         }
+        if (files.size() > 0) {
+          FileContentUtilCore.reparseFiles(files);
+        }
       }, ModalityState.defaultModalityState());
     }
   }
index f0bb0a1981b659b18d921b2c954a56935a0375c9..47189975efad238d32153e6fd18905b573a218e2 100644 (file)
@@ -44,13 +44,7 @@ public interface PsiElement extends UserDataHolder, Iconable {
    */
   PsiElement[] EMPTY_ARRAY = new PsiElement[0];
 
-  ArrayFactory<PsiElement> ARRAY_FACTORY = new ArrayFactory<PsiElement>() {
-    @NotNull
-    @Override
-    public PsiElement[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiElement[count];
-    }
-  };
+  ArrayFactory<PsiElement> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiElement[count];
 
   /**
    * Returns the project to which the PSI element belongs.
index 5759de338b3b167b39edba1d45264ddcbeca956f..4f3c31af5d2a791282423cd5162ed373d3758271 100644 (file)
@@ -37,13 +37,7 @@ import org.jetbrains.annotations.Nullable;
 public interface PsiReference {
   PsiReference[] EMPTY_ARRAY = new PsiReference[0];
 
-  ArrayFactory<PsiReference> ARRAY_FACTORY = new ArrayFactory<PsiReference>() {
-    @NotNull
-    @Override
-    public PsiReference[] create(final int count) {
-      return count == 0 ? EMPTY_ARRAY : new PsiReference[count];
-    }
-  };
+  ArrayFactory<PsiReference> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiReference[count];
 
   /**
    * Returns the underlying (referencing) element of the reference.
index 00e4e637cf4e9169e26827a2e55a6e37f63ba580..49044b85ef25dd5c369e6c9ba52bf1f94df92198 100644 (file)
@@ -73,12 +73,8 @@ public class PsiReferenceProviderBean extends AbstractExtensionPointBean impleme
     return null;
   }
 
-  private static final NullableFunction<ElementPatternBean,ElementPattern<? extends PsiElement>> PATTERN_NULLABLE_FUNCTION = new NullableFunction<ElementPatternBean, ElementPattern<? extends PsiElement>>() {
-    @Override
-    public ElementPattern<? extends PsiElement> fun(ElementPatternBean elementPatternBean) {
-      return elementPatternBean.compilePattern();
-    }
-  };
+  private static final NullableFunction<ElementPatternBean,ElementPattern<? extends PsiElement>> PATTERN_NULLABLE_FUNCTION =
+    elementPatternBean -> elementPatternBean.compilePattern();
 
   @Nullable
   public ElementPattern<PsiElement> createElementPattern() {
index da015d5fb685875d1fd71279cb8ff8756131943a..ebfea9edb300037c534ba4eeaec8916e5c178cbe 100644 (file)
@@ -143,12 +143,7 @@ public class SyntaxTraverser<T> extends FilteredTraverserBase<T, SyntaxTraverser
 
   @NotNull
   public final SyntaxTraverser<T> onRange(@NotNull final TextRange range) {
-    return onRange(new Condition<T>() {
-      @Override
-      public boolean value(T e){
-        return api.rangeOf(e).intersects(range);
-      }
-    });
+    return onRange(e -> api.rangeOf(e).intersects(range));
   }
 
   public abstract static class Api<T> implements Function<T, Iterable<? extends T>> {
@@ -174,12 +169,7 @@ public class SyntaxTraverser<T> extends FilteredTraverserBase<T, SyntaxTraverser
 
     @NotNull
     public JBIterable<T> parents(@Nullable final T element) {
-      return JBIterable.generate(element, new Function<T, T>() {
-        @Override
-        public T fun(T t) {
-          return parent(t);
-        }
-      });
+      return JBIterable.generate(element, t -> parent(t));
     }
 
     public final Function<T, IElementType> TO_TYPE = new Function<T, IElementType>() {
index 91fa79e52b398a2e602ba5e01fcfdaacddc008c0..9a7129b8c8478502c4656d2b328ad599a8ba3eaf 100644 (file)
@@ -52,17 +52,14 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.ElementBase");
 
   public static final int FLAGS_LOCKED = 0x800;
-  private static final NullableFunction<ElementIconRequest,Icon> ICON_COMPUTE = new NullableFunction<ElementIconRequest, Icon>() {
-    @Override
-    public Icon fun(ElementIconRequest request) {
-      final PsiElement element = request.getElement();
-      if (element == null || !element.isValid() || element.getProject().isDisposed()) return null;
-
-      int flags = request.getFlags();
-      Icon icon = computeIconNow(element, flags);
-      LastComputedIcon.put(element, icon, flags);
-      return icon;
-    }
+  private static final NullableFunction<ElementIconRequest,Icon> ICON_COMPUTE = request -> {
+    final PsiElement element = request.getElement();
+    if (element == null || !element.isValid() || element.getProject().isDisposed()) return null;
+
+    int flags = request.getFlags();
+    Icon icon = computeIconNow(element, flags);
+    LastComputedIcon.put(element, icon, flags);
+    return icon;
   };
 
   private static final NotNullLazyValue<Icon> VISIBILITY_ICON_PLACEHOLDER = new NotNullLazyValue<Icon>() {
index 344caf7cd10665c7f68b44c53496ae2723a4820f..8178c40a5a768a8c1f4da08aa87b3db8da6bcc63 100644 (file)
@@ -462,12 +462,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
     }
 
     private UnionScope(@NotNull GlobalSearchScope[] scopes) {
-      super(ContainerUtil.getFirstItem(ContainerUtil.mapNotNull(scopes, new Function<GlobalSearchScope, Project>() {
-        @Override
-        public Project fun(GlobalSearchScope scope) {
-          return scope.getProject();
-        }
-      }), null));
+      super(ContainerUtil.getFirstItem(ContainerUtil.mapNotNull(scopes, scope -> scope.getProject()), null));
       if (scopes.length <= 1) throw new IllegalArgumentException("Too few scopes: "+ Arrays.asList(scopes));
       myScopes = scopes;
       final int[] nested = {0};
@@ -492,73 +487,45 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
 
     @Override
     public boolean contains(@NotNull final VirtualFile file) {
-      return ContainerUtil.find(myScopes, new Condition<GlobalSearchScope>() {
-        @Override
-        public boolean value(GlobalSearchScope scope) {
-          return scope.contains(file);
-        }
-      }) != null;
+      return ContainerUtil.find(myScopes, scope -> scope.contains(file)) != null;
     }
 
     @Override
     public boolean isSearchOutsideRootModel() {
-      return ContainerUtil.find(myScopes, new Condition<GlobalSearchScope>() {
-        @Override
-        public boolean value(GlobalSearchScope scope) {
-          return scope.isSearchOutsideRootModel();
-        }
-      }) != null;
+      return ContainerUtil.find(myScopes, scope -> scope.isSearchOutsideRootModel()) != null;
     }
 
     @Override
     public int compare(@NotNull final VirtualFile file1, @NotNull final VirtualFile file2) {
       final int[] result = {0};
-      ContainerUtil.process(myScopes, new Processor<GlobalSearchScope>() {
-        @Override
-        public boolean process(GlobalSearchScope scope) {
-          int res1 = scope.contains(file1) && scope.contains(file2) ? scope.compare(file1, file2) : 0;
-          if (result[0] == 0) {
-            result[0] = res1;
-            return true;
-          }
-          if (result[0] > 0 != res1 > 0) {
-            result[0] = 0;
-            return false;
-          }
+      ContainerUtil.process(myScopes, scope -> {
+        int res1 = scope.contains(file1) && scope.contains(file2) ? scope.compare(file1, file2) : 0;
+        if (result[0] == 0) {
+          result[0] = res1;
           return true;
         }
+        if (result[0] > 0 != res1 > 0) {
+          result[0] = 0;
+          return false;
+        }
+        return true;
       });
       return result[0];
     }
 
     @Override
     public boolean isSearchInModuleContent(@NotNull final Module module) {
-      return ContainerUtil.find(myScopes, new Condition<GlobalSearchScope>() {
-        @Override
-        public boolean value(GlobalSearchScope scope) {
-          return scope.isSearchInModuleContent(module);
-        }
-      }) != null;
+      return ContainerUtil.find(myScopes, scope -> scope.isSearchInModuleContent(module)) != null;
     }
 
     @Override
     public boolean isSearchInModuleContent(@NotNull final Module module, final boolean testSources) {
-      return ContainerUtil.find(myScopes, new Condition<GlobalSearchScope>() {
-        @Override
-        public boolean value(GlobalSearchScope scope) {
-          return scope.isSearchInModuleContent(module, testSources);
-        }
-      }) != null;
+      return ContainerUtil.find(myScopes, scope -> scope.isSearchInModuleContent(module, testSources)) != null;
     }
 
     @Override
     public boolean isSearchInLibraries() {
-      return ContainerUtil.find(myScopes, new Condition<GlobalSearchScope>() {
-        @Override
-        public boolean value(GlobalSearchScope scope) {
-          return scope.isSearchInLibraries();
-        }
-      }) != null;
+      return ContainerUtil.find(myScopes, scope -> scope.isSearchInLibraries()) != null;
     }
 
     @Override
index 2c759f162e256081f354a0b97ceb80b91b710bb9..99fc61bbee6552afa6a240e27e76a4652ed3badb 100644 (file)
@@ -277,20 +277,17 @@ public class LocalSearchScope extends SearchScope {
     if (scope == EMPTY) {
       return EMPTY;
     }
-    return ApplicationManager.getApplication().runReadAction(new Computable<LocalSearchScope>() {
-      @Override
-      public LocalSearchScope compute() {
-        PsiElement[] elements = scope.getScope();
-        List<PsiElement> result = new ArrayList<PsiElement>(elements.length);
-        for (PsiElement element : elements) {
-          PsiFile containingFile = element.getContainingFile();
-          FileType fileType = containingFile.getFileType();
-          if (ArrayUtil.contains(fileType, fileTypes)) {
-            result.add(element);
-          }
+    return ApplicationManager.getApplication().runReadAction((Computable<LocalSearchScope>)() -> {
+      PsiElement[] elements = scope.getScope();
+      List<PsiElement> result = new ArrayList<PsiElement>(elements.length);
+      for (PsiElement element : elements) {
+        PsiFile containingFile = element.getContainingFile();
+        FileType fileType = containingFile.getFileType();
+        if (ArrayUtil.contains(fileType, fileTypes)) {
+          result.add(element);
         }
-        return result.isEmpty() ? EMPTY : new LocalSearchScope(PsiUtilCore.toPsiElementArray(result), scope.getDisplayName(), scope.isIgnoreInjectedPsi());
       }
+      return result.isEmpty() ? EMPTY : new LocalSearchScope(PsiUtilCore.toPsiElementArray(result), scope.getDisplayName(), scope.isIgnoreInjectedPsi());
     });
 
 
index 88ce0f98cea61e1f42739be85a6104564919ca98..0150e286535f2875df73ae8cd9ed652299f46f90 100644 (file)
@@ -96,11 +96,6 @@ public class NonClasspathDirectoriesScope extends GlobalSearchScope {
       VirtualFile root = myRoots.iterator().next();
       return "Directory '" + root.getName() + "'";
     }
-    return "Directories " + StringUtil.join(myRoots, new Function<VirtualFile, String>() {
-      @Override
-      public String fun(VirtualFile file) {
-        return "'" + file.getName() + "'";
-      }
-    }, ", ");
+    return "Directories " + StringUtil.join(myRoots, file -> "'" + file.getName() + "'", ", ");
   }
 }
index d9634c8a4a533db18faa8f7fb836d9bacd9d37c1..e626ff4ad386b3308eba75550e5367833292a2c8 100644 (file)
@@ -28,53 +28,23 @@ public class ProjectScope {
 
   private static final NotNullLazyKey<GlobalSearchScope, Project> ALL_SCOPE_KEY = NotNullLazyKey.create(
     "ALL_SCOPE_KEY",
-    new NotNullFunction<Project, GlobalSearchScope>() {
-      @NotNull
-      @Override
-      public GlobalSearchScope fun(Project project) {
-        return ProjectScopeBuilder.getInstance(project).buildAllScope();
-      }
-    });
+    project -> ProjectScopeBuilder.getInstance(project).buildAllScope());
   private static final NotNullLazyKey<GlobalSearchScope, Project> PROJECT_SCOPE_KEY = NotNullLazyKey.create(
     "PROJECT_SCOPE_KEY",
-    new NotNullFunction<Project, GlobalSearchScope>() {
-      @NotNull
-      @Override
-      public GlobalSearchScope fun(Project project) {
-        return ProjectScopeBuilder.getInstance(project).buildProjectScope();
-      }
-    });
+    project -> ProjectScopeBuilder.getInstance(project).buildProjectScope());
   private static final NotNullLazyKey<GlobalSearchScope, Project> LIBRARIES_SCOPE_KEY = NotNullLazyKey.create(
     "LIBRARIES_SCOPE_KEY",
-    new NotNullFunction<Project, GlobalSearchScope>() {
-      @NotNull
-      @Override
-      public GlobalSearchScope fun(Project project) {
-        return ProjectScopeBuilder.getInstance(project).buildLibrariesScope();
-      }
-    });
+    project -> ProjectScopeBuilder.getInstance(project).buildLibrariesScope());
   private static final NotNullLazyKey<GlobalSearchScope, Project> CONTENT_SCOPE_KEY = NotNullLazyKey.create(
     "CONTENT_SCOPE_KEY",
-    new NotNullFunction<Project, GlobalSearchScope>() {
-      @NotNull
-      @Override
-      public GlobalSearchScope fun(Project project) {
-        return ProjectScopeBuilder.getInstance(project).buildContentScope();
-      }
-    });
+    project -> ProjectScopeBuilder.getInstance(project).buildContentScope());
   private static final NotNullLazyKey<EverythingGlobalScope, Project> EVERYTHING_SCOPE_KEY = NotNullLazyKey.create(
     "EVERYTHING_SCOPE_KEY",
-    new NotNullFunction<Project, EverythingGlobalScope>() {
+    project -> new EverythingGlobalScope(project) {
       @NotNull
       @Override
-      public EverythingGlobalScope fun(Project project) {
-        return new EverythingGlobalScope(project) {
-          @NotNull
-          @Override
-          public String getDisplayName() {
-            return "All Places";
-          }
-        };
+      public String getDisplayName() {
+        return "All Places";
       }
     });
 
index d9207ae08a4b06fc2f679b54a466532bf10d3080..291740f795d7e145a6a7f30f88a691bc1a4703a8 100644 (file)
@@ -90,13 +90,7 @@ public class IElementType {
     this(debugName, language, true);
   }
 
-  private static final ArrayFactory<IElementType> FACTORY = new ArrayFactory<IElementType>() {
-    @NotNull
-    @Override
-    public IElementType[] create(int count) {
-      return new IElementType[count];
-    }
-  };
+  private static final ArrayFactory<IElementType> FACTORY = count -> new IElementType[count];
 
   /**
    * Allows to construct element types for some temporary purposes without registering them.
index 5d0b7826644222a861792b6262c1af8c7269c25e..b676912f523a0aa60f7619eecbe4859734abd96c 100644 (file)
@@ -137,19 +137,15 @@ public abstract class CachedValuesManager {
       return value.getValue();
     }
 
-    return getManager(psi.getProject()).getCachedValue(psi, key, new CachedValueProvider<T>() {
-      @Nullable
-      @Override
-      public Result<T> compute() {
-        Result<T> result = provider.compute();
-        if (result != null && !psi.isPhysical()) {