use of org.eclipse.mylyn.wikitext.markdown.internal.LinkDefinitionUsageTracker in project mylyn.docs by eclipse.
the class LinkDefinitionValidationRule method findProblems.
@Override
public List<ValidationProblem> findProblems(String markup, int offset, int length) {
MarkupParser parser = new MarkupParser(new MarkdownLanguage());
MarkdownContentStateDocumentBuilder builder = new MarkdownContentStateDocumentBuilder();
parser.setBuilder(builder);
parser.parse(markup);
MarkdownContentState markdownContentState = builder.markdownContentState;
LinkDefinitionUsageTracker linkDefinitionUsageTracker = markdownContentState.getLinkDefinitionUsageTracker();
List<ValidationProblem> problems = new ArrayList<ValidationProblem>();
List<Position> missingLinkDefinitionPositions = linkDefinitionUsageTracker.getMissingLinkDefinitionPositions();
for (Position position : missingLinkDefinitionPositions) {
problems.add(new ValidationProblem(Severity.ERROR, MessageFormat.format(// $NON-NLS-1$
Messages.getString("LinkDefinitionValidationRule.missing"), position.getId()), position.getOffset(), position.getLength()));
}
List<Position> unusedLinkDefinitionPositions = linkDefinitionUsageTracker.getUnusedLinkDefinitionPositions();
for (Position position : unusedLinkDefinitionPositions) {
problems.add(new ValidationProblem(Severity.WARNING, MessageFormat.format(// $NON-NLS-1$
Messages.getString("LinkDefinitionValidationRule.unused"), position.getId()), position.getOffset(), position.getLength()));
}
return problems;
}
Aggregations