mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RUBY-3844: Alt​-​F2 should work inside controller action methods
This commit is contained in:
@@ -5,6 +5,7 @@ import com.intellij.lang.html.HTMLLanguage;
|
||||
import com.intellij.lang.xhtml.XHTMLLanguage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -15,14 +16,19 @@ public class HtmlWebBrowserUrlProvider extends WebBrowserUrlProvider {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.browsers.HtmlWebBrowserUrlProvider");
|
||||
|
||||
@NotNull
|
||||
public String getUrl(@NotNull final PsiFile file, final boolean shiftDown) throws Exception {
|
||||
public String getUrl(@NotNull final PsiElement element, final boolean shiftDown) throws Exception {
|
||||
final PsiFile file = element instanceof PsiFile ? (PsiFile) element : element.getContainingFile();
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
LOG.assertTrue(virtualFile != null);
|
||||
return virtualFile.getUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandleFile(@NotNull final PsiFile file) {
|
||||
public boolean canHandleElement(@NotNull final PsiElement element) {
|
||||
final PsiFile file = element instanceof PsiFile ? (PsiFile) element : element.getContainingFile();
|
||||
if (file == null){
|
||||
return false;
|
||||
}
|
||||
final Language language = file.getViewProvider().getBaseLanguage();
|
||||
return HTMLLanguage.INSTANCE == language || XHTMLLanguage.INSTANCE == language;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.intellij.ide.browsers;
|
||||
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -19,8 +19,14 @@ public abstract class WebBrowserUrlProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invariant: element has not null containing psi file with not null virtual file
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String getUrl(@NotNull PsiFile file, boolean shiftDown) throws Exception;
|
||||
public abstract String getUrl(@NotNull PsiElement element, boolean shiftDown) throws Exception;
|
||||
|
||||
public abstract boolean canHandleFile(@NotNull final PsiFile file);
|
||||
/**
|
||||
* Invariant: element has not null containing psi file with not null virtual file
|
||||
*/
|
||||
public abstract boolean canHandleElement(@NotNull final PsiElement element);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.intellij.ide.browsers;
|
||||
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -11,14 +11,14 @@ public class WebBrowserUrlProviders {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static WebBrowserUrlProvider getProvider(@Nullable PsiFile file) {
|
||||
if (file == null) {
|
||||
public static WebBrowserUrlProvider getProvider(@Nullable PsiElement element) {
|
||||
if (element == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final WebBrowserUrlProvider[] urlProviders = WebBrowserUrlProvider.EP_NAME.getExtensions();
|
||||
for (WebBrowserUrlProvider urlProvider : urlProviders) {
|
||||
if (urlProvider.canHandleFile(file)) {
|
||||
if (urlProvider.canHandleElement(element)) {
|
||||
return urlProvider;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user