}
StringMultiset tagAttributes = tag.getAttributes();
while (index < size) {
Token token = tokens.get(index);
index++;
TokenType tokenType = token.getType();
if (ATTRIBUTE == tokenType) {
String attribute = token.getValue();
attribute = ignoreCase ? attribute.toLowerCase() : attribute;
attributes.add(attribute);
tagAttributes.add(attribute);
} else if (TAG == tokenType) {
// Tag closing token
tag.setDirty(false);
inTag = false;
break;
}
}
if (newAttributes && attributes.size() != 0) {
line.putTag(TAG_ATTRIBUTES, attributes);
} else if (!newAttributes && attributes.size() == 0) {
line.putTag(TAG_ATTRIBUTES, null);
}
} else {
line.putTag(TAG_ATTRIBUTES, null);
}
while (index < size) {
Token token = tokens.get(index);
index++;
TokenType tokenType = token.getType();
if (TAG == tokenType) {
if (inTag) {
if (">".equals(token.getValue()) || "/>".equals(token.getValue())) {
// If type is "tag" and content is ">", this is HTML token.
inTag = false;
}
} else {
// Check that we are in html mode.
if (CodeMirror2.HTML.equals(token.getMode())) {
lastTagTokenIndex = index - 1;
inTag = true;
}
}
}
}
if (inTag) {
if (lastTagTokenIndex != -1) {
index = lastTagTokenIndex;
Token token = tokens.get(index);
index++;
String tagName = token.getValue().substring(1).trim();
tag = new HtmlTagWithAttributes(tagName);
StringMultiset tagAttributes = tag.getAttributes();
while (index < size) {
token = tokens.get(index);
index++;
TokenType tokenType = token.getType();
if (ATTRIBUTE == tokenType) {
String attribute = token.getValue();
tagAttributes.add(ignoreCase ? attribute.toLowerCase() : attribute);
}
}
}