Theia API Documentation v1.65.0
    Preparing search index...
    • Compute the match between a document selector and a document. Values greater than zero mean the selector matches the document.

      A match is computed according to these rules:

      1. When DocumentSelector is an array, compute the match for each contained DocumentFilter or language identifier and take the maximum value.
      2. A string will be desugared to become the language-part of a DocumentFilter, so "fooLang" is like { language: "fooLang" }.
      3. A DocumentFilter will be matched against the document by comparing its parts with the document. The following rules apply:
      4. When the DocumentFilter is empty ({}) the result is 0
      5. When scheme, language, or pattern are defined but one doesn’t match, the result is 0
      6. Matching against * gives a score of 5, matching via equality or via a glob-pattern gives a score of 10
      7. The result is the maximum value of each match

      Samples:

      // default document from disk (file-scheme)
      doc.uri; //'file:///my/file.js'
      doc.languageId; // 'javascript'
      match('javascript', doc); // 10;
      match({language: 'javascript'}, doc); // 10;
      match({language: 'javascript', scheme: 'file'}, doc); // 10;
      match('*', doc); // 5
      match('fooLang', doc); // 0
      match(['fooLang', '*'], doc); // 5

      // virtual document, e.g. from git-index
      doc.uri; // 'git:/my/file.js'
      doc.languageId; // 'javascript'
      match('javascript', doc); // 10;
      match({language: 'javascript', scheme: 'git'}, doc); // 10;
      match('*', doc); // 5

      Parameters

      Returns number

      A number >0 when the selector matches and 0 when the selector does not match.