public override MatchContext Match(TypeDeclaration typeDeclaration, MatchContext context) { MatchContext newContext = Modifiers.MatchSubset(typeDeclaration.Modifiers, context); if (!newContext.Success) { return(newContext); } if (Name != null) { newContext = Name.MatchUst(typeDeclaration.Name, newContext); if (!newContext.Success) { return(newContext); } } newContext = BaseTypes.MatchSubset(typeDeclaration.BaseTypes, newContext); if (!newContext.Success) { return(newContext); } if (Body != null) { if (!typeDeclaration.TypeMembers.Any(m => Body.Match(m, newContext).Success)) { return(newContext.Fail()); } } return(newContext.AddUstIfSuccess(typeDeclaration)); }
protected override MatchContext Match(Ust ust, MatchContext context) { var typeDeclaration = ust as TypeDeclaration; if (typeDeclaration == null) { return(context.Fail()); } MatchContext newContext = Modifiers.MatchSubset(typeDeclaration.Modifiers, context); if (!newContext.Success) { return(newContext); } if (Name != null) { newContext = Name.MatchUst(typeDeclaration.Name, newContext); if (!newContext.Success) { return(newContext); } } newContext = BaseTypes.MatchSubset(typeDeclaration.BaseTypes, newContext); if (!newContext.Success) { return(newContext); } if (Body != null) { if (!typeDeclaration.TypeMembers.Any(m => Body.MatchUst(m, newContext).Success)) { return(newContext.Fail()); } } return(newContext.AddUstIfSuccess(typeDeclaration)); }