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

The following are Jave code examples for showing how to use XML_DOCTYPE_PUBLIC 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 processDoctypeNode(final XmlBuilder builder, final FlyweightCapableTreeStructure<LighterASTNode> structure,
                                final LighterASTNode doctype) {
  final Ref<LighterASTNode[]> tokens = new Ref<LighterASTNode[]>(null);
  final int tokenCount = structure.getChildren(structure.prepareForGetChildren(doctype), tokens);
  if (tokenCount > 0) {
    CharSequence publicId = null;
    boolean afterPublic = false;
    CharSequence systemId = null;
    boolean afterSystem = false;
    for (int i = 0; i < tokenCount; i++) {
      LighterASTNode token = tokens.get()[i];
      if (token.getTokenType() == XmlTokenType.XML_DOCTYPE_PUBLIC) {
        afterPublic = true;
      }
      else if (token.getTokenType() == XmlTokenType.XML_DOCTYPE_SYSTEM) {
        afterSystem = true;
      }
      else if (token.getTokenType() != TokenType.WHITE_SPACE && token.getTokenType() != XmlElementType.XML_COMMENT) {
        if (token.getTokenType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) {
          if (afterPublic) publicId = getTokenText(token);
          else if (afterSystem) systemId = getTokenText(token);
        }
        afterPublic = afterSystem = false;
      }
    }
    builder.doctype(publicId, systemId, doctype.getStartOffset(), doctype.getEndOffset());
  }
}
 
Example 2
Project: intellij-ce-playground   File: Html5CustomAttributesIndex.java   Source Code and License Vote up 5 votes
@Override
@NotNull
public Map<String, Void> map(@NotNull FileContent inputData) {
  CharSequence input = inputData.getContentAsText();
  Language language = ((LanguageFileType)inputData.getFileType()).getLanguage();
  if (language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE) {
    final Lexer lexer = (language == HTMLLanguage.INSTANCE ? new HtmlHighlightingLexer(FileTypeManager.getInstance().getStdFileType("CSS")) : new XHtmlHighlightingLexer());
    lexer.start(input);
    Map<String, Void> result = new HashMap<String, Void>();
    IElementType tokenType = lexer.getTokenType();
    while (tokenType != null) {
      if (tokenType == XmlTokenType.XML_NAME) {
        String xmlName = input.subSequence(lexer.getTokenStart(), lexer.getTokenEnd()).toString();
        if (HtmlUtil.isCustomHtml5Attribute(xmlName)) {
          result.put(xmlName, null);
        }
      }
      else if (tokenType == XmlTokenType.XML_DOCTYPE_PUBLIC || tokenType == XmlTokenType.XML_DOCTYPE_SYSTEM) {
        // this is not an HTML5 context
        break;
      }
      lexer.advance();
      tokenType = lexer.getTokenType();
    }
    return result;
  }
  return Collections.emptyMap();
}