From 4e98c9bb0147021d846600fa43dab55b9835ece1 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 5 Jan 2017 16:45:24 +0100 Subject: [PATCH] [ui] restores "Go to file" for out of project content targets --- .../com/intellij/navigation/ChooseByNameTest.groovy | 11 +++++++++++ .../intellij/ide/util/gotoByName/GotoFileModel.java | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy index bdc75526b675..e0ad8f771e21 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy +++ b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy @@ -24,8 +24,12 @@ import com.intellij.openapi.application.ModalityState import com.intellij.openapi.application.ReadAction import com.intellij.openapi.util.Computable import com.intellij.openapi.util.Disposer +import com.intellij.psi.CommonClassNames +import com.intellij.psi.PsiClass import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile +import com.intellij.psi.search.GlobalSearchScope +import com.intellij.psi.search.ProjectScope import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import com.intellij.util.Consumer import com.intellij.util.concurrency.Semaphore @@ -344,6 +348,13 @@ class Intf { assert popup.calcSelectedIndex(popupElements.toArray(), 'PsiCl') == 0 } + void "test out-of-project-content files"() { + def scope = ProjectScope.getAllScope(project) + def file = ReadAction.compute { myFixture.javaFacade.findClass(CommonClassNames.JAVA_LANG_OBJECT, scope).containingFile } + def elements = getPopupElements(new GotoFileModel(project), "Object.class", true) + assert file in elements + } + private List getPopupElements(ChooseByNameModel model, String text, boolean checkboxState = false) { return calcPopupElements(createPopup(model), text, checkboxState) } diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileModel.java index 252455040868..64ef1884272f 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -136,7 +136,8 @@ public class GotoFileModel extends FilteringGotoByModel implements Dum if (element instanceof PsiFileSystemItem) { VirtualFile file = ((PsiFileSystemItem)element).getVirtualFile(); VirtualFile root = getTopLevelRoot(file); - return root != null ? GotoFileCellRenderer.getRelativePathFromRoot(file, root) : null; + return root != null ? GotoFileCellRenderer.getRelativePathFromRoot(file, root) + : GotoFileCellRenderer.getRelativePath(file, myProject); } return getElementName(element);