mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-191229 reduce calls to PathMacrosImpl.getInstanceEx - no need if no used macros
GitOrigin-RevId: 4a9a1e9f54f7c73f4fc12666e13b1428fc5e3ea5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b21dd94e70
commit
ecbeefdbbe
@@ -34,7 +34,7 @@ public class PathMacrosCollectorTest extends UsefulTestCase {
|
||||
root.addContent(new Text("$Revision 1.23$"));
|
||||
root.addContent(new Text("file://$root$/some/path/just$file$name.txt"));
|
||||
|
||||
final Set<String> macros = PathMacrosCollector.Companion.getMacroNames(root, null, new PathMacrosImpl(false));
|
||||
final Set<String> macros = PathMacrosCollector.Companion.getMacroNames(root, null, () -> new PathMacrosImpl(false));
|
||||
UsefulTestCase.assertSameElements(macros, "MACro1", "macro4", "mac_ro6", "macr.o7", "mac-ro8", "root");
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class PathMacrosCollectorTest extends UsefulTestCase {
|
||||
public boolean recursePathMacros(@NotNull Attribute attribute) {
|
||||
return "value".equals(attribute.getName());
|
||||
}
|
||||
}, new PathMacrosImpl(false));
|
||||
}, () -> new PathMacrosImpl(false));
|
||||
UsefulTestCase.assertSameElements(macros, "macro5", "MACRO", "root");
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class PathMacrosCollectorTest extends UsefulTestCase {
|
||||
testTag.setAttribute("ignore", "$PATH$");
|
||||
root.addContent(testTag);
|
||||
|
||||
final Set<String> macros = PathMacrosCollector.Companion.getMacroNames(root, null, new PathMacrosImpl(false));
|
||||
final Set<String> macros = PathMacrosCollector.Companion.getMacroNames(root, null, () -> new PathMacrosImpl(false));
|
||||
assertEquals(2, macros.size());
|
||||
assertTrue(macros.contains("MACRO"));
|
||||
assertTrue(macros.contains("PATH"));
|
||||
@@ -71,7 +71,7 @@ public class PathMacrosCollectorTest extends UsefulTestCase {
|
||||
public boolean skipPathMacros(@NotNull Attribute attribute) {
|
||||
return "ignore".equals(attribute.getName());
|
||||
}
|
||||
}, new PathMacrosImpl(false));
|
||||
}, () -> new PathMacrosImpl(false));
|
||||
|
||||
assertEquals(1, filtered.size());
|
||||
assertTrue(macros.contains("MACRO"));
|
||||
|
||||
+7
-6
@@ -25,15 +25,15 @@ class PathMacrosCollector private constructor() : PathMacroMap() {
|
||||
val MACRO_PATTERN: Pattern = Pattern.compile("\\$([\\w\\-.]+?)\\$")
|
||||
|
||||
fun getMacroNames(element: Element): Set<String> {
|
||||
return getMacroNames(
|
||||
root = element,
|
||||
filter = CompositePathMacroFilter(MACRO_FILTER_EXTENSION_POINT_NAME.extensionList),
|
||||
pathMacros = PathMacrosImpl.getInstanceEx(),
|
||||
)
|
||||
return getMacroNames(root = element, filter = CompositePathMacroFilter(MACRO_FILTER_EXTENSION_POINT_NAME.extensionList))
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun getMacroNames(root: Element, filter: PathMacroFilter?, pathMacros: PathMacrosImpl): Set<String> {
|
||||
fun getMacroNames(
|
||||
root: Element,
|
||||
filter: PathMacroFilter?,
|
||||
pathMacrosGetter: () -> PathMacrosImpl = { PathMacrosImpl.getInstanceEx() },
|
||||
): Set<String> {
|
||||
val collector = PathMacrosCollector()
|
||||
collector.substitute(root, true, false, filter)
|
||||
val preResult = collector.macroMap.keys
|
||||
@@ -41,6 +41,7 @@ class PathMacrosCollector private constructor() : PathMacroMap() {
|
||||
return emptySet()
|
||||
}
|
||||
|
||||
val pathMacros = pathMacrosGetter()
|
||||
val result = HashSet<String>(preResult)
|
||||
result.removeAll(pathMacros.getSystemMacroNames())
|
||||
@Suppress("ConvertArgumentToSet")
|
||||
|
||||
+4
-2
@@ -4,7 +4,6 @@
|
||||
package com.intellij.openapi.components.impl.stores
|
||||
|
||||
import com.intellij.application.options.PathMacrosCollector
|
||||
import com.intellij.application.options.PathMacrosImpl
|
||||
import com.intellij.openapi.components.CompositePathMacroFilter
|
||||
import com.intellij.openapi.components.PathMacroSubstitutor
|
||||
import com.intellij.openapi.components.TrackingPathMacroSubstitutor
|
||||
@@ -55,7 +54,10 @@ object ComponentStorageUtil {
|
||||
if (filter == null) {
|
||||
filter = CompositePathMacroFilter(PathMacrosCollector.MACRO_FILTER_EXTENSION_POINT_NAME.extensionList)
|
||||
}
|
||||
pathMacroSubstitutor.addUnknownMacros(name, PathMacrosCollector.getMacroNames(element, filter, PathMacrosImpl.getInstanceEx()))
|
||||
pathMacroSubstitutor.addUnknownMacros(
|
||||
componentName = name,
|
||||
unknownMacros = PathMacrosCollector.getMacroNames(root = element, filter = filter),
|
||||
)
|
||||
}
|
||||
|
||||
// remove only after "getMacroNames" - some PathMacroFilter requires an element name attribute
|
||||
|
||||
Reference in New Issue
Block a user