Search in sources :

Example 1 with IssueNavigationConfiguration

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);
}
Also used : IssueNavigationConfiguration(com.intellij.openapi.vcs.IssueNavigationConfiguration)

Example 2 with IssueNavigationConfiguration

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);
    }
}
Also used : WebReference(com.intellij.openapi.paths.WebReference) IssueNavigationLink(com.intellij.openapi.vcs.IssueNavigationLink) IssueNavigationConfiguration(com.intellij.openapi.vcs.IssueNavigationConfiguration)

Example 3 with IssueNavigationConfiguration

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>");
}
Also used : IssueNavigationConfiguration(com.intellij.openapi.vcs.IssueNavigationConfiguration) TextRange(com.intellij.openapi.util.TextRange)

Example 4 with IssueNavigationConfiguration

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);
}
Also used : IssueNavigationLink(com.intellij.openapi.vcs.IssueNavigationLink) ColumnInfo(com.intellij.util.ui.ColumnInfo) IssueNavigationConfiguration(com.intellij.openapi.vcs.IssueNavigationConfiguration)

Aggregations

IssueNavigationConfiguration (com.intellij.openapi.vcs.IssueNavigationConfiguration)4 IssueNavigationLink (com.intellij.openapi.vcs.IssueNavigationLink)2 WebReference (com.intellij.openapi.paths.WebReference)1 TextRange (com.intellij.openapi.util.TextRange)1 ColumnInfo (com.intellij.util.ui.ColumnInfo)1