Repository: elm-tooling/elm-language-server
Pull request #365 (2020-11-11 11:46:04)

Rename ElmLsDiagnostic files


Patch:
diff --git a/src/providers/codeActionProvider.ts b/src/providers/codeActionProvider.ts
index 88a71bc..65e891b 100644
--- a/src/providers/codeActionProvider.ts
+++ b/src/providers/codeActionProvider.ts
@@ -1,5 +1,3 @@
-import { findType } from "../util/types/typeInference";
-import { TypeRenderer } from "../util/types/typeRenderer";
 import { container } from "tsyringe";
 import {
   ApplyWorkspaceEditResponse,
@@ -17,8 +15,10 @@ import { ElmWorkspaceMatcher } from "../util/elmWorkspaceMatcher";
 import { RefactorEditUtils } from "../util/refactorEditUtils";
 import { IClientSettings, Settings } from "../util/settings";
 import { TreeUtils } from "../util/treeUtils";
+import { findType } from "../util/types/typeInference";
+import { TypeRenderer } from "../util/types/typeRenderer";
 import { ElmAnalyseDiagnostics } from "./diagnostics/elmAnalyseDiagnostics";
-import { ElmDiagnostics } from "./diagnostics/elmDiagnostics";
+import { ElmLsDiagnostics } from "./diagnostics/elmLsDiagnostics";
 import { ElmMakeDiagnostics } from "./diagnostics/elmMakeDiagnostics";
 import { TypeInferenceDiagnostics } from "./diagnostics/typeInferenceDiagnostics";
 import { ExposeUnexposeHandler } from "./handlers/exposeUnexposeHandler";
@@ -30,7 +30,7 @@ export class CodeActionProvider {
   private elmAnalyse: ElmAnalyseDiagnostics | null = null;
   private elmMake: ElmMakeDiagnostics;
   private functionTypeAnnotationDiagnostics: TypeInferenceDiagnostics;
-  private elmDiagnostics: ElmDiagnostics;
+  private elmDiagnostics: ElmLsDiagnostics;
   private clientSettings: IClientSettings;
 
   constructor() {
@@ -45,7 +45,7 @@ export class CodeActionProvider {
     this.functionTypeAnnotationDiagnostics = container.resolve<
       TypeInferenceDiagnostics
     >(TypeInferenceDiagnostics);
-    this.elmDiagnostics = container.resolve<ElmDiagnostics>(ElmDiagnostics);
+    this.elmDiagnostics = container.resolve<ElmLsDiagnostics>(ElmLsDiagnostics);
     this.connection = container.resolve<IConnection>("Connection");
 
     this.onCodeAction = this.onCodeAction.bind(this);
diff --git a/src/providers/diagnostics/diagnosticsProvider.ts b/src/providers/diagnostics/diagnosticsProvider.ts
index b78ac70..befea7e 100644
--- a/src/providers/diagnostics/diagnosticsProvider.ts
+++ b/src/providers/diagnostics/diagnosticsProvider.ts
@@ -1,20 +1,20 @@
 import { IClientSettings, Settings } from "src/util/settings";
+import { debounce } from "ts-debounce";
 import { container, injectable } from "tsyringe";
 import { Diagnostic, FileChangeType, IConnection } from "vscode-languageserver";
 import { TextDocument } from "vscode-languageserver-textdocument";
 import { URI } from "vscode-uri";
 import { ElmAnalyseDiagnostics } from "..";
+import { IElmWorkspace } from "../../elmWorkspace";
 import { ElmWorkspaceMatcher } from "../../util/elmWorkspaceMatcher";
 import { NoWorkspaceContainsError } from "../../util/noWorkspaceContainsError";
 import { ElmAnalyseTrigger } from "../../util/settings";
 import { TextDocumentEvents } from "../../util/textDocumentEvents";
-import { ElmMakeDiagnostics } from "./elmMakeDiagnostics";
-import { TypeInferenceDiagnostics } from "./typeInferenceDiagnostics";
 import { ASTProvider } from "../astProvider";
-import { IElmWorkspace } from "../../elmWorkspace";
-import { debounce } from "ts-debounce";
+import { ElmLsDiagnostics } from "./elmLsDiagnostics";
+import { ElmMakeDiagnostics } from "./elmMakeDiagnostics";
 import { DiagnosticKind, FileDiagnostics } from "./fileDiagnostics";
-import { ElmDiagnostics } from "./elmDiagnostics";
+import { TypeInferenceDiagnostics } from "./typeInferenceDiagnostics";
 
 export interface IElmIssueRegion {
   start: { line: number; column: number };
@@ -36,7 +36,7 @@ export class DiagnosticsProvider {
   private elmMakeDiagnostics: ElmMakeDiagnostics;
   private elmAnalyseDiagnostics: ElmAnalyseDiagnostics | null = null;
   private typeInferenceDiagnostics: TypeInferenceDiagnostics;
-  private elmDiagnostics: ElmDiagnostics;
+  private elmDiagnostics: ElmLsDiagnostics;
   private elmWorkspaceMatcher: ElmWorkspaceMatcher<{ uri: string }>;
   private currentDiagnostics: Map<string, FileDiagnostics>;
   private events: TextDocumentEvents;
@@ -59,7 +59,7 @@ export class DiagnosticsProvider {
     this.typeInferenceDiagnostics = container.resolve<TypeInferenceDiagnostics>(
       TypeInferenceDiagnostics,
     );
-    this.elmDiagnostics = container.resolve<ElmDiagnostics>(ElmDiagnostics);
+    this.elmDiagnostics = container.resolve<ElmLsDiagnostics>(ElmLsDiagnostics);
     this.connection = container.resolve<IConnection>("Connection");
     this.events = container.resolve<TextDocumentEvents>(TextDocumentEvents);
     this.elmWorkspaceMatcher = new ElmWorkspaceMatcher((doc) =>
diff --git a/src/providers/diagnostics/elmDiagnostics.ts b/src/providers/diagnostics/elmLsDiagnostics.ts
similarity index 98%
rename from src/providers/diagnostics/elmDiagnostics.ts
rename to src/providers/diagnostics/elmLsDiagnostics.ts
index 970eb72..dcf69a4 100644
--- a/src/providers/diagnostics/elmDiagnostics.ts
+++ b/src/providers/diagnostics/elmLsDiagnostics.ts
@@ -1,4 +1,5 @@
 /* eslint-disable @typescript-eslint/no-unsafe-call */
+import { container } from "tsyringe";
 import {
   CodeAction,
   CodeActionKind,
@@ -9,18 +10,17 @@ import {
   Range,
   TextEdit,
 } from "vscode-languageserver";
+import { URI } from "vscode-uri";
 import { Language, Parser, SyntaxNode, Tree } from "web-tree-sitter";
+import { IElmWorkspace } from "../../elmWorkspace";
 import { PositionUtil } from "../../positionUtil";
-import { container } from "tsyringe";
-import { Utils } from "../../util/utils";
-import { RefactorEditUtils } from "../../util/refactorEditUtils";
 import { ElmWorkspaceMatcher } from "../../util/elmWorkspaceMatcher";
-import { URI } from "vscode-uri";
+import { RefactorEditUtils } from "../../util/refactorEditUtils";
 import { TreeUtils } from "../../util/treeUtils";
-import { IElmWorkspace } from "../../elmWorkspace";
 import { findType } from "../../util/types/typeInference";
+import { Utils } from "../../util/utils";
 
-export class ElmDiagnostics {
+export class ElmLsDiagnostics {
   ELMLS = "ElmLS";
 
   private language: Language;
@@ -178,7 +178,7 @@ export class ElmDiagnostics {
     const moduleImports = this.language
       .query(
         `
-        (import_clause 
+        (import_clause
           (upper_case_qid) @moduleName
         )
         `,
@@ -241,12 +241,12 @@ export class ElmDiagnostics {
     const exposedValuesAndTypes = this.language
       .query(
         `
-        (import_clause 
+        (import_clause
           (exposing_list
             (exposed_value) @exposedValue
           )
         )
-        (import_clause 
+        (import_clause
           (exposing_list
             (exposed_type) @exposedType
           )
@@ -267,7 +267,7 @@ export class ElmDiagnostics {
           ((value_expr) @value.reference
             (#eq? @value.reference "${exposedValueOrType.text}")
           )
-          ((type_ref 
+          ((type_ref
             (upper_case_qid) @type.reference)
             (#eq? @type.reference "${exposedValueOrType.text}")
           )
@@ -299,7 +299,7 @@ export class ElmDiagnostics {
     const moduleAliases = this.language
       .query(
         `
-        (import_clause 
+        (import_clause
           (as_clause
             (upper_case_identifier) @moduleAlias
           )
@@ -437,7 +437,7 @@ export class ElmDiagnostics {
               (module_declaration
                 (exposing_list
                   (double_dot)
-                ) @exposingAll 
+                ) @exposingAll
               )
             )
             `,
@@ -501,7 +501,7 @@ export class ElmDiagnostics {
       .query(
         `
         (
-          (case_of_branch 
+          (case_of_branch
             (pattern) @casePattern
             (value_expr) @caseValue
           ) @caseBranch
@@ -789,7 +789,7 @@ export class ElmDiagnostics {
         (module_declaration
           (port)
         ) @portModule
-        
+
         (port_annotation) @portAnnotation
         `,
       )
@@ -850,7 +850,7 @@ export class ElmDiagnostics {
       .query(
         `
         (type_alias_declaration
-          (upper_case_identifier) @typeAlias  
+          (upper_case_identifier) @typeAlias
         )
         `,
       )
@@ -869,7 +869,7 @@ export class ElmDiagnostics {
             ] @value.reference
             (#eq? @value.reference "${typeAlias.text}")
           )
-          ((type_ref 
+          ((type_ref
             (upper_case_qid) @type.reference)
             (#eq? @type.reference "${typeAlias.text}")
           )
@@ -903,7 +903,7 @@ export class ElmDiagnostics {
           (upper_case_identifier) @typeName
           (union_variant
             (upper_case_identifier) @unionVariant
-          ) 
+          )
         )
         `,
       )
@@ -923,7 +923,7 @@ export class ElmDiagnostics {
             (value_expr) @value.reference
             (#eq? @value.reference "${unionVariant.text}")
           )
-          ((type_ref 
+          ((type_ref
             (upper_case_qid) @type.reference)
             (#eq? @type.reference "${unionVariant.text}")
           )
diff --git a/src/server.ts b/src/server.ts
index c612b3c..fe29628 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -22,14 +22,14 @@ import {
   ElmAnalyseDiagnostics,
   ElmMakeDiagnostics,
   FoldingRangeProvider,
-  TypeInferenceDiagnostics,
   HoverProvider,
   ReferencesProvider,
   RenameProvider,
   SelectionRangeProvider,
+  TypeInferenceDiagnostics,
   WorkspaceSymbolProvider,
 } from "./providers";
-import { ElmDiagnostics } from "./providers/diagnostics/elmDiagnostics";
+import { ElmLsDiagnostics } from "./providers/diagnostics/elmLsDiagnostics";
 import { Settings } from "./util/settings";
 
 export interface ILanguageServer {
@@ -136,8 +136,8 @@ export class Server implements ILanguageServer {
       useValue: new TypeInferenceDiagnostics(),
     });
 
-    container.register(ElmDiagnostics, {
-      useValue: new ElmDiagnostics(),
+    container.register(ElmLsDiagnostics, {
+      useValue: new ElmLsDiagnostics(),
     });
 
     const clientSettings = await settings.getClientSettings();


Test patch:
diff --git a/test/diagnosticTests/elmDiagnostics.test.ts b/test/diagnosticTests/elmLsDiagnostics.test.ts
similarity index 99%
rename from test/diagnosticTests/elmDiagnostics.test.ts
rename to test/diagnosticTests/elmLsDiagnostics.test.ts
index 18cae63..96b5a84 100644
--- a/test/diagnosticTests/elmDiagnostics.test.ts
+++ b/test/diagnosticTests/elmLsDiagnostics.test.ts
@@ -5,15 +5,15 @@ import {
   Range,
 } from "vscode-languageserver";
 import { URI } from "vscode-uri";
-import { ElmDiagnostics } from "../../src/providers/diagnostics/elmDiagnostics";
+import { ElmLsDiagnostics } from "../../src/providers/diagnostics/elmLsDiagnostics";
 import { diagnosticsEquals } from "../../src/providers/diagnostics/fileDiagnostics";
 import { Utils } from "../../src/util/utils";
 import { baseUri } from "../utils/mockElmWorkspace";
 import { getSourceFiles } from "../utils/sourceParser";
 import { SourceTreeParser } from "../utils/sourceTreeParser";
 
-describe("ElmLSDiagnostics", () => {
-  let elmDiagnostics: ElmDiagnostics;
+describe("ElmLsDiagnostics", () => {
+  let elmDiagnostics: ElmLsDiagnostics;
   const treeParser = new SourceTreeParser();
 
   const debug = process.argv.find((arg) => arg === "--debug");
@@ -24,7 +24,7 @@ describe("ElmLSDiagnostics", () => {
     expectedDiagnostics: Diagnostic[],
   ) {
     await treeParser.init();
-    elmDiagnostics = new ElmDiagnostics();
+    elmDiagnostics = new ElmLsDiagnostics();
 
     const workspace = treeParser.getWorkspace(getSourceFiles(source));
     const uri = URI.file(baseUri + "Main.elm").toString();