当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Reporter.error方法代码示例

本文整理汇总了TypeScript中@aurelia/kernel.Reporter.error方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Reporter.error方法的具体用法?TypeScript Reporter.error怎么用?TypeScript Reporter.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@aurelia/kernel.Reporter的用法示例。


在下文中一共展示了Reporter.error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: get

  public static get(scope: IScope, name: string, ancestor: number, flags: LifecycleFlags): IBindingContext | IOverrideContext | IBinding {
    if (Tracer.enabled) { Tracer.enter('BindingContext', 'get', slice.call(arguments)); }
    if (scope === undefined) {
      throw Reporter.error(RuntimeError.UndefinedScope);
    }
    if (scope === null) {
      throw Reporter.error(RuntimeError.NullScope);
    }
    let overrideContext = scope.overrideContext;

    if (ancestor > 0) {
      // jump up the required number of ancestor contexts (eg $parent.$parent requires two jumps)
      while (ancestor > 0) {
        if (overrideContext.parentOverrideContext === null) {
          if (Tracer.enabled) { Tracer.leave(); }
          return undefined;
        }
        ancestor--;
        overrideContext = overrideContext.parentOverrideContext;
      }

      if (Tracer.enabled) { Tracer.leave(); }
      return name in overrideContext ? overrideContext : overrideContext.bindingContext;
    }

    // traverse the context and it's ancestors, searching for a context that has the name.
    while (overrideContext && !(name in overrideContext) && !(overrideContext.bindingContext && name in overrideContext.bindingContext)) {
      overrideContext = overrideContext.parentOverrideContext;
    }

    if (overrideContext) {
      if (Tracer.enabled) { Tracer.leave(); }
      // we located a context with the property.  return it.
      return name in overrideContext ? overrideContext : overrideContext.bindingContext;
    }

    // the name wasn't found. see if parent scope traversal is allowed and if so, try that
    if ((flags & LifecycleFlags.allowParentScopeTraversal) && scope.parentScope !== null) {
      const result = this.get(scope.parentScope, name, ancestor, flags
        // unset the flag; only allow one level of scope boundary traversal
        & ~LifecycleFlags.allowParentScopeTraversal
        // tell the scope to return null if the name could not be found
        | LifecycleFlags.isTraversingParentScope);
      if (result !== null) {
        if (Tracer.enabled) { Tracer.leave(); }
        return result;
      }
    }

    // still nothing found. return the root binding context (or null
    // if this is a parent scope traversal, to ensure we fall back to the
    // correct level)
    if (flags & LifecycleFlags.isTraversingParentScope) {
      if (Tracer.enabled) { Tracer.leave(); }
      return null;
    }
    if (Tracer.enabled) { Tracer.leave(); }
    return scope.bindingContext || scope.overrideContext;
  }
开发者ID:aurelia,项目名称:aurelia,代码行数:59,代码来源:binding-context.ts

示例2: parseForOfStatement

function parseForOfStatement(state: ParserState, result: BindingIdentifierOrPattern): ForOfStatement {
  if ((result.$kind & ExpressionKind.IsForDeclaration) === 0) {
    throw Reporter.error(SyntaxError.InvalidForDeclaration, { state });
  }
  if (state.currentToken !== Token.OfKeyword) {
    throw Reporter.error(SyntaxError.InvalidForDeclaration, { state });
  }
  nextToken(state);
  const declaration = result;
  const statement = parse(state, Access.Reset, Precedence.Variadic, BindingType.None);
  return new ForOfStatement(declaration, statement as IsBindingBehavior);
}
开发者ID:aurelia,项目名称:aurelia,代码行数:12,代码来源:expression-parser.ts

示例3: scanString

function scanString(state: ParserState): Token {
  const quote = state.currentChar;
  nextChar(state); // Skip initial quote.

  let unescaped = 0;
  const buffer = new Array<string>();
  let marker = state.index;

  while (state.currentChar !== quote) {
    if (state.currentChar === Char.Backslash) {
      buffer.push(state.input.slice(marker, state.index));
      nextChar(state);
      unescaped = unescapeCode(state.currentChar);
      nextChar(state);
      buffer.push(String.fromCharCode(unescaped));
      marker = state.index;
    } else if (state.index >= state.length) {
      throw Reporter.error(SyntaxError.UnterminatedQuote, { state });
    } else {
      nextChar(state);
    }
  }

  const last = state.input.slice(marker, state.index);
  nextChar(state); // Skip terminating quote.

  // Compute the unescaped string value.
  buffer.push(last);
  const unescapedStr = buffer.join('');

  state.tokenValue = unescapedStr;
  return Token.StringLiteral;
}
开发者ID:aurelia,项目名称:aurelia,代码行数:33,代码来源:expression-parser.ts

示例4: scanTemplate

function scanTemplate(state: ParserState): Token {
  let tail = true;
  let result = '';

  while (nextChar(state) !== Char.Backtick) {
    if (state.currentChar === Char.Dollar) {
      if ((state.index + 1) < state.length && state.input.charCodeAt(state.index + 1) === Char.OpenBrace) {
        state.index++;
        tail = false;
        break;
      } else {
        result += '$';
      }
    } else if (state.currentChar === Char.Backslash) {
      result += String.fromCharCode(unescapeCode(nextChar(state)));
    } else {
      if (state.index >= state.length) {
        throw Reporter.error(SyntaxError.UnterminatedTemplate, { state });
      }
      result += String.fromCharCode(state.currentChar);
    }
  }

  nextChar(state);
  state.tokenValue = result;
  if (tail) {
    return Token.TemplateTail;
  }
  return Token.TemplateContinuation;
}
开发者ID:aurelia,项目名称:aurelia,代码行数:30,代码来源:expression-parser.ts

示例5: scanTemplateTail

function scanTemplateTail(state: ParserState): Token {
  if (state.index >= state.length) {
    throw Reporter.error(SyntaxError.UnterminatedTemplate, { state });
  }
  state.index--;
  return scanTemplate(state);
}
开发者ID:aurelia,项目名称:aurelia,代码行数:7,代码来源:expression-parser.ts

示例6: createComputedObserver

export function createComputedObserver(
  flags: LifecycleFlags,
  observerLocator: IObserverLocator,
  dirtyChecker: IDirtyChecker,
  lifecycle: ILifecycle,
  instance: IObservable & { constructor: IObservable & ComputedLookup },
  propertyName: string,
  descriptor: PropertyDescriptor): IBindingTargetObserver {

  if (descriptor.configurable === false) {
    return dirtyChecker.createProperty(instance, propertyName);
  }

  if (descriptor.get) {
    const overrides = instance.constructor.computed && instance.constructor.computed[propertyName] || computedOverrideDefaults;

    if (descriptor.set) {
      if (overrides.volatile) {
        return new GetterObserver(flags, overrides, instance, propertyName, descriptor, observerLocator, lifecycle);
      }
      return new CustomSetterObserver(instance, propertyName, descriptor);
    }
    return new GetterObserver(flags, overrides, instance, propertyName, descriptor, observerLocator, lifecycle);
  }
  throw Reporter.error(18, propertyName);
}
开发者ID:aurelia,项目名称:aurelia,代码行数:26,代码来源:computed-observer.ts

示例7: bind

  public bind(flags: LifecycleFlags, scope: IScope, binding: SelfableBinding): void {
    if (!binding.callSource || !binding.targetEvent) {
      throw Reporter.error(8);
    }

    binding.selfEventCallSource = binding.callSource;
    binding.callSource = handleSelfEvent;
  }
开发者ID:aurelia,项目名称:aurelia,代码行数:8,代码来源:self.ts

示例8: consume

function consume(state: ParserState, token: Token): void {
  // tslint:disable-next-line:possible-timing-attack
  if (state.currentToken === token) {
    nextToken(state);
  } else {
    throw Reporter.error(SyntaxError.MissingExpectedToken, { state, expected: token });
  }
}
开发者ID:aurelia,项目名称:aurelia,代码行数:8,代码来源:expression-parser.ts

示例9: fromOverride

 public static fromOverride(flags: LifecycleFlags, oc: IOverrideContext): Scope {
   if (Tracer.enabled) { Tracer.enter('Scope', 'fromOverride', slice.call(arguments)); }
   if (oc === null || oc === undefined) {
     throw Reporter.error(RuntimeError.NilOverrideContext);
   }
   if (Tracer.enabled) { Tracer.leave(); }
   return new Scope(oc.bindingContext, oc);
 }
开发者ID:aurelia,项目名称:aurelia,代码行数:8,代码来源:binding-context.ts

示例10: fromParent

 public static fromParent(flags: LifecycleFlags, ps: IScope | null, bc: IBindingContext | IBinding): Scope {
   if (Tracer.enabled) { Tracer.enter('Scope', 'fromParent', slice.call(arguments)); }
   if (ps === null || ps === undefined) {
     throw Reporter.error(RuntimeError.NilParentScope);
   }
   if (Tracer.enabled) { Tracer.leave(); }
   return new Scope(bc, OverrideContext.create(flags, bc, ps.overrideContext));
 }
开发者ID:aurelia,项目名称:aurelia,代码行数:8,代码来源:binding-context.ts


注:本文中的@aurelia/kernel.Reporter.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。