Java Code Examples for com.intellij.psi.xml.XmlTokenType.XML_ELEMENT_DECL_START

The following are Jave code examples for showing how to use XML_ELEMENT_DECL_START of the com.intellij.psi.xml.XmlTokenType class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: intellij-ce-playground   File: DtdSelectioner.java   Source Code and License Vote up 5 votes
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
  PsiElement[] children = e.getChildren();

  PsiElement first = null;
  PsiElement last = null;
  for (PsiElement child : children) {
    if (child instanceof XmlToken) {
      XmlToken token = (XmlToken)child;
      if (token.getTokenType() == XmlTokenType.XML_TAG_END) {
        last = token;
        break;
      }
      if (token.getTokenType() == XmlTokenType.XML_ELEMENT_DECL_START ||
          token.getTokenType() == XmlTokenType.XML_ATTLIST_DECL_START
         ) {
        first = token;
      }
    }
  }

  List<TextRange> result = new ArrayList<TextRange>(1);
  if (first != null && last != null) {
    final int offset = last.getTextRange().getEndOffset() + 1;
      result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText,
                                      new TextRange(first.getTextRange().getStartOffset(), offset < editorText.length() ? offset:editorText.length()),
                                      false));
  }

  return result;
}