update copyright
[fedora-idea.git] / xml / impl / src / com / intellij / xml / util / documentation / XHtmlDocumentationProvider.java
blob8ca9fa78ed1211c53df1e353376502241dbcb29f
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.xml.util.documentation;
18 import com.intellij.psi.PsiElement;
19 import com.intellij.psi.PsiWhiteSpace;
20 import com.intellij.psi.xml.XmlTag;
21 import com.intellij.psi.xml.XmlText;
23 /**
24 * Created by IntelliJ IDEA.
25 * User: maxim
26 * Date: 24.12.2004
27 * Time: 23:55:20
28 * To change this template use File | Settings | File Templates.
30 public class XHtmlDocumentationProvider extends HtmlDocumentationProvider {
32 protected String generateDocForHtml(PsiElement element, boolean ommitHtmlSpecifics, XmlTag context, PsiElement originalElement) {
33 return super.generateDocForHtml(element, true, context, originalElement);
36 protected XmlTag findTagContext(PsiElement context) {
37 XmlTag tagBeforeWhiteSpace = findTagBeforeWhiteSpace(context);
38 if (tagBeforeWhiteSpace!=null) return tagBeforeWhiteSpace;
39 return super.findTagContext(context);
42 private XmlTag findTagBeforeWhiteSpace(PsiElement context) {
43 if (context instanceof PsiWhiteSpace) {
44 PsiElement parent = context.getParent();
45 if (parent instanceof XmlText) {
46 PsiElement prevSibling = parent.getPrevSibling();
47 if (prevSibling instanceof XmlTag) return (XmlTag)prevSibling;
48 } else if (parent instanceof XmlTag) {
49 return (XmlTag)parent;
53 return null;
56 protected boolean isAttributeContext(PsiElement context) {
57 if (findTagBeforeWhiteSpace(context)!=null) return false;
59 return super.isAttributeContext(context);