How to use the @tslab/typescript-for-tslab.isIdentifier function in @tslab/typescript-for-tslab

To help you get started, we’ve selected a few @tslab/typescript-for-tslab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yunabe / tslab / src / converter.ts View on Github external
const prev: ts.Node = ts.tslab.findPrecedingToken(pos, srcFile);
    // Note: In contradiction to the docstring, findPrecedingToken may return prev with
    // prev.end > pos (e.g. `members with surrounding` test case).
    //
    // Note: Be careful. node.pos != node.getStart().
    // (e.g. `globals with prefix` test case)
    if (prev && ts.isIdentifier(prev) && prev.end >= pos) {
      return completionWithId(info, prev, srcFile);
    }
    const next: ts.Node = prev
      ? ts.tslab.findNextToken(prev, srcFile, srcFile)
      : null;
    if (
      next &&
      ts.isIdentifier(next) &&
      next.getStart(srcFile) <= pos &&
      pos <= next.end
    ) {
      return completionWithId(info, next, srcFile);
    }
    let entries = info && info.entries ? info.entries.slice() : [];
    entries.sort((a, b) => {
      const ord = a.sortText.localeCompare(b.sortText);
      return ord !== 0 ? ord : a.name.localeCompare(b.name);
    });
    const candidates = entries.map(e => e.name);
    return {
      start: pos - srcPrefix.length,
      end: pos - srcPrefix.length,
      candidates,
      original: info
github yunabe / tslab / src / converter.ts View on Github external
() => {
        // ignore log messages
      },
      srcFile,
      pos,
      {},
      undefined
    );

    const prev: ts.Node = ts.tslab.findPrecedingToken(pos, srcFile);
    // Note: In contradiction to the docstring, findPrecedingToken may return prev with
    // prev.end > pos (e.g. `members with surrounding` test case).
    //
    // Note: Be careful. node.pos != node.getStart().
    // (e.g. `globals with prefix` test case)
    if (prev && ts.isIdentifier(prev) && prev.end >= pos) {
      return completionWithId(info, prev, srcFile);
    }
    const next: ts.Node = prev
      ? ts.tslab.findNextToken(prev, srcFile, srcFile)
      : null;
    if (
      next &&
      ts.isIdentifier(next) &&
      next.getStart(srcFile) <= pos &&
      pos <= next.end
    ) {
      return completionWithId(info, next, srcFile);
    }
    let entries = info && info.entries ? info.entries.slice() : [];
    entries.sort((a, b) => {
      const ord = a.sortText.localeCompare(b.sortText);
github yunabe / tslab / src / converter.ts View on Github external
stmt.declarationList.declarations.forEach(decl => {
          if (!ts.isIdentifier(decl.name)) {
            // This must not happen.
            return;
          }
          if (!names.has(decl.name.escapedText)) {
            return;
          }
          decls.push(decl);
        });
        stmt.declarationList.declarations = ts.createNodeArray(decls);