vsch / idea-multimarkdown

Markdown language support for IntelliJ IDEA.
https://plugins.jetbrains.com/plugin/7896-markdown-navigator
Apache License 2.0
812 stars 129 forks source link

Android Studio 3.6.3 refactor->rename file does not update markdown links #842

Open igorwojda opened 4 years ago

igorwojda commented 4 years ago

When renaming file within Android Studio links in the markdown file are not updated (link is invalid because it point to file with old name)

vsch commented 4 years ago

@igorwojda, first thing to check is that "Search for references" is enabled during refactoring:

image

Second, I will need your system config (IDE and plugin settings) from the about box. Click on the copy icon Screenshot_AboutCopy in the about box and paste it here:

Screenshot_About

igorwojda commented 4 years ago

image

image

Sample project https://github.com/nexmo-community/client-sdk-android-samples

  1. Open README.md
  2. Rename any class eg. BasicConfigurationActivityKotlin
igorwojda commented 4 years ago

BTW I know this should be separate issue, but If I also observe UI hangs while opening preview of README.md(I guess it has something to do with loading of batch image 🤔 )

vsch commented 4 years ago

@igorwojda, I will need to install and try it on AS 3.6.3, because in IDEA 2019.2 it is working.

  1. What plugin version are you using so I can reproduce your environment
  2. If you put the caret on the link to a Kotlin class and invoke go to definition action, does it open the class file?

As for the other comment regarding the preview. Does preview hang, or does it display the page but without the images? Are the images slow to load the first time or every time?

BTW, clicking on the clipboard icon in the about box and pasting it, gives much more useful information, including OS and versions and a list of installed plugins.

Here is an example:

IntelliJ IDEA 2020.2 Snapshot (Community Edition)
Build #IC-201.7223.20, built on April 18, 2020
Runtime version: 11.0.6+8-b765.38 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.3
GC: ParNew, ConcurrentMarkSweep
Memory: 6023M
Cores: 16
Registry: ide.ui.tree.indent=1, ide.mac.boldEditorTabs=true, show.diff.preview.as.editor.tab=true, gui.form.edit.property.keys=true, ide.popup.resizable.border.sensitivity=6, uast.java.use.psi.type.precheck=false, undo.documentUndoLimit=200, debugger.show.values.inplace=true, show.diff.as.editor.tab=true, ide.browser.jcef.enabled=true, undo.globalUndoLimit=50, debugger.watches.in.variables=false, vcs.commit.tool.window=false, debugger.single.smart.step.force=false, focus.fix.lost.cursor=true, debugger.valueTooltipAutoShowOnSelection=true, vcs.force.non.modal.commit=true, vcs.non.modal.commit.split.horizontal.if.no.diff.preview=true, editor.caret.width=1, ide.new.editor.tabs.selection.color=0,136,238
Non-Bundled Plugins: CMD Support, PlantUML integration, PsiViewer, String Manipulation, com.bulenkov.intellij.png.optimizer, YourKit Java Profiler 2019.8-b136 Integration, org.jetbrains.idea.grammar, nb-mind-map-idea, de.juserv.intellij-propertiessort, com.intellij.marketplace, com.lid.intellij.translateme, com.ultrahob.zerolength.plugin, com.vladsch.MissingInActions, com.vladsch.PluginDevelopersToolbox, com.vladsch.plugins.consoleFileCaddy, com.vladsch.plugins.touchTypistsCompletionCaddy, org.intellij.RegexpTester, com.jetbrains.space, com.vladsch.git-file-case-fixer, mobi.hsz.idea.gitignore, com.vladsch.idea.multimarkdown
igorwojda commented 4 years ago

Plugin 3.0.192.72

Android Studio 3.6.3
Build #AI-192.7142.36.36.6392135, built on April 14, 2020
Runtime version: 1.8.0_212-release-1586-b4-5784211 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.4
GC: ParNew, ConcurrentMarkSweep
Memory: 8108M
Cores: 12
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: AceJump, Key Promoter X, awesome.console, com.dubreuia, de.netnexus.camelcaseplugin, detekt, com.vladsch.idea.multimarkdown, org.jetbrains.kotlin, com.codota.csp.intellij, com.jetbrains.packagesearch.intellij-plugin, BashSupport, com.google.services.firebase, Docker, socrates.tabshifter, some.awesome

It is broken for both Java and Kotlin classes

Rename Gif Rename

vsch commented 4 years ago

@igorwojda, thank you for the clarification. I will test it in AS 3.6.3 to reproduce.

igorwojda commented 4 years ago

Regarding preview

  1. IDE hangs all the time when I enable preview (hangs for a few seconds)
  2. Here is what I see image
vsch commented 4 years ago

@igorwojda, can confirm that AS 3.6.3 reference contributor from markdown navigator is not working. This is the cause of rename refactoring failing. Find references on Kotlin files does not list any markdown links referencing the file.

Have to figure out why AS is different from other IDEs

vsch commented 4 years ago

@igorwojda, there appears to be differences in AS 3.6.3 in handling references.

First issue was that referenceSearch extension is passed a scope which filtered out non class files: Java or Kotlin when I tried to get list of link stubs pointing to the file.

I changed the code to pass my own "Everything" scope then filter out files using the passed scope. This had the effect of show usages (Cmd+F7) showing Markdown link references, which was not done before:

image

However, that still does not refactor links when the file is renamed. I suspect that AS implemented other changes in the way rename is handled. Most likely, it passes a class element reference for files so the rename does not see a file rename but a class rename. The plugin references files so does not see these.

I will need to dig deeper to figure out WTF is going on in AS 3.6.3. It used to work fine on previous versions when I tested this feature.

vsch commented 4 years ago

@igorwojda, it will take a lot more effort to figure out how to fix this. AS renames the class and does not address the fact that it renames the file the way IDEA does it.

Effectively, for the rename of the class all file references are ignored since they reference the file and not the class.

For now the link refactoring for Java and Kotlin files is broken in AS. I will ask JetBrains for suggestions on how to get around the problem.

igorwojda commented 4 years ago

Thanks for the update

BTW @vsch you are the best maintainer I ever interacted with‼ Man you are doing an amazing work! (seriously!) Keep going!

vsch commented 4 years ago

@igorwojda, thank you for the compliment.

BTW, I narrowed it down to the problem of AS ignoring your selected scope for find usages and renaming. It always uses "Modules, libraries and scratches" no matter what you select. So selecting "Project Files" is ignored and only module files are searched and accepted.

image

This is the reason why find usages did not work nor renaming because the Markdown file is outside any module, library or scratch file.

If the markdown file is in some module, find usages and renaming does work.

The only workaround I can see for now is putting the markdown files in a module, even if it is a fake one.

It really does sound like a bug in AS and you should probably open an issue. I am not a user of AS nor do I have a clue to where to do it. I will ask JB plugin forum for suggestions.

igorwojda commented 4 years ago

Issue reported https://issuetracker.google.com/issues/154646023

BTW For the future: Android Studio -> Help -> Submit feedback

vsch commented 4 years ago

@igorwojda, I am now seeing the same issue in my SNAPSHOT build of IDEA from latest intellij-community#master branch sources.

I am hoping this will be properly addressed in the API since it is no longer an Android Studio issue.

vsch commented 4 years ago

@igorwojda, some good news. I got a solution for the issue in 2020.1.2 and the same solution works for AS 3.6.

Latest AS 4.1 preview also appears to work with plugin EAP version 3.0.201.103.

EAP update with a fix for the issue is available in version 3.0.192.103.

Installing EAP Plugin Version

Please note the change that EAP channel is for JetBrains licensed plugin and Legacy EAP is for legacy licensing by vladsch.com