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

The following are Jave code examples for showing how to use XML_ATTRIBUTE_VALUE_START_DELIMITER 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: XmlHighlightingLexer.java   Source Code and License Vote up 6 votes
@Override
public IElementType getTokenType() {
  IElementType tokenType = getDelegate().getTokenType();

  if (tokenType == null) return tokenType;

  int state = getState() & 0xF;

  tokenType = fixWrongTokenTypes(tokenType, state);
  if (tokenType != XmlTokenType.XML_COMMENT_CHARACTERS &&
    tokenType != XmlTokenType.XML_COMMENT_END &&
    tokenType != XmlTokenType.XML_COMMENT_START &&
    tokenType != XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) {

    // TODO: do not know when this happens!
    switch (state) {
      case __XmlLexer.DOCTYPE:
        tokenType = XmlTokenType.XML_DECL_START;
        break;
    }
  }

  return tokenType;
}
 
Example 2
Project: intellij-ce-playground   File: XmlBraceMatcher.java   Source Code and License Vote up 6 votes
@Override
public int getBraceTokenGroupId(IElementType tokenType) {
  final Language l = tokenType.getLanguage();
  PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(l);
  
  if (matcher != null) {
    BracePair[] pairs = matcher.getPairs();
    for (BracePair pair : pairs) {
      if (pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType ) {
        return l.hashCode();
      }
    }
  }
  if (tokenType instanceof IXmlLeafElementType) {
    return tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER
           ? XML_VALUE_DELIMITER_GROUP
           : XML_TAG_TOKEN_GROUP;
  }
  else{
    return BraceMatchingUtil.UNDEFINED_TOKEN_GROUP;
  }
}
 
Example 3
Project: intellij-ce-playground   File: XmlBlock.java   Source Code and License Vote up 6 votes
private List<Block> splitAttribute(ASTNode node, XmlFormattingPolicy formattingPolicy) {
  final ArrayList<Block> result = new ArrayList<Block>(3);
  ASTNode child = node.getFirstChildNode();
  while (child != null) {
    if (child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER ||
        child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
      result.add(new XmlBlock(child, null, null, formattingPolicy, null, null, isPreserveSpace()));
    }
    else if (!child.getPsi().getLanguage().isKindOf(XMLLanguage.INSTANCE) && containsOuterLanguageElement(child)) {
      // Fix for EA-20311:
      // In case of another embedded language create a splittable XML block which can be
      // merged with other language's code blocks.
      createLeafBlocks(child, result);
    }
    else if (child.getElementType() != TokenType.ERROR_ELEMENT || child.getFirstChildNode() != null) {
      result.add(new ReadOnlyBlock(child));
    }
    child = child.getTreeNext();
  }
  return result;
}
 
Example 4
Project: intellij-ce-playground   File: HtmlParsing.java   Source Code and License Vote up 5 votes
private void parseAttributeValue() {
  final PsiBuilder.Marker attValue = mark();
  if (token() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) {
    while (true) {
      final IElementType tt = token();
      if (tt == null || tt == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER || tt == XmlTokenType.XML_END_TAG_START || tt == XmlTokenType
        .XML_EMPTY_ELEMENT_END ||
          tt == XmlTokenType.XML_START_TAG_START) {
        break;
      }

      if (tt == XmlTokenType.XML_BAD_CHARACTER) {
        final PsiBuilder.Marker error = mark();
        advance();
        error.error(XmlErrorMessages.message("unescaped.ampersand.or.nonterminated.character.entity.reference"));
      }
      else if (tt == XmlTokenType.XML_ENTITY_REF_TOKEN) {
        parseReference();
      }
      else {
        advance();
      }
    }

    if (token() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
      advance();
    }
    else {
      error(XmlErrorMessages.message("xml.parsing.unclosed.attribute.value"));
    }
  }
  else {
    if (token() != XmlTokenType.XML_TAG_END && token() != XmlTokenType.XML_EMPTY_ELEMENT_END) {
      advance(); // Single token att value
    }
  }

  attValue.done(XmlElementType.XML_ATTRIBUTE_VALUE);
}
 
Example 5
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 6
Project: intellij-ce-playground   File: XmlQuoteHandler.java   Source Code and License Vote up 4 votes
@Override
public boolean isOpeningQuote(HighlighterIterator iterator, int offset) {
  return iterator.getTokenType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER;
}