mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-119445 Remove first slash in "copy reference"
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
class X {
|
||||
String s = "/x/x.txt<caret>";
|
||||
String s = "x/x.txt<caret>";
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class Foo {
|
||||
performCopy()
|
||||
myFixture.configureByText 'a.txt', ''
|
||||
performPaste()
|
||||
myFixture.checkResult "/a.java:2"
|
||||
myFixture.checkResult "a.java:2"
|
||||
}
|
||||
|
||||
public void _testMethodOverloadCopy() {
|
||||
|
||||
@@ -20,7 +20,10 @@ import com.intellij.codeInsight.daemon.impl.IdentifierUtil;
|
||||
import com.intellij.codeInsight.highlighting.HighlightManager;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.dnd.FileCopyPasteUtil;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
@@ -33,14 +36,12 @@ import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.StatusBarEx;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.LogicalRoot;
|
||||
import com.intellij.util.LogicalRootsManager;
|
||||
import com.intellij.util.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -84,7 +85,7 @@ public class CopyReferenceAction extends DumbAwareAction {
|
||||
Project project = CommonDataKeys.PROJECT.getData(dataContext);
|
||||
PsiElement element = getElementToCopy(editor, dataContext);
|
||||
|
||||
if (!doCopy(element, project, editor) && editor != null) {
|
||||
if (!doCopy(element, project, editor) && editor != null && project != null) {
|
||||
Document document = editor.getDocument();
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
|
||||
if (file != null) {
|
||||
@@ -98,7 +99,7 @@ public class CopyReferenceAction extends DumbAwareAction {
|
||||
HighlightManager highlightManager = HighlightManager.getInstance(project);
|
||||
EditorColorsManager manager = EditorColorsManager.getInstance();
|
||||
TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
|
||||
if (element != null && editor != null) {
|
||||
if (element != null && editor != null && project != null) {
|
||||
PsiElement nameIdentifier = IdentifierUtil.getNameIdentifier(element);
|
||||
if (nameIdentifier != null) {
|
||||
highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{nameIdentifier}, attributes, true, null);
|
||||
@@ -181,7 +182,7 @@ public class CopyReferenceAction extends DumbAwareAction {
|
||||
|
||||
@Override
|
||||
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||
return ArrayUtil.find(getTransferDataFlavors(), flavor) != -1;
|
||||
return ArrayUtilRt.find(getTransferDataFlavors(), flavor) != -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,16 +239,16 @@ public class CopyReferenceAction extends DumbAwareAction {
|
||||
}
|
||||
final Project project = file.getProject();
|
||||
final LogicalRoot logicalRoot = LogicalRootsManager.getLogicalRootsManager(project).findLogicalRoot(virtualFile);
|
||||
if (logicalRoot != null) {
|
||||
String logical = FileUtil.toSystemIndependentName(VfsUtil.virtualToIoFile(logicalRoot.getVirtualFile()).getPath());
|
||||
String path = FileUtil.toSystemIndependentName(VfsUtil.virtualToIoFile(virtualFile).getPath());
|
||||
return "/" + FileUtil.getRelativePath(logical, path, '/');
|
||||
if (logicalRoot != null && logicalRoot.getVirtualFile() != null) {
|
||||
String logical = FileUtil.toSystemIndependentName(VfsUtilCore.virtualToIoFile(logicalRoot.getVirtualFile()).getPath());
|
||||
String path = FileUtil.toSystemIndependentName(VfsUtilCore.virtualToIoFile(virtualFile).getPath());
|
||||
return ObjectUtils.assertNotNull(FileUtil.getRelativePath(logical, path, '/'));
|
||||
}
|
||||
|
||||
final VirtualFile contentRoot = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(virtualFile);
|
||||
if (contentRoot != null) {
|
||||
return "/" + FileUtil.getRelativePath(VfsUtil.virtualToIoFile(contentRoot), VfsUtil.virtualToIoFile(virtualFile));
|
||||
}
|
||||
return ObjectUtils.assertNotNull(FileUtil.getRelativePath(VfsUtilCore.virtualToIoFile(contentRoot), VfsUtilCore.virtualToIoFile(virtualFile)));
|
||||
}
|
||||
return virtualFile.getPath();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user