diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/reference/RefMethod.java b/java/java-analysis-api/src/com/intellij/codeInspection/reference/RefMethod.java index 3803f38805ff..ce1552abad6c 100644 --- a/java/java-analysis-api/src/com/intellij/codeInspection/reference/RefMethod.java +++ b/java/java-analysis-api/src/com/intellij/codeInspection/reference/RefMethod.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -75,6 +75,7 @@ public interface RefMethod extends RefJavaElement { * * @return true if the method is a test method, false otherwise. */ + @Deprecated boolean isTestMethod(); /** diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java index a0e3b1d389e4..e236c0c5778c 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -127,20 +127,6 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass { getRefManager().getReference(psiField); } - if (!isApplet()) { - final PsiClass servlet = getRefJavaManager().getServlet(); - setServlet(servlet != null && psiClass.isInheritor(servlet, true)); - } - if (!isApplet() && !isServlet()) { - final boolean isTestClass = TestFrameworks.getInstance().isTestClass(psiClass); - setTestCase(isTestClass); - if (isTestClass) { - for (RefClass refBase : getBaseClasses()) { - ((RefClassImpl)refBase).setTestCase(true); - } - } - } - RefMethod varargConstructor = null; for (PsiMethod psiMethod : psiMethods) { RefMethod refMethod = (RefMethod)getRefManager().getReference(psiMethod); @@ -187,9 +173,6 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass { } } - - final PsiClass applet = getRefJavaManager().getApplet(); - setApplet(applet != null && psiClass.isInheritor(applet, true)); PsiManager psiManager = getRefManager().getPsiManager(); psiManager.dropResolveCaches(); PsiFile file = psiClass.getContainingFile(); @@ -198,6 +181,30 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass { } } + @Override + public void onInitialized() { + super.onInitialized(); + PsiClass psiClass = getElement(); + LOG.assertTrue(psiClass != null); + final PsiClass applet = getRefJavaManager().getApplet(); + boolean isApplet = applet != null && psiClass.isInheritor(applet, true); + setApplet(isApplet); + if (!isApplet) { + final PsiClass servlet = getRefJavaManager().getServlet(); + setServlet(servlet != null && psiClass.isInheritor(servlet, true)); + } + + if (!isApplet() && !isServlet()) { + final boolean isTestClass = TestFrameworks.getInstance().isTestClass(psiClass); + setTestCase(isTestClass); + if (isTestClass) { + for (RefClass refBase : getBaseClasses()) { + ((RefClassImpl)refBase).setTestCase(true); + } + } + } + } + private static ServerPageFile getJspFile(PsiClass psiClass) { final PsiFile psiFile = PsiUtilCore.getTemplateLanguageFile(psiClass); return psiFile instanceof ServerPageFile ? (ServerPageFile)psiFile : null; diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java index 88e3a763927b..da369aa65ba4 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -128,11 +128,6 @@ public class RefMethodImpl extends RefJavaElementImpl implements RefMethod { ((RefClassImpl)getOwnerClass()).addLibraryOverrideMethod(this); } - @NonNls final String name = method.getName(); - if (getOwnerClass().isTestCase() && name.startsWith("test")) { - setTestMethod(true); - } - PsiParameter[] paramList = method.getParameterList().getParameters(); if (paramList.length > 0){ myParameters = new RefParameterImpl[paramList.length]; diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java index 5bf052b6f5a7..319644f1e0e4 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -27,8 +27,6 @@ package com.intellij.codeInspection.reference; import com.intellij.codeInspection.SuppressionUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Iconable; import com.intellij.openapi.vfs.VirtualFile; @@ -254,6 +252,8 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement protected abstract void initialize(); + public void onInitialized() {} + public void addSuppression(final String text) { mySuppressions = text.split("[, ]"); } diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java index 4df677907bd0..e503ffaa0c42 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -582,6 +582,9 @@ public class RefManagerImpl extends RefManager { } } + if (result instanceof RefElementImpl) { + ((RefElementImpl)result).onInitialized(); + } return result; }