Search in sources :

Example 1 with PathMacrosImpl

use of com.intellij.application.options.PathMacrosImpl in project intellij-community by JetBrains.

the class PathMacrosCollectorTest method testWithFilter.

public void testWithFilter() throws Exception {
    Element root = new Element("root");
    final Element testTag = new Element("test");
    testTag.setAttribute("path", "$MACRO$");
    testTag.setAttribute("ignore", "$PATH$");
    root.addContent(testTag);
    final Set<String> macros = PathMacrosCollector.getMacroNames(root, null, new PathMacrosImpl());
    assertEquals(2, macros.size());
    assertTrue(macros.contains("MACRO"));
    assertTrue(macros.contains("PATH"));
    final Set<String> filtered = PathMacrosCollector.getMacroNames(root, new PathMacroFilter() {

        @Override
        public boolean skipPathMacros(Attribute attribute) {
            return "ignore".equals(attribute.getName());
        }
    }, new PathMacrosImpl());
    assertEquals(1, filtered.size());
    assertTrue(macros.contains("MACRO"));
}
Also used : PathMacrosImpl(com.intellij.application.options.PathMacrosImpl) Attribute(org.jdom.Attribute) Element(org.jdom.Element) PathMacroFilter(com.intellij.openapi.application.PathMacroFilter)

Example 2 with PathMacrosImpl

use of com.intellij.application.options.PathMacrosImpl in project intellij-community by JetBrains.

the class PathMacrosCollectorTest method testWithRecursiveFilter.

public void testWithRecursiveFilter() throws Exception {
    Element root = new Element("root");
    final Element configuration = new Element("configuration");
    configuration.setAttribute("value", "some text$macro5$fdsjfhdskjfsd$MACRO$");
    configuration.setAttribute("value2", "file://$root$/some/path/just$file$name.txt");
    root.addContent(configuration);
    final Set<String> macros = PathMacrosCollector.getMacroNames(root, new PathMacroFilter() {

        @Override
        public boolean recursePathMacros(Attribute attribute) {
            return "value".equals(attribute.getName());
        }
    }, new PathMacrosImpl());
    UsefulTestCase.assertSameElements(macros, "macro5", "MACRO", "root");
}
Also used : PathMacrosImpl(com.intellij.application.options.PathMacrosImpl) Attribute(org.jdom.Attribute) Element(org.jdom.Element) PathMacroFilter(com.intellij.openapi.application.PathMacroFilter)

Example 3 with PathMacrosImpl

use of com.intellij.application.options.PathMacrosImpl in project intellij-community by JetBrains.

the class PathMacrosCollectorTest method testCollectMacros.

public void testCollectMacros() {
    Element root = new Element("root");
    root.addContent(new Text("$MACro1$ some text $macro2$ other text $MACRo3$"));
    root.addContent(new Text("$macro4$ some text"));
    root.addContent(new Text("some text$macro5$"));
    root.addContent(new Text("file:$mac_ro6$"));
    root.addContent(new Text("jar://$macr.o7$ "));
    root.addContent(new Text("$mac-ro8$ "));
    root.addContent(new Text("$$$ "));
    root.addContent(new Text("$c:\\a\\b\\c$ "));
    root.addContent(new Text("$Revision 1.23$"));
    root.addContent(new Text("file://$root$/some/path/just$file$name.txt"));
    final Set<String> macros = PathMacrosCollector.getMacroNames(root, null, new PathMacrosImpl());
    UsefulTestCase.assertSameElements(macros, "MACro1", "macro4", "mac_ro6", "macr.o7", "mac-ro8", "root");
}
Also used : PathMacrosImpl(com.intellij.application.options.PathMacrosImpl) Element(org.jdom.Element) Text(org.jdom.Text)

Aggregations

PathMacrosImpl (com.intellij.application.options.PathMacrosImpl)3 Element (org.jdom.Element)3 PathMacroFilter (com.intellij.openapi.application.PathMacroFilter)2 Attribute (org.jdom.Attribute)2 Text (org.jdom.Text)1