How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • async function discoverAllFilesInWorkspace() {
      if (!vscode.workspace.workspaceFolders) {
        return []; // handle the case of no open folders
      }
    
      return Promise.all(
        vscode.workspace.workspaceFolders.map(async workspaceFolder => {
          const pattern = new vscode.RelativePattern(workspaceFolder, '**/*.md');
          const watcher = vscode.workspace.createFileSystemWatcher(pattern);
    
          // When files are created, make sure there's a corresponding "file" node in the tree
          watcher.onDidCreate(uri => getOrCreateFile(uri));
          // When files change, re-parse them. Note that you could optimize this so
          // that you only re-parse children that have been resolved in the past.
          watcher.onDidChange(uri => parseTestsInFileContents(getOrCreateFile(uri)));
          // And, finally, delete TestItems for removed files. This is simple, since
          // we use the URI as the TestItem's ID.
          watcher.onDidDelete(uri => controller.items.delete(uri.toString()));
    
          for (const file of await vscode.workspace.findFiles(pattern)) {
            getOrCreateFile(file);
          }
    
          return watcher;
        })
      );
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">discoverAllFilesInWorkspace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Promise</span><span class="token operator">&lt;</span>vscode<span class="token punctuation">.</span>FileSystemWatcher<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token operator">></span></code></pre>
    Docs
    0
  • // The code below shows an example of how to instantiate this type.
    // The values are placeholders you should change.
    import * as workspaces from '@aws-cdk/aws-workspaces';
    
    const cfnWorkspace = new workspaces.CfnWorkspace(this, 'MyCfnWorkspace', {
      bundleId: 'bundleId',
      directoryId: 'directoryId',
      userName: 'userName',
    
      // the properties below are optional
      rootVolumeEncryptionEnabled: false,
      tags: [{
        key: 'key',
        value: 'value',
      }],
      userVolumeEncryptionEnabled: false,
      volumeEncryptionKey: 'volumeEncryptionKey',
      workspaceProperties: {
        computeTypeName: 'computeTypeName',
        rootVolumeSizeGib: 123,
        runningMode: 'runningMode',
        runningModeAutoStopTimeoutInMinutes: 123,
        userVolumeSizeGib: 123,
      },
    });
    
    Docs
    0
  • const writeData = Buffer.from('my text data', 'utf8');
    vscode.workspace.fs.writeFile(fileUri, writeData);
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> writeData<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • async function discoverAllFilesInWorkspace() {
      if (!vscode.workspace.workspaceFolders) {
        return []; // handle the case of no open folders
      }
    
      return Promise.all(
        vscode.workspace.workspaceFolders.map(async workspaceFolder => {
          const pattern = new vscode.RelativePattern(workspaceFolder, '**/*.md');
          const watcher = vscode.workspace.createFileSystemWatcher(pattern);
    
          // When files are created, make sure there's a corresponding "file" node in the tree
          watcher.onDidCreate(uri => getOrCreateFile(uri));
          // When files change, re-parse them. Note that you could optimize this so
          // that you only re-parse children that have been resolved in the past.
          watcher.onDidChange(uri => parseTestsInFileContents(getOrCreateFile(uri)));
          // And, finally, delete TestItems for removed files. This is simple, since
          // we use the URI as the TestItem's ID.
          watcher.onDidDelete(uri => controller.items.delete(uri.toString()));
    
          for (const file of await vscode.workspace.findFiles(pattern)) {
            getOrCreateFile(file);
          }
    
          return watcher;
        })
      );
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">discoverAllFilesInWorkspace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Promise</span><span class="token operator">&lt;</span>vscode<span class="token punctuation">.</span>FileSystemWatcher<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token operator">></span></code></pre>
    Docs
    0
  • // First, create the `resolveHandler`. This may initially be called with
    // "undefined" to ask for all tests in the workspace to be discovered, usually
    // when the user opens the Test Explorer for the first time.
    controller.resolveHandler = async test => {
      if (!test) {
        await discoverAllFilesInWorkspace();
      } else {
        await parseTestsInFileContents(test);
      }
    };
    
    // When text documents are open, parse tests in them.
    vscode.workspace.onDidOpenTextDocument(parseTestsInDocument);
    // We could also listen to document changes to re-parse unsaved changes:
    vscode.workspace.onDidChangeTextDocument(e => parseTestsInDocument(e.document));
    
    // In this function, we'll get the file TestItem if we've already found it,
    // otherwise we'll create it with `canResolveChildren = true` to indicate it
    // can be passed to the `controller.resolveHandler` to gets its children.
    function getOrCreateFile(uri: vscode.Uri) {
      const existing = controller.items.get(uri.toString());
      if (existing) {
        return existing;
      }
    
      const file = controller.createTestItem(uri.toString(), uri.path.split('/').pop()!, uri);
      file.canResolveChildren = true;
      return file;
    }
    
    function parseTestsInDocument(e: vscode.TextDocument) {
      if (e.uri.scheme === 'file' && e.uri.path.endsWith('.md')) {
        parseTestsInFileContents(getOrCreateFile(e.uri), e.getText());
      }
    }
    
    async function parseTestsInFileContents(file: vscode.TestItem, contents?: string) {
      // If a document is open, VS Code already knows its contents. If this is being
      // called from the resolveHandler when a document isn't open, we'll need to
      // read them from disk ourselves.
      if (contents === undefined) {
        const rawContent = await vscode.workspace.fs.readFile(file.uri);
        contents = new TextDecoder().decode(rawContent);
      }
    
      // some custom logic to fill in test.children from the contents...
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">module</span> controller <span class="token keyword">const</span> controller<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples