createDiagnosticCollection

Create a diagnostics collection that can be used to display wavy lines in the error area of the document to identify problems during document verification.

Parameters and Returns

Parameters
Name Type Description
name String TThe name of the collection, which will be displayed in tooltips when the mouse is moved over the wavy line
Returns
Type Description
DiagnosticCollection A new diagnostic collection.
Example
  1. let activeEditor = hx.window.getActiveTextEditor();
  2. activeEditor.then(function(editor) {
  3. // Get file path
  4. let file_url = editor.document.uri.fsPath;
  5. // The document object can be obtained for verification through editor.document
  6. // Create a test question collection
  7. let collections = [{
  8. column: 0,
  9. line: 3,
  10. message: "error for test",
  11. severity: 'error'
  12. }
  13. ];
  14. let diagnostics = hx.languages.createDiagnosticCollection('eslint');
  15. diagnostics.set(file_url, collections);
  16. });

DiagnosticCollection

A diagnostics collection is a container that manages a set of diagnostics. Diagnostics are always scopes to a diagnostics collection and a resource.

Attributes List

Name Type Description
name String The name of this diagnostic collectionn

set

Parameters
Name Type Description
uri String or Uri A resource identifier.
diagnostics Array<DiagnosticItem> Array of diagnostics or undefined
Returns
Type Description
Promise<void> Promise
Example
  1. let diagnositics = hx.languages.createDiagnosticCollection('eslint');
  2. diagnositics.set("foo.js",[
  3. {
  4. column: 0,
  5. line: 0,
  6. message: 'a error message.'
  7. }
  8. ]);

DiagnosticItem

Diagnostic Item

Attributes List
Name Type Description
line String lines of the document
column String column of the document
message String Question details
severity String Problem level, value range:’error’,’warn’. The default value is’error’