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

The following are Jave code examples for showing how to use XML_CDATA_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: XmlBuilderDriver.java   Source Code and License Vote up 5 votes
private void processTextNode(FlyweightCapableTreeStructure<LighterASTNode> structure, LighterASTNode node, XmlBuilder builder) {
  node = structure.prepareForGetChildren(node);

  final Ref<LighterASTNode[]> childrenRef = Ref.create(null);
  final int count = structure.getChildren(node, childrenRef);
  LighterASTNode[] children = childrenRef.get();

  for (int i = 0; i < count; i++) {
    LighterASTNode child = children[i];
    IElementType tt = child.getTokenType();
    final int start = child.getStartOffset();
    final int end = child.getEndOffset();
    final CharSequence physical = getTokenText(child);

    if (XmlTokenType.COMMENTS.contains(tt)) continue;

    if (tt == XmlTokenType.XML_CDATA_START || tt == XmlTokenType.XML_CDATA_END) {
      builder.textElement("", physical, start, end);
    }
    else if (tt == XmlElementType.XML_CDATA) {
      processTextNode(structure, child, builder);
    }
    else if (tt == XmlTokenType.XML_CHAR_ENTITY_REF) {
      builder.textElement(new String(new char[] {XmlUtil.getCharFromEntityRef(physical.toString())}), physical, start, end);
    }
    else {
      builder.textElement(physical, physical, start, end);
    }
  }

  structure.disposeChildren(children, count);
}
 
Example 2
Project: intellij-ce-playground   File: HtmlLexer.java   Source Code and License Vote up 5 votes
private static boolean isStartOfEmbeddmentTagContent(final IElementType tokenType) {
  return (tokenType == XmlTokenType.XML_DATA_CHARACTERS ||
          tokenType == XmlTokenType.XML_CDATA_START ||
          tokenType == XmlTokenType.XML_COMMENT_START ||
          tokenType == XmlTokenType.XML_REAL_WHITE_SPACE || tokenType == TokenType.WHITE_SPACE
  );
}
 
Example 3
Project: intellij-ce-playground   File: XmlCDATAContentSelectioner.java   Source Code and License Vote up 5 votes
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
  List<TextRange> result = super.select(e, editorText, cursorOffset, 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_CDATA_START) {
        first = token.getNextSibling();
      }
      if (token.getTokenType() == XmlTokenType.XML_CDATA_END) {
        last = token.getPrevSibling();
        break;
      }
    }
  }

  if (first != null && last != null) {
    result.addAll(expandToWholeLine(editorText,
                                    new TextRange(first.getTextRange().getStartOffset(),
                                                  last.getTextRange().getEndOffset()),
                                    false));
  }

  return result;
}
 
Example 4
Project: intellij-ce-playground   File: XmlBraceMatcher.java   Source Code and License Vote up 5 votes
@Override
public boolean isLBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType) return true;
    }
  }
  return tokenType == XmlTokenType.XML_START_TAG_START ||
         tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER ||
         tokenType == XmlTokenType.XML_CDATA_START;
}
 
Example 5
Project: intellij-ce-playground   File: AbstractSyntheticBlock.java   Source Code and License Vote up 4 votes
public boolean containsCDATA() {
  return myStartTreeNode.getElementType() == XmlTokenType.XML_CDATA_START &&
         myEndTreeNode.getElementType() == XmlTokenType.XML_CDATA_END;
}