diff --git a/liberty-ls/src/main/java/io/openliberty/tools/langserver/diagnostic/LibertyPropertiesDiagnosticService.java b/liberty-ls/src/main/java/io/openliberty/tools/langserver/diagnostic/LibertyPropertiesDiagnosticService.java index 00762626..80058397 100644 --- a/liberty-ls/src/main/java/io/openliberty/tools/langserver/diagnostic/LibertyPropertiesDiagnosticService.java +++ b/liberty-ls/src/main/java/io/openliberty/tools/langserver/diagnostic/LibertyPropertiesDiagnosticService.java @@ -49,9 +49,12 @@ public Map compute(String text, LibertyTextD int lineNumber = 0; try { while ((line=br.readLine()) != null) { - PropertiesValidationResult validationResult = PropertiesValidationResult.validateServerProperty(line, openedDocument, lineNumber); - if (validationResult.hasErrors()) { - errors.put(line, validationResult); + //blank line is being ignored + if(!line.isBlank()) { + PropertiesValidationResult validationResult = PropertiesValidationResult.validateServerProperty(line, openedDocument, lineNumber); + if (validationResult.hasErrors()) { + errors.put(line, validationResult); + } } lineNumber++; } diff --git a/liberty-ls/src/main/java/io/openliberty/tools/langserver/utils/PropertiesValidationResult.java b/liberty-ls/src/main/java/io/openliberty/tools/langserver/utils/PropertiesValidationResult.java index f6183699..f6f960ab 100644 --- a/liberty-ls/src/main/java/io/openliberty/tools/langserver/utils/PropertiesValidationResult.java +++ b/liberty-ls/src/main/java/io/openliberty/tools/langserver/utils/PropertiesValidationResult.java @@ -67,7 +67,7 @@ public void validateServerProperty() { // check whitespace around equal sign (=) if (LibertyConfigFileManager.isServerEnvFile(textDocumentItem)) { - if (property.endsWith(" ") || value.startsWith(" ")) { + if ((property != null && property.endsWith(" ")) || (value != null && value.startsWith(" "))) { startChar = property.trim().length(); endChar = entry.getLineContent().length() - value.trim().length(); hasErrors = true; diff --git a/liberty-ls/src/test/java/io/openliberty/tools/langserver/diagnostic/ServerEnvDiagnosticTest.java b/liberty-ls/src/test/java/io/openliberty/tools/langserver/diagnostic/ServerEnvDiagnosticTest.java index aebc8b72..84547c97 100644 --- a/liberty-ls/src/test/java/io/openliberty/tools/langserver/diagnostic/ServerEnvDiagnosticTest.java +++ b/liberty-ls/src/test/java/io/openliberty/tools/langserver/diagnostic/ServerEnvDiagnosticTest.java @@ -27,7 +27,7 @@ public void testServerEnv() throws Exception { // Checking invalid whitespace before equal sign: WLP_DEBUG_REMOTE =n createRange(4,16,18), // Checking invalid whitespace after equal sign: WLP_LOGGING_MESSAGE_FORMAT= SIMPLE - createRange(5,26,28) + createRange(7,26,28) ); checkDiagnosticsContainsMessages( "The value `asdf` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.", diff --git a/liberty-ls/src/test/resources/workspace/diagnostic/src/main/liberty/config/server.env b/liberty-ls/src/test/resources/workspace/diagnostic/src/main/liberty/config/server.env index 28b3df42..ead7ede8 100644 --- a/liberty-ls/src/test/resources/workspace/diagnostic/src/main/liberty/config/server.env +++ b/liberty-ls/src/test/resources/workspace/diagnostic/src/main/liberty/config/server.env @@ -3,4 +3,6 @@ WLP_LOGGING_CONSOLE_LOGLEVEL=iNfO WLP_LOGGING_CONSOLE_SOURCE=messagE WLP_DEBUG_ADDRESS=-2 WLP_DEBUG_REMOTE =n +# adding comment line and blank line to check whether its being ignored + WLP_LOGGING_MESSAGE_FORMAT= SIMPLE \ No newline at end of file