當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript kernel.Reporter類代碼示例

本文整理匯總了TypeScript中@aurelia/kernel.Reporter的典型用法代碼示例。如果您正苦於以下問題:TypeScript Reporter類的具體用法?TypeScript Reporter怎麽用?TypeScript Reporter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Reporter類的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: createProperty

 public createProperty(obj: IObservable, propertyName: string): DirtyCheckProperty {
   if (DirtyCheckSettings.throw) {
     throw Reporter.error(800); // TODO: create/organize error code
   }
   if (DirtyCheckSettings.warn) {
     Reporter.write(801);
   }
   return new DirtyCheckProperty(this, obj, propertyName);
 }
開發者ID:aurelia,項目名稱:aurelia,代碼行數:9,代碼來源:dirty-checker.ts

示例3: validatePrototype

function validatePrototype(handler: IAttributePatternHandler, patternDefs: AttributePatternDefinition[]): void {
  for (const def of patternDefs) {
    // note: we're intentionally not throwing here
    if (!(def.pattern in handler)) {
      Reporter.write(401, def); // TODO: organize error codes
    } else if (typeof handler[def.pattern] !== 'function') {
      Reporter.write(402, def); // TODO: organize error codes
    }
  }
}
開發者ID:aurelia,項目名稱:aurelia,代碼行數:10,代碼來源:attribute-pattern.ts

示例4: 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

示例5: 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

示例6: detaching

 public detaching(flags: LifecycleFlags): void {
   Reporter.write(10000, 'DETACHING viewport', this.name);
   if (this.content.component) {
     this.content.removeComponent(this.element, this.options.stateful);
   }
   this.enabled = false;
 }
開發者ID:aurelia,項目名稱:aurelia,代碼行數:7,代碼來源:viewport.ts

示例7: attaching

 public attaching(flags: LifecycleFlags): void {
   Reporter.write(10000, 'ATTACHING viewport', this.name, this.content, this.nextContent);
   this.enabled = true;
   if (this.content.component) {
     this.content.addComponent(this.element);
   }
 }
開發者ID:aurelia,項目名稱:aurelia,代碼行數:7,代碼來源:viewport.ts

示例8: 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

示例9: 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

示例10: 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


注:本文中的@aurelia/kernel.Reporter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。