update copyright
[fedora-idea.git] / xml / impl / src / com / intellij / usageView / XmlUsageViewDescriptionProvider.java
blob8f328756b1d76c819b595502bb76987581e6f652
1 /*
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.usageView;
18 import com.intellij.codeInsight.highlighting.HighlightUsagesDescriptionLocation;
19 import com.intellij.lang.findUsages.FindUsagesProvider;
20 import com.intellij.lang.findUsages.LanguageFindUsages;
21 import com.intellij.psi.ElementDescriptionLocation;
22 import com.intellij.psi.ElementDescriptionProvider;
23 import com.intellij.psi.PsiElement;
24 import com.intellij.psi.PsiFile;
25 import com.intellij.psi.meta.PsiPresentableMetaData;
26 import com.intellij.psi.xml.XmlAttributeValue;
27 import com.intellij.psi.xml.XmlTag;
28 import org.jetbrains.annotations.NotNull;
30 /**
31 * @author yole
33 public class XmlUsageViewDescriptionProvider implements ElementDescriptionProvider {
34 public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
35 if (location instanceof UsageViewShortNameLocation) {
36 if (element instanceof XmlAttributeValue) {
37 return ((XmlAttributeValue)element).getValue();
41 if (location instanceof UsageViewLongNameLocation) {
42 if (element instanceof XmlTag) {
43 return ((XmlTag)element).getName();
45 else if (element instanceof XmlAttributeValue) {
46 return ((XmlAttributeValue)element).getValue();
50 if (location instanceof HighlightUsagesDescriptionLocation) {
51 if (element instanceof PsiPresentableMetaData) {
52 return null;
54 if (element instanceof PsiFile) {
55 return "File";
58 final FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(element.getLanguage());
59 return provider.getType(element);
61 return null;