From 1f3d9043e67e4789d2364ddf33610f0d8e882a86 Mon Sep 17 00:00:00 2001
From: manuEbg <m.waechtershaeuser@web.de>
Date: Tue, 17 Aug 2021 10:48:38 +0200
Subject: [PATCH 1/4] Fixed DiagnosticRange

---
 src/main/java/Server/Compiler/ModelicaDiagnostic.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/Server/Compiler/ModelicaDiagnostic.java b/src/main/java/Server/Compiler/ModelicaDiagnostic.java
index 805fc83..323f366 100644
--- a/src/main/java/Server/Compiler/ModelicaDiagnostic.java
+++ b/src/main/java/Server/Compiler/ModelicaDiagnostic.java
@@ -116,10 +116,10 @@ private void _parseErrorRange(String start, String end){
 
 
 
-        startP.setLine(Integer.parseInt(startRange[0]));
-        startP.setCharacter(Integer.parseInt(startRange[1]));
-        endP.setLine(Integer.parseInt(endRange[0]));
-        endP.setCharacter(Integer.parseInt(endRange[1]));
+        startP.setLine(Integer.parseInt(startRange[0]) - 1);
+        startP.setCharacter(Integer.parseInt(startRange[1]) -1);
+        endP.setLine(Integer.parseInt(endRange[0])-1);
+        endP.setCharacter(Integer.parseInt(endRange[1])-1);
 
         errorRange.setStart(startP);
         errorRange.setEnd(endP);

From 647e05e1ca3ea72d76ee4dc3494508cf90e34558 Mon Sep 17 00:00:00 2001
From: manuEbg <m.waechtershaeuser@web.de>
Date: Tue, 17 Aug 2021 10:49:28 +0200
Subject: [PATCH 2/4] PublishEmptyDiagnostics to clear them on the Clientside

---
 src/main/java/Server/DiagnosticHandler.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/main/java/Server/DiagnosticHandler.java b/src/main/java/Server/DiagnosticHandler.java
index ffaa7a7..3e16d23 100644
--- a/src/main/java/Server/DiagnosticHandler.java
+++ b/src/main/java/Server/DiagnosticHandler.java
@@ -19,16 +19,18 @@ public DiagnosticHandler(MopeLSPServer server){
     }
 
     public void publishDiagnostics(){
+        var params = new PublishDiagnosticsParams();
         for(String location : Diagnostics.keySet()){
-            var params = new PublishDiagnosticsParams();
+
             params.setUri(location);
             params.setDiagnostics(Diagnostics.get(location));
-            server.publishDiagnosticsToAllClients(params);
+
         }
+        server.publishDiagnosticsToAllClients(params);
     }
 
     public void addDiagnostics(List<ModelicaDiagnostic> diagnostics){
-        if(diagnostics.isEmpty()) return;
+        if(diagnostics.isEmpty()) {publishDiagnostics(); return;}
         for(ModelicaDiagnostic dia : diagnostics){
 
             if(Diagnostics.containsKey(dia.getUri())) Diagnostics.get(dia.getUri()).add(dia);
@@ -41,7 +43,8 @@ public void addDiagnostics(List<ModelicaDiagnostic> diagnostics){
     }
 
     public void clearDiagnostics(){
-        Diagnostics.clear();
+        for(String key : Diagnostics.keySet())
+        Diagnostics.get(key).clear();
     }
 
 }

From 9b8f0ee5e1d2dbb9057207d0abfdcd687f3efd92 Mon Sep 17 00:00:00 2001
From: manuEbg <m.waechtershaeuser@web.de>
Date: Tue, 17 Aug 2021 10:50:01 +0200
Subject: [PATCH 3/4] Complition Symbol Limiter Space

---
 src/main/java/Server/CompletionProvider.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/Server/CompletionProvider.java b/src/main/java/Server/CompletionProvider.java
index 0b2095e..c2659b7 100644
--- a/src/main/java/Server/CompletionProvider.java
+++ b/src/main/java/Server/CompletionProvider.java
@@ -27,7 +27,7 @@ public class CompletionProvider {
     /**
      * These Characters mark the beginning of a possible symbol
      */
-    private static final char[] limiter = {'\t',' ', ';', '\n'};
+    private static final char[] limiter = {'\t',' ', ';', '\n',};
     private static final Logger logger = LoggerFactory.getLogger(CompletionProvider.class);
 
     public static List<CompletionItem> complete(CompletionParams params, ICompilerAdapter compiler) throws FileNotFoundException {
@@ -100,7 +100,7 @@ private static String findCompletableSymbol(String URI, int line, int col) throw
         char current;
         while(col >= 0){
             current = selectedLine.charAt(col);
-            if(Arrays.asList(limiter).contains(current) ) break;
+            if(Arrays.asList(limiter).contains(current) || Character.isSpaceChar(current)) break;
             builder.append(current);
             col--;
         }

From fc0ca8232d95b4963ac292deb53cd8412dffe5d0 Mon Sep 17 00:00:00 2001
From: manuEbg <m.waechtershaeuser@web.de>
Date: Tue, 17 Aug 2021 11:27:20 +0200
Subject: [PATCH 4/4] Publish Diagnostics for all known files (not only one...)

---
 src/main/java/Server/DiagnosticHandler.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/main/java/Server/DiagnosticHandler.java b/src/main/java/Server/DiagnosticHandler.java
index 3e16d23..8ae7a82 100644
--- a/src/main/java/Server/DiagnosticHandler.java
+++ b/src/main/java/Server/DiagnosticHandler.java
@@ -19,14 +19,14 @@ public DiagnosticHandler(MopeLSPServer server){
     }
 
     public void publishDiagnostics(){
-        var params = new PublishDiagnosticsParams();
-        for(String location : Diagnostics.keySet()){
 
+        for(String location : Diagnostics.keySet()){
+            var params = new PublishDiagnosticsParams();
             params.setUri(location);
             params.setDiagnostics(Diagnostics.get(location));
-
+            server.publishDiagnosticsToAllClients(params);
         }
-        server.publishDiagnosticsToAllClients(params);
+
     }
 
     public void addDiagnostics(List<ModelicaDiagnostic> diagnostics){
@@ -43,8 +43,9 @@ public void addDiagnostics(List<ModelicaDiagnostic> diagnostics){
     }
 
     public void clearDiagnostics(){
-        for(String key : Diagnostics.keySet())
-        Diagnostics.get(key).clear();
+        for(String key : Diagnostics.keySet()){
+            Diagnostics.get(key).clear();
+        }
     }
 
 }