From 34868589edec781c635d0584f62830a1f5e12239 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Thu, 4 Dec 2014 21:48:25 +0300 Subject: [PATCH] PY-13986 View -> Open In Browser unavailable for Django projects --- .../openapi/actionSystem/impl/Utils.java | 9 ++++++-- .../PythonTemplateLanguage.java | 7 +++--- .../browsers/impl/WebBrowserServiceImpl.java | 4 ++++ .../com/intellij/lang/html/HTMLLanguage.java | 2 +- .../lang/html/HtmlCompatibleLanguage.java | 23 +++++++++++++++++++ 5 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 xml/xml-psi-api/src/com/intellij/lang/html/HtmlCompatibleLanguage.java diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java index 9af1d30c28bf..b7e6a185b8b6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java @@ -117,7 +117,9 @@ public class Utils{ actionManager, 0 ); - if (!doUpdate(group, e, presentation)) return; + if (!doUpdate(group, e, presentation)) { + return; + } if (!presentation.isVisible()) { // don't process invisible groups return; @@ -136,7 +138,9 @@ public class Utils{ e1.setInjectedContext(child.isInInjectedContext()); if (transparentOnly && child.isTransparentUpdate() || !transparentOnly) { - if (!doUpdate(child, e1, presentation)) continue; + if (!doUpdate(child, e1, presentation)) { + continue; + } } if (!presentation.isVisible() || (!presentation.isEnabled() && hideDisabled)) { // don't create invisible items in the menu @@ -176,6 +180,7 @@ public class Utils{ list.add(child); } } + int i = 1; } // returns false if exception was thrown and handled diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/PythonTemplateLanguage.java b/python/openapi/src/com/jetbrains/python/templateLanguages/PythonTemplateLanguage.java index 28a7e082ec65..64c867f6961f 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/PythonTemplateLanguage.java +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/PythonTemplateLanguage.java @@ -1,22 +1,23 @@ package com.jetbrains.python.templateLanguages; import com.intellij.lang.Language; -import com.intellij.openapi.module.Module; import com.intellij.psi.templateLanguages.TemplateLanguage; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** + * TODO: Make this class implemeent {@link com.intellij.lang.html.HtmlCompatibleLanguage} to prevent copy/paste by fixing dependencies * Python template language + * * @author Ilya.Kazakevich */ public abstract class PythonTemplateLanguage extends Language implements TemplateLanguage { protected PythonTemplateLanguage(@Nullable final Language baseLanguage, - @NotNull @NonNls final String ID, - @NotNull @NonNls final String... mimeTypes) { + @NotNull @NonNls final String ID, + @NotNull @NonNls final String... mimeTypes) { super(baseLanguage, ID, mimeTypes); } diff --git a/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java b/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java index 3d0451d71b3d..723d64bd1193 100644 --- a/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java +++ b/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java @@ -20,6 +20,7 @@ import com.intellij.ide.browsers.WebBrowserService; import com.intellij.ide.browsers.WebBrowserUrlProvider; import com.intellij.lang.Language; import com.intellij.lang.html.HTMLLanguage; +import com.intellij.lang.html.HtmlCompatibleLanguage; import com.intellij.lang.xhtml.XHTMLLanguage; import com.intellij.lang.xml.XMLLanguage; import com.intellij.openapi.project.DumbService; @@ -40,6 +41,9 @@ import java.util.Collections; public class WebBrowserServiceImpl extends WebBrowserService { public static boolean isHtmlOrXmlFile(@NotNull PsiElement element) { Language language = element.getLanguage(); + if (language instanceof HtmlCompatibleLanguage) { + return true; + } return language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE || language == XMLLanguage.INSTANCE; } diff --git a/xml/xml-psi-api/src/com/intellij/lang/html/HTMLLanguage.java b/xml/xml-psi-api/src/com/intellij/lang/html/HTMLLanguage.java index b401e7a65496..4df6a9be82a7 100644 --- a/xml/xml-psi-api/src/com/intellij/lang/html/HTMLLanguage.java +++ b/xml/xml-psi-api/src/com/intellij/lang/html/HTMLLanguage.java @@ -20,7 +20,7 @@ import com.intellij.lang.xml.XMLLanguage; /** * @author max */ -public class HTMLLanguage extends XMLLanguage { +public class HTMLLanguage extends XMLLanguage implements HtmlCompatibleLanguage { public static final HTMLLanguage INSTANCE = new HTMLLanguage(); diff --git a/xml/xml-psi-api/src/com/intellij/lang/html/HtmlCompatibleLanguage.java b/xml/xml-psi-api/src/com/intellij/lang/html/HtmlCompatibleLanguage.java new file mode 100644 index 000000000000..77aaf44a1b98 --- /dev/null +++ b/xml/xml-psi-api/src/com/intellij/lang/html/HtmlCompatibleLanguage.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.lang.html; + +/** + * Language that is based on HTML (like some template languages) + * @author Ilya.Kazakevich + */ +public interface HtmlCompatibleLanguage { +} -- 2.32.0