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
.refactoring
.util
;
18 import com
.intellij
.psi
.ElementDescriptionLocation
;
19 import com
.intellij
.psi
.ElementDescriptionProvider
;
20 import com
.intellij
.psi
.PsiElement
;
21 import com
.intellij
.psi
.xml
.XmlAttribute
;
22 import com
.intellij
.psi
.xml
.XmlAttributeValue
;
23 import com
.intellij
.psi
.xml
.XmlTag
;
24 import org
.jetbrains
.annotations
.Nullable
;
25 import org
.jetbrains
.annotations
.NotNull
;
30 public class XmlNonCodeSearchElementDescriptionProvider
implements ElementDescriptionProvider
{
31 public String
getElementDescription(@NotNull final PsiElement element
, @NotNull final ElementDescriptionLocation location
) {
32 if (!(location
instanceof NonCodeSearchDescriptionLocation
)) return null;
33 final NonCodeSearchDescriptionLocation ncdLocation
= (NonCodeSearchDescriptionLocation
)location
;
34 if (ncdLocation
.isNonJava()) return null;
35 if (element
instanceof XmlTag
) {
36 return ((XmlTag
)element
).getValue().getTrimmedText();
38 else if (element
instanceof XmlAttribute
) {
39 return ((XmlAttribute
)element
).getValue();
41 else if (element
instanceof XmlAttributeValue
) {
42 return ((XmlAttributeValue
)element
).getValue();