Class HeadLimitRules
java.lang.Object
org.eclipse.lemminx.extensions.index.HeadLimitRules
Compiled form of the
xml.workspaceIndex.headLimits setting.
Keys in the raw settings map are glob patterns (e.g. "**/*.xsd",
"**/vendor/**"). This class compiles them once into an ordered list
of HeadLimitRules.Rules and resolves the limit for a given file path efficiently.
Matching rule: rules are sorted by pattern length descending; the longest (most-specific) pattern wins. The first matching rule is returned.
Rule types and fast paths:
- Match-all (
"*","**","**/*") - always matches, O(1)."*"is accepted as a user-friendly alias for "any file" even though bare*does not cross path separators in strict glob semantics. - Extension-only (
"*.ext"or"**/*.ext") - matched via a string comparison on the file extension, O(1), noPathMatcherneeded. - Path-based (everything else, e.g.
"**/vendor/**") - usesPathMatcher.matches(Path)on the absolute path, computed lazily only when the rule is first reached. When the pattern ends with*.ext, an O(1) extension pre-filter skips thePathMatchercall for files whose extension does not match.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HeadLimitRulesSentinel used when noheadLimitsare configured — no limit for any file. -
Method Summary
Modifier and TypeMethodDescriptionstatic HeadLimitRulesCompiles a raw glob-pattern→size-string map into aHeadLimitRulesinstance.intReturns the head-read limit (in chars) forpath.
-
Field Details
-
NONE
Sentinel used when noheadLimitsare configured — no limit for any file.
-
-
Method Details
-
compile
Compiles a raw glob-pattern→size-string map into aHeadLimitRulesinstance.- Parameters:
raw- map from glob pattern to size string;nullor empty →NONE.- Returns:
- compiled rules, ready for repeated
getLimit(Path)calls.
-
getLimit
Returns the head-read limit (in chars) forpath. ReturnsInteger.MAX_VALUEwhen no rule matches (no limit — read the whole file).- Parameters:
path- the file being indexed; may be relative or absolute.- Returns:
- character limit, or
Integer.MAX_VALUEfor no limit.
-