internal SetOfSyntaxItems CacheFinalSetMembership() { this.EnsureFinalMembershipWasNotCached(); List <string> clustersBeingResolved = new List <string>(4); this.m_cachedMemberItems = this.GetMemberItems(clustersBeingResolved); return(this.m_cachedMemberItems); }
internal SyntaxContext(SyntaxDefinition syntaxDefinition, string scopeName) { this.SyntaxDefinition = syntaxDefinition; this.AllItems = new List <SyntaxItem>(16); this.NonTopItems = new SetOfSyntaxItems(); this.TopItems = new SetOfSyntaxItems(); this.Name = scopeName; this.TopClusters = new List <Cluster>(2); }
private SetOfSyntaxItems GetMemberItems(List <string> clustersBeingResolved) { if (this.m_cachedMemberItems != null) { // sometimes we get called after final membership was calculated and cached. This happens when CacheFinalSetMembership() is // being called for each cluster, and some have already have had their final memberships calculated, but others haven't. // Sometimes a cluster gets called later on, and then calls GetMemberItems() for a cluster that already has final cached // information available. If that's the case, we just return it. return(this.m_cachedMemberItems); } if (this.IsNamedCluster) { clustersBeingResolved.Add(this.m_clusterName); } IEnumerable <SyntaxItem> items; switch (this.ClusterType) { case ClusterType.ALL: items = this.SyntaxContext.AllItems; break; case ClusterType.ALLBUT: items = Extensions.Except(this.SyntaxContext.AllItems, this.GetItemsInMySets(clustersBeingResolved)); break; case ClusterType.CONTAINED: items = Extensions.Except(this.SyntaxContext.NonTopItems.Items, this.GetItemsInMySets(clustersBeingResolved)); break; case ClusterType.NONE: items = new SyntaxItem[0]; break; case ClusterType.NONMAGIC: items = this.GetItemsInMySets(clustersBeingResolved); break; case ClusterType.TOP: items = Extensions.Except(this.SyntaxContext.TopItems.Items, this.GetItemsInMySets(clustersBeingResolved)); break; default: throw new AssertionViolationException(StringExtensions.Fi("Unknown ClusterType {0}", this.ClusterType)); } clustersBeingResolved.Remove(this.m_clusterName); SetOfSyntaxItems myItems = new SetOfSyntaxItems(items); myItems.AddRange(this.m_directItems.Items); return(myItems); }
internal Cluster(SyntaxContext context) { ArgumentValidator.ThrowIfNull(context, "scope"); this.m_containedGroupsAndClusters = new List <string>(); this.m_syntaxContext = context; this.m_ClusterType = ClusterType.NONMAGIC; this.m_directItems = new SetOfSyntaxItems(); this.m_syntaxDefinition = context.SyntaxDefinition; }
internal static Scope BuildBackgroundScope(SetOfSyntaxItems topItems) { Scope backgroundScope = new Scope(); backgroundScope.SyntaxItem = BackgroundItem.Instance; backgroundScope.ActiveSyntaxItems = topItems; backgroundScope.PosStart = 0; backgroundScope.PosAfter = int.MaxValue; backgroundScope.PosHighlightStart = 0; backgroundScope.PosAfterHighlight = int.MaxValue; return(backgroundScope); }
internal override void PrepareForRuntime() { base.PrepareForRuntime(); // at this point the items that were included by ContainedIn= clauses in other items are in this.m_containedItems. // We must add these items to the ones that come from our Contains= clause. The union of these two sets comprises // all of the items that are contained in this ContainerItem this.m_containedItems = this.Contains.CacheFinalSetMembership().AddRange(this.m_containedItems.Items); this.m_containedItems = SetOfSyntaxItems.PrepareForRuntime(this.m_containedItems, this.m_syntaxDefinition); if (this.m_containedItems.IsEmpty) { if (this.IsTransparent) { bool containsClusterIsEmpty = (0 == this.Contains.ContainedGroupsAndClusters.Count); this.m_inheritActiveItemsFromTopScope = (containsClusterIsEmpty && !this.Contains.IsNone); } this.m_containedItems = SetOfSyntaxItems.EmptySet; } }
private IEnumerable <SyntaxItem> GetItemsInMySets(List <string> clustersBeingResolved) { SetOfSyntaxItems items = new SetOfSyntaxItems(); foreach (string setName in this.ContainedGroupsAndClusters) { // let's prevent infinite recursion in case there's a circular relationship (eg, @Foo=@Bar,Comment and @Bar=@Foo,StorageClass) if (Extensions.ContainsSorted(clustersBeingResolved, setName)) { continue; } if (ClusterMarker == setName[0]) { items.AddRange(this.m_syntaxDefinition.GetCluster(setName, this.m_syntaxContext).GetMemberItems(clustersBeingResolved).Items); } else { items.AddRange(this.m_syntaxDefinition.GetGroup(setName).Items); } } return(items.Items); }
/// <summary> /// I will go up to the six-fingered man and say: "Hello, my name is Inigo Montoya. You killed my father. Prepare to die!" /// </summary> internal virtual void PrepareForRuntime() { this.m_nextGroupItems = this.m_nextGroupCluster.CacheFinalSetMembership(); this.m_nextGroupItems = SetOfSyntaxItems.PrepareForRuntime(this.m_nextGroupItems, this.m_syntaxDefinition); this.HasNextGroup = !this.NextGroupItems.IsEmpty; }
internal void PrepareForRuntime() { this.TopItems = SetOfSyntaxItems.PrepareForRuntime(this.TopItems, this.SyntaxDefinition); this.AllItems.ForEach(item => item.AddYourselfToGroupsYouAreContainedIn()); }