diff --git a/java-analysis-api/src/main/java/com/intellij/java/analysis/codeInspection/GlobalJavaInspectionContext.java b/java-analysis-api/src/main/java/com/intellij/java/analysis/codeInspection/GlobalJavaInspectionContext.java index d51301ffe1..16a13199e9 100644 --- a/java-analysis-api/src/main/java/com/intellij/java/analysis/codeInspection/GlobalJavaInspectionContext.java +++ b/java-analysis-api/src/main/java/com/intellij/java/analysis/codeInspection/GlobalJavaInspectionContext.java @@ -13,14 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * User: anna - * Date: 18-Dec-2007 - */ package com.intellij.java.analysis.codeInspection; import com.intellij.java.analysis.codeInspection.ex.EntryPointsManager; +import consulo.annotation.access.RequiredReadAction; import consulo.language.editor.inspection.GlobalInspectionContextExtension; import com.intellij.java.analysis.codeInspection.reference.RefClass; import com.intellij.java.analysis.codeInspection.reference.RefField; @@ -32,67 +28,71 @@ import consulo.language.psi.PsiReference; import consulo.application.util.function.Processor; +/** + * @author anna + * @since 2007-12-18 + */ public abstract class GlobalJavaInspectionContext implements GlobalInspectionContextExtension { - public static final Key CONTEXT = Key.create("GlobalJavaInspectionContext"); + public static final Key CONTEXT = Key.create("GlobalJavaInspectionContext"); - public interface DerivedClassesProcessor extends Processor { - } + public interface DerivedClassesProcessor extends Processor { + } - public interface DerivedMethodsProcessor extends Processor { - } + public interface DerivedMethodsProcessor extends Processor { + } - public interface UsagesProcessor extends Processor { - } + public interface UsagesProcessor extends Processor { + } - /** - * Requests that usages of the specified class outside the current analysis - * scope be passed to the specified processor. - * - * @param refClass the reference graph node for the class whose usages should be processed. - * @param p the processor to pass the usages to. - */ - public abstract void enqueueClassUsagesProcessor(RefClass refClass, UsagesProcessor p); + /** + * Requests that usages of the specified class outside the current analysis + * scope be passed to the specified processor. + * + * @param refClass the reference graph node for the class whose usages should be processed. + * @param p the processor to pass the usages to. + */ + public abstract void enqueueClassUsagesProcessor(RefClass refClass, UsagesProcessor p); - /** - * Requests that derived classes of the specified class outside the current analysis - * scope be passed to the specified processor. - * - * @param refClass the reference graph node for the class whose derived classes should be processed. - * @param p the processor to pass the classes to. - */ - public abstract void enqueueDerivedClassesProcessor(RefClass refClass, DerivedClassesProcessor p); + /** + * Requests that derived classes of the specified class outside the current analysis + * scope be passed to the specified processor. + * + * @param refClass the reference graph node for the class whose derived classes should be processed. + * @param p the processor to pass the classes to. + */ + public abstract void enqueueDerivedClassesProcessor(RefClass refClass, DerivedClassesProcessor p); - /** - * Requests that implementing or overriding methods of the specified method outside - * the current analysis scope be passed to the specified processor. - * - * @param refMethod the reference graph node for the method whose derived methods should be processed. - * @param p the processor to pass the methods to. - */ - public abstract void enqueueDerivedMethodsProcessor(RefMethod refMethod, DerivedMethodsProcessor p); + /** + * Requests that implementing or overriding methods of the specified method outside + * the current analysis scope be passed to the specified processor. + * + * @param refMethod the reference graph node for the method whose derived methods should be processed. + * @param p the processor to pass the methods to. + */ + public abstract void enqueueDerivedMethodsProcessor(RefMethod refMethod, DerivedMethodsProcessor p); - /** - * Requests that usages of the specified field outside the current analysis - * scope be passed to the specified processor. - * - * @param refField the reference graph node for the field whose usages should be processed. - * @param p the processor to pass the usages to. - */ - public abstract void enqueueFieldUsagesProcessor(RefField refField, UsagesProcessor p); + /** + * Requests that usages of the specified field outside the current analysis + * scope be passed to the specified processor. + * + * @param refField the reference graph node for the field whose usages should be processed. + * @param p the processor to pass the usages to. + */ + public abstract void enqueueFieldUsagesProcessor(RefField refField, UsagesProcessor p); - /** - * Requests that usages of the specified method outside the current analysis - * scope be passed to the specified processor. - * - * @param refMethod the reference graph node for the method whose usages should be processed. - * @param p the processor to pass the usages to. - */ - public abstract void enqueueMethodUsagesProcessor(RefMethod refMethod, UsagesProcessor p); + /** + * Requests that usages of the specified method outside the current analysis + * scope be passed to the specified processor. + * + * @param refMethod the reference graph node for the method whose usages should be processed. + * @param p the processor to pass the usages to. + */ + public abstract void enqueueMethodUsagesProcessor(RefMethod refMethod, @RequiredReadAction UsagesProcessor p); - public abstract EntryPointsManager getEntryPointsManager(RefManager manager); + public abstract EntryPointsManager getEntryPointsManager(RefManager manager); - @Override - public Key getID() { - return CONTEXT; - } + @Override + public Key getID() { + return CONTEXT; + } } \ No newline at end of file diff --git a/java-analysis-impl/src/main/java/com/intellij/java/analysis/impl/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java b/java-analysis-impl/src/main/java/com/intellij/java/analysis/impl/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java index 59d9a66f5f..bac1e093d8 100644 --- a/java-analysis-impl/src/main/java/com/intellij/java/analysis/impl/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java +++ b/java-analysis-impl/src/main/java/com/intellij/java/analysis/impl/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java @@ -106,6 +106,7 @@ private static PsiMethod findWrapper(PsiType type, @Nonnull PsiClassType expecte } @Override + @RequiredReadAction public boolean isAvailable(@Nonnull Project project, Editor editor, PsiFile file) { return myExpression.isValid() && myExpression.getManager().isInProject(myExpression) @@ -125,10 +126,9 @@ public void invoke(@Nonnull Project project, Editor editor, PsiFile file) throws assert wrapper != null; PsiElementFactory factory = JavaPsiFacade.getInstance(file.getProject()).getElementFactory(); String methodCallText = "Foo." + wrapper.getName() + "()"; - PsiMethodCallExpression call = (PsiMethodCallExpression)factory.createExpressionFromText(methodCallText, null); + PsiMethodCallExpression call = (PsiMethodCallExpression) factory.createExpressionFromText(methodCallText, null); call.getArgumentList().add(myExpression); - ((PsiReferenceExpression)call.getMethodExpression().getQualifierExpression()) - .bindToElement(wrapper.getContainingClass()); + ((PsiReferenceExpression) call.getMethodExpression().getQualifierExpression()).bindToElement(wrapper.getContainingClass()); myExpression.replace(call); } @@ -155,7 +155,7 @@ public static void registerWrapAction( PsiSubstitutor substitutor = candidate.getSubstitutor(); PsiElement element = candidate.getElement(); assert element != null; - PsiMethod method = (PsiMethod)element; + PsiMethod method = (PsiMethod) element; PsiParameter[] parameters = method.getParameterList().getParameters(); if (!method.isVarArgs() && parameters.length != expressions.length) { continue; diff --git a/plugin/src/main/java/com/intellij/java/impl/ig/abstraction/StaticMethodOnlyUsedInOneClassInspection.java b/plugin/src/main/java/com/intellij/java/impl/ig/abstraction/StaticMethodOnlyUsedInOneClassInspection.java index 70dd47f7b8..a64f70dd90 100644 --- a/plugin/src/main/java/com/intellij/java/impl/ig/abstraction/StaticMethodOnlyUsedInOneClassInspection.java +++ b/plugin/src/main/java/com/intellij/java/impl/ig/abstraction/StaticMethodOnlyUsedInOneClassInspection.java @@ -32,6 +32,7 @@ import com.siyeh.ig.psiutils.DeclarationSearchUtils; import com.siyeh.ig.psiutils.TestUtils; import com.siyeh.localize.InspectionGadgetsLocalize; +import consulo.annotation.access.RequiredReadAction; import consulo.annotation.component.ExtensionImpl; import consulo.application.progress.ProgressManager; import consulo.application.util.function.Processor; @@ -51,7 +52,7 @@ import consulo.language.psi.util.PsiTreeUtil; import consulo.localize.LocalizeValue; import consulo.util.dataholder.Key; -import consulo.util.lang.ref.Ref; +import consulo.util.lang.ref.SimpleReference; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -60,7 +61,6 @@ @ExtensionImpl public class StaticMethodOnlyUsedInOneClassInspection extends BaseGlobalInspection { - @SuppressWarnings("PublicField") public boolean ignoreTestClasses = false; @@ -87,7 +87,7 @@ public HighlightDisplayLevel getDefaultLevel() { @Nullable @Override public JComponent createOptionsPanel() { - final MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this); + MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this); panel.addCheckbox( InspectionGadgetsLocalize.staticMethodOnlyUsedInOneClassIgnoreTestOption().get(), "ignoreTestClasses" @@ -105,21 +105,23 @@ public JComponent createOptionsPanel() { @Nullable @Override - public CommonProblemDescriptor[] checkElement(@Nonnull RefEntity refEntity, - @Nonnull AnalysisScope scope, - @Nonnull InspectionManager manager, - @Nonnull GlobalInspectionContext globalContext, - Object state) { - if (!(refEntity instanceof RefMethod)) { + @RequiredReadAction + public CommonProblemDescriptor[] checkElement( + @Nonnull RefEntity refEntity, + @Nonnull AnalysisScope scope, + @Nonnull InspectionManager manager, + @Nonnull GlobalInspectionContext globalContext, + @Nonnull Object state + ) { + if (!(refEntity instanceof RefMethod method)) { return null; } - final RefMethod method = (RefMethod) refEntity; if (!method.isStatic() || method.getAccessModifier() == PsiModifier.PRIVATE) { return null; } RefClass usageClass = null; for (RefElement reference : method.getInReferences()) { - final RefClass ownerClass = RefJavaUtil.getInstance().getOwnerClass(reference); + RefClass ownerClass = RefJavaUtil.getInstance().getOwnerClass(reference); if (usageClass == null) { usageClass = ownerClass; } @@ -127,29 +129,31 @@ else if (usageClass != ownerClass) { return null; } } - final RefClass containingClass = method.getOwnerClass(); + RefClass containingClass = method.getOwnerClass(); if (usageClass == containingClass) { return null; } if (usageClass == null) { - final PsiClass aClass = containingClass.getElement(); + PsiClass aClass = containingClass.getElement(); if (aClass != null) { - final SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(manager.getProject()); + SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(manager.getProject()); method.putUserData(MARKER, smartPointerManager.createSmartPsiElementPointer(aClass)); } return null; } - if (ignoreAnonymousClasses && (usageClass.isAnonymous() || usageClass.isLocalClass() || usageClass.getOwner() instanceof RefClass && !usageClass.isStatic())) { + if (ignoreAnonymousClasses + && (usageClass.isAnonymous() || usageClass.isLocalClass() + || usageClass.getOwner() instanceof RefClass && !usageClass.isStatic())) { return null; } if (ignoreTestClasses && usageClass.isTestCase()) { return null; } - final PsiClass psiClass = usageClass.getElement(); + PsiClass psiClass = usageClass.getElement(); if (psiClass == null) { return null; } - final PsiMethod psiMethod = (PsiMethod) method.getElement(); + PsiMethod psiMethod = (PsiMethod) method.getElement(); if (psiMethod == null) { return null; } @@ -158,52 +162,58 @@ else if (usageClass != ownerClass) { return null; } } - final SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(manager.getProject()); + SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(manager.getProject()); method.putUserData(MARKER, smartPointerManager.createSmartPsiElementPointer(psiClass)); return new ProblemDescriptor[]{createProblemDescriptor(manager, psiMethod.getNameIdentifier(), psiClass)}; } @Nonnull + @RequiredReadAction static ProblemDescriptor createProblemDescriptor(@Nonnull InspectionManager manager, PsiElement problemElement, PsiClass usageClass) { - LocalizeValue message = (usageClass instanceof PsiAnonymousClass) - ? InspectionGadgetsLocalize.staticMethodOnlyUsedInOneAnonymousClassProblemDescriptor(((PsiAnonymousClass) usageClass).getBaseClassReference().getText()) + LocalizeValue message = usageClass instanceof PsiAnonymousClass anonymousClass + ? InspectionGadgetsLocalize.staticMethodOnlyUsedInOneAnonymousClassProblemDescriptor( + anonymousClass.getBaseClassReference().getText() + ) : InspectionGadgetsLocalize.staticMethodOnlyUsedInOneClassProblemDescriptor(usageClass.getName()); return manager.createProblemDescriptor(problemElement, message.get(), false, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } @Override - public boolean queryExternalUsagesRequests(@Nonnull final InspectionManager manager, - @Nonnull final GlobalInspectionContext globalContext, - @Nonnull final ProblemDescriptionsProcessor problemDescriptionsProcessor, - Object state) { + public boolean queryExternalUsagesRequests( + @Nonnull final InspectionManager manager, + @Nonnull final GlobalInspectionContext globalContext, + @Nonnull final ProblemDescriptionsProcessor problemDescriptionsProcessor, + Object state + ) { globalContext.getRefManager().iterate(new RefJavaVisitor() { @Override + @RequiredReadAction public void visitElement(@Nonnull RefEntity refEntity) { - if (refEntity instanceof RefMethod) { - final SmartPsiElementPointer classPointer = refEntity.getUserData(MARKER); + if (refEntity instanceof RefMethod refMethod) { + SmartPsiElementPointer classPointer = refMethod.getUserData(MARKER); if (classPointer != null) { - final Ref ref = Ref.create(classPointer.getElement()); - final GlobalJavaInspectionContext globalJavaContext = globalContext.getExtension(GlobalJavaInspectionContext.CONTEXT); - globalJavaContext.enqueueMethodUsagesProcessor((RefMethod) refEntity, new GlobalJavaInspectionContext.UsagesProcessor() { - @Override - public boolean process(PsiReference reference) { - final PsiClass containingClass = ClassUtils.getContainingClass(reference.getElement()); - if (problemDescriptionsProcessor.getDescriptions(refEntity) != null) { + SimpleReference ref = SimpleReference.create(classPointer.getElement()); + GlobalJavaInspectionContext globalJavaContext = globalContext.getExtension(GlobalJavaInspectionContext.CONTEXT); + globalJavaContext.enqueueMethodUsagesProcessor( + refMethod, + reference -> { + PsiClass containingClass = ClassUtils.getContainingClass(reference.getElement()); + if (problemDescriptionsProcessor.getDescriptions(refMethod) != null) { if (containingClass != ref.get()) { - problemDescriptionsProcessor.ignoreElement(refEntity); + problemDescriptionsProcessor.ignoreElement(refMethod); return false; } return true; } else { - final PsiIdentifier identifier = ((PsiMethod) ((RefMethod) refEntity).getElement()).getNameIdentifier(); - final ProblemDescriptor problemDescriptor = createProblemDescriptor(manager, identifier, containingClass); - problemDescriptionsProcessor.addProblemElement(refEntity, problemDescriptor); + PsiIdentifier identifier = ((PsiMethod) refMethod.getElement()).getNameIdentifier(); + ProblemDescriptor problemDescriptor = createProblemDescriptor(manager, identifier, containingClass); + problemDescriptionsProcessor.addProblemElement(refMethod, problemDescriptor); ref.set(containingClass); return true; } } - }); + ); } } } @@ -212,8 +222,8 @@ public boolean process(PsiReference reference) { return false; } - static boolean areReferenceTargetsAccessible(final PsiElement elementToCheck, final PsiElement place) { - final AccessibleVisitor visitor = new AccessibleVisitor(elementToCheck, place); + static boolean areReferenceTargetsAccessible(PsiElement elementToCheck, PsiElement place) { + AccessibleVisitor visitor = new AccessibleVisitor(elementToCheck, place); elementToCheck.accept(visitor); return visitor.isAccessible(); } @@ -229,15 +239,15 @@ public AccessibleVisitor(PsiElement elementToCheck, PsiElement place) { } @Override - public void visitCallExpression(PsiCallExpression callExpression) { + @RequiredReadAction + public void visitCallExpression(@Nonnull PsiCallExpression callExpression) { if (!myAccessible) { return; } super.visitCallExpression(callExpression); - final PsiMethod method = callExpression.resolveMethod(); - if (callExpression instanceof PsiNewExpression && method == null) { - final PsiNewExpression newExpression = (PsiNewExpression) callExpression; - final PsiJavaCodeReferenceElement reference = newExpression.getClassReference(); + PsiMethod method = callExpression.resolveMethod(); + if (callExpression instanceof PsiNewExpression newExpression && method == null) { + PsiJavaCodeReferenceElement reference = newExpression.getClassReference(); if (reference != null) { checkElement(reference.resolve()); } @@ -248,6 +258,7 @@ public void visitCallExpression(PsiCallExpression callExpression) { } @Override + @RequiredReadAction public void visitReferenceExpression(PsiReferenceExpression expression) { if (!myAccessible) { return; @@ -257,13 +268,13 @@ public void visitReferenceExpression(PsiReferenceExpression expression) { } private void checkElement(PsiElement element) { - if (!(element instanceof PsiMember)) { + if (!(element instanceof PsiMember member)) { return; } if (PsiTreeUtil.isAncestor(myElementToCheck, element, false)) { return; // internal reference } - myAccessible = PsiUtil.isAccessible((PsiMember) element, myPlace, null); + myAccessible = PsiUtil.isAccessible(member, myPlace, null); } public boolean isAccessible() { @@ -272,22 +283,22 @@ public boolean isAccessible() { } private static class UsageProcessor implements Processor { - private final AtomicReference foundClass = new AtomicReference<>(); @Override + @RequiredReadAction public boolean process(PsiReference reference) { ProgressManager.checkCanceled(); - final PsiElement element = reference.getElement(); - final PsiClass usageClass = ClassUtils.getContainingClass(element); + PsiElement element = reference.getElement(); + PsiClass usageClass = ClassUtils.getContainingClass(element); if (usageClass == null) { return true; } if (foundClass.compareAndSet(null, usageClass)) { return true; } - final PsiClass aClass = foundClass.get(); - final PsiManager manager = usageClass.getManager(); + PsiClass aClass = foundClass.get(); + PsiManager manager = usageClass.getManager(); return manager.areElementsEquivalent(aClass, usageClass); } @@ -296,14 +307,16 @@ public boolean process(PsiReference reference) { * used from 0 or more than 1 other classes. */ @Nullable - public PsiClass findUsageClass(final PsiMethod method) { - ProgressManager.getInstance().runProcess(() -> - { - final Query query = MethodReferencesSearch.search(method); - if (!query.forEach(this)) { - foundClass.set(null); - } - }, null); + public PsiClass findUsageClass(PsiMethod method) { + ProgressManager.getInstance().runProcess( + () -> { + Query query = MethodReferencesSearch.search(method); + if (!query.forEach(this)) { + foundClass.set(null); + } + }, + null + ); return foundClass.get(); } } @@ -314,38 +327,38 @@ public LocalInspectionTool getSharedLocalInspectionTool() { return new StaticMethodOnlyUsedInOneClassLocalInspection(this); } - private static class StaticMethodOnlyUsedInOneClassLocalInspection extends BaseSharedLocalInspection { - + private static class StaticMethodOnlyUsedInOneClassLocalInspection + extends BaseSharedLocalInspection { public StaticMethodOnlyUsedInOneClassLocalInspection(StaticMethodOnlyUsedInOneClassInspection settingsDelegate) { super(settingsDelegate); } - @Override @Nonnull + @Override + @RequiredReadAction protected String buildErrorString(Object... infos) { - final PsiClass usageClass = (PsiClass) infos[0]; - if (usageClass instanceof PsiAnonymousClass) { - return InspectionGadgetsLocalize.staticMethodOnlyUsedInOneAnonymousClassProblemDescriptor(((PsiAnonymousClass) usageClass) - .getBaseClassReference().getText()).get(); + PsiClass usageClass = (PsiClass) infos[0]; + if (usageClass instanceof PsiAnonymousClass anonymousClass) { + String refText = anonymousClass.getBaseClassReference().getText(); + return InspectionGadgetsLocalize.staticMethodOnlyUsedInOneAnonymousClassProblemDescriptor(refText).get(); } else { return InspectionGadgetsLocalize.staticMethodOnlyUsedInOneClassProblemDescriptor(usageClass.getName()).get(); } } - @Override @Nullable + @Override protected InspectionGadgetsFix buildFix(Object... infos) { - final PsiClass usageClass = (PsiClass) infos[0]; + PsiClass usageClass = (PsiClass) infos[0]; return new StaticMethodOnlyUsedInOneClassFix(usageClass); } private static class StaticMethodOnlyUsedInOneClassFix extends RefactoringInspectionGadgetsFix { - private final SmartPsiElementPointer usageClass; public StaticMethodOnlyUsedInOneClassFix(PsiClass usageClass) { - final SmartPointerManager pointerManager = SmartPointerManager.getInstance(usageClass.getProject()); + SmartPointerManager pointerManager = SmartPointerManager.getInstance(usageClass.getProject()); this.usageClass = pointerManager.createSmartPsiElementPointer(usageClass); } @@ -363,6 +376,7 @@ public RefactoringActionHandler getHandler() { @Nonnull @Override + @RequiredReadAction public DataContext enhanceDataContext(DataContext context) { return DataContext.builder().parent(context).add(LangDataKeys.TARGET_PSI_ELEMENT, usageClass.getElement()).build(); } @@ -374,29 +388,28 @@ public BaseInspectionVisitor buildVisitor() { } private class StaticMethodOnlyUsedInOneClassVisitor extends BaseInspectionVisitor { - @Override - public void visitMethod(final PsiMethod method) { + public void visitMethod(@Nonnull PsiMethod method) { super.visitMethod(method); - if (!method.hasModifierProperty(PsiModifier.STATIC) || method.hasModifierProperty(PsiModifier.PRIVATE) || method.getNameIdentifier() == null) { + if (!method.isStatic() || method.isPrivate() || method.getNameIdentifier() == null) { return; } if (DeclarationSearchUtils.isTooExpensiveToSearch(method, true)) { return; } - final UsageProcessor usageProcessor = new UsageProcessor(); - final PsiClass usageClass = usageProcessor.findUsageClass(method); + UsageProcessor usageProcessor = new UsageProcessor(); + PsiClass usageClass = usageProcessor.findUsageClass(method); if (usageClass == null) { return; } - final PsiClass containingClass = method.getContainingClass(); + PsiClass containingClass = method.getContainingClass(); if (usageClass.equals(containingClass)) { return; } if (mySettingsDelegate.ignoreTestClasses && TestUtils.isInTestCode(usageClass)) { return; } - if (usageClass.getContainingClass() != null && !usageClass.hasModifierProperty(PsiModifier.STATIC) || PsiUtil.isLocalOrAnonymousClass(usageClass)) { + if (usageClass.getContainingClass() != null && !usageClass.isStatic() || PsiUtil.isLocalOrAnonymousClass(usageClass)) { if (mySettingsDelegate.ignoreAnonymousClasses) { return; } diff --git a/plugin/src/test/java_/com/intellij/projectView/NavigateFromSourceTest.java b/plugin/src/test/java_/com/intellij/projectView/NavigateFromSourceTest.java index 707d2c0969..c647e38a20 100644 --- a/plugin/src/test/java_/com/intellij/projectView/NavigateFromSourceTest.java +++ b/plugin/src/test/java_/com/intellij/projectView/NavigateFromSourceTest.java @@ -45,7 +45,6 @@ import consulo.project.ui.view.ProjectViewPane; import consulo.ide.impl.idea.ide.projectView.impl.ProjectViewToolWindowFactory; import consulo.dataContext.DataContext; -import consulo.language.editor.LangDataKeys; import consulo.fileEditor.FileEditorManager; import consulo.ui.ex.toolWindow.ToolWindow; import consulo.virtualFileSystem.VirtualFile; @@ -105,7 +104,7 @@ public void testAutoscrollFromSourceOnOpening() throws Exception JComponent component = ((ProjectViewImpl) projectView).getComponent(); DataContext context = DataManager.getInstance().getDataContext(component); - PsiElement element = context.getData(LangDataKeys.PSI_ELEMENT); + PsiElement element = context.getData(PsiElement.KEY); assertEquals("Class1.java", ((PsiJavaFile) element).getName()); }