public static void EnumConditions(ConditionSet cs,IStatement stmt, IBlockNode block, ResolutionContext ctxt, CodeLocation caret) { var l = new MutableConditionFlagSet(); cs.LocalFlags = l; // If the current scope is a dedicated block.. (so NOT in a method but probably in an initializer or other static statement) if(block is DBlockNode) { // If so, get all (scoping) declaration conditions in the current block // and add them to the condition list var mblocks = ((DBlockNode)block).GetMetaBlockStack(caret, false, true); if(mblocks!=null && mblocks.Length!=0) foreach(var mb in mblocks) { var amd = mb as AttributeMetaDeclaration; if(amd!=null && amd.AttributeOrCondition!=null && amd.AttributeOrCondition.Length!=0) foreach(var attr in amd.AttributeOrCondition) if(attr is DeclarationCondition) l.Add((DeclarationCondition)attr); } } // Scan up the current statement when e.g. inside a method body while (stmt != null) { if (stmt is StatementCondition) l.Add(((StatementCondition)stmt).Condition); stmt = stmt.Parent; } // Go up the block hierarchy and add all conditions that belong to the respective nodes while (block != null) { var dn = block as DNode; if (dn!=null) { if(dn is DBlockNode) GetDoneVersionDebugSpecs(cs, l, dn as DBlockNode, ctxt); if(dn.Attributes!=null) foreach (var attr in dn.Attributes) if (attr is DeclarationCondition) l.Add(((DeclarationCondition)attr)); } block = block.Parent as IBlockNode; } }
static void GetDoneVersionDebugSpecs(ConditionSet cs, MutableConditionFlagSet l, DBlockNode m, ResolutionContext ctxt) { if (m.StaticStatements == null || m.StaticStatements.Count == 0) { return; } foreach (var ss in m.StaticStatements) { if (ss is VersionSpecification) { var vs = (VersionSpecification)ss; if (!_checkForMatchinSpecConditions(m, cs, ss, ctxt)) { continue; } if (vs.SpecifiedId == null) { l.AddVersionCondition(vs.SpecifiedNumber); } else { l.AddVersionCondition(vs.SpecifiedId); } } else if (ss is DebugSpecification) { var ds = (DebugSpecification)ss; if (!_checkForMatchinSpecConditions(m, cs, ss, ctxt)) { continue; } if (ds.SpecifiedId == null) { l.AddDebugCondition(ds.SpecifiedDebugLevel); } else { l.AddDebugCondition(ds.SpecifiedId); } } } }
public static void EnumConditions(ConditionSet cs, IStatement stmt, IBlockNode block, ResolutionContext ctxt, CodeLocation caret) { var l = new MutableConditionFlagSet(); cs.LocalFlags = l; // If the current scope is a dedicated block.. (so NOT in a method but probably in an initializer or other static statement) if (block is DBlockNode) { // If so, get all (scoping) declaration conditions in the current block // and add them to the condition list var mblocks = ((DBlockNode)block).GetMetaBlockStack(caret, false, true); if (mblocks != null && mblocks.Length != 0) { foreach (var mb in mblocks) { var amd = mb as AttributeMetaDeclaration; if (amd != null && amd.AttributeOrCondition != null && amd.AttributeOrCondition.Length != 0) { foreach (var attr in amd.AttributeOrCondition) { if (attr is DeclarationCondition) { l.Add((DeclarationCondition)attr); } } } } } } // Scan up the current statement when e.g. inside a method body while (stmt != null) { if (stmt is StatementCondition) { l.Add(((StatementCondition)stmt).Condition); } stmt = stmt.Parent; } // Go up the block hierarchy and add all conditions that belong to the respective nodes while (block != null) { var dn = block as DNode; if (dn != null) { if (dn is DBlockNode) { GetDoneVersionDebugSpecs(cs, l, dn as DBlockNode, ctxt); } if (dn.Attributes != null) { foreach (var attr in dn.Attributes) { if (attr is DeclarationCondition) { l.Add(((DeclarationCondition)attr)); } } } } block = block.Parent as IBlockNode; } }
static void GetDoneVersionDebugSpecs(ConditionSet cs, MutableConditionFlagSet l, DBlockNode m, ResolutionContext ctxt) { if (m.StaticStatements == null || m.StaticStatements.Count == 0) return; foreach(var ss in m.StaticStatements) { if(ss is VersionSpecification) { var vs = (VersionSpecification)ss; if(!_checkForMatchinSpecConditions(m,cs,ss,ctxt)) continue; if(vs.SpecifiedId==null) l.AddVersionCondition(vs.SpecifiedNumber); else l.AddVersionCondition(vs.SpecifiedId); } else if(ss is DebugSpecification) { var ds = (DebugSpecification)ss; if(!_checkForMatchinSpecConditions(m,cs,ss, ctxt)) continue; if (ds.SpecifiedId == null) l.AddDebugCondition(ds.SpecifiedDebugLevel); else l.AddDebugCondition(ds.SpecifiedId); } } }