protected TryStatementImpl(LexicalInfo lexicalInfo, Block successBlock, Block ensureBlock) : base(lexicalInfo) { ProtectedBlock = new Block(); _exceptionHandlers = new ExceptionHandlerCollection(this); SuccessBlock = successBlock; EnsureBlock = ensureBlock; }
public MessageCollection CheckMethod(MethodDefinition methodDefinition, Runner runner) { MessageCollection messageCollection = new MessageCollection(); if (methodDefinition.HasBody) { ExceptionHandlerCollection exceptionHandlerCollection = methodDefinition.Body.ExceptionHandlers; foreach (ExceptionHandler exceptionHandler in exceptionHandlerCollection) { if (exceptionHandler.Type == ExceptionHandlerType.Catch) { string catchTypeName = exceptionHandler.CatchType.FullName; if (IsForbiddenTypeInCatches(catchTypeName)) { if (!ThrowsGeneralException(exceptionHandler)) { Location location = new Location(methodDefinition.Name, methodDefinition.Name, exceptionHandler.HandlerStart.Offset); Message message = new Message("Do not swallow errors catching nonspecific exceptions.", location, MessageType.Error); messageCollection.Add(message); } } } } } if (messageCollection.Count == 0) { return(null); } return(messageCollection); }
protected TryStatementImpl(Block successBlock, Block ensureBlock) { ProtectedBlock = new Block(); _exceptionHandlers = new ExceptionHandlerCollection(this); SuccessBlock = successBlock; EnsureBlock = ensureBlock; }
void CheckExceptionHandlers(ExceptionHandlerCollection handlers) { for (int i = 1; i < handlers.Count; ++i) { ExceptionHandler handler = handlers[i]; for (int j = i - 1; j >= 0; --j) { ExceptionHandler previous = handlers[j]; IType handlerType = handler.Declaration.Type.Entity as IType; IType previousType = previous.Declaration.Type.Entity as IType; if (null == handlerType || null == previousType) { continue; } if ((handlerType == previousType && null == previous.FilterCondition) || handlerType.IsSubclassOf(previousType)) { Error(CompilerErrorFactory.ExceptionAlreadyHandled( handler, previous)); break; } } } }
public void VisitExceptionHandlerCollection(ExceptionHandlerCollection seh) { foreach (ExceptionHandler eh in seh) { eh.Accept(this); } }
public override void VisitExceptionHandlerCollection(ExceptionHandlerCollection seh) { for (int i = 0; i < seh.Count; i++) { VisitExceptionHandler(seh[i]); } }
void MarkBlockStarts(ExceptionHandlerCollection handlers) { for (int i = 0; i < handlers.Count; i++) { var handler = handlers [i]; MarkBlockStart(handler.TryStart); MarkBlockStart(handler.HandlerStart); if (handler.Type == ExceptionHandlerType.Filter) { MarkExceptionObjectPosition(handler.FilterStart); MarkBlockStart(handler.FilterStart); } else if (handler.Type == ExceptionHandlerType.Catch) { MarkExceptionObjectPosition(handler.HandlerStart); } } }
protected PlSqlBlockStatement(SerializationInfo info, StreamingContext context) : base(info, context) { Declarations = new DeclarationCollection(); ExceptionHandlers = new ExceptionHandlerCollection(); var decls = (SqlStatement[])info.GetValue("Declarations", typeof(SqlStatement[])); foreach (var statement in decls) { Declarations.Add(statement); } var handlers = (ExceptionHandler[])info.GetValue("ExceptionHandlers", typeof(ExceptionHandler[])); foreach (var handler in handlers) { ExceptionHandlers.Add(handler); } }
private void MarkExceptionHandlers(ExceptionHandlerCollection exceptionHandlers) { foreach (ExceptionHandler exceptionHandler in exceptionHandlers) { AddActionAfter(exceptionHandler.TryStart, delegate { generator.BeginExceptionBlock(); }); if (exceptionHandler.Type == ExceptionHandlerType.Filter) { AddActionAfter(exceptionHandler.FilterStart, delegate { generator.BeginExceptFilterBlock(); }); } AddActionAfter(exceptionHandler.HandlerStart, delegate { switch (exceptionHandler.Type) { case ExceptionHandlerType.Catch: generator.BeginCatchBlock(outer.ResolveType(exceptionHandler.CatchType)); break; case ExceptionHandlerType.Fault: generator.BeginFaultBlock(); break; case ExceptionHandlerType.Finally: generator.BeginFinallyBlock(); break; } }); AddActionBefore(exceptionHandler.HandlerEnd, delegate { generator.EndExceptionBlock(); }); } }
public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n, Func <ExceptionHandler, ExceptionHandler, bool> checkitem) { return(Compare <ExceptionHandler>(source, n, checkitem)); }
protected TryStatementImpl() { ProtectedBlock = new Block(); _exceptionHandlers = new ExceptionHandlerCollection(this); }
public virtual IExceptionHandlerCollection TransformExceptionHandlerCollection(IExceptionHandlerCollection value) { IExceptionHandler[] array = new IExceptionHandler[value.Count]; for (int i = 0; i < value.Count; i++) { array[i] = this.TransformExceptionHandler(value[i]); } IExceptionHandlerCollection target = new ExceptionHandlerCollection(); target.AddRange(array); return target; }
protected TryStatementImpl(LexicalInfo lexicalInfo) : base(lexicalInfo) { ProtectedBlock = new Block(); _exceptionHandlers = new ExceptionHandlerCollection(this); }
public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n, Func<ExceptionHandler, ExceptionHandler, Action<string, string>, bool> checkitem, Action<string, string> errAct) { return Compare<ExceptionHandler>(source,n,checkitem,errAct); }
public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n, Func<ExceptionHandler, ExceptionHandler, bool> checkitem) { return Compare<ExceptionHandler>(source,n,checkitem); }
public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n) { return(Compare <ExceptionHandler>(source, n)); }
public virtual void VisitExceptionHandlerCollection(ExceptionHandlerCollection seh) { }
public virtual void VisitExceptionHandlerCollection (ExceptionHandlerCollection seh) { }
public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n, Func <ExceptionHandler, ExceptionHandler, Action <string, string>, bool> checkitem, Action <string, string> errAct) { return(Compare <ExceptionHandler>(source, n, checkitem, errAct)); }
public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n) { return Compare<ExceptionHandler>(source,n); }
public PlSqlBlockStatement() { Declarations = new DeclarationCollection(); ExceptionHandlers = new ExceptionHandlerCollection(); }