mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make copy line reference copy relative file path (IDEA-93625)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.intellij.codeInsight;
|
||||
package com.intellij.codeInsight
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.ide.actions.CopyReferenceAction;
|
||||
@@ -7,7 +7,6 @@ import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
|
||||
public class CopyReferenceTest extends LightCodeInsightFixtureTestCase {
|
||||
@NonNls private static final String BASE_PATH = "/codeInsight/copyReference";
|
||||
@@ -53,11 +52,10 @@ public class CopyReferenceTest extends LightCodeInsightFixtureTestCase {
|
||||
myFixture.configureByText 'a.java', '''
|
||||
<caret>class Foo {
|
||||
}'''
|
||||
def path = FileUtil.toSystemDependentName(myFixture.file.virtualFile.path)
|
||||
performCopy()
|
||||
myFixture.configureByText 'a.txt', ''
|
||||
performPaste()
|
||||
myFixture.checkResult "$path:2"
|
||||
myFixture.checkResult "/a.java:2"
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.StatusBarEx;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiReference;
|
||||
@@ -141,9 +142,9 @@ public class CopyReferenceAction extends AnAction {
|
||||
|
||||
if (!doCopy(element, project, editor) && editor != null) {
|
||||
Document document = editor.getDocument();
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
|
||||
if (file != null) {
|
||||
String toCopy = FileUtil.toSystemDependentName(file.getPath()) + ":" + (editor.getCaretModel().getLogicalPosition().line + 1);
|
||||
String toCopy = getFileFqn(file) + ":" + (editor.getCaretModel().getLogicalPosition().line + 1);
|
||||
CopyPasteManager.getInstance().setContents(new StringSelection(toCopy));
|
||||
setStatusBarText(project, toCopy + " has been copied");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user