push method

ScopeStack push(
  1. String? scopePath
)

Pushes scopePath. Space-separated paths push one scope per segment, as in vscode-textmate. A null or empty path returns this stack.

Implementation

ScopeStack push(String? scopePath) {
  if (scopePath == null || scopePath.isEmpty) return this;
  if (!scopePath.contains(' ')) return ScopeStack._(this, scopePath);
  var result = this;
  for (final segment in scopePath.split(' ')) {
    if (segment.isNotEmpty) result = ScopeStack._(result, segment);
  }
  return result;
}