2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.ide
.browsers
;
18 import com
.intellij
.lang
.Language
;
19 import com
.intellij
.lang
.html
.HTMLLanguage
;
20 import com
.intellij
.lang
.xhtml
.XHTMLLanguage
;
21 import com
.intellij
.openapi
.diagnostic
.Logger
;
22 import com
.intellij
.openapi
.vfs
.VirtualFile
;
23 import com
.intellij
.psi
.PsiElement
;
24 import com
.intellij
.psi
.PsiFile
;
25 import org
.jetbrains
.annotations
.NotNull
;
30 public class HtmlWebBrowserUrlProvider
extends WebBrowserUrlProvider
{
31 private static final Logger LOG
= Logger
.getInstance("#com.intellij.ide.browsers.HtmlWebBrowserUrlProvider");
34 public String
getUrl(@NotNull final PsiElement element
, final boolean shiftDown
) throws Exception
{
35 final PsiFile file
= element
instanceof PsiFile ?
(PsiFile
) element
: element
.getContainingFile();
36 final VirtualFile virtualFile
= file
.getVirtualFile();
37 LOG
.assertTrue(virtualFile
!= null);
38 return virtualFile
.getUrl();
42 public boolean canHandleElement(@NotNull final PsiElement element
) {
43 final PsiFile file
= element
instanceof PsiFile ?
(PsiFile
) element
: element
.getContainingFile();
47 final Language language
= file
.getViewProvider().getBaseLanguage();
48 return HTMLLanguage
.INSTANCE
== language
|| XHTMLLanguage
.INSTANCE
== language
;
51 public static boolean isAvailableFor(@NotNull final PsiFile file
) {
52 final Language language
= file
.getLanguage();
53 return language
instanceof HTMLLanguage
|| language
instanceof XHTMLLanguage
;