/// <summary> /// Returns an array consisting of meta declarations orderd from outer to inner-most, depending on the 'Where' parameter. /// </summary> public List <IMetaDeclaration> GetMetaBlockStack(CodeLocation Where, bool takeBlockStartLocations = false, bool mindAttributeSections = false) { var l = new List <IMetaDeclaration>(); IMetaDeclaration lastSr = null; foreach (var mb in MetaBlocks) { if (mb is AttributeMetaDeclarationSection) { if (mindAttributeSections && Where >= mb.EndLocation) { // Don't let multiple section attributes like 'private:' nest within each other if (lastSr is AttributeMetaDeclarationSection) { l.Remove(lastSr); } l.Add(lastSr = mb); } continue; } if (lastSr != null && !(mindAttributeSections && lastSr is AttributeMetaDeclarationSection) && mb.Location < lastSr.Location && mb.EndLocation > lastSr.EndLocation) { continue; } // Check if 1) block is inside last inner-most meta block if (((takeBlockStartLocations && mb is IMetaDeclarationBlock) ? ((IMetaDeclarationBlock)mb).BlockStartLocation : mb.Location) <= Where && mb.EndLocation >= Where) { // and 2) if Where is completely inside the currently handled block. l.Add(lastSr = mb); } } return(l); }
public ISyntaxRegion GetNextMetaBlockOrStatStmt(CodeLocation until) { if (nextStatStmt == null && StaticStatementEnum != null) { if (StaticStatementEnum.MoveNext ()) nextStatStmt = StaticStatementEnum.Current; else StaticStatementEnum = null; } if (nextMetaDecl == null && MetaBlockEnum != null) { if (MetaBlockEnum.MoveNext ()) nextMetaDecl = MetaBlockEnum.Current; else MetaBlockEnum = null; } ISyntaxRegion sr; if (nextStatStmt != null) { if (nextMetaDecl == null) sr = nextStatStmt; else sr = nextStatStmt.First (nextMetaDecl); } else if (nextMetaDecl != null) sr = nextMetaDecl; else return null; return sr.Location < until ? sr : null; }
public ISyntaxRegion GetNextMetaBlockOrStatStmt(CodeLocation until) { if (nextStatStmt == null && StaticStatementEnum != null) { if (StaticStatementEnum.MoveNext()) { nextStatStmt = StaticStatementEnum.Current; } else { StaticStatementEnum = null; } } if (nextMetaDecl == null && MetaBlockEnum != null) { if (MetaBlockEnum.MoveNext()) { nextMetaDecl = MetaBlockEnum.Current; } else { MetaBlockEnum = null; } } ISyntaxRegion sr; if (nextStatStmt != null) { if (nextMetaDecl == null) { sr = nextStatStmt; } else { sr = nextStatStmt.First(nextMetaDecl); } } else if (nextMetaDecl != null) { sr = nextMetaDecl; } else { return(null); } return(sr.Location < until ? sr : null); }
public ConditionsFrame(IEnumerable<StaticStatement> ssEnum, IEnumerable<IMetaDeclaration> metaBlocks) { this.StaticStatementEnum = (IEnumerator<StaticStatement>)ssEnum.GetEnumerator(); this.MetaBlockEnum = (IEnumerator<IMetaDeclaration>)metaBlocks.GetEnumerator(); // opt-in: Initially check whether there are any static statements or meta decls available if(StaticStatementEnum.MoveNext()) nextStatStmt = StaticStatementEnum.Current; else StaticStatementEnum = null; if(MetaBlockEnum.MoveNext()) nextMetaDecl = MetaBlockEnum.Current; else MetaBlockEnum = null; }
public ConditionsFrame(IEnumerable <StaticStatement> ssEnum, IEnumerable <IMetaDeclaration> metaBlocks) { this.StaticStatementEnum = (IEnumerator <StaticStatement>)ssEnum.GetEnumerator(); this.MetaBlockEnum = (IEnumerator <IMetaDeclaration>)metaBlocks.GetEnumerator(); // opt-in: Initially check whether there are any static statements or meta decls available if (StaticStatementEnum.MoveNext()) { nextStatStmt = StaticStatementEnum.Current; } else { StaticStatementEnum = null; } if (MetaBlockEnum.MoveNext()) { nextMetaDecl = MetaBlockEnum.Current; } else { MetaBlockEnum = null; } }
public void Add(IMetaDeclaration MetaDecl) { MetaBlocks.Add(MetaDecl); }
void VisitMetaBlockChildren(List<INode> children, List<StaticStatement> staticStatements, IMetaDeclaration mb) { for(int k = 0; k < children.Count; k++) { var ch = children[k]; if(ch.Location > mb.Location) { if(ch.EndLocation < mb.EndLocation || mb is AttributeMetaDeclarationSection) { ch.Accept(this); children.RemoveAt(k--); } else break; } } for(int k = 0; k < staticStatements.Count; k++) { var ss = staticStatements[k]; if(ss.Location > mb.Location && (ss.EndLocation < mb.EndLocation || mb is AttributeMetaDeclarationSection)) { ss.Accept(this); staticStatements.RemoveAt(k--); } } }
void HandleMetaDecl(IMetaDeclaration md) { }
void VisitMetaBlockChildren(List <INode> children, List <StaticStatement> staticStatements, IMetaDeclaration mb) { for (int k = 0; k < children.Count; k++) { var ch = children[k]; if (ch.Location > mb.Location) { if (ch.EndLocation < mb.EndLocation || mb is AttributeMetaDeclarationSection) { ch.Accept(this); children.RemoveAt(k--); } else { break; } } } for (int k = 0; k < staticStatements.Count; k++) { var ss = staticStatements[k]; if (ss.Location > mb.Location && (ss.EndLocation < mb.EndLocation || mb is AttributeMetaDeclarationSection)) { ss.Accept(this); staticStatements.RemoveAt(k--); } } }