use of com.intellij.openapi.vcs.IssueNavigationConfiguration in project intellij-community by JetBrains.
the class IssueNavigationConfigurationPanel method apply.
public void apply() {
IssueNavigationConfiguration configuration = IssueNavigationConfiguration.getInstance(myProject);
configuration.setLinks(myLinks);
}
use of com.intellij.openapi.vcs.IssueNavigationConfiguration in project intellij-community by JetBrains.
the class JavadocHighlightingTest method testIssueLinksInJavaDoc.
public void testIssueLinksInJavaDoc() {
IssueNavigationConfiguration navigationConfiguration = IssueNavigationConfiguration.getInstance(getProject());
List<IssueNavigationLink> oldLinks = navigationConfiguration.getLinks();
try {
navigationConfiguration.setLinks(ContainerUtil.newArrayList(new IssueNavigationLink("ABC-\\d+", "http://example.com/$0"), new IssueNavigationLink("INVALID-\\d+", "http://example.com/$0/$1")));
configureByFile(getTestName(false) + ".java");
List<String> expected = ContainerUtil.newArrayList("http://example.com/ABC-1123", "http://example.com/ABC-2", "http://example.com/ABC-22", "http://example.com/ABC-11");
List<WebReference> refs = PlatformTestUtil.collectWebReferences(myFile);
assertTrue(refs.stream().allMatch(PsiReferenceBase::isSoft));
assertEquals(expected, refs.stream().map(WebReference::getUrl).collect(Collectors.toList()));
} finally {
navigationConfiguration.setLinks(oldLinks);
}
}
use of com.intellij.openapi.vcs.IssueNavigationConfiguration in project intellij-community by JetBrains.
the class IssueLinkHtmlRenderer method formatTextWithLinks.
@SuppressWarnings({ "HardCodedStringLiteral" })
public static String formatTextWithLinks(Project project, String str, Convertor<String, String> convertor) {
if (StringUtil.isEmpty(str))
return "";
String comment = XmlStringUtil.escapeString(str, false);
StringBuilder commentBuilder = new StringBuilder();
IssueNavigationConfiguration config = IssueNavigationConfiguration.getInstance(project);
final List<IssueNavigationConfiguration.LinkMatch> list = config.findIssueLinks(comment);
int pos = 0;
for (IssueNavigationConfiguration.LinkMatch match : list) {
TextRange range = match.getRange();
commentBuilder.append(convertor.convert(comment.substring(pos, range.getStartOffset()))).append("<a href=\"").append(match.getTargetUrl()).append("\">");
commentBuilder.append(range.substring(comment)).append("</a>");
pos = range.getEndOffset();
}
commentBuilder.append(convertor.convert(comment.substring(pos)));
comment = commentBuilder.toString();
return comment.replace("\n", "<br>");
}
use of com.intellij.openapi.vcs.IssueNavigationConfiguration in project intellij-community by JetBrains.
the class IssueNavigationConfigurationPanel method reset.
public void reset() {
IssueNavigationConfiguration configuration = IssueNavigationConfiguration.getInstance(myProject);
myLinks = new ArrayList<>();
for (IssueNavigationLink link : configuration.getLinks()) {
myLinks.add(new IssueNavigationLink(link.getIssueRegexp(), link.getLinkRegexp()));
}
myModel = new ListTableModel<>(new ColumnInfo[] { ISSUE_COLUMN, LINK_COLUMN }, myLinks, 0);
myLinkTable.setModel(myModel);
}
Aggregations