use of com.intellij.psi.xml.XmlComment in project intellij-community by JetBrains.
the class HtmlConditionalCommentInjector method parseConditionalCommentBoundaries.
/**
* Tries to parse given element as <a href="http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx">conditional comment</a>.
*
* @param host target element to parse
* @return {@code null} if given element is not a conditional comment;
* pair like {@code (conditional comment start element; conditional comment end element)} otherwise
*/
@Nullable
private static Pair<ASTNode, ASTNode> parseConditionalCommentBoundaries(@NotNull PsiElement host) {
if (!(host instanceof XmlComment)) {
return null;
}
final ASTNode comment = host.getNode();
if (comment == null) {
return null;
}
final ASTNode conditionalStart = comment.findChildByType(TokenSet.create(XmlTokenType.XML_CONDITIONAL_COMMENT_START_END));
if (conditionalStart == null) {
return null;
}
final ASTNode conditionalEnd = comment.findChildByType(TokenSet.create(XmlTokenType.XML_CONDITIONAL_COMMENT_END_START));
if (conditionalEnd == null) {
return null;
}
final ASTNode endOfEnd = comment.findChildByType(TokenSet.create(XmlTokenType.XML_CONDITIONAL_COMMENT_END));
return endOfEnd == null ? null : Pair.create(conditionalStart, conditionalEnd);
}
Aggregations