From 732238fb13684d59eba4901ec97e95d05edd6866 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 5 Jun 2014 18:23:51 +0400 Subject: [PATCH] performance --- .../codeInsight/daemon/impl/PostHighlightingPass.java | 5 ++++- .../intellij/codeInsight/daemon/impl/RefCountHolder.java | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java index 3cd72560f13e..06b11a3d364d 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java @@ -49,6 +49,7 @@ import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.PomNamedTarget; +import com.intellij.pom.java.LanguageLevel; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; @@ -77,6 +78,7 @@ import java.util.*; public class PostHighlightingPass extends ProgressableTextEditorHighlightingPass { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.PostHighlightingPass"); private static final Key LAST_POST_PASS_TIMESTAMP = Key.create("LAST_POST_PASS_TIMESTAMP"); + private final LanguageLevel myLanguageLevel; private RefCountHolder myRefCountHolder; private final PsiFile myFile; @Nullable private final Editor myEditor; @@ -109,6 +111,7 @@ public class PostHighlightingPass extends ProgressableTextEditorHighlightingPass myEndOffset = file.getTextLength(); myCurrentEntryIndex = -1; + myLanguageLevel = PsiUtil.getLanguageLevel(file); } static boolean isUpToDate(@NotNull PsiFile file) { @@ -509,7 +512,7 @@ public class PostHighlightingPass extends ProgressableTextEditorHighlightingPass //parameter is defined by functional interface final PsiElement declarationScope = parameter.getDeclarationScope(); if (declarationScope instanceof PsiMethod && - myRefCountHolder.isReferencedByMethodReference((PsiMethod)declarationScope)) { + myRefCountHolder.isReferencedByMethodReference((PsiMethod)declarationScope, myLanguageLevel)) { return null; } String message = JavaErrorMessages.message("parameter.is.not.used", identifier.getText()); diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java index 018fce54ddba..f63ea55608a2 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.UserDataHolderEx; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.util.PsiMatcherImpl; import com.intellij.psi.util.PsiMatchers; @@ -204,8 +205,8 @@ public class RefCountHolder { return usedStatus == Boolean.TRUE; } - public boolean isReferencedByMethodReference(@NotNull PsiMethod method) { - if (!PsiUtil.isLanguageLevel8OrHigher(method)) return false; + public boolean isReferencedByMethodReference(@NotNull PsiMethod method, @NotNull LanguageLevel languageLevel) { + if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) return false; List array; synchronized (myLocalRefsMap) {