use of org.sonar.plugins.html.node.Attribute in project sonar-web by SonarSource.
the class ElementTokenizer method handleBeforeAttributeValue.
private static void handleBeforeAttributeValue(CodeReader codeReader, TagNode element) {
Attribute attribute;
if (!element.getAttributes().isEmpty()) {
attribute = element.getAttributes().get(element.getAttributes().size() - 1);
StringBuilder sbValue = new StringBuilder();
int ch = codeReader.peek();
if (isQuote((char) ch)) {
codeReader.pop();
if (codeReader.peek() != ch) {
QuoteMatcher quoteMatcher = new QuoteMatcher((char) ch);
quoteMatcher.match(codeReader.peek());
codeReader.popTo(quoteMatcher, sbValue);
attribute.setValue(unescapeQuotes(sbValue.toString(), (char) ch));
}
codeReader.pop();
attribute.setQuoteChar((char) ch);
} else {
codeReader.popTo(endUnquotedAttributeMatcher, sbValue);
attribute.setValue(sbValue.toString().trim());
}
}
}
use of org.sonar.plugins.html.node.Attribute in project sonar-web by SonarSource.
the class DeprecatedAttributesInHtml5Check method startElement.
@Override
public void startElement(TagNode element) {
String nodeName = element.getNodeName();
String elementName = nodeName.toLowerCase(Locale.ROOT);
Set<String> deprecatedAttributes = DEPRECATED.get(elementName);
if (deprecatedAttributes != null) {
List<Attribute> attributes = element.getAttributes();
for (Attribute attribute : attributes) {
if (isDeprecated(element, deprecatedAttributes, getOriginalAttributeName(attribute.getName()), attribute.getValue().toLowerCase(Locale.ROOT))) {
createViolation(element, "Remove this deprecated \"" + attribute.getName() + "\" attribute.");
}
}
}
}
Aggregations